Skip to content

Duration

Chanan edited this page Aug 15, 2020 · 7 revisions

Duration Class

Namespace: CW.Soloist.CompositionService.MusicTheory
Assembly: CW.Soloist.CompositionService.dll


Summary

Represents a duration of a musical component such as a note or chord.

internal class Duration : IDuration

Implements IDuration


Remarks

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.


Constructors

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.

Properties

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.

Methods

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.

Operators

This class overrides the following comparison operators: '<=', '>=', '<' and '>',
so these can be used to compare the length of a given duration instance to another.

  • Home
  • Getting Started
  • Design
    • Business Logical Layer (CW.Soloist.CompositionService)
    • Data Access Layer
    • Presentation Layer
Clone this wiki locally