Jump to content

Having trouble getting code to run without errors


Recommended Posts

I've downloaded the trial version of Opusmodus, and it looks like exactly what I'm looking for.

 

I'm having trouble running almost all of the code examples though. (M1 MacBook, Ventura 13.1)

 

For example, I copied the score on this page and pasted it into a new opmo file.

 

(setf pitches '(c4 cs4 fs4 g4 c5))
(setf p-transp (pitch-transpose (pitch-to-integer pitches) (gen-repeat 5 (list pitches))))
(setf r-transp (gen-retrograde p-transp :flatten t))
(setf c-ambitus (ambitus '(c2 c3) p-transp))
(setf p-ambitus (ambitus '(c2 c3) p-transp :type :flat-invert))
(setf s-ambitus (ambitus '((c2 c3) (b2 f3) (g3 cs4) (fs4 g5) (c4 c5)) p-transp))
(setf lengths (span p-transp '(1/8)))
(setf interlude (span s-ambitus '(1/16)))
(setf dynamics (mclist '(p mp mf f ff)))
(setq r-dynamics (mclist '(ff f mf mp p)))

(setf p-rh1 (make-omn
             :length lengths
             :pitch p-transp
             :velocity dynamics))

(setf p-lh1 (make-omn
             :length lengths
             :pitch c-ambitus
             :velocity dynamics))

(setf p-rh2 (make-omn
             :length interlude
             :pitch s-ambitus
             :velocity r-dynamics))

(setf p-lh2 (gen-pause p-rh2 :section '(0 1 2 3 4)))

(setf p-rh3 (make-omn
             :length lengths
             :pitch r-transp
             :velocity dynamics))

(setf p-lh3 (make-omn
             :length lengths
             :pitch p-ambitus
             :velocity dynamics))

(setf rh-1 (assemble-seq p-rh1 p-rh2 p-rh3))
(setf lh-1 (assemble-seq p-lh1 p-lh2 p-lh3))

(setf timesigs (get-time-signature rh-1 :group '((5))))
(def-score lesson-16
           (:key-signature 'chromatic
            :time-signature timesigs
            :flexible-clef t
            :tempo 80
            :layout (piano-layout 'piano-rh 'piano-lh))
  
  (piano-rh
   :omn rh-1
   :channel 1
   :sound 'gm
   :program 'acoustic-grand-piano)
  
  (piano-lh
   :omn lh-1)
  )

 

Then I save the file and run it with Tools -> Evaluate Score -> Notation. That produces an error like this:

 

image.thumb.png.373052436e35b99d1c408494e97414cc.png

Maybe some functions were removed from the software since the tutorials were written? It looks like a function there rnd-range doesn't exist.

 

image.thumb.png.d03b8e1d1393231b40ca58a74b273b89.png

 

If I change rnd-range to gen-integer it gets me past that point in the code, but then it doesn't recognize the variable line-rnd which was defined in the line above where it's used.

 

image.thumb.png.8760cca3e14aace0687b141789eac9df.png

 

 

In this screenshot, I've defined line-rnd in the REPL, but then when I try to use it, the variable says that it's unbound.

 

image.thumb.png.df3cb193e220b0fc6426a0dcbd4ac671.png

 

I can define and use other variables though:

 

image.thumb.png.e52c691015045d63d2a2b63f3224c191.png

 

Most of the code examples I've tried don't run. Am I doing something wrong? I'm not very familiar with lisps, but I do a bit of computer programming in other languages.

Link to comment
Share on other sites

Here's another example from the home page:

OPUSMODUS.COM

 

Screenshot of the code:

 

image.thumb.png.9910c4746f433b788b0223b1b49085bd.png

 

My typed code:

 

;; I carefully checked that Ls and 1s are typed correctly.
(setf transition (rnd-sample 32 '(01 0rl 0lr) :seed 90198))
(setf rotation (rnd-sample 32 '(0 -1 1) :seed 431458))

(tonnetz '(c4e4g4) transition
         :net 11
         :join 1
         :rotate rotation)

 

My result:

 

image.thumb.png.18c603a4cc3f8d631cef77c370ca3643.png

 

I'm guessing that it's a bug. I'm not sure how the program is supposed to be installed, but I dragged the extracted .app file into my Applications folder. For some reason, Spotlight doesn't find it though. I press command-space and type "opus" but the app doesn't appear. Could the problem be related to that? Is there a way to clear all the program data and reinstall the trial version without losing access to the trial? I want to make sure it works on my computer before I buy it.

 

One other thing I did during installation is to set the opusmodus directory to ~/Dropbox/MUSIC/COMPOSITION/OPUSMODUS instead of the default location. I'm not sure if that might affect something.

Edited by j111
added more info
Link to comment
Share on other sites

The first value should be 0l (0L) 🙂  and not 01.
'(01 0rl 0lr)
(setf transition (rnd-sample 32 '(0L 0rl 0lr) :seed 90198))
(setf rotation (rnd-sample 32 '(0 -1 1) :seed 431458))

(tonnetz '(c4e4g4) transition
         :net 11
         :join 1
         :rotate rotation)

 

Any error has nothing to do with M1 or Intel processor.

Copy from html of pdf files will not always work - format problems.

Images are not helpful with errors, only code please.

Link to comment
Share on other sites

17 minutes ago, opmo said:

The first value should be 0l (0L) 🙂 and not 01.

 

Thanks, I checked that so many times and still missed it. 🙂

 

After fixing that, it generates the omn, but when I try to view the rendered score I get this other error. I see this error a lot, which I can only seem to fix by consing a note value to the beginning of the list.

 

image.thumb.png.59a41f3ca3349d0a470fd672cedb3b28.png

 

Example of how to get that snippet working:

 

image.thumb.png.d16ddd3787b19cc41d3be4cea3df404e.png

 

Is that the expected behavior?

 

Any ideas why other examples aren't working? For example, in the first code snippet I pasted above, if I evaluate line by line, I get an error on line 2. It doesn't seem to know what the pitch-transpose function is. Could it have something to do with the alternate location of my opusmodus folder (in Dropbox)?

 

image.thumb.png.1f9e60569213af5d2f83da14190d08e4.png

 

Link to comment
Share on other sites

Place the coursor on the end of the expression and press cmd-1

 

(tonnetz '(c4e4g4) transition
         :net 11
         :join 1
         :rotate rotation)

 

I would suggest to contact Stephane and take a introduction lesson.

All example in the How-to etc... are working 🙂

 

I copied the code and I don't see any errors:

(setf pitches '(c4 cs4 fs4 g4 c5))
(setf p-transp (pitch-transpose (pitch-to-integer pitches) (gen-repeat 5 (list pitches))))
(setf r-transp (gen-retrograde p-transp :flatten t))
(setf c-ambitus (ambitus '(c2 c3) p-transp))
(setf p-ambitus (ambitus '(c2 c3) p-transp :type :flat-invert))
(setf s-ambitus (ambitus '((c2 c3) (b2 f3) (g3 cs4) (fs4 g5) (c4 c5)) p-transp))
(setf lengths (span p-transp '(1/8)))
(setf interlude (span s-ambitus '(1/16)))
(setf dynamics (mclist '(p mp mf f ff)))
(setq r-dynamics (mclist '(ff f mf mp p)))

(setf p-rh1 (make-omn
             :length lengths
             :pitch p-transp
             :velocity dynamics))

(setf p-lh1 (make-omn
             :length lengths
             :pitch c-ambitus
             :velocity dynamics))

(setf p-rh2 (make-omn
             :length interlude
             :pitch s-ambitus
             :velocity r-dynamics))

(setf p-lh2 (gen-pause p-rh2 :section '(0 1 2 3 4)))

(setf p-rh3 (make-omn
             :length lengths
             :pitch r-transp
             :velocity dynamics))

(setf p-lh3 (make-omn
             :length lengths
             :pitch p-ambitus
             :velocity dynamics))

(setf rh-1 (assemble-seq p-rh1 p-rh2 p-rh3))
(setf lh-1 (assemble-seq p-lh1 p-lh2 p-lh3))

(setf timesigs (get-time-signature rh-1 :group '((5))))

(def-score lesson-16
           (:key-signature 'chromatic
            :time-signature timesigs
            :flexible-clef t
            :tempo 80
            :layout (piano-layout 'piano-rh 'piano-lh))
  
  (piano-rh
   :omn rh-1
   :channel 1
   :sound 'gm
   :program 'acoustic-grand-piano)
  
  (piano-lh
   :omn lh-1)
  )

 

Quit and restart the app and run the code from above.

Link to comment
Share on other sites

2 hours ago, opmo said:

Place the coursor on the end of the expression and press cmd-1

 

Thanks, I did that, but I'm getting inconsistent results. It worked now, but not earlier. Even the menu item works now. I'm not sure how lisp works other than briefly tinkering with some Scheme and Clojure years ago, but I'm wondering if that REPL is holding onto state that is causing the error(s) under certain conditions.

 

If you look at one of my snippets above, the pitch-transpose function isn't syntax highlighted and the REPL thinks it's undefined. Here's a copy of the screenshot:

 

image.thumb.png.efe3884e153a9add4a48760f73e13d1f.png

 

But when I paste the code in now, pitch-transpose is syntax-highlighted, and the REPL is aware of it.

 

image.thumb.png.529ded6e3d1e7f7f5a8096e1f0078f4d.png

 

2 hours ago, opmo said:

Quit and restart the app and run the code from above.

 

I've tried it multiple times and just did it again. Here's a video of the latest attempt. The code was pasted directly from your comment above after restarting and creating a new file.

 

 

 

 
2 hours ago, opmo said:

I would suggest to contact Stephane and take a introduction lesson.

 

Sounds like a good idea, but it's out of my budget. Even the software is out of my budget, but if I can get code running I'm going to take a risk on it. 🙂

 

Link to comment
Share on other sites

21 hours ago, Stephane Boussuge said:

help you to solve this problem

 

Thanks for your offer. I will send an email.

 

18 hours ago, Pli said:

running on m2 ventura 13.1 with installed to ~/Opusmodus

 

As a quick experiment to try to eliminate a possible cause of the problem, I just tried renaming my Opusmodus folder in Dropbox (so that the program can't find it) and then restarted the program. Opusmodus then prompted me to choose a location for my Opusmodus folder. This time I chose the default location at ~/Opusmodus and I created a new workspace before pasting in code.

 

The code example from above that works for everyone else still crashes on my computer though. It looks like it evaluates up to the piano-layout function successfully, but then fails on make-instrument, which I'm guessing is called by def-score. It looks like there are two blank spaces after the dot, so maybe there is a clue there?

 

Error: syntax error in (make-instrument .   ):
The call (make-instrument .   ) does not match the definition (make-instrument name &body body &key span text ast omn omn-plist length pitch velocity channel port sound program volume pan tuning duration duration-add controllers).

 

image.thumb.png.5f41b12481858037d28f103520ce4c7e.png

 

The one other strange behavior I noticed is that Spotlight can't find Opusmodus.app. It's there in the Applications directory, and Spotlight seems to be able to find the other apps there, but when I type Opusmodus, it doesn't show up. I checked the file permissions and ownership in a terminal (they are the same as the other apps), and forced Spotlight to reindex the Applications directory, but it still can't find the app.

 

image.thumb.png.036d84becaed645904cf8d4a006109a0.png

 

Another possibility is that there is some condition that only exists in the trial version -- I might be getting that condition because I'm using the trial version, but everyone else in the topic here is probably using the full version?

Link to comment
Share on other sites

It just started working. After clearing the caches, moving the Opusmodus directory, tinkering with things, and rebooting the computer, everything suddenly works. 🙃

 

Thanks for the help with debugging it. I'm going to dive into the function documentation tonight.

Link to comment
Share on other sites

Actually, the bug returned temporarily. I'm not sure how many users it affects, but you might be able to reproduce it with this information:

 

I wanted to move the Opusmodus directory back to Dropbox, so I did the same process as before (deleting the existing ~/Opusmodus folder and restarting the program). The new folder was named OPUSMODUS (all-caps due to a naming scheme I use) in subfolders on Dropbox.

 

(Dropbox has an online-only mode that could cause problems with some programs, but it is turned off for my music-related files.)

 

As soon as I did that, code stopped running. I rebooted the computer. Same problem. I deleted OPUSMODUS in Dropbox and restarted the computer and program. Even though the folder was now at ~/Opusmodus and I restarted multiple times, the code still wasn't working.

 

Finally, I left the folder at ~/Opusmodus alone for one more reboot (instead of recreating it after reboot), and it's working again.

 

 

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