Listening to audio events from classes that don't extend ofBaseApp

I’m still in the early learning stages with openFrameworks, and am currently wrapping my head around the event system. I’m having trouble listening to audio events outside of the application class.

Looking at the docs and examples I could find, I thought I could add a listener in a class:

  
  
  
// in wlSequencer.cpp   
wlSequencer::wlSequencer() {  
    cout << "wlSequencer constructor" << endl;  
  
    ofAddListener(ofEvents().audioRequested, this, &wlSequencer::audioOut);  
}  
  
// the event handler  
void wlSequencer::audioOut(ofAudioEventArgs &eventArgs) {  
    cout << "wlSequencer::audioOut()" << endl;  
  
    audioOut(eventArgs.buffer, eventArgs.bufferSize, eventArgs.nChannels);  
}  
  
  

And in my application class, calling ofSoundStreamSetup in order to get the audio events flowing:

  
  
  
void testApp::setup(){  
    cout << "Starting up... " << endl;  
      
    seq = new wlSequencer();  
      
    ofSoundStreamSetup(1,0,this,96000,256,4);  
}  
  
  

The audioOut method gets called in the application class, as expected. Unfortunately, the listener in the wlSequencer class doesn’t pick up the audio event. This type of thing *does* work with other events (e.g. mouse/keyboard), just not with audio.

In order to get it working, I am re-broadcasting the event from with the application’s audioOut method:

  
  
  
// no ofEventArgs subclass argument, so I guess this isn't actually a listener?  
void testApp::audioOut(float *output, int bufferSize, int numChannels) {  
    ofAudioEventArgs args;  
    args.buffer = output;  
    args.bufferSize = bufferSize;  
    args.nChannels = numChannels;  
    ofNotifyEvent(ofEvents().audioRequested, args, this);  
}  
  
  

Once I do that, the wlSequencer class picks up the events… but I think maybe I’m missing something in order to listen to the events directly without needing to call ofNotifyEvent?