Jump to content

Featured Replies

Posted

Hallo,

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

 

REVERSE and NREVERSE are Common Lisp functions and are destructive.

The function you need to use is GEN-RETROGRADE

(setf left-lengths (gen-retrograde lengths-rests))

 

seed - an integer or nil. An integer ensures the same result each time the code is evaluated.

The seed number is the random state number.

More here:

 

 

apple-touch-icon@2.png?v=73d79a89bded
STACKOVERFLOW.COM

What is the correct definition of destructive and non-destructive constructs in LISP (or in general). I have tried to search for the actual meaning but I have only found a lot of usage of these terms

 

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