Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8784787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:11:31+00:00 2026-06-13T21:11:31+00:00

I was trying to set up an audio unit to render the music (instead

  • 0

I was trying to set up an audio unit to render the music (instead of Audio Queue.. which was too opaque for my purposes).. iOS doesn’t have this property kAudioDevicePropertyBufferFrameSize.. any idea how I can derive this value to set up the buffer size of my IO unit?

I found this post interesting.. it asks about the possibility of using a combination of kAudioSessionProperty_CurrentHardwareIOBufferDuration and kAudioSessionProperty_CurrentHardwareOutputLatency audio session properties to determine that value.. but there is no answer.. any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:11:32+00:00Added an answer on June 13, 2026 at 9:11 pm

    You can use the kAudioSessionProperty_CurrentHardwareIOBufferDuration property, which represents the buffer size in seconds. Multiply this by the sample rate you get from kAudioSessionProperty_CurrentHardwareSampleRate to get the number of samples you should buffer.

    The resulting buffer size should be a multiple of 2. I believe either 512 or 4096 are what you’re likely to get, but you should always base it off of the values returned from AudioSessionGetProperty.

    Example:

    Float64 sampleRate;
    UInt32 propSize = sizeof(Float64);
    AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareSampleRate, 
                            &propSize,
                            &sampleRate);
    
    Float32 bufferDuration;
    propSize = sizeof(Float32);
    AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareIOBufferDuration, 
                            &propSize,
                            &bufferDuration);
    
    UInt32 bufferLengthInFrames = sampleRate * bufferDuration;
    

    The next step is to find out the input stream format of the unit you’re sending audio to. Based on your description, I’m assuming that you’re programmatically generating audio to send to the speakers. This code assumes unit is an AudioUnit you’re sending audio to, whether that’s the RemoteIO or something like an effect Audio Unit.

    AudioStreamBasicDescription inputASBD;
    UInt32 propSize = sizeof(AudioStreamBasicDescription);
    AudioUnitGetProperty(unit,
                         kAudioUnitProperty_StreamFormat,
                         kAudioUnitScope_Input,
                         0,
                         &inputASBD,
                         &propSize);
    

    After this, inputASBD.mFormatFlags will be a bit field corresponding to the audio stream format that unit is expecting. The two most likely sets of flags are named kAudioFormatFlagsCanonical and kAudioFormatFlagsAudioUnitCanonical. These two have corresponding sample types AudioSampleType and AudioUnitSampleType that you can base your size calculation off of.

    As an aside, AudioSampleType typically represents samples coming from the mic or destined for the speakers, whereas AudioUnitSampleType is usually for samples that are intended to be processed (by an audio unit, for example). At the moment on iOS, AudioSampleType is a SInt16 and AudioUnitSampleType is fixed 8.24 number stored in a SInt32 container. Here’s a post on the Core Audio mailing list explaining this design choice

    The reason I hold back from saying something like “just use Float32, it’ll work” is because the actual bit representation of the stream is subject to change if Apple feels like it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to play audio file at particular time which i have set.for that
I have a Multichannel Mixer audio unit playing back audio files in an iOS
I am trying to have an audio only player in my App which can
Right now I'm trying to set the default audio device on Windows 7 programmatically,
I'm trying to create my own custom sound effects Audio Unit based on the
I Am trying to set a currentTime while streaming a audio src from a
I'm trying to save some audio data to a WAV file -- I have
I'm trying to use AVFoundation to have three recording modes: Audio, Video and Photo.
I am trying to stream a remote mp3 using AVPlayer. I have set up
Basically, what I'm trying to do is extract the audio from a set of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.