-
Notifications
You must be signed in to change notification settings - Fork 0
Duration.IsDenominatorPowerOfTwo
Chanan edited this page Aug 15, 2020
·
1 revision
Duration.IsDenominatorPowerOfTwo Method
Namespace: CW.Soloist.CompositionService.MusicTheory
Assembly: CW.Soloist.CompositionService.dll
Utility method which determines whether this duration's denominator is a power of two or not.
This could be helpful for musical quantization process.
True if this duration's denominator is a power of two, and false else-wise.
public bool IsDenominatorPowerOfTwo()
{
byte num = this.Denominator;
int remainder = 0;
while (remainder == 0)
{
remainder = num % 2;
num /= 2;
}
if (num == 0)
return true;
else return false;
/* // alternative implemntation which is more compact but less clear
return (int)Math.Ceiling(Math.Log(Denominator) / Math.Log(2))
== (int)Math.Floor(Math.Log(Denominator) / Math.Log(2)); */
}
© 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)