Yuichi Yamamoto Posted September 17, 2016 Share Posted September 17, 2016 Hi, I'm Yuichi. I don't know if there was anyone else who already did similar things or not, but I would like to share the way I achieved the continuously self-evaluating program. I actually made a video of it and hopefully I can post it here but I'll paste the code down here anyway, too. CODE wrap the whole music with a function named "evalAll (better name should be applied): (defun evalAll () (setf pitch (integer-to-pitch (rnd-row))) (setf len (span pitch '(s))) (setf omn (make-omn :pitch pitch :length len)) (def-score 12-tone (:key-signature 'atonal :time-signature '(4 3) :tempo 120) (inst :omn omn)) (display-musicxml '12-tone) (display-midi '12-tone) (sleep 1.5) (evalAll) ) (evalAll) This is just a tiny fragment of music so I'm not going to discuss the music but you see the difference between this and "live-coding-midi". In each loop it re-evaluates itself: meaning if there is random things, it will get each different results. Note that this is an infinite loop so in order to stop this, you have to press "command" + ",". If you don't like the program to freeze while executing this program, there is a way. Thanks to the developers for adding bordeaux-threads in the recent update, you can have multi-threads in Opusmodus now, so if you just make a thread of this recurrent program alone you won't be bothered to be stopped anymore. And extending this idea will lead you to have one recurrent program running while you can freely change some variables(maybe scales / chords/ instruments/ whatever) and it will be, right-on-time, reflected to the music. I hope this will inspire somebody's imagination. Yuichi recurrent.mp4 Quote Link to comment Share on other sites More sharing options...
AM Posted September 17, 2016 Share Posted September 17, 2016 hi yuichi here a version without exit-problems... a simple loop (with x-generations), that's what your code is doing... so you don't have to re-evaluate, loop is doing this... (setf generations 20) (setf omn (loop repeat generations do (setf pitch (integer-to-pitch (rnd-row))) do (setf len (span pitch '(s))) collect (make-omn :pitch pitch :length len))) (def-score 12-tone (:key-signature 'atonal :time-signature '(4 4) :tempo 120) (inst :omn omn)) (display-musicxml '12-tone) (display-midi '12-tone) opmo and RST 2 Quote Link to comment Share on other sites More sharing options...
AM Posted September 17, 2016 Share Posted September 17, 2016 ;;; i think what you are looking for is something like that: ;;; in every generation the sequence will be new, and at some ;;; points (when sample-length = 1) the row is changing... (setf generations 200) (setf omn (loop repeat generations with seq = (rnd-row) do (setf pitch (integer-to-pitch (setf seq (rnd-sample-seq (1+ (random (length seq))) seq)))) ;; picks a rnd-length-sample of the row ;; when the random-chosen seq-length = 1 then a new row will be generated but ONE value shorter ;; (see: (butlast (rnd-row)) , so the feedback will come quicker and quicker... because ;; of the chance to match seq-length = 1 when (= (length seq) 1) do (setq seq (butlast (rnd-row))) ;; the feedback on production do (setf len (span pitch '(s))) collect (make-omn :pitch pitch :length len))) (def-score 12-tone (:key-signature 'atonal :time-signature '(4 4) :tempo 120) (inst :omn omn)) (display-musicxml '12-tone) (display-midi '12-tone) ;;; opmo 1 Quote Link to comment Share on other sites More sharing options...
AM Posted September 17, 2016 Share Posted September 17, 2016 for further ideas: i think it's a good solution to work with "structures" = "datasets" and a "machine" who generates output based on these datas. ... your "machine" will pick its rules/datas... from there, so you have good possibilties to work with more then one dataset, and give also a feedback on this sets (such a dataset is like a "GENOM", and the machine produces its outputs based on this "GENOM" but also influences it = feeback)... an dataset-example from my current project... ;;; defines a structure called CHORDSET (defstruct chordset name interval-seq interval-direction startpitch durations rhy velocity cresc-dim seq-length rotate-dynmics sampling-types form-types data1) ;;; VARIABLE CHORD1 will be "filled" with datas in this structure -> see "make-chordset" (setf chord1 (make-chordset :name 'chord1 :interval-seq '(3 5 3 3 5 3 3 5 3 3) :interval-direction '((up 0.5) (down 0.5)) :startpitch '(c4 gs4) :durations '1 :rhy '((1/32 0.4) (1/20 0.4) (1/12 0.2)) :velocity (weighted-random '(((pppp ppp pp p mp mf mp p pp ppp pppp) 0.5) ((p p p mp mp mf mp mp p p p) 0.5))) :cresc-dim '(pppp p) :seq-length '((3 0.3) (5 0.3) (7 0.1) (11 0.3)) :form-types '(crippled asymmetric symmetric broken) :sampling-types '(rnd from-center))) ;;; every data could be read by (for example) (chordset-startpitch chord1) => (c4 gs4) ;;; or could be rewritten by (setf (chordset-startpitch chord1) 'c3) ;;; then: (chordset-startpitch chord1) => c3 => the machine reads this self-definied datas and generating output (like YOUR program) => an perhaps when some patterns are recognized (in the production-process) there could be an influence on the dataset -> rewrite the dataset => that's a way to control and design such recursiv-production-systems, but there are also many other ways... i hope that helps you - and i hope i did not misunderstand your ideas/code... regards andré opmo 1 Quote Link to comment Share on other sites More sharing options...
Stephane Boussuge Posted September 17, 2016 Share Posted September 17, 2016 Another example (a score example) of using a loop for generate some multiple output of a process. ;;; FORME ETRANGE ;;; POUR PIANO SEUL. (setf row '(c4 e4 g4 bb4 d5 fs5 a5 gs5 f5 eb4 cs4 b4)) (setf set1 (subseq row 0 6)) (setf set2 (subseq row 3 9)) (setf set3 (subseq row 6 12)) (setf couleur1 (gen-chord 12 5 5 -6 6 (gen-repeat 12 set1))) (setf couleur2 (gen-chord 12 5 5 -6 6 (gen-repeat 12 set2))) (setf couleur3 (gen-chord 12 5 5 -6 6 (gen-repeat 12 set3))) (setf path1 (tonality-series couleur1)) (setf path2 (tonality-series couleur2)) (setf path3 (tonality-series couleur3)) ;;;============================================= (setf ch1 (mclist (position-insert '(0) '(ped) (assemble-seq (gen-loop 24 (make-omn :pitch (rnd-sample 6 couleur1) :length (rnd-sample 1 '((q h -q) (h h) (e e e e h) (w) (q q) (q e e q) (q -q) )) :velocity (rnd-sample 1 '((f)(ff)(fff)(mf)(mp)(p)(pp))) )))))) (setf un1 (mclist (position-insert '(0) '(ped) (assemble-seq (gen-loop 24 (make-omn :pitch (pitch-transpose -48 (rnd-sample 1 (melodize (rnd-sample 1 couleur1)))) :length (rnd-sample 1 '((h -q) (w) (q -h) )) :velocity '((ffff)) )))))) (setf ar1 (mclist (position-insert '(0) '(ped) (assemble-seq (gen-loop 24 (make-omn :pitch (pitch-transpose (rnd-pick '(10 11 12 13 14 15 16 17)) (tonality-map (rnd-sample 1 path1) (rnd-sample 1 '( (c2 e2 g2 b2 d3 fs3 c4 e4 g4 b4 d5 fs5) (c2 e2 g2 b2 d3 fs3 d3 fs3 a4 e5 b5) (fs5 d5 b4 g4 e4 c4 b4 g4 e4 c4 b3 g3 e3 c3) (fs5 d5 b4 d5 b4 g4 b4 g4 e4 g4 e4 c4 g3 c3) )))) :length (rnd-sample 1 '((t t t t t q -q) (t t t t t t t t t t t t) (s s s s s s s s) (t t t t t t e e q -q))) :velocity (rnd-sample 1 '((f)(ff)(fff)(mf)(mp)(p)(pp))) )))))) (setf ar1b (mclist (position-insert '(0) '(ped) (assemble-seq (gen-loop 24 (make-omn :pitch (filter-repeat 1 (pitch-transpose 12 (tonality-map (rnd-sample 1 path1) (rnd-sample 6 '(c4 d4 e4 f4 g4 a4 b4 c5 d5 e4 fs5))))) :length (rnd-sample 1 '((t t t t t q -q) (t t t t t t t t t t t t) (s s s s s s s s) (t t t t t t e e q -q))) :velocity (rnd-sample 1 '((f)(ff)(fff)(mf)(mp)(p)(pp))) )))))) ;; Assemblage (setf s1 (rnd-sample 24 (append ch1 un1 ar1 ar1b))) ;;;========================================== (setf ch1 (mclist (position-insert '(0) '(ped) (assemble-seq (gen-loop 24 (make-omn :pitch (rnd-sample 6 couleur2) :length (rnd-sample 1 '((q h -q) (h h) (e e e e h) (w) (q q) (q e e q) (q -q) )) :velocity (rnd-sample 1 '((f)(ff)(fff)(mf)(mp)(p)(pp))) )))))) (setf un1 (mclist (position-insert '(0) '(ped) (assemble-seq (gen-loop 24 (make-omn :pitch (pitch-transpose -48 (rnd-sample 1 (melodize (rnd-sample 1 couleur2)))) :length (rnd-sample 1 '((h -q) (w) (q -h) )) :velocity '((ffff)) )))))) (setf ar1 (mclist (position-insert '(0) '(ped) (assemble-seq (gen-loop 24 (make-omn :pitch (pitch-transpose (rnd-pick '(10 11 12 13 14 15 16 17)) (tonality-map (rnd-sample 1 path2) (rnd-sample 1 '( (c2 e2 g2 b2 d3 fs3 c4 e4 g4 b4 d5 fs5) (c2 e2 g2 b2 d3 fs3 d3 fs3 a4 e5 b5) (fs5 d5 b4 g4 e4 c4 b4 g4 e4 c4 b3 g3 e3 c3) (fs5 d5 b4 d5 b4 g4 b4 g4 e4 g4 e4 c4 g3 c3) )))) :length (rnd-sample 1 '((t t t t t q -q) (t t t t t t t t t t t t) (s s s s s s s s) (t t t t t t e e q -q))) :velocity (rnd-sample 1 '((f)(ff)(fff)(mf)(mp)(p)(pp))) )))))) (setf ar1b (mclist (position-insert '(0) '(ped) (assemble-seq (gen-loop 24 (make-omn :pitch (filter-repeat 1 (pitch-transpose 12 (tonality-map (rnd-sample 1 path2) (rnd-sample 6 '(c4 d4 e4 f4 g4 a4 b4 c5 d5 e4 fs5))))) :length (rnd-sample 1 '((t t t t t q -q) (t t t t t t t t t t t t) (s s s s s s s s) (t t t t t t e e q -q))) :velocity (rnd-sample 1 '((f)(ff)(fff)(mf)(mp)(p)(pp))) )))))) ;; Assemblage (setf s2 (rnd-sample 24 (append ch1 un1 ar1 ar1b))) ;;;========================================== (setf ch1 (mclist (position-insert '(0) '(ped) (assemble-seq (gen-loop 24 (make-omn :pitch (rnd-sample 6 couleur3) :length (rnd-sample 1 '((q h -q) (h h) (e e e e h) (w) (q q) (q e e q) (q -q) )) :velocity (rnd-sample 1 '((f)(ff)(fff)(mf)(mp)(p)(pp))) )))))) (setf un1 (mclist (position-insert '(0) '(ped) (assemble-seq (gen-loop 24 (make-omn :pitch (pitch-transpose -48 (rnd-sample 1 (melodize (rnd-sample 1 couleur3)))) :length (rnd-sample 1 '((h -q) (w) (q -h) )) :velocity '((ffff)) )))))) (setf ar1 (mclist (position-insert '(0) '(ped) (assemble-seq (gen-loop 24 (make-omn :pitch (pitch-transpose (rnd-pick '(10 11 12 13 14 15 16 17)) (tonality-map (rnd-sample 1 path3) (rnd-sample 1 '( (c2 e2 g2 b2 d3 fs3 c4 e4 g4 b4 d5 fs5) (c2 e2 g2 b2 d3 fs3 d3 fs3 a4 e5 b5) (fs5 d5 b4 g4 e4 c4 b4 g4 e4 c4 b3 g3 e3 c3) (fs5 d5 b4 d5 b4 g4 b4 g4 e4 g4 e4 c4 g3 c3) )))) :length (rnd-sample 1 '((t t t t t q -q) (t t t t t t t t t t t t) (s s s s s s s s) (t t t t t t e e q -q))) :velocity (rnd-sample 1 '((f)(ff)(fff)(mf)(mp)(p)(pp))) )))))) (setf ar1b (mclist (position-insert '(0) '(ped) (assemble-seq (gen-loop 24 (make-omn :pitch (filter-repeat 1 (pitch-transpose 12 (tonality-map (rnd-sample 1 path3) (rnd-sample 6 '(c4 d4 e4 f4 g4 a4 b4 c5 d5 e4 fs5))))) :length (rnd-sample 1 '((t t t t t q -q) (t t t t t t t t t t t t) (s s s s s s s s) (t t t t t t e e q -q))) :velocity (rnd-sample 1 '((f)(ff)(fff)(mf)(mp)(p)(pp))) )))))) ;; Assemblage (setf s3 (rnd-sample 24 (append ch1 un1 ar1 ar1b))) (def-score FormeEtrange-s1 ( :title "FormeEtrange" :composer "S.Boussuge" :copyright "Copyright © 2014 S.Boussuge" :key-signature 'chromatic :time-signature (get-time-signature s1) :tempo 108 :layout (piano-grand-layout 'piano) ) (piano :omn s1 :channel 1 :sound 'gm :program 'acoustic-grand-piano ;:port 0 ) ) (def-score FormeEtrange-s2 ( :title "FormeEtrange" :composer "S.Boussuge" :copyright "Copyright © 2014 S.Boussuge" :key-signature 'chromatic :time-signature (get-time-signature s2) :tempo 108 :layout (piano-grand-layout 'piano) ) (piano :omn s2 :channel 1 :sound 'gm :program 'acoustic-grand-piano ;:port 0 ) ) (def-score FormeEtrange-s3 ( :title "FormeEtrange" :composer "S.Boussuge" :copyright "Copyright © 2014 S.Boussuge" :key-signature 'chromatic :time-signature (get-time-signature s3) :tempo 108 :layout (piano-grand-layout 'piano) ) (piano :omn s3 :channel 1 :sound 'gm :program 'acoustic-grand-piano ;:port 0 ) ) (compile-score '( FormeEtrange-s1 FormeEtrange-s2 FormeEtrange-s3 )) opmo 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.