AudioKit 4.0.1 - Value of type 'AKSequencer

2019-07-13 11:36发布

My app has stopped working after recent upgrade of AudioKit from 3.7.1 to 4.0.1.

Here is my code:

    sequencer = AKSequencer(filename: myMidi)

    for i in 0..<popCount {

        //start Audio
        sequencer!.avTracks[i].destinationAudioUnit = gPOPs[i].samplePlayer.samplerUnit          
    }

And here is the error message I get:

Value of type 'AKSequencer' has no member 'avTracks'

Just wondering if anyone can help me with understanding what has changed and how I can fix it.

EDIT
Also tried:

sequencer!.tracks[i].destinationAudioUnit = gPOPs[i].samplePlayer.samplerUnit

And now get this error message:

Value of type 'AKMusicTrack' has no member 'destinationAudioUnit'

And tried:

sequencer!.tracks[i].internalMusicTrack = gPOPs[i].samplePlayer.samplerUnit

which gives the following error:

Cannot assign value of type 'AVAudioUnitSampler' to type 'MusicTrack?' (aka 'Optional<OpaquePointer>')

2条回答
放荡不羁爱自由
2楼-- · 2019-07-13 12:01

Sorry that this never ended up on AudioKit's core team's radar. Looks like you did properly ask the question with the audiokit hash tag. In any event, from 3.7->4.0 we made the sequencer simpler and we moved the functionality you were using into AKMIDIPlayer:

https://github.com/AudioKit/AudioKit/blob/master/AudioKit/Common/MIDI/AKMIDIPlayer.swift

If you use that and reference "tracks" instead of avTracks you should be well on your way.

查看更多
干净又极端
3楼-- · 2019-07-13 12:09

Thanks for input Aure, this helped me find my way through this issue. As did this post on Google Groups. Particularly last comment by Michael Hill.

Here is an update to my method (edited and simplified to show only necessary parts):

var MIDISamplePlayer = AKMIDISampler()
var sequencer: AKSequencer?
var mixer: AKMixer!

// initialise the mixer
mixer = AKMixer()

do  {
        audiofile = try AKAudioFile(readFileName: SoundFilename as! String, 
        baseDir: .resources)
    } catch let error as NSError {
        print("There's an error: \(error)")
    }

do {
       try sprite.MIDISamplePlayer.loadAudioFile(audiofile)
    } catch let error as NSError {
       print("There's an error: \(error)")
    }

sprite.tracker = AKAmplitudeTracker(sprite.MIDISamplePlayer)
mixer.connect(to:sprite.tracker, bus: mixer.nextInput.bus)

sequencer = AKSequencer(filename: POPmidi)
sequencer?.enableLooping()

let midi = AKMIDI()

for i in 0..<popCount {
    gPOPs[i].MIDISamplePlayer.enableMIDI(midi.client, name: "MIDISample_\(i)")
    mixer.connect(gPOPs[i].MIDISamplePlayer)
    sequencer!.tracks[i].setMIDIOutput(gPOPs[i].MIDISamplePlayer.midiIn)
}

AudioKit.start()
sequencer!.play()

Everything now working, BUT I have a mysterious sinewave tone playing at all times. I can't locate the source of it? Any help on debugging this would be a lifesaver! Thanks

查看更多
登录 后发表回答