New information!
In the process of putting together a repeatable experience with Midi Recording Demo, I found that the callback fires while midi is being played back! In other words, while recording midi, the callback does not fire even though this is when it is needed. But it does fire when you play back the midi you just recorded.
This is easy to reproduce. Simply make the following modifications to the Midi Recording Demo;
In the Component.h
file, add the te::AudioTrack::Listener
to the constructor for TrackComponent
.
class TrackComponent : public Component,
private te::ValueTreeAllEventListener,
private FlaggedAsyncUpdater,
private ChangeListener,
public te::AudioTrack::Listener
{
And in the private:
section of trackcomponent
add;
void recordedMidiMessageSentToPlugins(te::AudioTrack&, const juce::MidiMessage&) override
{
AlertWindow::showMessageBoxAsync(AlertWindow::InfoIcon,
"TrackComponent",
"We Reached the Callback!");
}
And te::AudioTrack* audioTrack;
as a member variable.
Then, over in Component.cpp
initialize the audioTrack
variable;
TrackComponent::TrackComponent (EditViewState& evs, te::Track::Ptr t)
: editViewState (evs), track (t), audioTrack(dynamic_cast<te::AudioTrack*>(t.get()))
{
Now, in the constructor add the listener, and in the destructor remove the listener;
audioTrack->addListener(this);
audioTrack->removeListener(this);
You can now run the demo, arm a midi track and record some midi. You will not see the AlertWindow for the callback.
But, if you then rewind and play the notes just recorded, the AlertWindow appears!
And, of course, we need this to happen when recording!
Thank you for your efforts with this! I appreciate it.