Crate rstmt_core

Crate rstmt_core 

Source
Expand description

This crate provides the core functionality for the rstmt library, including Aspn, NoteBase, Pitch, and Octave. Additionally, the crate provides a host of other primitives and utilities designed to manifest and manipulate musical concepts.

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 Error type and provides a type alias for a Result with an Error.
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 Pitch and PitchClass implementations designed to generically represent these musical concepts. The PitchClass isn’t necessarily intended to be used directly, rather through type aliases such as C, 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§

AFlatNote
ANote
ASharpNote
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 an Octave) 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
BFlatNote
BNote
CNote
CSharpNote
ConstInterval
DFlatNote
DNote
DSharpNote
Diminished
EFlatNote
ENote
FNote
FSharpNote
Fifth
FifthsIter
An iterator over the variants of Fifths
Flat
FlatsIter
An iterator over the variants of Flats
Fourth
FourthsIter
An iterator over the variants of Fourths
Frequency
The Frequency type is a generic wrapper around type T that implements the RawFrequency trait. 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.
GFlatNote
GNote
GSharpNote
HalfTone
HarmonicFunctionIter
An iterator over the variants of HarmonicFunction
IntervalBase
Major
Minor
Natural
NaturalsIter
An iterator over the variants of Naturals
NoteBase
The NoteBase is a generic representation of a musical note
NoteFlagIter
An iterator over the variants of NoteFlag
Octave
A type defining an octave
Perfect
Pitch
The Pitch implementation 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.
PitchClass
The PitchClass implementations 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.), and K, which defines the kind of pitch (e.g., sharp, flat, natural, etc.).
Scale
The Scale implementation uses the defined root or anchor frequency as the basis for classfifications and other related computations.
Seventh
SeventhsIter
An iterator over the variants of Sevenths
Sharp
SharpsIter
An iterator over the variants of Sharps
Sixth
SixthsIter
An iterator over the variants of Sixths
StepSizeIter
An iterator over the variants of StepSize
Third
ThirdsIter
An iterator over the variants of Thirds
Tone

Enums§

Error
The Error enum represents various errors that can occur in the application.
Fifths
Flats
A representation of the flat pitch class
Fourths
HarmonicFunction
Harmonic functions in tonal music
Intervals
Naturals
A representation of the natural pitch class
NoteFlag
Notes
Notes is 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
SingleOrDouble
Sixths
StepSize
StepSize provides 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 AsAspn trait is used to convert a reference into a Aspn
AsFrequency
AsFrequency is a trait enabling the conversion of a reference to a type into a Frequency instance.
AsOctave
A trait for converting a reference into an Octave.
AsPitch
A trait for converting a reference into a Pitch.
Chroma
Chroma defines a trait for establishing a chromatic relationship between pitches.
Classify
Classify defines an interface for objects capable of being classified as other types.
ClassifyBy
ClassifyBy is a trait defining the ability for an object to be classified by or with another object.
IntervalKind
The IntervalKind trait is a sealed marker trait used to define the allowable representations, or kinds, of musical intervals.
IntoAspn
A trait for converting a type into a Aspn
IntoFrequency
The IntoFrequency trait consumes the value and converts it into a Frequency.
IntoOctave
A trait for converting a type into an Octave.
IntoPitch
IntoPitch defines a consuming conversion from some type into a Pitch.
MusicScalar
NumPitch
NumPitch extends the RawPitch trait with additional capabilities for numerical types. The trait is automatically implemented for all
Numerical
OrderedNum
PitchClassRepr
PitchClassRepr extends RawPitchClass, providing various initialization routines, defaults, and other methods useful for pitch class representations.
PitchMod
The PitchMod trait is a particular implementation of the PyMod trait, specifically binding the caller to a mod 12 space.
Pitched
The Pitched trait provides a method for viewing the pitch of the implementor.
PyMod
PyMod is 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
Accidental is a sealed marker trait used to designate various kinds of musical notes, i.e., sharp, flat, natural, etc.
RawChord
The RawChord trait 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.
RawChordMut
The RawChordMut trait extends the RawChord trait to provide mutable access to the underlying elements of the chord representation.
RawFrequency
RawFrequency is a marker trait denoting objects capable of representing a frequency
RawOctave
RawOctave is a marker trait denoting objects allowed to define octaves; it is implemented for all (un)signed integer types.
RawPitch
RawPitch defines an interface for all raw pitch types.
RawPitchClass
The RawPitchClass is a sealed trait used to define raw pitch class types.
RawQuality
Quality is a sealed marker trait used to define compatible intervallic qualities.
Semitone
Similar to the One trait, the Semitone is an identity and unit for musical contexts.
StepSizeOps
StepSizeOps provides a generic trait for types that can be operated on with StepSize values.
Transform
The Transform trait establishes a common interface for objects that can be transformed with respect to a given transformation, input, etc. to produce a new output.
TryTransform
TryTransform defines a fallible transformation operation that can fail, producing an
Unison
A musical unison is the identity interval in music theory, representing no pitch difference.
WholeTone

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$.

Type Aliases§

A
AFlat
ASharp
B
BFlat
C
CSharp
D
DFlat
DSharp
E
EFlat
F
FSharp
G
GFlat
GSharp
MajorInterval
Result
a type alias for a Result with a Error type