AudioKit 4.6版本:AKMIDICallbackInstrument不回叫

时间:2019-02-14 02:45:49

标签: ios swift audiokit

真的很高兴4.6中的所有添加!回顾了大部分更改之后,我发现AKMIDICallbackInstrument中没有任何明显不同的地方,但是,我无法再打回电话来工作。这是我的实现:

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
    }

当我呼叫sequencer.play()时,callbackInst无法再次触发回调。我的假设是setMIDIOutput()方法是否有所改变?如果在我的音序器中触发.noteOn事件时,如果有更好的方法来获取回调,我想知道。谢谢大家!

1 个答案:

答案 0 :(得分:0)

感谢AudioKit的贡献者oettam看到4.6.0中的很小变化影响了所有MIDI组件!此问题已在4.6.1中修复!他的承诺:https://github.com/AudioKit/AudioKit/commit/dcfbbb98058425e43af23b9df69fd9794ecc34d5