print()
statement.import UIKit
import AudioKit
class ViewController: UIViewController {
var sequencer = AKAppleSequencer()
var tempo = 120.0
var division = 1
var callbacker = AKMIDICallbackInstrument { statusByte, note, _ in
print("Callback called")
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let clickTrack = sequencer.newTrack()
for i in 0 ..< division {
clickTrack?.add(noteNumber: 80,
velocity: 100,
position: AKDuration(beats: Double(i) / Double(division)),
duration: AKDuration(beats: Double(0.1 / Double(division))))
clickTrack?.add(noteNumber: 60,
velocity: 100,
position: AKDuration(beats: (Double(i) + 0.5) / Double(division)),
duration: AKDuration(beats: Double(0.1 / Double(division))))
}
clickTrack?.setMIDIOutput(callbacker.midiIn)
clickTrack?.setLoopInfo(AKDuration(beats: 1.0), numberOfLoops: 10)
sequencer.setTempo(tempo)
sequencer.play()
}
}
If you are hearing sounds, but haven't connected your tracks to an audio generating output, then you are probably hearing the default sampler. This will happen if you do not have audio enabled, in 'Background Modes'. If you look at the console output, you should see a message to instructing you to make sure that it is enabled - it is necessary with MusicSequence
/AKAppleSequencer
.