Expand description
Modules§
- chord
- this module defines the chord-related implementations, interfaces, and more in an effort to generalize their behavior across various representations.
- comp
- composition related implementations, primitives, and utilities for creating music with the framework.
- consts
- various constants defined and used throughout the library.
- error
- this module defines the
Errortype and provides a type alias for aResultwith anError. - freq
- intervals
- this module implements intervallic relationships in music theory
- note
- octave
- pitch
- this module implements various pitch-related items used throughout the library. Some of the
key abstractions defined here are the
PitchandPitchClassimplementations designed to generically represent these musical concepts. ThePitchClassisn’t necessarily intended to be used directly, rather through type aliases such asC,DSharp,EFlat, etc. Additionally, the module provides various traits, types, and other implementations aimed at facilitating the manipulation and representation of pitches in a musical context. - traits
- A collection of useful traits focused on musical abstractions, composition, and operations.
- types
- this module imimplements various types and other primitives used throughout the library
- utils
- useful utilities for musical primitives for converting between different representations, classification routines, and more.
Structs§
- AFlat
Note - ANote
- ASharp
Note - Aspn
- An american scientific pitch notation (
Aspn) representation of a musical note; this standard is used to represent notes in a way that is consistent with the American scientific pitch notation system, which uses a combination of a pitch class (represented as an integer) and an octave (represented as anOctave) to uniquely identify a musical note. The pitch class is the note’s position in the chromatic scale, while the octave indicates the note’s position in the musical range. - Augmented
- BFlat
Note - BNote
- CNote
- CSharp
Note - Const
Interval - DFlat
Note - DNote
- DSharp
Note - Diminished
- EFlat
Note - ENote
- FNote
- FSharp
Note - Fifth
- Fifths
Iter - An iterator over the variants of Fifths
- Flat
- Flats
Iter - An iterator over the variants of Flats
- Fourth
- Fourths
Iter - An iterator over the variants of Fourths
- Frequency
- The
Frequencytype is a generic wrapper around typeTthat implements theRawFrequencytrait. This implementation is designed to provide a consistent interface for dealing with frequencies within the crate, enabling conversion, arithmetic operations, and other utilities that are common to frequency values. - GFlat
Note - GNote
- GSharp
Note - Half
Tone - Harmonic
Function Iter - An iterator over the variants of HarmonicFunction
- Interval
Base - Major
- Minor
- Natural
- Naturals
Iter - An iterator over the variants of Naturals
- Note
Base - The
NoteBaseis a generic representation of a musical note - Note
Flag Iter - An iterator over the variants of NoteFlag
- Octave
- A type defining an octave
- Perfect
- Pitch
- The
Pitchimplementation is a generic wrapper used to represent a musical pitch. A pitch is defined to be a perceptual property of sounds that enables one to define the highness or lowness of a sound. In music, pitch is often associated with the frequency of a sound wave, with higher frequencies corresponding to higher pitches. - Pitch
Class - The
PitchClassimplementations works to generically define the structure for a pitch class. This is accomplished through the use of two type parameters:N, which defines the note (e.g., C, D, E, etc.), andK, which defines the kind of pitch (e.g., sharp, flat, natural, etc.). - Scale
- The
Scaleimplementation uses the defined root or anchor frequency as the basis for classfifications and other related computations. - Seventh
- Sevenths
Iter - An iterator over the variants of Sevenths
- Sharp
- Sharps
Iter - An iterator over the variants of Sharps
- Sixth
- Sixths
Iter - An iterator over the variants of Sixths
- Step
Size Iter - An iterator over the variants of StepSize
- Third
- Thirds
Iter - An iterator over the variants of Thirds
- Tone
Enums§
- Error
- The
Errorenum represents various errors that can occur in the application. - Fifths
- Flats
- A representation of the flat pitch class
- Fourths
- Harmonic
Function - Harmonic functions in tonal music
- Intervals
- Naturals
- A representation of the natural pitch class
- Note
Flag - Notes
Notesis an enumeration of all allowed symbolic representations of pitch classes considered in music theory. For us, it provides a dynamic way of managing the different pitch classes whiole providing a direct mapping to a static index- Sevenths
- Sharps
- A representation of the sharp pitch class
- Single
OrDouble - Sixths
- Step
Size StepSizeprovides an enumeration for musical step sizes, namely semitones and tones. The implementation primarily works to provide a generic unit of measurement for musical intervals.- Thirds
- Represents the various kinds of thirds in music theory.
Constants§
- A4_
FREQUENCY - Defines the frequency of the A4 note in Hertz.
- C4_
FREQUENCY - Defines the frequency of the C4 note in Hertz.
- C_
MAJOR_ SCALE - The C Major scale represented as an array of pitch class indices.
- DOUBLE_
FLAT_ SYMBOL - DOUBLE_
SHARP_ SYMBOL - ENHARMONIC_
EQUIVALENTS - FLAT_
PITCH_ CLASSES - FLAT_
SYMBOL - NATURAL_
PITCH_ CLASSES - NATURAL_
SYMBOL - OCTAVE_
SIZE - SHARP_
PITCH_ CLASSES - SHARP_
SYMBOL
Traits§
- Accidental
- AsAspn
- The
AsAspntrait is used to convert a reference into aAspn - AsFrequency
AsFrequencyis a trait enabling the conversion of a reference to a type into aFrequencyinstance.- AsOctave
- A trait for converting a reference into an
Octave. - AsPitch
- A trait for converting a reference into a
Pitch. - Chroma
Chromadefines a trait for establishing a chromatic relationship between pitches.- Classify
Classifydefines an interface for objects capable of being classified as other types.- Classify
By ClassifyByis a trait defining the ability for an object to be classified by or with another object.- Interval
Kind - The
IntervalKindtrait is a sealed marker trait used to define the allowable representations, or kinds, of musical intervals. - Into
Aspn - A trait for converting a type into a
Aspn - Into
Frequency - The
IntoFrequencytrait consumes the value and converts it into aFrequency. - Into
Octave - A trait for converting a type into an
Octave. - Into
Pitch IntoPitchdefines a consuming conversion from some type into aPitch.- Music
Scalar - NumPitch
NumPitchextends theRawPitchtrait with additional capabilities for numerical types. The trait is automatically implemented for all- Numerical
- Ordered
Num - Pitch
Class Repr PitchClassReprextendsRawPitchClass, providing various initialization routines, defaults, and other methods useful for pitch class representations.- Pitch
Mod - The
PitchModtrait is a particular implementation of thePyModtrait, specifically binding the caller to a mod 12 space. - Pitched
- The
Pitchedtrait provides a method for viewing the pitch of the implementor. - PyMod
PyModis a modulo operator inspired by Python’s%operator, which handles negative values differently than rust’s built-in%operator. Specifically, the sign of the result will always match the sign of the divisor.- Quality
- RawAccidental
Accidentalis a sealed marker trait used to designate various kinds of musical notes, i.e., sharp, flat, natural, etc.- RawChord
- The
RawChordtrait works to define a basic interface shared by all compatible reprsentations of a chord. Since a chord is essentially a sequence of pitches, the trait captures this behavior through association with an element type. - RawChord
Mut - The
RawChordMuttrait extends theRawChordtrait to provide mutable access to the underlying elements of the chord representation. - RawFrequency
RawFrequencyis a marker trait denoting objects capable of representing a frequency- RawOctave
RawOctaveis a marker trait denoting objects allowed to define octaves; it is implemented for all (un)signed integer types.- RawPitch
RawPitchdefines an interface for all raw pitch types.- RawPitch
Class - The
RawPitchClassis a sealed trait used to define raw pitch class types. - RawQuality
Qualityis a sealed marker trait used to define compatible intervallic qualities.- Semitone
- Similar to the
Onetrait, theSemitoneis an identity and unit for musical contexts. - Step
Size Ops StepSizeOpsprovides a generic trait for types that can be operated on withStepSizevalues.- Transform
- The
Transformtrait establishes a common interface for objects that can be transformed with respect to a given transformation, input, etc. to produce a new output. - TryTransform
TryTransformdefines a fallible transformation operation that can fail, producing an- Unison
- A musical unison is the identity interval in music theory, representing no pitch difference.
- Whole
Tone
Functions§
- classify_
freq_ with_ scale - Compute the pitch class of a frequency (in hertz), using the formula:
- compute_
freq_ of_ pitch - Given some pitch class $
n$ (in semitones) and an optional base frequency $\beta$ (in hertz), calculate the corresponding frequency $f$.