Extending pc_ivl.xtm to handle real and integer midi

36 views
Skip to first unread message

George

unread,
Feb 14, 2023, 11:43:28 PM2/14/23
to Extempore
Gidday all
Minoru, Ben and all others
Following on from discussions in this thread:
..............................
I have loaded to my public Gist the work of Minore and George on real midi processing.
This link should get you to the "gpc_ivl.xtm" file which is the "real midi"
extension of  Andrew Sorensen's "extempore/libs/core/pc_ivl.xtm".
Andrew's original file can be found here:
https://github.com/digego/extempore/blob/accbe7e0abb13567ecdcc25ccf9a54c92b0eb8c9/libs/core/pc_ivl.xtm

The link to the public real midi extension "gpc_ivl.xtm" is:
https://gist.github.com/georgejwright/5a170b890d069bbb586536f0ffacf0d3

In my system I have saved this extension file to "libs/contrib/gpc_ivl.xtm"
..............................
In addition I have assembled tests for each of the redefined functions together
with  demonstrations of making musical sounds using some of the new functions.
The file has been named  "testing_gpc_ivl.xtm"
The link to the public file on my Gist is:
https://gist.github.com/georgejwright/f64b9118e307a1404fa202360dd99109

I hope you try it and like it and I hope to hear any new sounds you can make.

Regards
George


Minoru

unread,
Feb 15, 2023, 3:23:32 AM2/15/23
to Extempore
Hi George

;; Wow, you have done it !
;;
;; Then I found your comments .....

;;>>> NOTE problem sometimes yields chords with duplicate pitches ? (68.28 79.24 79.24) ?
;;>>> Need to eliminate duplicate pitches in chord ?

;; For me it's not problem, the same pitch 2 or more sounds could make a bigger or
;; deeper/thicker sound than 1 sound, it's not the same sound.
;; I think it's one of the important/basic techniques for the music.....
;; But I think it depends on the person, too,
;; there are those who love light sounds ....


;; https://gist.github.com/georgejwright/5a170b890d069bbb586536f0ffacf0d3#file-gpc_ivl-xtm-L297

;; if need, insert new 2 lines

            (cl:remove-duplicates(map (lambda (x) x)
                                      (cl:sort chord <)))

;; and comment out 2 liens

            ;; (map (lambda (x) x)
            ;;   (cl:sort chord <))


;; then modified like follows .....

        (if (< n 1)
            (cl:remove-duplicates(map (lambda (x) x)
                                      (cl:sort chord <)))
            ;; (map (lambda (x) x)
            ;;   (cl:sort chord <))
            (let* ((range (- u l))


;; but the result is different, sometimes number of chord elements are
;; less than the number of 3rd argument, due to remove duplicates ....
;; on the other hand, original pc:make-chord and original
;; gpc:make-chord(before modified these 2 lines) brings the same results,
;; that is, sometimes there found the same pitches, but number of chord
;; elements is just the number of 3rd argument the user set !
;; it's not bad for user to choice the code ....
;;
;; or, adding optional argument again, remove duplicates or not by #t/#f etc
;; default is not remove duplicates .... etc ....
;;
;; or, just like ..

(cl:remove-duplicates (gpc:make-chord ......))          

;; this is much enough, too, I think.

Regards
2023年2月15日水曜日 13:43:28 UTC+9 George:

George

unread,
Feb 15, 2023, 6:19:10 AM2/15/23
to Extempore
Glad you liked it Minoru.
Interesting ideas about the duplicates. Will listen.
Regards
George

Minoru

unread,
Feb 15, 2023, 9:07:10 PM2/15/23
to Extempore
 Hi george

;; It seems that this another get-r-pc(already posting) is better than
;;    https://gist.github.com/georgejwright/5a170b890d069bbb586536f0ffacf0d3#file-gpc_ivl-xtm-L196
;; more compact, in order to keep up with the times, too ....  

(define get-r-pc
     (lambda (pc)
          (filter (lambda (x) (not (integer? x))) pc)))
2023年2月15日水曜日 20:19:10 UTC+9 George:

Minoru

unread,
Feb 18, 2023, 9:40:30 PM2/18/23
to Extempore
Hi George
 
;; And about duplicates, sometimes I use some functions like this ...
;;     if found duplicate notes, they are changed to 1 or 2 octave higher or lower
;;     but not to too low or high pitches ....
;;
;; It is not bad to play these notes which this func returns as a chord,
;; that is, playing them at the same time,
;; buuut, it's nice to play them as a note sequence, that is, playing 1 note at the time,
;; with random or defined duration, then next note, kind of arpeggio or some phrase ......
;; it's boring to play them only in orderd(returned values), so picking out at random....
;; and more, sometimes adding 1 or more notes which pc:relative returns to a note
;; pc:make-chord made, then playing them at the same time...
;; yes, this could make nice phrases easily, too.
;;
;;
;; Back to duplicates ....
;;
;; A. play C(60) then play C(60)   feel twice same note,
;;      it's easy to notice that they are just the same note,
;; B. play C(60) then play C(48)   feel twice different note,
;;      it's not easy for many people to notice that they are the same note C !!
;; It brings very different effects to play them, though they are the same note
;; which pc:make-chord made,
;; I think that this is one of techniques to expand/develop a phrase/tune when
;; some sounds lack or wanting to add sounds by my experience/realization .....

;; p.s. I even think that pc:make-chord doesn't need cl:sort, because
;;      when playing them as a chord, the order seems to mean nothing,
;;      when playing them like arpeggio, usualy doing random choice(in above case),
;;      when playing in order, from lower or higher, yes it's the time to use cl:sort ...
;;      like as (cl:sort (pc:make-chord .... ) < or > ),
;;      this seems to be lower cost than every time sorting ...

(define dup-octv
    (lambda (p-lis)
       (let ((dup-lis (cl:duplicates p-lis)))
           (if  (null? dup-lis)
                 p-lis
                (let  ((n (random '(56 60 68 72)))
                         (octv-lis '(12 24))
                         (p-lis2 (cl:remove-duplicates p-lis))
                         (f +))
                     (cl:sort (append (map (lambda (p)
                                                                (if (> p n)(set! f -)(set! f +))
                                                                (f p (random octv-lis)))
                                                             dup-lis)
                                                  p-lis2)
                                   <))))))

(dup-octv '(60 64 65 69 71 72)) ; '(60 64 65 69 71 72)
(dup-octv '(60 64 64 65 69 69))
;; (52 57 60 64 65 69)
;; (40 45 60 64 65 69)
;; (40 57 60 64 65 69)
;; (57 60 64 65 69 88)
;; (60 64 65 69 81 88)
;; (57 60 64 65 69 76)
;; (45 52 60 64 65 69)
;; (40 57 60 64 65 69)
;; (60 64 65 69 88 93)

(dup-octv '(60 60 60 64 64 64))
;; (60 64 76 84 84 88)
;; (36 40 48 52 60 64)
;; (60 64 72 84 88 88)
;; (40 48 48 52 60 64)
;; (40 52 60 64 72 72)
;; (40 52 60 64 72 84)
;; (60 64 72 76 84 88)
;; (60 64 72 72 76 88)

(G-pc:make-chord 60 72 6 '(0 2 4 5 9))
;; 3rd argument is 6, elements of PC=5, so result has dup invariably ....
;; (60 62 64 64 64 69)
;; (60 60 62 65 69 69)
;; (60 62 65 65 69 69)
;; (60 60 62 64 65 69)
;; (60 62 62 64 65 69)
;; (60 60 62 65 65 69)
;; (60 62 64 65 69 69)  etc ...
;; deleted .000000, 60.000000 -> 60

(dup-octv (G-pc:make-chord 60 72 6 '(0 2 4 5 9)))
;; (52 60 62 64 65 69)
;; (45 57 60 62 64 69)
;; (53 60 62 65 69 84)
;; (38 60 62 64 69 84)
;; (60 62 64 65 69 72)
;; (60 62 64 65 69 86)
;; (60 62 64 65 69 81)
;; (60 62 64 69 72 93)
;; (36 50 60 62 64 69)   ... etc ...
;; deleted .000000

Best Regards

2023年2月16日木曜日 11:07:10 UTC+9 Minoru:

Minoru

unread,
Feb 18, 2023, 10:47:15 PM2/18/23
to Extempore
Hi George,

;; About gpc:make-chord
;;
;; Sorry, I noticed my mistake, leaving a residue ....
;; https://gist.github.com/georgejwright/5a170b890d069bbb586536f0ffacf0d3#file-gpc_ivl-xtm-L297

(map (lambda (x) x)
     (cl:sort chord <))

;; but this is nonsense, map function works nothing ...
;; (original pc:make-chord converts real to integer)
;; so modified these 2 lines to just 1 line, without map, as follows ...

(cl:sort chord <)
;; or its' ok without cl:sort , just only a variable ..
chord

;; so,  if my own code is ......
(define G-pc:make-chord
    (lambda (lower upper number pc . opt)
         (let ((tn (if (null? opt) 12 (car opt)))
                 (chord '()))
            (let loop ((l (round lower))
                             (u (round upper))
                             (n number)
                             (p pc))
               (if (< n 1)
                    (cl:sort chord <);;;;; or just chord without cl:sort

                    (let* ((range (- u l))
                              (gap (round (/ range n)))
                              (pitch (G-pc:random l (+ l gap) p tn)))
                        (if (not pitch) ; if new pitch is #f, try from whole range
                             (set! chord (cl:remove #f (cons (G-pc:random lower upper p tn) chord)))
                             (set! chord (cons pitch chord)))
                        (loop (+ l gap)
                                  u
                                 (- n 1)
                                 pc)))))))


Best Regards

2023年2月19日日曜日 11:40:30 UTC+9 Minoru:
Reply all
Reply to author
Forward
0 new messages