• 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: Issues for loading an array of data into a stream buffer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Issues for loading an array of data into a stream buffer


  • Subject: Re: Issues for loading an array of data into a stream buffer
  • From: David Lecoutre <email@hidden>
  • Date: Tue, 4 Aug 2009 09:52:58 -0500

I see, if I set the fields with the right values, I'm getting some sound. But it is pretty bad, I hear only noise as if I was playing the buffer very fast.
I did double check and the buffer is fully load one time. The Callback function "RenderSin" is called 90-100 times per sec, the "inFrame" variable is equal to 470 ( this is the number of values that will be load in the "mBuffers[0].mData" each time the callback function is called). The size of my buffer from java is equal 44000 ( around 1 sec of sound ). It is taking 100 callback to fully load my buffer into "mBuffers[0].mData".

This is my callback function :

OSStatus    MyRenderer(void                 *inRefCon,
                       AudioUnitRenderActionFlags     *ioActionFlags,
                       const AudioTimeStamp         *inTimeStamp,
                       UInt32                         inBusNumber,
                       UInt32                         inNumberFrames,
                       AudioBufferList             *ioData)

{
    // load 1/90 of the buffer in mBuffers[0].mData
    RenderSin (sSinWaveFrameCount,
               inNumberFrames, 
               ioData->mBuffers[0].mData,
               sSampleRate,
               sAmplitude,
               sToneFrequency,
               sWhichFormat,
               MySoundBuffer,
                SizeBuffer);

    sSinWaveFrameCount += inNumberFrames;
   
    return noErr;
}

This is how the call back function is called :

// call the callback function for 1 second...
    CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, false);

This is how I initialize the callback function :

    AURenderCallbackStruct input;
    input.inputProc = MyRenderer;
    input.inputProcRefCon = NULL;
   
    err = AudioUnitSetProperty (gOutputUnit,kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input,0, &input, sizeof(input));

I think that the call back function is called at 90-100hz and the buffer "mBuffers[0].mData" is send to the output Unit in real time ( each time that the callback function is call ). Maybe I didn't fully understand how the callback function is working.

Thanks,
David

On Mon, Aug 3, 2009 at 8:05 PM, Jeff Moore <email@hidden> wrote:
You problem is probably that you are not filling out the ASBD correctly. Specifically, you are not setting the fields, mBytesPerPacket, mBytesPerFrame, and mBitsPerChannel to the proper values to describe a 32 bit floating point number, which is four bytes in size. You have filled out the ASBD as if the 32 bit float was only two bytes long.



 _______________________________________________
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

  • Follow-Ups:
    • Re: Issues for loading an array of data into a stream buffer
      • From: Jeff Moore <email@hidden>
References: 
 >Issues for loading an array of data into a stream buffer (From: David Lecoutre <email@hidden>)
 >Re: Issues for loading an array of data into a stream buffer (From: William Stewart <email@hidden>)
 >Re: Issues for loading an array of data into a stream buffer (From: David Lecoutre <email@hidden>)
 >Re: Issues for loading an array of data into a stream buffer (From: Jeff Moore <email@hidden>)

  • Prev by Date: Realtime AC3 mixer plugin for Core Audio
  • Next by Date: [OT] How to update my software on Apple's "Download Submissions" page?
  • Previous by thread: Re: Issues for loading an array of data into a stream buffer
  • Next by thread: Re: Issues for loading an array of data into a stream buffer
  • Index(es):
    • Date
    • Thread