0

I have a sequencer built in AudioKit made up of various AKMIDISamplers to create a 12 beat sequence. This works great. Now I would like to chain multiple sequencers together and have the sequences play one after another (instead of at the same time). I keep the Sequencer Formulas in separate functions. I am still getting a handle on Audiokit.

Cheers and Thanks!

class Conductor {

   var sequencer = AKSequencer()
     var midi = AKMIDI()
     var mixer = AKMixer()  
   var cajonA = AKMIDISampler()
     var cajonG = AKMIDISampler()
     var clave = AKMIDISampler()
     var darbukaA =  AKMIDISampler()

   init() {
        do {
            let cajonASF = try AKAudioFile(readFileName: "cajonA.wav", baseDir: .resources)
            try cajonA.loadAudioFile(cajonASF)
            cajonA.enableMIDI(midi.client, name: "DemoApp")
            mixer.connect(input: cajonA)
            AKLog("Item 1 Loaded")
            let cajonGSF = try AKAudioFile(readFileName: "cajonG.wav", baseDir: .resources)
            try cajonG.loadAudioFile(cajonGSF)
            mixer.connect(input: cajonG)
            AKLog("Item 2 Loaded")
            let claveSF = try AKAudioFile(readFileName: "clave.wav", baseDir: .resources)
            try clave.loadAudioFile(claveSF)
            mixer.connect(input: clave)
            AKLog("Item 3 Loaded")

  } ..etc



  func Seq1(_ stepSize: Float = 1.0){
        let numberOfSteps = Int(12.0)
        for i in 0 ..< numberOfSteps * 2 {
            let step = Double(i) * stepSize / 2
            if ( step == 0 || step == 1 || step == 2 || step == 3 || step == 4 || step == 5){
                sequencer.tracks[19].add(
                    noteNumber: 60,
                    velocity: 100,
                    position: AKDuration(beats: step ),
                    duration: AKDuration(beats: 1.0))
            }
            if ( step == 6.5 || step == 7.5 || step == 8.5 || step == 9.5 || step == 10.5 || step == 11.5) {
                sequencer.tracks[19].add(
                    noteNumber: 60,
                    velocity: 100,
                    position: AKDuration(beats: step ),
                    duration: AKDuration(beats: 0.5))
            }
        }//end palmaS
        for i in 0 ..< numberOfSteps * 2 {
            let step = Double(i) * stepSize / 2
            if ( step == 0 || step == 0.5 || step == 5 || step == 5.5 || step == 10 || step == 10.5){
                sequencer.tracks[6].add(
                    noteNumber: 60,
                    velocity: 100,
                    position: AKDuration(beats: step ),
                    duration: AKDuration(beats: 0.5))
            }


  ....etc


  func Seq2(_ stepSize: Float = 1.0){
        let numberOfSteps = Int(12.0)
        for i in 0 ..< numberOfSteps * 2 {
            let step = Double(i) * stepSize / 2
            if ( step == 0 || step == 1 || step == 2 || step == 3 || step == 4 || step == 5){
                sequencer.tracks[19].add(
                    noteNumber: 60,
                    velocity: 100,
                    position: AKDuration(beats: step ),
                    duration: AKDuration(beats: 1.0))
            }
            if ( step == 6.5 || step == 7.5 || step == 8.5 || step == 9.5 || step == 10.5 || step == 11.5) {
                sequencer.tracks[19].add(
                    noteNumber: 60,
                    velocity: 100,
                    position: AKDuration(beats: step ),
                    duration: AKDuration(beats: 0.5))
            }
        }//end palmaS


  ..etc till end of fucntion

  }//end of class
fletan_
  • 9
  • 2
  • Wondering if this post could help me? a solution might be to rewrite the sequence? https://stackoverflow.com/questions/50622527/audiokit-ios-aksequencer-not-restarting-playback-accurately – fletan_ Sep 07 '19 at 19:48
  • Instead of the former, I have gone with a solution of substitution. The original intent was to chain the sequences together to spice up the 12 beat sequence as in ie. 3 x 12 beat sequences, which in consequence left me having to deal with a 36beat sequence. For now using the sequencers current position I am just swapping sequencers, I rather deal with 12 beats for now, which is the original intent – fletan_ Sep 09 '19 at 03:50

0 Answers0