Jump to content

How to share stuff generated by rnd-sample to other parts of the code?


Recommended Posts

(setf my-sequence (make-omn
                   :length (gen-loop times (rnd-sample 1 '((q s) (q q))))
                   :pitch (gen-repeat times my-pitches)
                   :span :pitch))

(def-score my-score
  (:title "my-score"
	  :key-signature 'chromatic
	  :time-signature (gen-repeat times '((5 8 1) (4 4 1)))
	  :tempo 161)

In my-sequence, my bars are going to be a random sequence of 5/8 and 4/4. I want my score's time-signature to match, of course, but the code above will strictly alternate. It's been a very long time since I've worked with Lisp. I tried a few things using LET, but I just can't figure this out. How do I pass the current lengths generated by gen-loop's evaluations of rnd-sample so that my score ends up with a matching time-signature?

 

I wouldn't ask for this spoonfeeding if this weren't a paradigmatic situation that I need to re-understand for various uses.

 

Link to comment
Share on other sites

Your example is not very helpful. I can't see the my-pitches values, and the times value - I need to see the my-sequence output to determine the :span :pitches use.

 

I think the :span :pitches is the problem.

 

What about:

(setf my-sequence (make-omn
                   :length (gen-loop times (rnd-sample 1 '((q s) (q q))))
                   :pitch (gen-repeat times my-pitches)))

(def-score my-score
  (:title "my-score"
      :key-signature 'chromatic
      :time-signature (get-time-signature my-sequence)
      :tempo 161)

 

Link to comment
Share on other sites

OK, thanks, I thought I simplified it without losing any important info. Here's everything except the time signature:

(setf my-root -24)
(setf my-intervals '(0 1 4 7))
(setf my-pitches (pitch-transpose my-root (integer-to-pitch my-intervals)))
(setf my-lengths (rnd-sample 1 '((q s) (q q))))

(setf times 100)
(setf my-sequence (make-omn
                   :length (gen-loop times (rnd-sample 1 '((q s) (q q))))
                   :pitch (gen-repeat times my-pitches)
                   :span :pitch))
(def-score my-score
  (:title "my-score"
	  :key-signature 'chromatic
	  :time-signature <what should I put here?>
	  :tempo 161)
  (instrument-1
   :omn my-sequence
   :port 0
   :channel 1
   :volume 100
  )

  (instrument-2
   :omn my-sequence
   :port 0
   :channel 2
   :volume 60)
)

 

Link to comment
Share on other sites

One possibility:

(setf times 100)
(setf my-root -24)
(setf my-intervals '(0 1 4 7))
(setf my-pitches (pitch-transpose my-root (integer-to-pitch my-intervals)))
(setf my-lengths (gen-loop times (rnd-pick '((q s) (q q)))))

(setf my-sequence (make-omn
                   :length my-lengths
                   :pitch my-pitches))

(setf gts (get-time-signature my-sequence))

(def-score my-score
    (:title "my-score"
     :key-signature 'chromatic
     :time-signature gts
     :tempo 161)
  
  (instrument-1
   :omn my-sequence
   :port 0
   :channel 1
   :volume 100
   )
  
  (instrument-2
   :omn my-sequence
   :port 0
   :channel 2
   :volume 60)
  )

 

With rnd-sample:

 

(setf my-lengths (gen-loop times (first (rnd-sample 1 '((q s) (q q))))))

 

Link to comment
Share on other sites

Thanks, I'll study this. rnd-pick and, more importantly, get-time-signature are new for me, or more likely stuff from the tutorials that I've forgotten. Currently, I'm just trying to build toys to get used to the basic functionality and to learn what's available in the library of functions.

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