HI,
I am doing an iphone application that works with audio files. Application also contains an audio converter, so I can potentially have a file of any audio format in my /Documents folder.
What I want is to implement a smooth audio file ending by reducing volume level at the end and fading it in at the beginning of the file.
How can I do that? (just point a direction. a framework, function, method)
I can use all Apple audio frameworks, both high level and low level ones.
I can even access audio buffers while file is being converted.
Thanks in advance.
NOTE: I do not need audio Fade in/out feature while PLAYING it. I need this feature already written in audio file.
Because you are dealing with different formats, your best bet here is to apply the fade at the sample level when you are converting the data.
If you are doing the conversion offline, then you already know the number of samples in the file, so you can process
X - Bsamples normally (whereXis the total number of samples andBis the fade duration):Then, for the last
Bsamples, you’d do something like this:That would be for a linear fade slope, so if you want something fancier, well, then go knock yourself out. 😉 Basically, the formula for doing a linear fade is
y = m * x + b(remember algebra class?), where your slope in this case is1 / B, and the y offset is 1.0, which is the maximum volume gain you want to apply (ie, no gain).If you are doing the conversion in realtime, then you will need to keep
Bsamples in a ringbuffer, and then apply the above algorithm when you reach the end of processing.