Jump to content

Independence of random functions and seeds


Recommended Posts

Greetings:

I am working with this fragment and I am confused by the result.  If, there is no :seed in any function then the code fragment compiles as expected - the output is different each time.  If there is a :seed value in the setq function then the pitch order is always the same - even though the RND-ORDER function has :seed NIL.

Is there a ways to gain independence with seeding of random functions in this example?  Keeping rhythm constant but having new pitch output each time, for example.

Many thanks for any help on this.

***

(setq rhy3
      (gen-loop 16 (rnd-pick
                    '((-h -) (q - - ) (q -) (5qqq = - = -)
                      (5qq = = = =) (5ss = = = =) (7eee = = = = = =)))
                :seed 123))

(setf sl-1 '(c4 cs4 fs4 g4))

(setf p-group
      (sort-asc
       (find-unique
        (flatten
         (pitch-transpose '(-12 0)
                          (gen-repeat 5 (list sl-1)))))))

(setf p-group-rand (rnd-order p-group))
(setf p-group-rand-1 (gen-loop 8  (rnd-order p-group :seed nil)))
(setf output (make-omn :length rhy3 :pitch p-group-rand-1))

(def-score score-name
           (:title "GUITAR_SECTION_X"
                   :key-signature '(c maj)
                   :time-signature (get-time-signature rhy3)
                   :tempo 102
                   :layout (list
                            (bracket-group
                             (guitar-down8-layout 'guitar))))
  
  (guitar
   :omn output
   :channel 1
   :sound 'gm
   :program 'acoustic-guitar-nylon
   :pan 64))
Link to comment
Share on other sites

The GEN-LOOP is marco and is bit confusing because of the compile warnings.

I think in version 1.0 you could use GEN-EVAL function which will produce the same result but without any compile warnings and without the need to use (init-seen nil) reset  each time you use the function.

Try this:

(setq rhy3
      (gen-eval 16 '(rnd-pick
                    '((-h -) (q - - ) (q -) (5qqq = - = -)
                      (5qq = = = =) (5ss = = = =)
                      (7eee = = = = = =))) :seed 123))

(setf sl-1 '(c4 cs4 fs4 g4))

(setf p-group
      (sort-asc
       (find-unique
        (flatten
         (pitch-transpose '(-12 0)
                          (gen-repeat 5 (list sl-1)))))))

(setf p-group-rand (rnd-order p-group))
(setf p-group-rand-1 (gen-eval 8 '(rnd-order p-group)))
(span rhy3 p-group-rand-1)
(setf output (make-omn :length rhy3 :pitch p-group-rand-1))

(def-score score-name
           (:title "GUITAR_SECTION_X"
            :key-signature '(c maj)
            :time-signature (get-time-signature rhy3)
            :tempo 102
            :layout (guitar-down8-layout 'guitar))

  (guitar
   :omn output
   :channel 1
   :sound 'gm
   :program 'acoustic-guitar-nylon
   :pan 64))

 

Edited by opmo
Link to comment
Share on other sites

Thanks for this code.  However, this is the same, generally in terms of the output as the code I posted originally.

Compiling the code results in the same ordering of pitches each time - there is no change.  My question is this: is it possible to have the rhythm evaluation static (with a constant seed) while having the pitch evaluation different with each iteration of the program (with a dynamic seeding of the randomization)?  This would be helpful - to have independence of seeds within a given context and so on.

Thanks for help on this.  

Link to comment
Share on other sites

Add (init-seed nil) after each gen-loop or gen-eval expression. Those two function/macro are very spacial.

This is a bug and it is fixed in version 1.1 and you will not needed to use (init-seed nil) function each time but for now you must in order to get the desired result.

Copy the score below and try few times.

(setq rhy3
      (gen-eval 16 '(rnd-pick
                    '((-h -) (q - - ) (q -) (5qqq = - = -)
                      (5qq = = = =) (5ss = = = =)
                      (7eee = = = = = =))) :seed 123))

(init-seed nil)

(setf sl-1 '(c4 cs4 fs4 g4))

(setf p-group
      (sort-asc
       (find-unique
        (flatten
         (pitch-transpose '(-12 0)
                          (gen-repeat 5 (list sl-1)))))))

(setf p-group-rand (rnd-order p-group))
(setf p-group-rand-1 (gen-eval 8 '(rnd-order p-group)))

(span rhy3 p-group-rand-1)
(setf output (make-omn :length rhy3 :pitch p-group-rand-1))

(def-score score-name
           (:title "GUITAR_SECTION_X"
            :key-signature '(c maj)
            :time-signature (get-time-signature rhy3)
            :tempo 102
            :layout (guitar-down8-layout 'guitar))

  (guitar
   :omn output
   :channel 1
   :sound 'gm
   :program 'acoustic-guitar-nylon
   :pan 64))

This is a bug and it is fixed in version 1.1 and you will not needed to use (init-seed nil) function each time.

Link to comment
Share on other sites

This works perfectly of course.  Thank you for the idea.  I would never have thought of this.  However, with the new bug-fix in ver 1.1 it will no longer be a concern.  The only current drawback is that notation and playback do not match.  This is important for evaluation in a compositional context of course.   I do not suppose that there is a workaround for this at present.  Perhaps I will have to await ver 1.1.

 

Link to comment
Share on other sites

The notation and the playback is absolutely the same.
After the playback or notation display (what ever you do first) chose 'Last Score' shortcut, ⌃⌥⌘P for playback and ⌃⌥⌘N for notation.
You find the short keys in the Tools menu as well, look for 'Last Score' menu.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy