Create an audio file on your iPhone / iPad from many other audio files (mixer)

I am trying to create something similar like a piano app on iPhone. When people press a key, he plays a piano note. Basically, at the moment there will be only 7 notes (C). Each note is a .caf file, and its length is 5 seconds.

I donโ€™t know if there is a way to save the user of the song that was played and exported to mp3 / caf? AVAudioRecord seems to be just a microphone input.

Many thanks

+4
source share
1 answer

For such an application, you probably do not want to record to an audio file - instead, record notes and timings for a more compact format, and then play back the same as if the user had pressed notes on recorded times.

If you want to export the audio file format, you can write a simple mixer that adds together separate samples from the original samples with the correct offsets and puts the results in the output audio buffer. You might also need to write a very simple compressor to save sample size without distortion caused by clipping. This can be done by dividing any total sample above 95% of the maximum sample value. There may also be a way to use OpenAL for this mix for you and play in the sound buffer.

0
source

Source: https://habr.com/ru/post/1305996/


All Articles