danomatika / ofxPd

(maintained) a Pure Data addon for OpenFrameworks using libpd
Other
202 stars 45 forks source link

iOS audioinput buffer causes crash on setup #34

Closed stc closed 9 years ago

stc commented 10 years ago

some compiler errors arise when initializing ofxPd on iOS if you use microphone input. if using lots of memory with your app, sometimes BAD MEMORY access arise because of the audioIn(float* input, int bufferSize, int nChannels) function in ofxPd.cpp

at first time, initial buffer size is larger than desired, no matter how I set ticksperbuffer, etc. so I ended up adding this:

void ofxPd::audioIn(float* input, int bufferSize, int nChannels) { try {
if(inputBuffer != NULL) { if(bufferSize==inputBufferSize) { _LOCK(); memcpy(inputBuffer, input, bufferSize_nChannels_sizeof(float));
_UNLOCK(); } else { cout << "skip init buffersize" << endl; } } } catch (...) { ofLogError("Pd") << "could not copy input buffer, " << "check your buffer size and num channels"; } }

where inputBufferSize set manually to desired buffer size. after adding this, everything works fine, no bad memory access anymore. hope this helps

danomatika commented 10 years ago

That's weird. I've used both 1 and 2 channel input and it worked before ...

danomatika commented 9 years ago

Is this still happening or can I close this issue?

stc commented 9 years ago

we've had to remove OpenFrameworks (& ofxPd) from this project, however in my other apps, i don't run into this problem

danomatika commented 9 years ago

Yeah, I haven't seen that before either. If you're using AudioBus, sometimes the buffer size can be changed on the fly, but I haven't seen it otherwise. We catch that in the libpd Obj-C wrapper, but I'm not sure if the ofxiOSSoundStream does.