Search the Community
Showing results for tags 'index'.
Found 1 result
When working with Opusmodus, it is very common to run many times a script containing some random process and you may want to keep and redo the last output for refine it or whatever. It can be also good to save multiples output from a script with an index number attached to the output name. In this post, i will show you how to achieve this two technics. 1.Seed record: The first operation is to generate randomly a seed value and bind it to a variable: (setf my-seed (rnd-range 1 10000)) Pass it to the init-seed function (init-seed my-seed) Now you can evaluate you score many times and when the output is ok for you, recall the last random seed by evaluating the seed variable name, the seed number will be showed in the listener. Just copy and past it as the value of init-seed function in place of "my-seed". Here’s a small score example: (setf my-seed (rnd-range 1 10000)) (init-seed my-seed) (setf size 12) (setf pitch (rnd-sample (rnd-number size 1 16) (list (make-scale 'a4 12 :alt '(2 1 2 3))))) (setf len (gen-tuplet 1 1 'm '? 'w (mapcar 'length pitch))) (setf phrase (make-omn :pitch pitch :length len )) (def-score flute ( :key-signature 'chromatic :time-signature '(4 4) :tempo 112 :layout (flute-layout 'flt) ) (flt :omn phrase :channel 1 :sound 'gm :program 'flute ) ) Now if you want to recall the last seed, you can evaluate my-seed and copy the result from the listener into the init-seed function: (init-seed 37281) ..... 2. Indexing Midi files: You can add a compile-score function at the end of your score script and give it some instructions regarding the output format AND a possible versioning system. A small score example: Evaluate this score several times and you will find in your midi folder each output indexed: Flute2-001 Flute2-002 Flute2-003 .... (setf size2 12) (setf pitch2 (rnd-sample (rnd-number size2 1 16) (list (make-scale 'a4 12 :alt '(2 1 2 3))))) (setf len2 (gen-tuplet 1 1 'm '? 'w (mapcar 'length pitch2))) (setf phrase2 (make-omn :pitch pitch2 :length len2 )) (def-score flute2 ( :key-signature 'chromatic :time-signature '(4 4) :tempo 112 :layout (flute-layout 'flt) ) (flt :omn phrase2 :channel 1 :sound 'gm :program 'flute ) ) (compile-score 'flute2 :output :midi :file "Flute2" :new-index t) SB.