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

function to rnd-order length, pitch,velocity etc of a omn-list

Featured Replies

Edit: Thanks to Janusz and Stephane I could correct and improve the function .    See below.

 

This is an earlier version:

For the fun of it and hopefully some use I wrote this simple function:

;;;;;;;;;

(defun rk_rnd-order-omn (inomnl &key (exclude nil) seed  (flat nil))
"to exclude use l for :length, p for :pitch, v for :velocity; d for :duration, a for :articulation, 
 leg for :leg, ped for :ped;   i.e :exclude '(p leg)
  To be even more random flatten the omn with :flat t"
  (let* ( 
          (state *init-seed* )
          (vseed (rnd-seed seed))
          (omnl (if flat (flatten inomnl) inomnl))
          (len (if (member 'l exclude) (omn :length omnl) (rnd-order (omn :length omnl) :seed vseed) )) 
          (pit (if (member 'p exclude) (omn :pitch omnl) (rnd-order (omn :pitch omnl) :seed vseed) )) 
          (vel (if (member 'v exclude) (omn :velocity omnl) (rnd-order (omn :velocity omnl) :seed vseed) )) 
          (dur (if (member 'd exclude) (omn :duration omnl) (rnd-order (omn :duration omnl) :seed vseed) )) 
          (arti (if (member 'a exclude) (omn :articulation omnl) (rnd-order (omn :articulation omnl) :seed vseed) )) 
          (vleg (if (member 'leg exclude) (omn :leg omnl) (rnd-order (omn :leg omnl) :seed vseed) )) 
          (vped (if (member 'ped exclude) (omn :ped omnl) (rnd-order (omn :ped omnl) :seed vseed) ))
          (x )
       )
       (progn
         (init-state state) 
         (make-omn :length len :pitch pit :velocity vel :duration dur :articulation arti  :leg vleg :ped vped)
       )
  )
)  ;end rk_rnd-order-omn

 

(setf mat2 '((q e5 leg e fs5 leg gs5 q a5 ten cs6 ten)
  (h cs6 leg q b5 e d6 leg cs6 leg)
  (q a5 cs6 marc+leg gs5 cs6 leg)
  (h. fs5)))

(gen-loop 10 (rk_rnd-order-omn mat2 :seed 10 ))
(gen-loop 10 (rk_rnd-order-omn mat2 :flat t :seed 10 ))
(gen-loop 10 (rk_rnd-order-omn mat2 :exclude '(p ) :flat t :seed 10))

(gen-loop 10 (rk_rnd-order-omn mat2  ))
(gen-loop 10 (rk_rnd-order-omn mat2 :exclude '(p ) ))
(gen-loop 10 (rk_rnd-order-omn mat2 :exclude '(l a leg) :seed 60))
(gen-loop 10 (rk_rnd-order-omn mat2 :flat t ))
 

;;;;;;;;

 

I find the results interesting to create variations with selected similarities.

 

If there is already a function like this or another easy way to get the same results please let me know.

  • erka changed the title to function to rnd-order length, pitch,velocity etc of a omn-list
  • Author

Thanks.

Edited the code. Hope this is correct now.

You should omit the use of 'flat' or 'exclude', the keywords are often used with a different functionality in OM.

 

Here is the correct use of seed in a function:

(defun rk-rnd-order-omn (omn &key omit flatten seed)
  (let (state)
    (setf state *init-seed*)
    (setf seed (rnd-seed seed))
    (do-verbose ("rk-rnd-order-omn ~s" seed)
      (let* ((omnl (if flatten (flatten omn) omn))
             (len (if (member 'l omit) (omn :length omnl) (rnd-order (omn :length omnl) :seed (seed))))
             (pit (if (member 'p omit) (omn :pitch omnl) (rnd-order (omn :pitch omnl) :seed (seed))))
             (vel (if (member 'v omit) (omn :velocity omnl) (rnd-order (omn :velocity omnl) :seed (seed))))
             (dur (if (member 'd omit) (omn :duration omnl) (rnd-order (omn :duration omnl) :seed (seed))))
             (arti (if (member 'a omit) (get-articulation omnl) (rnd-order (get-articulation omnl) :seed (seed))))
             (out (make-omn :length len :pitch pit :velocity vel :duration dur :articulation arti)))
        (init-state state)
        out))))


 Examples:

(setf mat2 '((q e5 leg e fs5 leg gs5 q a5 ten cs6 ten)
             (h cs6 leg q b5 e d6 leg cs6 leg)
             (q a5 cs6 marc+leg gs5 cs6 leg)
             (h. fs5)))
             
(gen-loop 10 (rk-rnd-order-omn mat2 :seed 10))
(gen-loop 10 (rk-rnd-order-omn mat2 :flatten t :seed 10))
(gen-loop 10 (rk-rnd-order-omn mat2 :omit '(p) :flatten t :seed 10))
(gen-loop 10 (rk-rnd-order-omn mat2))
(gen-loop 10 (rk-rnd-order-omn mat2 :omit '(p)))
(gen-loop 10 (rk-rnd-order-omn mat2 :omit '(l a leg) :seed 60))
(gen-loop 10 (rk-rnd-order-omn mat2 :flatten t))

 

This is how the function could be written. Playing with duration will destroy the original events - as you can see in the result of your function.

  • Author

Thank you Janusz and Stephane. I learned a lot. 

Janusz I can see the chaos with the durations. Therefore I added a :withdurs option. The default ignores :durations.

here another try:

 

(defun rk_rnd-order-omn (omn &key omit seed flatten withdurs)
"To omit randomization use l for :length, p for :pitch, v for :velocity; a for :articulation in the omit-list, i.e :omit '(p arti).
  :articulation includes leg and ped.
  To be even more random flatten the omn with :flatten t.
  To be more chaotic use withdurs t."
  (let (state)
    (setf state *init-seed*)
    (setf seed (rnd-seed seed))
    (do-verbose ("rk-rnd-order-omn ~s" seed)
      (let* ((omnl (if flatten (flatten omn) omn))
             (len (if (member 'l omit) (omn :length omnl) (rnd-order (omn :length omnl) :seed (seed))))
             (pit (if (member 'p omit) (omn :pitch omnl) (rnd-order (omn :pitch omnl) :seed (seed))))
             (vel (if (member 'v omit) (omn :velocity omnl) (rnd-order (omn :velocity omnl) :seed (seed))))
             (dur (rnd-order (omn :duration omnl) :seed  (seed)) )
             (arti (if (member 'a omit) (get-articulation omnl) (rnd-order (get-articulation omnl) :seed (seed))))
             (out (if withdurs (make-omn :length len :pitch pit :velocity vel :duration dur :articulation arti )
                   (make-omn :length len :pitch pit :velocity vel :articulation arti ))))
        (init-state state)
        out))))

Create an account or sign in to comment


Copyright © 2014-2026 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

Account

Navigation

Search

Search

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.