Getting Started
This guide will walk you through the basic concepts and usage patterns of the MusicTheory library.
Core Concepts
The MusicTheory library is built around several core concepts that mirror traditional music theory:
- Note
The fundamental unit of music - a specific pitch with a name, alteration, and octave.
- Interval
The distance between two notes, characterized by quality (Perfect, Major, Minor, etc.) and size.
- Scale
A sequence of notes following a specific pattern of intervals.
- Chord
A collection of notes played together, built from a root note and following specific interval patterns.
- Key Signature
Defines the tonal center and the sharps or flats used in a piece of music.
Basic Usage Patterns
Creating Notes
Notes are the building blocks of all other musical constructs:
Working with Intervals
Intervals represent the distance between notes:
Building Chords
The library supports 40+ chord types:
Generating Scales
Create and work with various scale types:
Common Patterns
Chord Progressions
Work with chord progressions using Roman numeral analysis:
Transposition
Transpose musical elements up or down:
MIDI Integration
Convert between musical notation and MIDI:
Best Practices
Immutability: All objects are immutable. Methods return new instances rather than modifying existing ones.
Fluent API: Chain method calls for readable code:
chord.AddExtension(7, IntervalQuality.Major).WithInversion(ChordInversion.First)
Type Safety: Use enums like
NoteName
,ChordType
, andScaleType
instead of stringsError Handling: The library throws descriptive exceptions for invalid operations
Next Steps
Now that you understand the basics, explore these topics: