Page 1 of 1

Mozart's Musikalisches Würfelspiel

Posted: Sat Jan 09, 2021 5:00 pm
by richmond62
Which, probably, has got very little to do with either Leopold or Wolfgang, or Salieri, for that matter. 8)

I'm having a seriously nutty patch: and you too are welcome to partake in my lunacy:

Found this: http://www.cs.cornell.edu/courses/cs100 ... a5/a5.html

and thought I'd "have a go" in LiveCode:

https://www.dropbox.com/s/r52gkwlvshtnr ... e.zip?dl=0

-
MOZGEN.jpg
-
It is alright as far as it goes: BUT I cannot work out how to play audioClips sequentially so they sound like a single
sound file . . .

Re: Mozart's Musikalisches Würfelspiel

Posted: Sat Jan 09, 2021 5:25 pm
by richmond62
This is the first time I have attempted anything with sound in LiveCode since 2004.

Re: Mozart's Musikalisches Würfelspiel

Posted: Sun Jan 10, 2021 10:29 am
by richmond62
I wonder why this:

Code: Select all

on mouseUp
get the length of audioClip "M9.wav"
end mouseUp
crashes LiveCode.

macOS 11.2 beta / LC 9.6.1

Re: Mozart's Musikalisches Würfelspiel

Posted: Sun Jan 10, 2021 11:07 am
by richmond62
Screenshot 2021-01-10 at 11.59.04.png
-
If 'size' corresponds to the length of a piece . . .

The problem lies outwith LiveCode insofar as the WAV files I have of all the 'Mozart' measures have been regularised to 2 seconds in length,
obviously redulting in patch of silence at the ends of some of them.

Re: Mozart's Musikalisches Würfelspiel

Posted: Sun Jan 10, 2021 6:53 pm
by jacque
LC has set up a method to do what you want, did you look at the "prepare" entry in the dictionary? The basic idea is to start the first audio file and immediately prepare the next. When the first one is done you'll get a message which you use to fire off the next one and prepare the following one. When I get back to my Mac I'll look up the message name unless someone else beats me to it.

Re: Mozart's Musikalisches Würfelspiel

Posted: Sun Jan 10, 2021 7:10 pm
by richmond62
The problem does not seem to lie with LiveCOde, but with some software that I used to convert MIDI files
into WAV files. It 'padded' out each sound file to the nearest second: padding with silence!

Re: Mozart's Musikalisches Würfelspiel

Posted: Sun Jan 10, 2021 9:50 pm
by jacque
Your best bet is to use a player control and sound files on disk. The player can be invisible if you don't want it to show. This lets you start the player at any location in the file, which will allow you to skip the silence at the beginning. You'll probably also want to skip any silence at the end, which you can do if you query the currentTime of the player and stop playback as needed, but it's much easier to just edit the file to eliminate the silences.

Once the files are cleaned up, use the method I described to seamlessly play back all the files. Without the prepare command, there will always be a delay between audio segments because LC has to load the entire content into memory before it can be played back. The prepare command was implemented to solve this problem.

The message that is sent when playback ends is "playStopped". Write a playStopped handler that immediately starts the next file and also prepares the following one so it's ready to go. That's as close as you'll get for continuous playback.