gpt4 book ai didi

使用 AVFoundation 和 Swift 的 iOS 多 channel 音频

转载 作者:行者123 更新时间:2023-12-03 18:47:55 34 4
gpt4 key购买 nike

我目前正处于一个项目的研究和原型(prototype)设计阶段,该项目旨在开发一个 native iOS 应用程序 (Swift 3),其中包括一个多 channel 音频播放器(多个立体声 MP3 文件)。我在网上找到的信息非常有限,尤其是用 Swift 3 编写的信息,因此我想在继续研究时我会在这里提出一个问题。

关于框架,从我到目前为止所看到的来看,似乎很清楚 AVFoundation将会完成这项工作。它的级别不太低,并且具有一套很好的功能。它支持播放多个音频文件 AVAudioPlayer 。我计划很快开始用这个制作原型(prototype)。

但是我对 Swift 和拥有大量库的 iOS 开发还是新手,所以我想知道我是否遗漏了任何东西,我是否走在正确的轨道上。任何包含一般信息和对此的想法的答案都将被投票。对于接受的答案,一些使用适当框架、AVFoundation 或合理替代方案的示例大纲代码。

如果没有答案,我会在到达那里时发布我自己的代码。

具体来说,我需要从项目资源中的 MP3 文件中获得两到十个输入 channel ,每个 channel 都有自己的增益,可以单独调整,然后所有这些混合,保持其立体声 channel ,到单个输出(设备)与主增益。有些轨道需要循环播放,有些则不需要。轨道需要精确同步。这只是为了提供信息,大纲代码就可以涵盖要点。

研究笔记和资源

<强> Apple: AVFoundation

与 AVFoundation 相关的资源集合。

<强> Apple: AVFoundation Programming Guide

这份文档乍一看似乎令人鼓舞,但实际上只涉及视频。它说:

There are two facets to the AVFoundation framework—APIs related to video and APIs related just to audio. The older audio-related classes provide easy ways to deal with audio. They are described in the Multimedia Programming Guide, not in this document.

苹果公司其他地方也提到了与此相关的“多媒体编程指南”,但从未链接过,谷歌结果指向苹果网站上未找到的页面。好像消失了。

<强> Rudi Strahl: Mixing Multiple Audio Tracks with AVFoundation

使用 AVComposition 进行比较使用多个 AVPlayer s。示例代码是 Objective-C。不确定 AVPlayers 在第二个解决方案中是如何混合的。也许与 AVAudioMix 。目前正在看这个。这篇文章对此进行了一些讨论,但没有提供任何具体细节。

<强> Audio Session Programming Guide

本文档着眼于 AVAudioSession它提供支持功能:

AVAudioSession gives you control your app’s audio behavior. You can:

  • Select the appropriate input and output routes for your app
  • Determine how your app integrates audio from other apps
  • Handle interruptions from other apps
  • Automatically configure audio for the type of app your are creating

<强> Techotopia: Playing Audio on iOS 10 using AVAudioPlayer

有关使用 AVAudioPlayer 的一些有用信息.

<强> Stack Overflow: Playing a Sound with AVAudioPlayer

用于播放声音的基本 Swift 代码。有些答案包括一些额外的功能。

<强> Hacking with Swift: How to Play Sounds Using AVAudioPlayer

再次涵盖基础知识。

<强> Sweet Tutos: How To Play Sounds Files And Manage Duration Progress – AVAudioPlayer Tutorial

已更新至 Swift 3。一些有用的信息。

<强> Xamarin: Playing Sound with AVAudioPlayer

我认为是用 Swift 2 编写的。

<强> Apple Video: WWDC 2013 Moving to AV Kit and AV Foundation

虽然没有直接相关,但我发现该视频的前 30 分钟向开发人员介绍了 OS X 10 中的 AV Kit 和 AV Foundation,提供了对该技术的有用概述。

最佳答案

我正在解决同样的问题,我能做的最好的事情就是对要使用 avplayer 播放的媒体内容进行转码,这里是 draft ,也许能有所帮助。

关于使用 AVFoundation 和 Swift 的 iOS 多 channel 音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40876363/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com