C# Class Midi.Scale

A scale based on a particular tonic.

For our purposes, a scale is defined by a tonic and then the pattern that it uses to ascend up to the next tonic and then descend back to the original tonic. The tonic is described with a NoteFamily because it is not specific to any one octave. The ascending/descending pattern is provided by the Pattern nested class.

This class comes with a collection of predefined patterns, such as Scale.Major and Scale.HarmonicMinor.

Show file Open project: jstnryan/midi-dot-net Class Usage Examples

Public Properties

Property Type Description
Chromatic ScalePattern
HarmonicMinor ScalePattern
Major ScalePattern
MelodicMinorAscending ScalePattern
MelodicMinorDescending ScalePattern
NaturalMinor ScalePattern
Patterns Midi.ScalePattern[]

Public Methods

Method Description
Contains ( Pitch pitch ) : bool

Returns true if pitch is in this scale.

Equals ( System obj ) : bool

Value equality.

GetHashCode ( ) : int

Hash code.

Scale ( Midi.Note tonic, ScalePattern pattern ) : System

Constructs a scale from its tonic and its pattern.

ScaleDegree ( Pitch pitch ) : int

Returns the scale degree of the given pitch in this scale.

ToString ( ) : string

ToString returns the scale's human-readable name.

operator ( ) : bool

Inequality operator does value inequality because Chord is immutable.

Private Methods

Method Description
Build ( Midi.Note tonic, ScalePattern pattern, int positionInOctaveToSequenceIndex, Midi.Note noteSequence, int &numAccidentals ) : void

Builds a scale.

Method Details

Contains() public method

Returns true if pitch is in this scale.
public Contains ( Pitch pitch ) : bool
pitch Pitch The pitch to test.
return bool

Equals() public method

Value equality.
public Equals ( System obj ) : bool
obj System
return bool

GetHashCode() public method

Hash code.
public GetHashCode ( ) : int
return int

Scale() public method

Constructs a scale from its tonic and its pattern.
tonic or pattern is null.
public Scale ( Midi.Note tonic, ScalePattern pattern ) : System
tonic Midi.Note The tonic note.
pattern ScalePattern The scale pattern.
return System

ScaleDegree() public method

Returns the scale degree of the given pitch in this scale.
public ScaleDegree ( Pitch pitch ) : int
pitch Pitch The pitch to test.
return int

ToString() public method

ToString returns the scale's human-readable name.
public ToString ( ) : string
return string

operator() public static method

Inequality operator does value inequality because Chord is immutable.
public static operator ( ) : bool
return bool

Property Details

Chromatic public static property

Pattern for Chromatic scales.
public static ScalePattern,Midi Chromatic
return ScalePattern

HarmonicMinor public static property

Pattern for Harmonic Minor scales.
public static ScalePattern,Midi HarmonicMinor
return ScalePattern

Major public static property

Pattern for Major scales.
public static ScalePattern,Midi Major
return ScalePattern

MelodicMinorAscending public static property

Pattern for Melodic Minor scale as it ascends.
public static ScalePattern,Midi MelodicMinorAscending
return ScalePattern

MelodicMinorDescending public static property

Pattern for Melodic Minor scale as it descends.
public static ScalePattern,Midi MelodicMinorDescending
return ScalePattern

NaturalMinor public static property

Pattern for Natural Minor scales.
public static ScalePattern,Midi NaturalMinor
return ScalePattern

Patterns public static property

Array of all the built-in scale patterns.
public static ScalePattern[],Midi Patterns
return Midi.ScalePattern[]