Skip to content

Instantly share code, notes, and snippets.

@Pash237
Pash237 / CreateMIDI.swift
Last active December 30, 2019 10:08
Creating MIDI file with AudioKit's AKSequencer
let sequencer = AKSequencer()
let track = sequencer.newTrack()
sequencer.setLength(AKDuration(seconds: 2.0))
track?.add(noteNumber: MIDINoteNumber(60),
velocity: MIDIVelocity(100),
position: AKDuration(seconds: 1, tempo: 120),
duration: AKDuration(seconds: 0.5, tempo: 120))
try! sequencer.genData()!.write(to: url)