Put Own Data in to AudioBuffer
Put Own Data in to AudioBuffer
- Subject: Put Own Data in to AudioBuffer
- From: "sam aspin" <email@hidden>
- Date: Tue, 14 Feb 2006 15:23:43 +0000
Hi Guys, just trying to post this again as it didnt seem to appear last
time:
Hi folks,
Im trying to get audio data i have stored in a byte array into an
AudioBuffer so I can play it back using my modified version of the
DefaultOutputUnit example.
I declared the following outside of the method...
**********************************************************
AudioBuffer myBuffer, *mb;
AudioBufferList myBufferList, *mbl;
**********************************************************
These hopefully create an AudioBuffer and AudioBufferList with pointers (i
think!)
The array is received by a native c++ method from java, and given the
reference 'b'
**********************************************************
JNIEXPORT jint JNICALL Java_JNIWrapper_mySDLNativeMethod
(JNIEnv *env, jclass theClass, jstring arg, jbyteArray b){
**********************************************************
i then try to put the data into the AudioBuffer and associate it with the
AudioBufferList. I feel I could be going wrong here....
**********************************************************
myBuffer.mNumberChannels = 1;
myBuffer.mDataByteSize = 512;
myBuffer.mData = b;
myBufferList.mNumberBuffers = 1;
myBufferList.mBuffers[0] = myBuffer;
**********************************************************
Within the DefaultOutputUnit example I have modified the
UsingDefaultNOAC.cpp file so that the original references to AudioBufferList
*ioData now refer to AudioBufferList *mbl and ioData to mbl.
e.g. MyRenderer(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *mbl)
It's quite likely that i am going about this in completely the wrong way and
if anyone can shed light on what i should be doing it would be greatly
appreciated.
BTW This code currently runs but results in a signal 11 (SIGSEGV) error
during the following loop:
for (UInt32 channel = 1; channel < mbl->mNumberBuffers; channel++){
memcpy (mbl->mBuffers[channel].mData, mbl->mBuffers[0].mData,
mbl->mBuffers[0].mDataByteSize);
thanks in advance
Sam Aspin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden