August 8, 20232 yr Hello , i am looking to find a way to assign random midi channel numbers with the possibility to set some repetition of midi channel number as an option EX : in turn midi channel 1 2 3 4 5 6 or 1 1 1 1 2 2 2 2 3 3 3 12 13 14 etc .... The midi channel are distributed for each pitch, beat or a measure or set of measures per voice Thanks Patrick
August 9, 20232 yr I don't think it is possible to change the midi-channel in the instrument this way. But what you can do is influence what events from the omn-list gets played on the instrument channel. There are probably better ways and this can be improved. ;; evaluate all ;; evaluate pattern you want to use ;; cmd-1 def-score ;; for external midi comment rk_evpos-gm and uncomment rk_evpos-extern ;; function for :omn in :instrument in def-score (defun events-to-ch (ch poslist omnl) (let* ( (somnl (single-events (flatten omnl))) (chplist (position-item ch poslist))) (loop for n from 0 to (length somnl) for i in somnl collect (if ( equal n (car (member n chplist))) i (if (event-restp i) i (length-invert i)))) )) (setf mat '((5q c4 p cs5 pp d4 p ds5 pp e4 p) (s f5 pp fs4 mf g4 pp gs5 mf) (5q a4 p as5 mf b4 mp c4 pp cs5 d4 p ds5 mf e4 mp f5 pp fs4) (e g4 gs5 s a4 pp e as5 mf s b4 e c4 pp s cs5 mf e d4 -q) (s ds5 pp e4 p f5 mp fs4 pp 3q g4 p gs5 mp a4 pp q as5 p 5q b4 mp c4 pp cs5 p d4 mp ds5 pp) (s e4 p f5 pp fs4 p g4 pp))) ;;pattern-examples for the function events-to-ch called in :omn of instrument ;; the numbers e.g. '(1 2 3 4) are the midi-channels (setf patt1 (gen-repeat 100 '(1 4))) (setf patt1 (gen-repeat 100 (gi '(4 1..4 2 4..1)))) (setf patt1 (gen-repeat 100 '(2 4 3 2))) (setf patt1 (gen-repeat 100 (rp '((1 1) (1 2) (1 3) (1 4))))) (setf patt1 (gen-repeat 100 (rp '((4 1) (3 2) (1 3) (2 4))))) (setf patt1 (gen-repeat 100 (rp '((4 1) (4 2) (3 3) (1 12) (1 13) (1 14))))) (setf patt1 (rnd-sample 500 '(1 2 3 4) :seed 300)) (setf patt1 (rnd-sample 500 '(1 2) :seed 300)) (setf patt1 (gen-repeat 100 '(1 2 3 4))) (def-score rk_evpos-gm (:title "rk_evpos_gm" :key-signature 'chromatic :time-signature '(4 4) :tempo 120) (instrument1 :omn (events-to-ch 1 patt1 mat) :channel 1 :sound 'gm :program 'Lead-2-Sawtooth) (instrument2 :omn (events-to-ch 2 patt1 mat) :channel 2 :sound 'gm :program 'Violin) (instrument3 :omn (events-to-ch 3 patt1 mat) :channel 3 :sound 'gm :program 'Trumpet) (instrument4 :omn (events-to-ch 4 patt1 mat) :channel 4 :sound 'gm :program 'Marimba) ) #| (def-score rk_evpos-extern (:title "rk_evpos_extern" :key-signature 'chromatic :time-signature '(4 4) :tempo 120) (instrument1 :omn (events-to-ch 1 patt1 mat) :port 0 :channel 1) (instrument2 :omn (events-to-ch 2 patt1 mat) :port 0 :channel 2) (instrument3 :omn (events-to-ch 3 patt1 mat) :port 0 :channel 3) (instrument4 :omn (events-to-ch 4 patt1 mat) :port 0 :channel 4) ) |# (midi-destinations)
August 11, 20232 yr I edited my first post as it was not complete. I had not inserted rests for the channels that were not playing. Now it does what it should. If there are cases in the omn I have not considered please let me know. If there are better ways to do this I would like to know. Always learning.
Create an account or sign in to comment