iOS Audio unit cut sound above some frequency

爷,独闯天下 提交于 2019-12-04 16:43:06

That is not as easy as it may seem. One approach would be to use a FFT to move the data into the frequency domain, remove the high frequencies and then move back to the time domain with a reverse FFT. There are FFT functions available in iOS. See Using Fourier Transforms vDSP Programming Guide.

One starting point is Apple's sample code aurioTouch2.

In answer to a comment: A byte does not have a frequency, just an amplitude (loudness). Basically there are amplitude samples at a periodic rate such as 44100Hz. A naive approach to lowpass audio would be to remove every other sample but that does not work, it just aliases the higher frequencies into lower frequencies.

You can use AudioUnit to do this:

@constant       kAudioUnitSubType_LowPassFilter         
                A filter that passes frequencies below a specified cut-off frequency

@constant       kAudioUnitSubType_HighPassFilter        
                A filter that passes frequencies above a specified cut-off frequency

@constant       kAudioUnitSubType_BandPassFilter        
                A filter that passes frequencies between a low and high cut-off frequency.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!