[英]exporting filtered audio using AudioKit 5
I've been unable to find any examples that walk one through how to export audio that you have piped through AudioKit's 5 filters.我一直找不到任何示例来说明如何导出您通过 AudioKit 的 5 个过滤器传输的音频。
I want to add some effect to the audio (like reverb..etc) then export filtered audio我想为音频添加一些效果(如混响..等)然后导出过滤后的音频
here my try:这是我的尝试:
// load empty file to write
let docs = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
let dstURL:URL = docs.appendingPathComponent("rendred.caf")
var audioFile:AVAudioFile!
do {
audioFile = try AVAudioFile(forReading: dstURL)
} catch {
Log("Could not load file")
}
// duration of audio after add some effects
let duration = self.conductor.player.duration
let rendredTime = Double(duration)
// using AudioEngine() to export mixed audio but it's not work <----🛑
do {
try? self.conductor.engine.renderToFile(audioFile, duration: rendredTime, prerender: {
self.conductor.player.play()
})
}
I'm not sure how renderToFile()
function work我不确定
renderToFile()
函数是如何工作的
It's hard to answer without your answers to what Mark Jeschke asked you but in general:如果没有您对 Mark Jeschke 所问的问题的回答,您很难回答,但总的来说:
You can load the audio file, create a new reverb (like CostelloReverb for example).您可以加载音频文件,创建新的混响(例如 CostelloReverb)。 Put the loaded audio as a node to the reverb.
将加载的音频作为节点加入混响。 Put the reverb as the output (again - it depends what exactly you want to do) to the AudioEngine output.
将混响作为输出(同样 - 这取决于您想要做什么)到 AudioEngine 输出。
If you want to blend with playback you can use DryWetMixer.如果您想与播放混合,您可以使用 DryWetMixer。
Some general example:一些一般示例:
import Foundation
import AudioKit
import SoundpipeAudioKit
class AudioProcessing {
let audioFile:(choose the way you want to load/play)
let playback :(same)
let reverb:CostelloReverb
let dryWetMix:DryWetMixer
let engine = AudioEngine()
init() {
(init the audioFile and playback here)
reverb = CostelloReverb(audioFile)
dryWetMix = DryWetMixer(playback, reverb)
engine.output = dryWetMix
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.