I am trying to add audio output to my app. I’ve compiled the audio output example and it works fine. I’ve added an audio requested function and when I call
ofSoundStreamSetup(1,0,this, sampleRate,sampleSize, 2);
I get a runtime error.
any ideas?
I am trying to add audio output to my app. I’ve compiled the audio output example and it works fine. I’ve added an audio requested function and when I call
ofSoundStreamSetup(1,0,this, sampleRate,sampleSize, 2);
I get a runtime error.
any ideas?
Please post the relevant parts of your code up and I’ll take a look and see if I can help you sort it out.
void testApp::setup(){
// audio
printf("starting audio...");
curIndex = 0;
sampleSize = 512;
int sampleRate = 44100;
exportAudio = false;
ofSoundStreamSetup(1,0,this, sampleRate,sampleSize, 2);
printf("done\n");
....
I see “starting audio…” in the console and then the runtime error pops up. It doesn’t get past the ofSoundStreamSetup line.
I also have an audio requested callback setup, but it never even gets hit.
in the header:
void audioRequested(float * output, int bufferSize, int nChannels);
in the cpp:
void testApp::audioRequested (float * output, int bufferSize, int nChannels){
printf("Audio requested!\n");
}
I just ran the debugger in VS and it says:
Unhandled exception at 0x7c812aeb in movieGrabberExample.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012e948…
Okay, I’ve tracked the error to this line in ofSoundStream.cpp
void ofSoundStreamSetup(int nOutputs, int nInputs, ofBaseApp * OFSA, int sampleRate, int bufferSize, int nBuffers){
...
...
audio = new RtAudio();
It fails on instantiating RtAudio.
are you in debug or release?
are you using 0.06 OF, vs 2008?
can you try rebuilding the project and / or switching the build target and see if that helps ?
do the normal 0.06 audio input and audio output examples that use rtAudio compile and run for you in both targets?
just to point out, we’ve had issues in the past with using release rtAudio on a debug build or a debug rtAudio library in a release build, but that should be setup right for both examples in VS download. the problem is with different memory layouts and you get a crash there…
take care,
zach
Ah, Zach beat me to it. Yeah, if the normal examples run ok, then it’s not the lib. That’s an odd error though…failing on the next call to openStream() would make more sense I’d think.
[quote author=“zach”]are you in debug or release?
are you using 0.06 OF, vs 2008?
[/quote]
Yes
can you try rebuilding the project and / or switching the build target and see if that helps ?
do the normal 0.06 audio input and audio output examples that use rtAudio compile and run for you in both targets?
in debug mode everything works fine. When i build AudioOutputExample in release yields this:
1>Generating Code...
1>Linking...
1>fatal error C1900: Il mismatch between 'P1' version '20080116' and 'P2' version '20070207'
1>LINK : fatal error LNK1257: code generation failed
Normally I just do a clean then rebuild and it fixes this issue, but not this time.
just to point out, we’ve had issues in the past with using release rtAudio on a debug build or a debug rtAudio library in a release build, but that should be setup right for both examples in VS download. the problem is with different memory layouts and you get a crash there…
Ah, so that is the difference between rtAudio.lib and rtAudioD.lib?
take care,
zach
from the looks of it, you might want to try resintalling VS:
http://stackoverflow.com/questions/1322-…-p2-version
it looks like something is wrong there? can you give that a try first?
I’m thinking that maybe you have wrong service pack or something like that, and it’s causing some compilation issues. (like what we see when we mix the debug and release versions of rtAudio)
take care,
zach
Alright I just downloaded the VS 2008 service pack 1. This fixed the linker error and now, using rtAudio.lib as opposed to rtAudioD.lib, everything works. Thanks for your help zach!
oh great – glad to hear it’s all up and running.
take care!
zach