use*_*846 6 macos avfoundation avcapturesession avcapturedevice audiokit
嘿,我想知道是否有人可以指出我正确的方向。
我正在构建一个 Mac 音频应用程序,我需要执行以下操作
到目前为止,我已经研究过使用以下内容:
AudioKit
这个框架看起来很棒,并且有我想做的大部分事情的示例应用程序,但是它似乎只接受 Mac 在设置中选择的音频输入。这对我来说是不可能的,因为我希望用户能够在应用程序中进行选择(就像 GarageBand 或 Neural Dsp 插件一样)
使用AudioEngine我可以获得可用的输入设备,但我发现的所有内容都表明它们在应用程序中不可更改 - 这是显示它们的代码
struct InputDevicePicker: View {
@State var device: Device
var engine: AudioEngine
var body: some View {
Picker("Input: \(device.deviceID)", selection: $device) {
ForEach(getDevices(), id: \.self) {
Text($0.name)
}
}
.pickerStyle(MenuPickerStyle())
.onChange(of: device, perform: setInputDevice)
}
func getDevices() -> [Device] {
AudioEngine.inputDevices.compactMap { $0 }
}
func setInputDevice(to device: Device) {
// set the input device on the AudioEngine
}
}
}
Run Code Online (Sandbox Code Playgroud)
或者
AVFoundation
它有一个很好的 API,用于列出设备和设置输入,但是当涉及到处理委托提供的数据时,我不知道如何处理这个问题,即创建音频图并保存数据重播。这是委托方法供参考
extension Recorder: AVCaptureAudioDataOutputSampleBufferDelegate {
func captureOutput(_ output: AVCaptureOutput,
didOutput sampleBuffer: CMSampleBuffer,
from connection: AVCaptureConnection) {
print("Audio data recieved")
// Needs to save audio here
// Needs to play through speakers or other audio source
// Need to show audio graph
}
}
Run Code Online (Sandbox Code Playgroud)
如果有使用这些经验的人可以建议这是否可能以及我可以在哪里寻找示例/指导,那就太好了
任何帮助指示,救生员将不胜感激
如果您能走到这一步,谢谢!
| 归档时间: |
|
| 查看次数: |
138 次 |
| 最近记录: |