[英]AudioKit 4.6 release: AKMIDICallbackInstrument not calling back
Really excited by all the additions in 4.6! 4.6中的所有新增功能实在令人兴奋! After reviewing most of the changes, I did not see anything explicitly different in
AKMIDICallbackInstrument
, however, I cannot get the call back to work anymore. 查看了大部分更改之后,我在
AKMIDICallbackInstrument
没有看到任何明显不同的AKMIDICallbackInstrument
,但是,我无法再继续使用该呼叫了。 Here is my implementation: 这是我的实现:
var sequencer: AKSequencer = AKSequencer()
var callbackTrack: AKMusicTrack = AKMusicTrack()
var callbackInst: AKMIDICallbackInstrument = AKMIDICallbackInstrument()
---
public func setupSequencerWithBeats(beats: Int, bpm: Double) {
print("Num beats: \(beats) | BPM: \(bpm)")
sequencer.setTempo(bpm)
callbackTrack = sequencer.newTrack()!
callbackTrack.setMIDIOutput(callbackInst.midiIn)
for i in 0 ..< beats {
callbackTrack.add(noteNumber: MIDINoteNumber(60), velocity: 100, position: AKDuration(beats: Double(i)), duration: AKDuration(beats: 1))
}
callbackInst.callback = {status, noteNumber, velocity in
//Using the new AKMIDIStatus object to unwrap the status and check if it's .noteOn
if let midiStatus = AKMIDIStatus(byte: status), midiStatus.type != .noteOn
{
return
}
// just some delegates to other classes
self.sequencerdDelegate?.didRecieveCallbackFromSequencer(beatNumber: self.beatNumber)
self.beatNumber += 1
}
When I call sequencer.play()
the callbackInst
fails to fire the callback anymore. 当我调用
sequencer.play()
, callbackInst
无法再次触发回调。 My assumption here is did something change with setMIDIOutput()
method? 我的假设是
setMIDIOutput()
方法是否有所改变? If there is a better way to get a callback when a .noteOn event is fired in my sequencer, I would love to know. 如果在我的音序器中触发.noteOn事件时,如果有更好的方法来获取回调,我想知道。 Thanks everyone!
感谢大家!
Thanks to AudioKit contributor oettam for seeing a very small change in the 4.6.0 that affected all MIDI components! 感谢AudioKit的贡献者oettam看到4.6.0中的很小变化影响了所有MIDI组件! This issue is fixed with 4.6.1!
此问题已在4.6.1中修复! His commit: https://github.com/AudioKit/AudioKit/commit/dcfbbb98058425e43af23b9df69fd9794ecc34d5
他的提交: https : //github.com/AudioKit/AudioKit/commit/dcfbbb98058425e43af23b9df69fd9794ecc34d5
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.