Class Interval
Represents a musical interval in terms of half steps number.
Assembly: Melanchall.DryWetMidi.dll
Syntax
public sealed class Interval : IComparable<Interval>
Fields
Eight
Interval of eight half steps up.
Declaration
public static readonly Interval Eight
Field Value
Eleven
Interval of eleven half steps up.
Declaration
public static readonly Interval Eleven
Field Value
Five
Interval of five half steps up.
Declaration
public static readonly Interval Five
Field Value
Four
Interval of four half steps up.
Declaration
public static readonly Interval Four
Field Value
Nine
Interval of nine half steps up.
Declaration
public static readonly Interval Nine
Field Value
One
Interval of one half step up.
Declaration
public static readonly Interval One
Field Value
Seven
Interval of seven half steps up.
Declaration
public static readonly Interval Seven
Field Value
Six
Interval of six half steps up.
Declaration
public static readonly Interval Six
Field Value
Ten
Interval of ten half steps up.
Declaration
public static readonly Interval Ten
Field Value
Three
Interval of three half steps up.
Declaration
public static readonly Interval Three
Field Value
Twelve
Interval of twelve half steps up (one octave up).
Declaration
public static readonly Interval Twelve
Field Value
Two
Interval of two half steps up.
Declaration
public static readonly Interval Two
Field Value
Zero
Interval of zero half steps up.
Declaration
public static readonly Interval Zero
Field Value
Properties
Direction
Gets the direction of the interval represented by the current
Interval.
Declaration
public IntervalDirection Direction { get; }
Property Value
HalfSteps
Gets signed half steps number which represents an interval of the current
Interval.
Declaration
public int HalfSteps { get; }
Property Value
Size
Gets the size of interval represented by the current
Interval as a
number of half steps away.
Declaration
public SevenBitNumber Size { get; }
Property Value
Methods
CompareTo(Interval)
Compares the current instance with another object of the same type and returns
an integer that indicates whether the current instance precedes, follows, or
occurs in the same position in the sort order as the other object.
Declaration
public int CompareTo(Interval other)
Parameters
Type |
Name |
Description |
Interval |
other |
An object to compare with this instance. |
Returns
Type |
Description |
int |
A value that indicates the relative order of the objects being compared. The
return value has these meanings:
Value | Meaning |
---|
Less than zero | This instance precedes other in the sort order. | Zero | This instance occurs in the same position in the sort order as other . | Greater than zero | This instance follows other in the sort order. |
|
Down()
Returns downward version of the current
Interval.
Declaration
Returns
Equals(object)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
object |
obj |
The object to compare with the current object. |
Returns
Type |
Description |
bool |
true if the specified object is equal to the current object; otherwise, false . |
Overrides
FromDefinition(IntervalDefinition)
Declaration
public static Interval FromDefinition(IntervalDefinition intervalDefinition)
Parameters
Type |
Name |
Description |
IntervalDefinition |
intervalDefinition |
Interval definition to create interval from. |
Returns
Exceptions
FromHalfSteps(int)
Returns an
Interval by the specified signed number of
half steps where negative one means downward interval.
Declaration
public static Interval FromHalfSteps(int halfSteps)
Parameters
Type |
Name |
Description |
int |
halfSteps |
The number of half steps. |
Returns
Exceptions
Get(SevenBitNumber, IntervalDirection)
Returns an
Interval by the specified half steps number and
interval's direction.
Declaration
public static Interval Get(SevenBitNumber intervalSize, IntervalDirection direction)
Parameters
Type |
Name |
Description |
SevenBitNumber |
intervalSize |
The size of an interval as a number of half steps away. |
IntervalDirection |
direction |
The direction of an interval (up or down). |
Returns
Type |
Description |
Interval |
An Interval with the specified interval and direction. |
Exceptions
Get(IntervalQuality, int)
Gets an instance of the
Interval by the specified interval quality and number.
Declaration
public static Interval Get(IntervalQuality intervalQuality, int intervalNumber)
Parameters
Type |
Name |
Description |
IntervalQuality |
intervalQuality |
Interval quality. |
int |
intervalNumber |
Interval number. |
Returns
Type |
Description |
Interval |
An instance of the Interval which represents intervalNumber
along with intervalQuality . |
Exceptions
GetDown(SevenBitNumber)
Returns a downward
Interval by the specified half steps number.
Declaration
public static Interval GetDown(SevenBitNumber intervalSize)
Parameters
Type |
Name |
Description |
SevenBitNumber |
intervalSize |
The size of an interval as a number of half steps away. |
Returns
GetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
Type |
Description |
int |
A hash code for the current object. |
Overrides
GetIntervalDefinitions()
Returns collection of definitions of the current
Interval.
Declaration
public IReadOnlyCollection<IntervalDefinition> GetIntervalDefinitions()
Returns
GetUp(SevenBitNumber)
Returns an upward
Interval by the specified half steps number.
Declaration
public static Interval GetUp(SevenBitNumber intervalSize)
Parameters
Type |
Name |
Description |
SevenBitNumber |
intervalSize |
The size of an interval as a number of half steps away. |
Returns
IsPerfect(int)
Gets a value indicating whether the specified interval number (1 and greater) is perfect or not.
Declaration
public static bool IsPerfect(int intervalNumber)
Parameters
Type |
Name |
Description |
int |
intervalNumber |
Interval number to determine whether it's perfect or not. |
Returns
Type |
Description |
bool |
true if intervalNumber is perfect; otherwise, false . |
Exceptions
IsQualityApplicable(IntervalQuality, int)
Gets a value indicating whether quality is applicable to the specified interval number (1 and greater) or not.
Declaration
public static bool IsQualityApplicable(IntervalQuality intervalQuality, int intervalNumber)
Parameters
Type |
Name |
Description |
IntervalQuality |
intervalQuality |
Interval quality to check whether it's applicable to
intervalNumber or not. |
int |
intervalNumber |
Interval number to check whether intervalQuality is
applicable to it or not. |
Returns
Type |
Description |
bool |
true if intervalQuality is applicable to intervalNumber ;
otherwise, false . |
Exceptions
Parse(string)
Converts the string representation of a musical interval to its
Scale equivalent.
Declaration
public static Interval Parse(string input)
Parameters
Type |
Name |
Description |
string |
input |
A string containing an interval to convert. |
Returns
Type |
Description |
Interval |
A Scale equivalent to the musical interval contained in input . |
Exceptions
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
Type |
Description |
string |
A string that represents the current object. |
Overrides
TryParse(string, out Interval)
Converts the string representation of a musical interval to its
Interval equivalent.
A return value indicates whether the conversion succeeded.
Declaration
public static bool TryParse(string input, out Interval interval)
Parameters
Type |
Name |
Description |
string |
input |
A string containing an interval to convert. |
Interval |
interval |
When this method returns, contains the Interval
equivalent of the musical interval contained in input , if the conversion succeeded,
or null if the conversion failed. The conversion fails if the input is null or
Empty, or is not of the correct format. This parameter is passed uninitialized;
any value originally supplied in result will be overwritten. |
Returns
Type |
Description |
bool |
true if input was converted successfully; otherwise, false . |
Up()
Returns upward version of the current
Interval.
Declaration
Returns
Operators
operator +(Interval, int)
Adds the specified number of half steps to an
Interval.
Declaration
public static Interval operator +(Interval interval, int halfSteps)
Parameters
Type |
Name |
Description |
Interval |
interval |
The interval to add half steps to. |
int |
halfSteps |
The number of half steps to add to the interval . |
Returns
Type |
Description |
Interval |
The Interval which is the interval
shifted by the halfSteps . |
Exceptions
operator /(Interval, int)
Shrinks the specified
Interval by dividing it by an integer number.
Declaration
public static Interval operator /(Interval interval, int divisor)
Parameters
Type |
Name |
Description |
Interval |
interval |
The interval to shrink. |
int |
divisor |
The number to divide the interval by. |
Returns
Type |
Description |
Interval |
The Interval which is the interval
shrunk by the divisor . |
Exceptions
operator ==(Interval, Interval)
Determines if two
Interval objects are equal.
Declaration
public static bool operator ==(Interval interval1, Interval interval2)
Parameters
Returns
Type |
Description |
bool |
true if the intervals are equal, false otherwise. |
implicit operator Interval(SevenBitNumber)
Declaration
public static implicit operator Interval(SevenBitNumber interval)
Parameters
Returns
implicit operator int(Interval)
Declaration
public static implicit operator int(Interval interval)
Parameters
Returns
Type |
Description |
int |
interval represented as int. |
operator !=(Interval, Interval)
Determines if two
Interval objects are not equal.
Declaration
public static bool operator !=(Interval interval1, Interval interval2)
Parameters
Returns
Type |
Description |
bool |
false if the intervals are equal, true otherwise. |
operator *(Interval, int)
Stretches the specified
Interval by multiplying it by an integer number.
Declaration
public static Interval operator *(Interval interval, int multiplier)
Parameters
Type |
Name |
Description |
Interval |
interval |
The interval to stretch. |
int |
multiplier |
The number to multiply the interval by. |
Returns
Type |
Description |
Interval |
The Interval which is the interval
stretched by the multiplier . |
Exceptions
operator -(Interval, int)
Subtracts the specified number of half steps from an
Interval.
Declaration
public static Interval operator -(Interval interval, int halfSteps)
Parameters
Type |
Name |
Description |
Interval |
interval |
The interval to subtract half steps from. |
int |
halfSteps |
The number of half steps to subtract from the interval . |
Returns
Type |
Description |
Interval |
The Interval which is the interval
shifted by the halfSteps . |
Exceptions
operator -(Interval)
Returns downward version of the specified
Interval.
Declaration
public static Interval operator -(Interval interval)
Parameters
Type |
Name |
Description |
Interval |
interval |
The Interval to get downward version of. |
Returns
Type |
Description |
Interval |
A downward version of the interval . |
Exceptions
operator +(Interval)
Returns upward version of the specified
Interval.
Declaration
public static Interval operator +(Interval interval)
Parameters
Returns
Type |
Description |
Interval |
An upward version of the interval . |
Exceptions
Implements