Starting and Stopping Drum Machine


One of my plugins is GrooveAgent 2 (a drum machine) from steinberg. It has stop and run buttons on it. To make it play you push the ‘run’ button. It works in my juce based audio host. But…when used in cubase and ‘run’ (arming the thing) is pushed it manages to start and stop itself along with cubase’s transport. So when playing a song in cubase the drum machine starts and stops automatically according to the the run/pause state of the transport.

Does anybody know HOW cubase is telling the thing to run and pause? I’m providing position info via an AudioPlayHead to the plugins, but the drum machine (and everything else?) is ignoring the state of the isPlaying flag. I know the position info is getting to the drum machine because it’s responding to the ppqPosition and tempo.

So does anybody have a clue as to what magic cubase is wielding in order to do this? - Oh…I can grab the ‘run/stop’ parameter and COULD change that (and it would work) but that takes ‘special knowledge’ of the plugin. Is there a ‘generic’ way to accomplish this? - Since steinberg wrote both cubase and grooveagent 2 it’s within the realm of possibility that they’re taking advantage of this and directly controlling the drum machine via setting a parameter I guess.


Have a look at AudioPlayHead - it contains a flag to tell the plugin whether it’s playing.

It’s ignoring the flag…In your experience can you recall anything that does pay attention to the playing/recording flags so that I can get a usage example to exercise?

Solved…In my own class ‘GraphPlayer’

class JUCE_API  GraphPlayer	: public AudioIODeviceCallback,
							  public MidiInputCallback,
							  public AudioPlayHead


Which has these methods, attached to gui widgets:


void GraphPlayer::setPlaying(bool state) {
positionInfo.isPlaying = state;
bool GraphPlayer::isPlaying() {
return positionInfo.isPlaying;

void GraphPlayer::setRecording(bool state) {
positionInfo.isRecording = state;
bool GraphPlayer::isRecording() {
return positionInfo.isRecording;

The audio callback can do this, which stops providing timing info when not playing.

void GraphPlayer::audioDeviceIOCallback (const float** const inputChannelData,
                                                  const int numInputChannels,
                                                  float** const outputChannelData,
                                                  const int numOutputChannels,
                                                  const int numSamples)
    // these should have been prepared by audioDeviceAboutToStart()...
    jassert (sampleRate > 0 && blockSize > 0);

	if( positionInfo.isPlaying ) {
		// update the timing info
		positionInfo.timeInSeconds = totalSamples / sampleRate;
		positionInfo.ppqPosition   = positionInfo.timeInSeconds / (/*quarter note duration*/ 60.0/positionInfo.bpm);
		totalSamples += numSamples;