MS3 plugin error trying to use window.setTimeout

• Nov 7, 2024 - 19:56

This gives error, "ReferenceError: window is not defined", so how do I reference the setTimeout() method from within a MS3 plugin?


Comments

In reply to by msfp

I've got the code working but it stops on the second score.
The idea is to make a JukeBox of scores based on a master score of snippets:

The stave texts on the right give the score filename, (in current folder), and the number of seconds to play.

jukebox1.png
The loader correctly loads information for these 2 scores and presents the play option:

jukebox0.png

On pressing Play JukeBox the first score loads and correctly plays for 3 seconds. The second score then loads in it's place, (so the recursive call is working), but doesn't start playing.

Any ideas?

jukebox2.png

iSts = Jukebox status 0:Not Loaded, 1:Loaded, 2:Playing

(The callWaiter code will need to be moved into the preceding if block but this is not the issue since there are no awol scores in this test scenario.)

In reply to by yonah_ag

A really lovely plugin idea! I love it when hardcopy anthology publisher adds a contents page that shows a few bars of each piece, it makes searching for the melody stuck in my head much easier.

My wild guess of the cause of error would be the score's not yet ready after readScore(), does it work when cmds are scheduled with 1ms?

msDurn = juDurn[ixJu]
callWaiter.createObject(museJuke, {interval: 1, running:true})
.trigger.connect(function(){
  cmd('rewind)
  cmd('play')
})
iSts=0

awol LOL

In reply to by msfp

Thanks for the suggestion, I'll give it a try.

The JukeBox idea has a duration so that the user can control how much of a sample to play. A value of zero is used to play the whole score and it takes the score duration property from the plugin api. The parameter texts would be hidden in a finished score.

In reply to by msfp

The delay worked so it does look like the score wasn't quite ready. I have increased the delay to 1000ms so that there is a brief pause between scores as it sounded rather abrupt otherwise.

I've got a bug in my logic as the second score doesn't stop but I can see from the console log that I haven't quite got iSts correct through the recursive calling. This shouldn't take long to fix and then I can finish things off - there needs to be a way for the user to stop the playback.

Do you still have an unanswered question? Please log in first to post your question.