• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Playing AudioBuffers from Memory
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Playing AudioBuffers from Memory


  • Subject: Re: Playing AudioBuffers from Memory
  • From: john <email@hidden>
  • Date: Mon, 9 Feb 2004 17:36:01 -0500

Hi Craig,

I'm using Cocoa and ioprocs, but I'm sure the copy method would be
fundamentally the same. Here's a snippet of code:

// get the relevant bytes
[theAudioData getBytes: tempBuf range: NSMakeRange(thePosition,
kFrameSize)];
// copy it
memcpy(outOutputData->mBuffers[0].mData, &tempBuf, ((MIN(dstFrames,
kFrameCount ) * 2) * 4));
// update the copy position
thePosition += kFrameSize

Prior to this the audio data is read from disk into the NSMutableData
object (theAudioData) from another thread. You'll need to adjust the
copy size to whatever you need. tempBuf is just a class member setup
just for this purpose.

-- John


> Hi,
> I am still working on recording audio. It is a challenge for me. The
> following code is recording data, and I am able to save it to disk!
> Horray, yet now the challenge is to play the captureStorage.
> captureStorage is a Ptr, and captureCurrentPtr is a Ptr and
> captureTotalBytesCaptured is a UInt32. I am having a brain freeze on
> how to unwrap the Ptr.
>
> OSStatus recordCallback(AudioDeviceID device, const AudioTimeStamp
> *now,
> const AudioBufferList *inputdata,
> const AudioTimeStamp *input_time,
> AudioBufferList *outputdata,
> const AudioTimeStamp *output_time,
> void *refCon)
> {
> MyWindowController *con = (MyWindowController *)refCon;
>
> if((inputdata != NULL) && (inputdata->mNumberBuffers > 0))
> {
> if(inputdata->mBuffers[0].mData)
> {
> if (con->captureCurrentPtr + inputdata->mBuffers[0].mDataByteSize <
> con->captureStorage + kSizeOfCaptureBuffer)
> {
> BlockMove(inputdata->mBuffers[0].mData, con->captureCurrentPtr,
> inputdata->mBuffers[0].mDataByteSize);
> con->captureCurrentPtr += inputdata->mBuffers[0].mDataByteSize;
> con->captureTotalBytesCaptured +=
> inputdata->mBuffers[0].mDataByteSize;
> }
> }
> }
> return(kAudioHardwareNoError);
> }
>
> This is my inputCallback that is called on an reverbUnit in a graph, it
> works, I get junk sizzling through when I hit a play button, yet I do
> not have a clue as to how to fill in the AudioBufferList into *ioData.
>
> OSStatus myInputCallback(void *inRefCon,
> AudioUnitRenderActionFlags *inActionFlags,
> const AudioTimeStamp *inTimeStamp,
> UInt32 inBusNumber,
> UInt32 inNumFrames,
> AudioBufferList *ioData)
> {
> MyWindowController *con = (MyWindowController *)inRefCon;
> //how do I fill in the *ioData,
> // I can't event do ioData->mBuffers[0].mData = NULL;
> ioData->mBuffers[0].mDataByteSize = 0;
> return 0;
> }
>
> All of the examples for how to do this stop at this point, and say,
> "add buffers here". Is there and example of how to "add buffers
> here". It's gotta be a memset of some kind or I gotta do some offset
> thing. I'll take any help!
>
>
> Craig Bakalian
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

References: 
 >Playing AudioBuffers from Memory (From: Craig Bakalian <email@hidden>)

  • Prev by Date: Re: On Memory Management & MusicSequence
  • Next by Date: Re: On Memory Management & MusicSequence
  • Previous by thread: Playing AudioBuffers from Memory
  • Next by thread: Re: Playing AudioBuffers from Memory
  • Index(es):
    • Date
    • Thread