Hello forum,
I am working on a project currently involving 13 ofxAudioUnitFileplayer objects all playing simultaneously in sync. While they are all playing, only about 4 - 8 of them have their volume turned up above 0.0 at the same time. My problem is that when I run the program, some of the files are not playing. Stranger still, each time I run the program, different files are not playing. Sometimes, if I’m lucky, there are all playing. So, I found that between 0 and 4 tracks are not playing. I nterestingly, if I only use 7 ofxAudioUnitFilePlayer objects, I no longer have a problem.
Here’s how I’m setting up my signal chain:
First I have a object which handles groups of 3 tracks
trackStrip::trackStrip(string file1, string file2, string file3){
track1.setFile(ofToDataPath(file1));
track2.setFile(ofToDataPath(file2));
track3.setFile(ofToDataPath(file3));
mixer.setInputBusCount(3);
track1.connectTo(mixer, 0);
track2.connectTo(mixer, 1);
track3.connectTo(mixer, 2);
mixer >> tap;
}
void trackStrip::start() {
track1.loop();
track2.loop();
track3.loop();
}
then in my testApp.cpp
bg_track.setFile(ofToDataPath("audio/bg_track.wav"));
trackStrip *kick = new trackStrip("audio/kick_1.wav", "audio/kick_2.wav", "audio/kick_3.wav");
trackStrips.push_back(kick);
trackStrip *snare = new trackStrip("audio/snare_1.wav", "audio/snare_2.wav", "audio/snare_3.wav");
trackStrips.push_back(snare);
trackStrip *hats = new trackStrip("audio/hats_1.wav", "audio/hats_2.wav", "audio/hats_3.wav");
trackStrips.push_back(hats);
trackStrip *perc = new trackStrip("audio/perc_1.wav", "audio/perc_2.wav", "audio/perc_3.wav");
trackStrips.push_back(perc);
mainMixer.setInputBusCount(4);
bg_track.connectTo(mainMixer, 0);
trackStrips[0]->tap.connectTo(mainMixer, 1);
trackStrips[1]->tap.connectTo(mainMixer, 2);
trackStrips[2]->tap.connectTo(mainMixer, 3);
trackStrips[3]->tap.connectTo(mainMixer, 4);
mainMixer.setInputVolume(0.5, 0);
mainMixer >> output;
output.start();
bg_track.loop();
for (int i = 0; i < trackStrips.size(); i++) {
trackStrips[i]->start();
}
I never receive an error from the setFile function and after this part of setFile()
AudioFileGetProperty(_fileID[0],
kAudioFilePropertyAudioDataPacketCount,
&dataSize,
&numPackets);
is called, all tracks have an equal and appropriate amount of packets.
Finally I tried to set a breakpoint in the render function in the base class ofxAudioUnit to see if some of the ofxAudioUnitFilePlayer’s were not streaming audio data. However, whenever I hit the breakpoint, it would have been called by a ofxAudioUnitTap object. So I used a dynamic cast with an if statement to so that I could break only if the render function was being called by an instance of an ofxAudioUnitFilePlayer object like this:
OSStatus debug = AudioUnitRender(*_unit, ioActionFlags, inTimeStamp,
inOutputBusNumber, inNumberFrames, ioData);
ofxAudioUnitFilePlayer* filePlayer = dynamic_cast<ofxAudioUnitFilePlayer*>(this);
if (filePlayer) {
cout << "is fileplayer"; //breakpoint here
}
return debug;
and the breakpoint was never triggered. So now I’m realizing how little a really understand about audio units!
Has anyone run into problems like this when using multiple ofxAudioUnitFilePlayer objects? Could there be a built in limit to the number of them that can run simultaneously?
Any audio insight is greatly appreciated,
Jason