Member-only story
Play MIDI Notes in Swift’s Playgrounds
Sounds good to me!
Prerequisites:
- Coding in Swift Playgrounds (guide HERE)
A Singleton is covered in slight detail, some might benefit from the background information in a more in-depth article
Terminology
AudioToolbox: A framework to record and play audio
MIDI (Music Instrument Digital Interface): A standard for musical instruments, and can be used to play MIDI instruments on Apple Devices
MusicSequence: The music sequence previously attached to the audio engine
MusicTrack: Several music events, each timestamped using a series of beats
Motivation
I’ve created several Apps that require a small piece of audio to play (a *bing* or *chime*. I’ve experimented with AVPlayer
and AVAudioPlayer
, and looking around on the web for public domain chimes.
It wasn’t that fun I’ll admit that. The performance wasn’t where I wanted it to be, and the quality of the samples I used.
Well.
I’m a better developer now (probably). I can find a better solution (probably).