Using ofSoundStream in my own class

Hi, I’m trying to make an audio visualizer class and I wanted to separate the responsibilities between ofApp and my class implementing ofSoundStream only in the visualizer class.

I thought that this would work:

#include "AudioVizClass.h"
#include "ofApp.h"

AudioVizClass::AudioVizClass(){
//...
}

void AudioVizClass::setup(){
//...
    soundStream.setup((ofApp*)ofGetAppPtr(), 0, 2, 44100, 256, 4);
}

//--------------------------------------------------------------
void AudioVizClass::audioIn(float * input, int bufferSize, int nChannels){    
}

But the audioIn function is not being called at all.

Did you inherit ofBaseApp class in AudioVizClass.h file?

class AudioVizClass : public ofBaseApp{

}
1 Like

I didn’t…:sweat_smile:

Just for anyone reading this after a while, after you inherit from ofBaseApp you don’t need to use (ofApp*)ofGetAppPtr()

soundStream.setup(this, 0, 2, 44100, 256, 4);

…would be enough.