iPhone:编程混合两个音频文件? [英] iPhone: Mix two audio files programmatically?

查看:188
本文介绍了iPhone:编程混合两个音频文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有两个音频文件和混合编程播放。当我玩的第一个音频文件,一段时间(动态时间)后,我需要添加第二小的音频文件,第一个音频文件的某处中间播放时第一个音频文件,然后最终我需要保存为一个音频在设备上的文件。它应该播放的音频文件与音频混音器包括我的第二个。

I want to have two audio files and mix and play it programmatically. When I am playing the first audio file, after some time(dynamic time) I need to add the second small audio file with the first audio file when somewhere middle of the first audio file is playing, then finally I need to save as one audio file on the device. It should play the audio file with the mixer audio I included the second one.

我已经通过很多论坛了,但不能得到线索究竟是如何实现这一目标?

I have gone through many forums, but couldn't get the clue exactly how to achieve this?

可能有人请澄清我下面的疑问?

Could someone please clarify my below doubts?


  1. 在这种情况下,我应该用什么样的音频文件/格式?我可以使用.avi文件?

  2. 如何设置到编程第一个音频文件的动态时间后添加第二个音频?为例如:如果第一音频总时间为2分钟,我可能需要在1分钟或1.5分钟,或在第一文件的55秒某处混合所述第二音频文件(3秒钟音频)。其动态。

  3. 如何保存在设备上的最终输出的音频文件?如果我保存音频文件编程的地方,我可以打回来?

我不知道如何来实现这一目标。请提出您的想法!

I don't know how to achieve this. Please suggest your thoughts!

推荐答案


  • 开启每个音频文件

  • 读取头信息

  • 获取原始uncom pressed音频到内存中整数每个文件的数组

  • 在你想要file2中,通过循环混合,添加文件2的int值文件1的,是一定要的任何值高于或最大下面的夹在文件1的阵列点开始(这是你如何混合音频。 ..是的,它的的简单)。如果文件2较长,你将不得不作出的第一个数组足够长的时间来完全保存文件2的剩余部分。

  • 编写新的头信息,然后从阵列的音频其中添加文件2到。

  • 如果有涉及COM pression或文件将不适合在内存中,你可能需要实现更复杂的缓冲机制。

  • Open each audio file
  • Read the header info
  • Get raw uncompressed audio into memory as an array of ints for each file
  • Starting at the point in file 1's array where you want to mix in file2, loop through, adding file2's int value to file1's, being sure to 'clip' any values above or below the max (this is how you mix audio ... yes, it's that simple). If file2 is longer, you'll have to make the first array long enough to hold the remainder of file2 completely.
  • Write new header info and then the audio from the array to which you added file2.
  • If there is compression involved or the files won't fit in memory, you may have to implement a more complex buffering scheme.
  • 这篇关于iPhone:编程混合两个音频文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆