Skip to content

Instantly share code, notes, and snippets.

@mmuszynski
Last active January 19, 2017 21:31
Show Gist options
  • Save mmuszynski/7db4f1d037361f12dca5e6c335c7a355 to your computer and use it in GitHub Desktop.
Save mmuszynski/7db4f1d037361f12dca5e6c335c7a355 to your computer and use it in GitHub Desktop.
//Intervals
let C0 = MusicPitch(name: .c, accidental: .natural, octave: 0)
let D0 = MusicPitch(name: .d, accidental: .natural, octave: 0)
let majorSecond = try MusicInterval(rootPitch: C0, destinationPitch: D0)
XCTAssertEqual(majorSecond.halfStepDistance, 2)
XCTAssertEqual(majorSecond.quality, MusicIntervalQuality.major)
XCTAssertEqual(majorSecond.quantity, MusicIntervalQuantity.second)
//Scales
let root = MusicPitch(name: .d, accidental: .natural, octave: 0)
let scale = MusicScale(root: root, mode: .harmonicMinor)
let dMinor = [root,
MusicPitch(name: .e, accidental: .natural, octave: 0),
MusicPitch(name: .f, accidental: .natural, octave: 0),
MusicPitch(name: .g, accidental: .natural, octave: 0),
MusicPitch(name: .a, accidental: .natural, octave: 0),
MusicPitch(name: .b, accidental: .flat, octave: 0),
MusicPitch(name: .c, accidental: .sharp, octave: 1)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment