Starting and Stopping Drum Machine

Discuss issues relating to audio plugins

Starting and Stopping Drum Machine

Postby kurt6string » Sat Jan 14, 2012 8:27 am

Aloha,

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.

Mahalo,
Kurt
User avatar
kurt6string
JUCE UberWeenie
 
Posts: 126
Joined: Sun Dec 04, 2011 3:21 am
Location: Kapolei, Hawaii

Re: Starting and Stopping Drum Machine

Postby jules » Sat Jan 14, 2012 3:39 pm

Have a look at AudioPlayHead - it contains a flag to tell the plugin whether it's playing.
User avatar
jules
Fearless Leader
 
Posts: 17209
Joined: Mon Sep 06, 2004 9:03 am
Location: London, UK

Re: Starting and Stopping Drum Machine

Postby kurt6string » Sat Jan 14, 2012 11:53 pm

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?
User avatar
kurt6string
JUCE UberWeenie
 
Posts: 126
Joined: Sun Dec 04, 2011 3:21 am
Location: Kapolei, Hawaii

Re: Starting and Stopping Drum Machine

Postby kurt6string » Sun Jan 15, 2012 5:52 am

Solved..In my own class 'GraphPlayer'

Code: Select all
class JUCE_API  GraphPlayer   : public AudioIODeviceCallback,
                       public MidiInputCallback,
                       public AudioPlayHead
private:

   CurrentPositionInfo
      positionInfo;
...


Which has these methods, attached to gui widgets:
Code: Select all

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.

Code: Select all
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;
   }
...
User avatar
kurt6string
JUCE UberWeenie
 
Posts: 126
Joined: Sun Dec 04, 2011 3:21 am
Location: Kapolei, Hawaii


Return to Audio Plugins

Who is online

Users browsing this forum: No registered users and 2 guests