Audio across scenes with ofxAppUtils?

I’ve got some scenes happening with ofxAppUtils and an audio analyzer running and drawn from my ofApp.cpp file. The analyzer gui displays correctly over all scenes… I’m hearing audio but the waveform plotter from the analyzer is not moving. Any ideas what I’m doing wrong? @danomatika ?

Probably due to the missing ofSoundBuffer callbacks in ofxApp & ofxScene. I just added those and a few others added in OF 0.9.0+ in the latest commit.

Cheers. I’ve updated and got it working… but only after i disabled ofxFFT’s fftLive from one of the scenes. Both fftLive and AudioAnalyzer had coexisted peacefully when they were both in ofApp but fftLive takes over when moved to a scene. Any suggestions? Thanks again for your great work.

Probably related to how either of those grab events automatically. ofxScene or ofxAppmay be missing a lower level callback aka void mousePressed(ofMouseEventArgs) vs. void mousePressed(int x, int y, int button), etc.

Could ofxScene be missing void audioIn(float * input, int bufferSize, int nChannels); ? Sorry. I’m new at all of this.

Hmm. Still not working properly and I fear I’m doing it all wrong. To clarify: I’m using ofxAppUtils, ofxAudioAnalyzer and ofxFilterbank and can’t get the different audio analyzers working together in a scene.

In my ofApp.ccp I have, amongst other things:

void ofApp::audioIn(float * input, int bufferSize, int nChannels){
    for (int i = 0; i < bufferSize; i++){
        left[i]	= input[i*nChannels];
        right[i]	= input[i*nChannels+1];
    audioAnalyzer1.analyze(left, bufferSize);
    audioAnalyzer2.analyze(right, bufferSize);

in ofApp.h I have, amongst other things :

        #include "ofxAudioAnalyzer.h"

        void audioIn(float *input, int bufferSize, int nChannels);
        ofSoundStream soundStream;
        ofxAudioAnalyzer audioAnalyzer1, audioAnalyzer2;
        float *left;
        float *right;

and in one of the scenes I have, amongst other things:

    #include "ofxFilterbank.h"
    ofxFilterbank filterBank;

    void audioIn(float * input, int bufferSize, int nChannels){    

What’s in the scene seems to override what’s in the ofApp whereas I’d like it to add to it, if that makes sense? ie. In most scenes I’d like just the ofxAudioAnalyzer but in one particular scene I want that AND ofxFilterBank.

The odd thing is that it has sometimes compiled the way I’d want. But then I close the generated app, rebuild/relaunch it, and without having changed a line of code it no longer works anymore. And usually when it does work it takes about a minute before ofxFilterbank and ofxAudioAnalyzer both come to life.

I’ve also tried using ofxFFT’s ofxFFTLive instead of ofxFilterbank. It’s got it’s own audioIn method and also overrides rather than adds to ofxAudioAnalyzer… The difference being that with FFTLive included in a scene, ofxAudioAnalyzer doesn’t work in any scene whereas with ofxFilterBank included instead, ofxAudioAnalyzer just doesn’t work in that particular scene.

Thanks in advance for any assistance!

@arturo, @roymacdonald, @julapy, @kylemcdonald or @benMcChesney, sorry for the call out but you guys seem to be the audio experts here… any ideas?

I’ve just discovered that pulling my headphones out and plugging them back in makes ofxFilterbank and ofAudioAnalyzer suddenly play well together in the same scene. It’s weird that it would be my headphone cable and not the one going into the laptop’s line-in. I suppose I should point out that I’m using Loopback rather than Soundflower to route my audio internally. Presuming it’s an issue linked with that somehow?

Hey @clem,
can you provide any code please?

@roymacdonald, the rest of the code is a bit of a mess right now because I’m refactoring everything to use ofxGuiExtended. Will post a link soon! Cheers.

@danomatika, one thing I’m having trouble with is accessing ofApp.cpp variables from within scenes. When i try something like ofApp::audioAnalyzer.getRms(); or ofApp::gui.addPanel("My Panel"); in a scene, when gui and audioAnalyzer are declared in ofApp, I getInvalid use of non-static data member errors.

The static error sounds like you’re trying to access one of the ofApp member variables as if it was static but its not, which is not allowed by C++. You probably want to grab the pointer to ofApp instance and then access the member variable.

I believe the example talks about this in one of the scenes:

If you’re using ofRunAppWithAppUtils() in main.cpp, you would do it this way in each scene:

#include "ofApp.h"
// grab the global pointer to the ofApp instance
ofApp *app = (ofApp *)ofxGetAppPtr();

// access the ofApp instance's member variable

If you’re not using ofRunAppWithAppUtils(), then use ofGetAppPtr() instead (not the lack of the ‘x’).

Thanks! I had seen that but, rather than modifying the commented-out code, I had used the ofxApp *app = ofxGetAppPtr(); line from the example as I thought that was a default (but in the example it’s a pointer to ofxApp and not ofApp). Sorry! I’m totally new to all of this so hadn’t fully understood the comment in the LineScene header.