Get plugin to get DAW playback status

I am just starting out with plugin programming and I would like to be able to get the playback states of the DAW (record, play, stop) in order to mute the channel during recording and have it open during playback. How can I read the playback state?

Thanks in advance

see getAudioPlayhead() in PluginProcessor and

Thank you! However I am still just starting out and cannot quite seem to figure it out. I guess I have to use AudioPlayHead::getCurrentPosition(). It then tells me that in there I can find an isRecording Attribute. How can I assign that to my variable?
My code is:

void PluginTest1AudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
 ScopedNoDenormals noDenormals;
 auto totalNumInputChannels  = getTotalNumInputChannels();
 auto totalNumOutputChannels = getTotalNumOutputChannels();

if (recStatus == true)
    amplitude = 0;
    amplitude = 1;

for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
    buffer.clear (i, 0, buffer.getNumSamples());

for (int channel = 0; channel < totalNumInputChannels; ++channel)
    auto* channelData = buffer.getWritePointer (channel);

    for(int sample = 0; sample < buffer.getNumSamples(); ++sample)
        channelData[sample] = buffer.getSample(channel, sample) * amplitude;


In your processBlock method :

amplitude = 1.0f; // default to full gain here because of all the things that can go wrong in the following code
	auto playhead = getPlayHead(); 
	if (playhead!=nullptr) // playhead may not always exist
		AudioPlayHead::CurrentPositionInfo info;
		if (playhead->getCurrentPosition(info)) // even if playhead exists, it may not return valid position info
			if (info.isRecording) // note that even this probably can't be trusted to work consistently across plugin formats and hosts
				amplitude = 0.0;

Note that you can only use the plugin’s AudioPlayHead and attempt to get the position info in the processBlock method. If you need to pass the information outside the method for example to show it in the GUI, you need to store the information in a member variable of your AudioProcessor subclass.


Thank you!

I do have a follow up question though. How do I make it work in the opposite direction (make the DAW record or play through the plugin)? My guess was to use
playhead->transportPlay( true );

but that doesn’t seem to do anything at all.

You cannot control the DAW from your plugin

1 Like

You can do it using ReWire, but I strongly advise against it unless you absolutely must, especially if you’re only getting started with plugin programming.

You may be interested in this approach: I have 2 open source plugins that can “override” the host transport, and run by themselves. In override mode you can set e.g. meter and BPM in the plugin itself. Source is here: - there is a manual that describes how this works from a user point of view here: - do a search for “override” and you’ll find the relevant section.