Getting start/stop and tempochange from host


#1

Hi all,

I am writing a plugin that is depending on start and stop playback signals from the host. Well, start is the only real important one, since I have to clear some buffers, and zero some indices on start. the prepareToPlay() is called immediately when my plugin is loaded, and then never again, so this won’t do.

Also, I would love to be able to track tempo change…

Does anyone know how to have my plugin notified of the above…? Thanks in advance!

  • A

#2

look at the demo plugin and the AudioPlayHead class, it’s all there.


#3

Aaah yes, some of it is indeed there… I hadn’t thought that this would be abstracted into a nested class like this. Great! Now, I just need to set it up so I will be notified about start/stop, and don’t have to check for it myself :slight_smile:

  • A

#4

Nope, I wasn’t that lucky… I tried to install a callback with the AUBase AddPropertyListener. Didn’t get the ring. Then I thought “ok, I gotta take a hit on performance, and in every call to processBlock, check if we recently started or stopped”. No luck either, since processBlock isn’t called when the host (Logic) is not playing - duh, but AU LAb does…

So the only solution I can see now is to start a timer when the host starts, and check every very-often, to see if the host stopped yet. That is about the last thing I want to do, but right now it is what I can think of. Has anyone had any luck with the AddPropertyListener?

  • A

#5

… But obviously I can’t do this, since the playhead returned in the timer callback always states that we are not currently playing. Stuck. Allright, I will think of something :slight_smile:

Edit: Keeping a pointer to the playhead obtained in processBlock yields the same results: always not playing.

  • A

#6

For anyone interested in the ramblings of a desperate man:

I solved the problem by having a timer. This timer is reset to callback after 250 msecs at each invocation of the audio callback function (processBlock), when this timer calls back, I assume that playback has been stopeed, since the timer has not been reset for 250 msecs. The only scenario in which this fails, is if the host is stopped, and then started again within the 250 msecs…

I am not proud…

  • A

#7

There must be an option in Logic to keep the plugins running when it’s stopped?..

But your solution sounds pretty good to me - can’t think of anything better you could do. I’d have thought that if they hit stop and start within 250ms, it wouldn’t really matter if you missed it.


#8

i think it will cause problems when rendering audio tracks, 250ms might be a very long time when the host is trying to downmix tracks.


#9