All Projects → cemolcay → Musictheory

cemolcay / Musictheory

Licence: mit
Universal music theory library for iOS, iPadOS, macOS, tvOS and watchOS in Swift

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Musictheory

Tonal
A functional music theory library for Javascript
Stars: ✭ 2,156 (+722.9%)
Mutual labels:  interval, scale
Notable
The Markdown-based note-taking app that doesn't suck.
Stars: ✭ 18,866 (+7100.76%)
Mutual labels:  note, mac
mahler.c
Western music theory library in C99
Stars: ✭ 13 (-95.04%)
Mutual labels:  scale, interval
macOS-Tips
macOS 系统的使用技巧介绍、常用软件推荐、效率工具推荐。
Stars: ✭ 23 (-91.22%)
Mutual labels:  mac
lhtml
An app for working with local HTML files.
Stars: ✭ 86 (-67.18%)
Mutual labels:  mac
agent-mac
falcon-agent for mac
Stars: ✭ 12 (-95.42%)
Mutual labels:  mac
Portion
portion, a Python library providing data structure and operations for intervals.
Stars: ✭ 255 (-2.67%)
Mutual labels:  interval
WebDAVServerSamples
WebDAV, CalDAV & CardDAV server examples in C# and VB based on IT Hit WebDAV Server Engine for .NET
Stars: ✭ 39 (-85.11%)
Mutual labels:  mac
omnitty
Omnitty: Multiple-Machine SSH Multiplexer
Stars: ✭ 20 (-92.37%)
Mutual labels:  mac
trillion-graph
A scale demo of Neo4j Fabric spanning up to 1129 machines/shards running a 100TB (LDBC) dataset with 1.2tn nodes and relationships.
Stars: ✭ 73 (-72.14%)
Mutual labels:  scale
crypto.graphics
crypto.graphics
Stars: ✭ 20 (-92.37%)
Mutual labels:  mac
ProtonClient
An unofficial desktop client for ProtonMail done with electron nativefier
Stars: ✭ 50 (-80.92%)
Mutual labels:  mac
darim
🏕 A private journal service that supports client-side encryption
Stars: ✭ 33 (-87.4%)
Mutual labels:  note
hosts
🄯Curated lists of hosts files with various domain blocks.🄯
Stars: ✭ 15 (-94.27%)
Mutual labels:  mac
RateKit
📦RateKit for macOS
Stars: ✭ 28 (-89.31%)
Mutual labels:  mac
Rocket-Notes
The World's Fastest Note Taking App. Fast. Simple. Create a note in one tap! Create image and text notes directly from your home screen!
Stars: ✭ 20 (-92.37%)
Mutual labels:  note
CaravanPi
System for measuring and displaying various values in caravans and motor homes, including climate values, filling levels and levelling data. MagicMirror (https://magicmirror.builders/) is used for presentation. A circuit board design is available now
Stars: ✭ 14 (-94.66%)
Mutual labels:  scale
yout
🔥 YouTube playlist player for desktop. Free, no YouTube ads, floating window. Available for Linux, Mac and Windows.
Stars: ✭ 82 (-68.7%)
Mutual labels:  mac
cron-schedule
A zero-dependency cron parser and scheduler for Node.js, Deno and the browser.
Stars: ✭ 28 (-89.31%)
Mutual labels:  interval
Sengiri
Sengiri is the screen recording utility. It can easily create GIF movie.
Stars: ✭ 23 (-91.22%)
Mutual labels:  mac

MusicTheory Build Status

A music theory library with Key, Pitch, Interval, Scale and Chord representations in swift enums.

Requirements

  • Swift 4.0+
  • iOS 8.0+
  • macOS 10.9+
  • tvOS 9.0+
  • watchOS 2.0+

Install

CocoaPods

pod 'MusicTheorySwift'

Swift Package Manager

let package = Package(
  name: ...
  dependencies: [
    .package(url: "https://github.com/cemolcay/MusicTheory.git")
  ],
  targets: ...
)

Usage

MusicTheory adds a bunch of basic enums and structs that you can define pretty much any music related data. Most importants are Pitch, Key, Scale and Chord.

All data types conforms Codable, CustomStringConvertable.
Pitch, and Accident structs are RawPresentable with Int as well as ExpressibleByIntegerLiteral that you can represent them directly with Ints.

Pitch and Key

  • All keys can be defined with Key struct.
  • It has a KeyType where you can set the base key like C, D, A, G, and an Accidental where it can be .natural, .flat, sharp or more specific like .sharps(amount: 3).
  • You can create Pitches with a Key and octave.
  • Also, you can create Pitches with MIDI note number. rawValue of a pitch is its MIDI note number.
  • Pitch, Key, Accidental structs are equatable, + and - custom operators defined for making calculations easier.
  • Also, there are other helper functions or properties like frequency of a note.
  • You can define them with directly string representations as well.
let dFlat = Key(type: d, accidental: .flat)
let c4 = Pitch(key: Key(type: .c), octave: 4)
let aSharp: Key = "a#" // Key(type: .a, accidental: .sharp)
let gFlat3: Pitch = "gb3" // or "g♭3" or "Gb3" is Pitch(key: (type: .g, accidental: .flat), octave: 3)

Interval

  • Intervals are halfsteps between pitches.
  • They are IntegerLiteral and you can make add/substract them between themselves, notes or note types.
  • You can build up a custom interval with its quality, degree and semitone properties.
  • You can build scales or chords from intervals.
  • Minor, major, perfect, augmented and diminished intervals up to 2 octaves are predefined.

ScaleType and Scale

  • ScaleType enum defines a lot of readymade scales.
  • Also, you can create a custom scale type by ScaleType.custom(intervals: [Interval], description: String)
  • Scale defines a scale with a scale type and root key.
  • You can generate notes of scale in an octave range.
  • Also you can generate HarmonicField of a scale.
  • Harmonic field is all possible triad, tetrad or extended chords in a scale.
let c = Key(type: .c)
let maj: ScaleType = .major
let cMaj = Scale(type: maj, key: c)

ChordType and Chord

  • ChordType is a struct with ChordParts which are building blocks of chords.
  • You can define any chord existing with ChordType.
  • Thirds, fifths, sixths, sevenths and extensions are parts of the ChordType.
  • Each of them also structs which conforms ChordPart protocol.
  • Chord defines chords with type and a root key.
  • You can generate notes of chord in any octave range.
  • You can generate inversions of any chord.
let m13 = ChordType(
  third: .minor,
  seventh: .dominant,
  extensions: [
    ChordExtensionType(type: .thirteenth)
  ])
let cm13 = Chord(type: m13, key: Key(type: .c))
  • You can generate chord progressions with ChordProgression enum.
  • For any scale, in any harmonic field, for any inversion.
let progression = ChordProgression.i_ii_vi_iv
let cSharpHarmonicMinorTriadsProgression = progression.chords(
  for: cSharpHarmonicMinor,
  harmonicField: .triad,
  inversion: 0)

Tempo and TimeSignature

  • Tempo is a helper struct to define timings in your music app.
  • TimeSignature is number of beats in per measure and NoteValue of each beat.
  • You can calculate notes duration in any tempo by ther NoteValue.
  • Note value defines the note's duration in a beat. It could be whole note, half note, quarter note, 8th, 16th or 32nd note.

HarmonicFunctions

  • Harmonic functions is a utility for finding related notes or chords in a scale when composing.
  • You can create recommendation engines or chord generators with that.

Playgrounds

  • You can experiment with the library right away in the Xcode Playgrounds!
  • After cloning the project, build it for the Mac target,
  • Go to playground page in the project,
  • Make sure the macOS platform is selected,
  • And make sure the "Build Active Scheme" option is selected in the playground settings.
  • There are some recipes ready in the playground page, you can just run them right away.

Documentation

Full documentation is here

Unit Tests

You can find unit tests in MusicTheoryTests target.
Press ⌘+U for running tests.

AppStore

This library battle tested in my apps for iOS, macOS, watchOS and tvOS, check them out!
KeyBud (iOS, watchOS, tvOS, macOS)
FretBud (iOS, watchOS, tvOS)
ChordBud (iOS)
ArpBud (iOS)
ScaleBud (iOS, AUv3)
StepBud (iOS, AUv3)
RhythmBud (iOS, AUv3)
ArpBud 2 (iOS, AUv3)
ChordBud 2 (iOS, AUv3)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].