Obtain track details in prepareToPlay callback

I suspect this is a simple thing and I am just not seeing it in the documentation. Is it possible to obtain details about the track that a plugin is on? For example, in the AudioProcessor::prepareToPlay, can I read information from the host track?

I am attempting (just for my own use) to write a MIDI plugin that displays information about the notes on playback for a track. I would like to be able to scroll that information across the editor display and have the start of that display occur before the note is actually being played (sort of a preview). To do that, I need to have notes (and time info) available in advance.

I suppose one way to do this would be to play the track once and my plugin could collect the data and save it as state info, then on replay, it would have it available up front (assuming it hadn’t been edited in the meantime). But that is pretty clunky.



Unfortunately, what you have in mind is not that simple. Every plugin gets the data from the host in real time for processing. Events on the timeline are only given to the plugin when they are played. This means that you can either display the notes played in the past or, as you said yourself, record the signal once.

Many other plugins (Autotune, Melodyne, …) also have your problem. In the past they used the second method to load the signal into the plugin, meanwhile there is also the ARA standard, which unfortunately won’t be able to help you with MIDI (as far as I know).

1 Like

Hello and thank you!

I appreciate the response. It helps me direct my efforts. I use the Melodyne plugin and that is partly what made me think it was possible to accomplish what I was asking.

I will work on my alternative approach then. And that will work fine for my own use case even though it is not quite as clean. Maybe I can use some kind of bounce/freeze trick to be able to read the notes quickly.

(And also thank you for the github juce-cookbook … it was helpful to me in getting things figured out with JUCE).


1 Like