2

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>')

Mr_P
  • 523
  • 2
  • 16
  • According to the [documentation](http://audiokit.io/docs/Classes/AKSequencer.html#/s:8AudioKit11AKSequencerC6tracksSayAA12AKMusicTrackCGv), `avTracks` got renamed to `tracks`, which is an array of `AKMusicTrack`s. – Tamás Sengel Oct 09 '17 at 12:50
  • Following this advice, tried the following: `sequencer!.tracks[i].destinationAudioUnit = gPOPs[i].samplePlayer.samplerUnit` And now get this error message: `Value of type 'AKMusicTrack' has no member 'destinationAudioUnit'` – Mr_P Oct 09 '17 at 14:47
  • This has become a blocker for me. I’m hoping someone can help here. I’m no expert in swift or audiokit, and the documentation doesn’t make clear to me what has changed. Any further pointers would be greatly appreciated. 8-) Thanks – Mr_P Oct 11 '17 at 07:19

2 Answers2

3

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

Mr_P
  • 523
  • 2
  • 16
  • 1
    Moved this sinewave issue to a new question here... https://stackoverflow.com/questions/47160168/trying-to-debug-mystery-sinewave-using-akmidisampler-in-audiokit – Mr_P Nov 07 '17 at 14:30
1

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.

Aurelius Prochazka
  • 4,510
  • 2
  • 11
  • 34
  • I can see the swift class on github but the actual class doesn't exist. I get only AKMIDISampler but not Player. – L_Sonic Nov 20 '17 at 19:44