Jump to content
View in the app

A better way to browse. Learn more.

Opusmodus

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

(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.

 

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)

 

  • Author

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)
)

 

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))))))

 

  • Author

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.

Create an account or sign in to comment


Copyright © 2014-2025 Opusmodus™ Ltd. All rights reserved.
Product features, specifications, system requirements and availability are subject to change without notice.
Opusmodus, the Opusmodus logo, and other Opusmodus trademarks are either registered trademarks or trademarks of Opusmodus Ltd.
All other trademarks contained herein are the property of their respective owners.

Powered by Invision Community

Important Information

Terms of Use Privacy Policy

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.