好吧,我真的很困惑,因为当我更改参数并尝试使用iBAction启动()/ bypass()一个节点时,什么都没有发生。振荡器(WhiteNoise)似乎正常工作,而均衡器却无法工作。这些参数确实发生了变化,但是声音保持不变。
这是我的代码:
import AudioKit
class Conductor {
private var oscillator = AKWhiteNoise()
public var filter = AKEqualizerFilter()
private var gain = -12.0
init() {
oscillator.amplitude = 1
oscillator.stop()
filter = AKEqualizerFilter(oscillator)
filter.bypass()
AudioKit.output = filter
do {
try AudioKit.start()
} catch {
AKLog("AudioKit did not start!")
}
}
func play() {
if oscillator.isPlaying {
oscillator.stop()
} else {
oscillator.play()
}
}
func bypass(centerFrequency: Double, Q: Double) {
if filter.isBypassed {
filter.rampDuration = 0.3
filter.centerFrequency = centerFrequency
filter.bandwidth = centerFrequency/Q
filter.gain = pow(10, gain/20)
filter.start()
} else {
filter.bypass()
}
print(filter.isBypassed)
}
}
和我在ViewController中的呼叫
@IBAction func bypass(_ sender: Any) {
conductor.bypass(centerFrequency: 125, Q: 7)
}