[英]Is there a way to create a spectrogram of an audio file using Swift and AudioKit?
[英]exporting filtered audio using AudioKit 5
我一直找不到任何示例来说明如何导出您通过 AudioKit 的 5 个过滤器传输的音频。
我想为音频添加一些效果(如混响..等)然后导出过滤后的音频
这是我的尝试:
// 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()
})
}
我不确定renderToFile()
函数是如何工作的
如果没有您对 Mark Jeschke 所问的问题的回答,您很难回答,但总的来说:
您可以加载音频文件,创建新的混响(例如 CostelloReverb)。 将加载的音频作为节点加入混响。 将混响作为输出(同样 - 这取决于您想要做什么)到 AudioEngine 输出。
如果您想与播放混合,您可以使用 DryWetMixer。
一些一般示例:
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.