简体   繁体   English

从许多其他音频文件(混音器)在iPhone / iPad上创建音频文件

[英]Create Audio file on iPhone/iPad from many other audio files (mixer)

I am trying to create something similar like Piano app on the iPhone. 我正在尝试在iPhone上创建类似Piano app的东西。 When people tap a key, it play a piano note. 当人们点击一个键时,它会弹奏钢琴音符。 Basically, there will have only 7 notes (C) at the moment. 基本上,目前只有7个音符(C)。 Each note is a .caf file and its length is 5 seconds. 每个音符都是.caf文件,长度为5秒。

I do not know if there is any way to save the song user played and export to mp3/caf format? 我不知道是否有任何方法可以保存用户播放的歌曲并导出为mp3 / caf格式? The AVAudioRecord seems only record from the microphone input. AVAudioRecord似乎只记录麦克风输入。

Many thanks 非常感谢

For such an app you probably don't want to record into an audio-file - instead record the note-presses and timings for a much more compact format and then play back the same as if the user was pressing the notes at the recorded times. 对于这样的应用程序,您可能不希望录制到音频文件中 - 而是记录按键和时序以获得更紧凑的格式,然后播放相同的内容,就像用户在记录时按下音符一样。

If you do want to be able to export an audio file format then you can write a simple mixer which adds together the individual samples from your source samples with the correct offsets and puts the results in your output audio buffer. 如果您确实希望能够导出音频文件格式,那么您可以编写一个简单的混音器,将源样本中的各个样本与正确的偏移量相加,并将结果放入输出音频缓冲区。 You should probably also write a very simple compressor so that you keep the sample volume without any distortion caused by 'clipping'. 您可能还应该编写一个非常简单的压缩器,以便保持样本量而不会因“剪切”而导致任何失真。 This can be done by dividing down any summed sample above 95% of the maximum sample value. 这可以通过将任何求和的样本除以最大样本值的95%来完成。 There may also be a way to use OpenAL to do this mixing for you and play back into an audio buffer. 可能还有一种方法可以使用OpenAL为您进行混音并回放到音频缓冲区。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM