prepareToPlay() and releaseResources() are never called

with Steinberg sequencers (nuendo or cubase) neither prepareToPlay() nor releaseResources() are ever called. With Samplitude it works fine.
Is this a bug or is this a known behaviour due to the steinberg architecture? It would be nice if anybody had a suggestion for a workaround.


Are you sure about that?? Looking at the code, you can see that prepareToPlay is called during the VST resume() callback, and I’m pretty certain that Cubase calls that. Are you sure you’re not just failing to spot the callback in your own code?

I can’t say anything about the versions 4 of cubase and nuendo but at least with version 3 when using a vst plugin there is no call to none of the two functions. I set breakpoints in each function and there is no call no matter how often the playback is stopped and started. When using Samplitude with the same vst plugin the functions are called each start of the playback after it was stopped. I don’t think I’m missing anything. I can reproduce this behaviour on two different machines.

You understand that you can’t expect those to be called every time the user hits play/stop, right? They get called when the audio stream starts/stops, not when the transport starts or stops. Maybe samplitude stops the audio stream when it’s not playing, but most sequencers will keep it running the whole time so that the filters are continuously streaming.

Oh sorry, you are right, that was totally what I expected because Apple Logic and Samplitude do really stop the audio stream in stop mode but the steinberg sequencers (version 3) don’t do that. I wasn’t aware of that. So it was my fault and these functions work as they are supposed to.

Thanks for your quick reply.


I would like to know, if it is ok or save to manually call the methods prepareToPlay and releaseResources?

I wrote my own AudioSource, in which these methods are used to initialise other obejcts and free them respectively. I want now to change some params for my objects, so I need to call releaseResources, setAnyNewParams, prepareToPlay.

Thanks for your help! :slight_smile:

Well only you know what’s safe for your own code, but obviously if you tried to do what you say above while the audio thread is still running, it’d cause absolute carnage.

Surely you could just use the suspendProcessing() method? Or just stop the audio entirely, and restart it?

Thanks for your answer.

Of course I change only when (audioTransportSource.isPlaying() is false). So the getNextAudioBlock-Method of my AudioSource won´t be called, while changes take effect (if you mean this method when you´re talking about “audio thread is still running” )

It looks like this. Would it be fine?

			if (currentAudioFileSource != 0 && !transportSource.isPlaying())
				currentAudioFileSource->releaseResources(); // MyAudioSource* currentAudioFileSource;
				currentAudioFileSource->prepareToPlay(m_iDevCurrentBufferSize, m_dDevCurrentSampleRate);

This looks nice, but (unfortunately) I implemented all my processing stuff in an AudioSource (actually an modified AudioFormatReaderSource).

The reason why I am asking is, that I am thinking calling these methods are reserved for other methods like audioDeviceAboutToStart and not meant for calling them manually, like when the user chooses another ProcMode. So I am a little bit worried about calling them.

Stopping the transport isn’t the same as stopping callbacks. The transport source keeps running, and could decide to keep its input sources running too, e.g. for background buffering. The only time you can safely assume it won’t get a callback is after the releaseResources() call.

Probably the best approach is just to implement something like suspendProcessing() in your own code. It’s very easy to do that.


Who checks the boolean “suspended” and stops then calling the audio-callback “getNextAudioBlock” ?

I searched in amalamated, but there is no use of this boolean, except of setting it within suspendProcessing().

Your processing code would check isSuspended() in its process method and if it’s suspended, should either emit silence or bypass the input as appropriate. (I should probably explain that better in the comments…)

kuul, this sounds very good. I will think about it :slight_smile:

For the time beeing I intend to use the releaseResources() call.
In order to ascertain myself, please let me ask concretely: Is it true, that the methods prepareToPlay and releaseResourses() are not explicitly intended for being called by JUCE internal functions/methods?

That’s right. They’re not intended to be used directly.

Honestly, if you feel you need to call them, it’s a sign that you probably need to rethink your design.

1 Like