Skip to content

Commit

Permalink
changed PPQN checks to avoid smaller than 24 instead of multiple of 24
Browse files Browse the repository at this point in the history
  • Loading branch information
tebjan committed Feb 3, 2018
1 parent 4f760ec commit 50ed89d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
7 changes: 1 addition & 6 deletions Source/Sanford.Multimedia.Midi/Clocks/PpqnClock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,7 @@ public int Ppqn
if(value < PpqnMinValue)
{
throw new ArgumentOutOfRangeException("Ppqn", value,
"Pulses per quarter note out of range.");
}
else if(value % PpqnMinValue != 0)
{
throw new ArgumentException(
"Pulses per quarter note is not a multiple of 24.");
"Pulses per quarter note is smaller than 24.");
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,9 +529,10 @@ public int Division
{
throw new ObjectDisposedException("OutputStream");
}
else if((value % PpqnClock.PpqnMinValue) != 0)
else if(value < PpqnClock.PpqnMinValue)
{
throw new ArgumentException();
throw new ArgumentOutOfRangeException("Ppqn", value,
"Pulses per quarter note is smaller than 24.");
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ public int Ppqn
{
#region Require

if(value % PpqnClock.PpqnMinValue != 0)
if(value < PpqnClock.PpqnMinValue)
{
throw new ArgumentException(
"Invalid pulses per quarter note value.");
throw new ArgumentOutOfRangeException("Ppqn", value,
"Pulses per quarter note is smaller than 24.");
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private void AssertValid()
else
{
Debug.Assert(SequenceType == SequenceType.Ppqn);
Debug.Assert(Division % PpqnClock.PpqnMinValue == 0);
Debug.Assert(Division >= PpqnClock.PpqnMinValue);
}
}

Expand Down Expand Up @@ -345,10 +345,10 @@ public int Division
}
else
{
if(value % PpqnClock.PpqnMinValue != 0)
if(value < PpqnClock.PpqnMinValue)
{
throw new ArgumentException(
"Invalid pulses per quarter note value.");
throw new ArgumentOutOfRangeException("Ppqn", value,
"Pulses per quarter note is smaller than 24.");
}
else
{
Expand Down

0 comments on commit 50ed89d

Please sign in to comment.