我有2个连接到AKMixer的AKSamplers,但是当我为每个AKSampler调用停止功能时,音频不会停止播放,只有当我调用AKMixer的停止时才停止播放。如何停止播放连接到AXMixer的AKSampler?
示例代码:
func stop() {
let sampler1 = AKSampler()
let sampler2 = AKSampler()
let mixer = AKMixer(sampler1, sampler2)
AudioKit.output = mixer
do {
try sampler1.loadWav("Support Objects/audio")
try sampler2.loadWav("Support Objects/audio")
} catch {
return
}
do {
try AudioKit.start()
} catch let error as NSError{
print(error.debugDescription)
}
sampler1.play(noteNumber: //some midi number)
sampler2.play(noteNumber: //some midi number)
sampler1.stop() // does not stop sampler1 from playing
}
答案 0 :(得分:2)
使用AKSampler停止音符的首选方法是停止之前启动的特定 AKSampler音符。
例如:
sampler1.play(noteNumber: yourMIDINoteNumber)
...
sampler1.stop(noteNumber: yourMIDINoteNumber)
应成功停止AKSampler。