alexbw / novocaine

Painless high-performance audio on iOS and Mac OS X
http://alexbw.github.com/novocaine/
MIT License
2.23k stars 274 forks source link

Does default sample rate cause resampling and setting buffer size for minimum latency? #138

Closed ilkercankaya closed 3 years ago

ilkercankaya commented 3 years ago

Hello, Firstly HUGE thanks for the library. Working with AudioUnit RemoteIO is a real pain!

I am wondering two things: 1 - I see that you set the sample rate here with the following code:

    // TODO: check this works on iOS!
    _inputFormat.mSampleRate = 44100.0;
    _outputFormat.mSampleRate = 44100.0;

AFAIK newest iphones have a default sample rate of 48kHz, is there a resampling done to ensure 44100kHz gets resampled to 48kHz? Is this done by Apple automatically?

2 - Can I set the buffer size with AudioSessionSetProperty? Normally with AudioUnits you can ask for a preferred buffer size with the following code:

float aBufferLength = 0.005; // In seconds
AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareIOBufferDuration, 
                        sizeof(aBufferLength), &aBufferLength);

Does this also affect novocaine's internal buffer size?

ilkercankaya commented 3 years ago

1 is Mentioned here, so I am closing this issue :) https://github.com/alexbw/novocaine/pull/134