• 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
mAudioData values
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mAudioData values


  • Subject: mAudioData values
  • From: Phillip Parker <email@hidden>
  • Date: Thu, 26 Apr 2012 21:48:35 +0100

Hello everyone,

I'm having a bit of trouble with the sample values returned from mAudioData. When I output the values to the console using this:

    SInt16 *buf = (SInt16 *)inBuffer->mAudioData;
    for(int i=0; i< inBuffer->mAudioDataByteSize / 2; i=i+2) {
        printf("\n%d\n%d ", buf[i], buf[i+1]);
    }

I receive sporadic results that don't match with results from Apple's SpeakHere example. I can record and play fine but the values are just odd. Any help or an insight into the problem would be greatly appreciated. Here's the callback function i'm using if it helps debug:

static void HandleInputBuffer (
                               void                                 *aqData,
                               AudioQueueRef                        inAQ,
                               AudioQueueBufferRef                  inBuffer,
                               const AudioTimeStamp                 *inStartTime,
                               UInt32                               inNumPackets,
                               const AudioStreamPacketDescription   *inPacketDesc
                               )  {
    RecordState *pAqData = (RecordState *) aqData;
    if (inNumPackets == 0 &&
        pAqData->dataFormat.mBytesPerPacket != 0)
        inNumPackets =
        inBuffer->mAudioDataByteSize / pAqData->dataFormat.mBytesPerPacket;

    


    SInt16 *buf = (SInt16 *)inBuffer->mAudioData;
    for(int i=0; i< inBuffer->mAudioDataByteSize / 2; i=i+2) {
        printf("\n%d\n%d ", buf[i], buf[i+1]);
    }

    if (AudioFileWritePackets (
                               pAqData->audioFile,
                               NO,
                               inBuffer->mAudioDataByteSize,
                               inPacketDesc,
                               pAqData->currentPacket,
                               &inNumPackets,
                               inBuffer->mAudioData
                               ) == noErr) {
        pAqData->currentPacket += inNumPackets;
        if (pAqData->recording == 0)
            return;
        AudioQueueEnqueueBuffer (
                                 pAqData->queue,
                                 inBuffer,
                                 0,
                                 NULL
                                 );
    }
}

Many Thanks!
Phill
 _______________________________________________
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

  • Prev by Date: Feeding audio data to a AudioUnit / AUGraph on iOS
  • Next by Date: possible to use headset mic input with speakerphone output on iPhone?
  • Previous by thread: Feeding audio data to a AudioUnit / AUGraph on iOS
  • Next by thread: possible to use headset mic input with speakerphone output on iPhone?
  • Index(es):
    • Date
    • Thread