-
Notifications
You must be signed in to change notification settings - Fork 0
Duration
Duration Class
Namespace: CW.Soloist.CompositionService.MusicTheory
Assembly: CW.Soloist.CompositionService.dll
Represents a duration of a musical component such as a note or chord.
internal class Duration : IDuration
Implements IDuration
Each duration is assembled of two properties:
Numerator, which represents the number of beats in the duration,
and Denominator, which represents the duration of a single beat, in relation to whole note duration.
For example, a chord which is played over half a bar, would have a duration of 1/2.
Duration of notes and chords are calculated as the quotient of the nominator divided by the denominator,
so for example, a duration instance of 2/4 is equivalent to 1/2.
Signature | Description |
---|---|
Duration(byte,byte,bool) | Constructs a duration based on a numerator and a denominator. |
Duration(IDuration,bool) | Constructs a duration based on an existing duration. |
Property Name | Type | Description |
---|---|---|
Numerator | byte | Number of beats in the duration. |
Denominator | byte | Length of the beat in relation to a whole note duration. |
Fraction | float | Quotient of the division of the duration's numerator by the duration's denominator. |
Method Name | Return Type | Description |
---|---|---|
Add | IDuration | Adds the given duration to this duration, and returns the sum. |
Subtract | IDuration | Subtracts the given duration from this duration, and returns the difference. |
IsDenominatorPowerOfTwo | bool | Determines whether this duration's denominator is a power of two or not. |
ToString | string | Returns a string that represents the current duration. |
GreatestCommonDivisor | int | Returns GCD of two given natural numbers. |
This class overrides the following comparison operators: '<=', '>=', '<' and '>',
so these can be used to compare the length of a given duration instance to another.
© Chanan Welt - Soloist
- Home
- Getting Started
- Design
- Business Logical Layer (CW.Soloist.CompositionService)
- Duration Representation
- IDuration
- Duration
- Duration Representation
- Data Access Layer
- Presentation Layer
- Business Logical Layer (CW.Soloist.CompositionService)