alexbw / novocaine

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

How to change sample rate #39

Closed soulfly closed 11 years ago

soulfly commented 11 years ago

Hi, could you explain how to change current sample rate?

Lines inputFormat.mSampleRate = 44100.0; outputFormat.mSampleRate = 44100.0;

dont affect to this

thanks

soulfly commented 11 years ago

already implemented https://github.com/soulfly/novocaine/commit/b4ce807c110c4f1b68e355a26a0617c9882c100c hope this help to other

partho-maple commented 11 years ago

I am working on an iOS audio processing app where i would like to use novocaine project. But i need to change the default input and output audio settings. The settings is(may be, but i am not sure.)...

inputFormat.mSampleRate = 44100.0; outputFormat.mSampleRate = 44100.0; mBitsPerChannel = 32; mBytesPerSample = 4 mNumberOfChannels = 2

But i need to change the input and output audio settings to the following...

inputAudioStream.mSampleRate = 8000.0; inputAudioStream.mFormatID = kAudioFormatLinearPCM; inputAudioStream.mBitsPerChannel = 16; inputAudioStream.mBytesPerFrame = 2; inputAudioStream.mChannelsPerFrame = 1; inputAudioStream.mFramesPerPacket = 1; inputAudioStream.mReserved = 0;

outputAudioStream.mSampleRate = 8000.0; outputAudioStream.mFormatID = kAudioFormatLinearPCM; outputAudioStream.mBitsPerChannel = 16; outputAudioStream.mBytesPerFrame = 2; outputAudioStream.mChannelsPerFrame = 1; outputAudioStream.mFramesPerPacket = 1; outputAudioStream.mReserved = 0; Can you please suggest me that from where and how i will be able to do this ? Any sample code would be very help full.

Thanks in advance for your help and time.

partho-maple commented 11 years ago

@soulfly Would you please answer this question ? I would be very grateful if you do that. Thanks.

soulfly commented 11 years ago

Please check my fork https://github.com/soulfly/novocaine/commit/b4ce807c110c4f1b68e355a26a0617c9882c100c

I use 8000 sample rate

partho-maple commented 11 years ago

@soulfly I have checked it and already implemented it successfully. But i couldn't change the settings. Can you please advise me that how can i change the other settings ?

soulfly commented 11 years ago

Which other settings do you need to change? Not sure exactly what you mean

partho-maple commented 11 years ago

@soulfly You have described how to change mSampleRate to 8000Hz of AudioStreamBasicDescription for both input and output.

But i also need to change mFormatID, mBitsPerChannel, mBytesPerFrame, mChannelsPerFrame, mFramesPerPacket, mReserved of AudioStreamBasicDescription for both input and output. Actually i want to change the current settings to the following for both input and output...

mFormatID = kAudioFormatLinearPCM; mBitsPerChannel = 16; mBytesPerFrame = 2; mChannelsPerFrame = 1; mFramesPerPacket = 1; mReserved = 0;

I badly need this. Please help me with this. And feel free to ask me any question.

Thank you very much for your help.