Search the Community
Showing results for tags 'seed'.
Found 7 results
Custom Seed List
NagyMusic posted a topic in Function ExamplesI wonder if it's possible to evaluate a function (that has a seed argument) a set number of times (using gen-loop) with a predefined, custom seed list applied to the function. Something that I'm trying to achieve in the example below. Thank you! (setf seeds (vector-round 1 100 (gen-white-noise 8 :seed 13))) (setf rhythm (gen-loop 8 (euclidean-rhythm 16 4 16 's :type 2 :seed seeds)))
resolved Strange behaviour with function reverse?
spuki posted a topic in Support & TroubleshootingHallo, newbie here I'm just starting with OM and playing around with the tutorials. I slightly changed tutorial #4 and run into something strange. If i run the script as posted below, all works as expected. But when i change the function reverse to nreverse (and nreverse is the oficially documented name of the function) the omn result will leave the right hand empty. Why ist that? And why does reverse work as i expect it to work? And, another thing: i dont understand what the term seed will do. Will it make random functions behave always the same as long as the seed is the same? ...and what does the number following the seed mean? Thank you !! Best, Sebasian (setf pitches (gen-repeat 5 '(c4 cs4 fs4 g4 c5 cs5))) (setf transposed-pitches (gen-repeat 5 (pitch-transpose -24 pitches))) (setf lengths (span pitches '(e))) (setf lengths-rests (length-weight lengths :weight '(2 1) :seed 12)) (setf left-lengths (reverse lengths-rests)) (setf piano-righthand (make-omn :length lengths-rests :pitch pitches :velocity'(mp))) (setf piano-lefthand (make-omn :length left-lengths :pitch transposed-pitches :velocity '(f))) (setf timesigs (get-time-signature left-lengths)) (def-score lesson-4 (:key-signature 'chromatic :time-signature '( 5 8 ) :tempo 190 :layout (piano-layout 'piano-rh 'piano-lh)) (piano-rh :omn piano-righthand :channel 1 :sound 'gm :program 'acoustic-grand-piano) (piano-lh :omn piano-lefthand) )
Andy posted a topic in Support & TroubleshootingHello I'm new here. I'm on the demo and doing fine but for the life of me I can't figure out what the n integer does after :seed? I know seed fixes a random function so it is repeatable but what does that number do? I tried changing it in Tutorial 5 but I can't make sense of it! Thanks Andy
Help with seed and semi-colons
Andy posted a topic in Support & TroubleshootingHi I'm starting to loose the will to progress. So I just spent an hour trying to evaluate this and getting errors and thinking I'd got the wrong number of brackets and yet it looks fine. (setf motifx12 (rnd-order (gen-repeat 12 (list motif)))) :seed3) And then I realise that I have to place the cursor not on the final bracket but on the one before :seed3) Nowhere does it say this in the manual as far as I can tell. And why? I think it's something to do with the : colon that I don't understand in the language. And I still don't understand seed. I'm really trying to get to grips with lisp but my hair is on fire.
implemented Posting seed value
EAIP posted a topic in Suggestions & IdeasHere is a suggestion for posting the random seed value used by a function. When using Open Music way back in time I remember that you could "lock" a random function if you liked the result, which IMO was a great workflow feature. Perhaps a similar thing could be achived in Opusmodus if the random seed used for a function was posted to the post window in addition to the result of the evaluation. If you like the result of a particular seed you could then manually "lock" the randomization using the :seed keyword for the function: ; first try different randomizations (setf bin-rhythm (gen-binary-rnd 5 5 2 1)) => gen-binary-rnd :seed 752 (setf bin-rhythm (gen-binary-rnd 5 5 2 1)) => gen-binary-rnd :seed 234 ; then lock seed if you like the result (setf bin-rhythm (gen-binary-rnd 5 5 2 1) :seed 234) Perhaps if possible also with the variable name as a label to keep track of things when using several random functions in complex code: (setf bin-rhythm (gen-binary-rnd 5 5 2 1)) => bin-rhytm gen-binary-rnd :seed 37 I think that this or a similar approach would be a really powerful way of trying different results when working with randomization in Opusmodus.
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.
example How to add a SEED into your own function
opmo posted a topic in User Extensions Source CodeTo add a SEED to your own function and make it work you need to follow three simple rules: Add keyword SEED into the function arguments. (rnd-seed seed) should be placed at the beginning of the function. Nested functions that use seed need to use a (seed) function and not a seed argument. Example: (defun rnd-number (n low high &key seed) (do-verbose ("rnd-number") (rnd-seed seed) (if (zerop n) nil (cons (round (+ low (rnd-round 0 (- high low) :seed (seed)))) (rnd-number (decf n) low high :seed (seed)))))) Each time we evaluate the expression we get a different result. (rnd-number 12 0 5) => (0 3 2 5 3 3 4 3 2 2 4 4) Adding seed to the expression will produce always the same result. (rnd-number 12 0 5 :seed 45) => (2 2 5 4 5 0 5 3 5 3 1 1)