prepareToPlay and releaseResources are not getting called?

First of all, let me say, that I am relatively new to Juce and C++, so there is a strong chance, that the error is on my side.
It seems to me that the prepareToPlay and the releaseResources methods of the plugin are not getting called, when starting or stopping the sequencer. At least not in Live 8.1.1 and Renoise 2.1 on Windows XP. I found out, when debugging my own plugin, but it has the same behaviour with the demo plugin.

To reproduce do the following:
-compile the demo plugin from the latest tip
-set breakpoints inside both functions
-start Live and insert the plugin in a track
-attach debugging to the Live process
-start and stop the sequencer-> the functions don´t get called

Am I missing something about how these functions work? Maybe I´m making a very stupid mistake, as nobody seems to have had this problem before. Anyway, help is very much appreciated.

Have you tried starting live from inside the IDE and can you reach breakpoints at other locations?


I’d be surprised if these functions weren’t called - pretty well every AudioSource depends on them.

Have you tried simply putting “print” statements in the AudioSource’s constructor and its prepareToPlay and releaseResources, and looking at the console? I’m not sure where the console is on Windows but I’m sure it’s somewhere.

Thank you both very much for your help. Just like I guessed in my first post, it was my mistake. I thought, that both methods would be called by the host, every time the playing is started or stopped. I had searched the forum for “prepare to play” but not for “prepareToPlay”, so I missed this thread, which explains everything.

Thanks again for taking the time to help me.

Well, :smiley: IMHO this is a documentation bug!

If one person falls into a trap, it might be their fault, but if two do…

The documentation should say something like:

[]prepareToPlay() is guaranteed to be called at least once before the first call to getNextAudioBlock(), or before the first call to getNextAudioBlock() after releaseResouces() has been called.
[]releaseResources() is guaranteed to be called at least once after the last call to getNextAudioBlock() or prepareToPlay().
[]There are no other guarantees. Some streams will call prepareToPlay()/releaseResources() repeatedly if they stop and start, others will not. It is possible for releaseResources() to be called when prepareToPlay() has not.[/][/list]
Or another way to look at it that I find a little more intuitive:

[list][]An AudioStream can only have two states, prepared and released,
[]An AudioStream must always start and end its life in the released state…
[]…but getNextAudioBlock() can only be called if the AudioStream is in the prepared state.
[]prepareToPlay() puts the AudioStream into the prepared state; releaseResources() puts it in the released state.
[] prepareToPlay() and releaseResources() can be called at any time, in any order.[/][/list]

Quite so! I’ll get in there and add some extra blurb…