Skip to content

Commit

Permalink
Added note length modifier support to l directive
Browse files Browse the repository at this point in the history
This primairly includes the dotted note and if it were inside a triplet.
This commit references #1.
  • Loading branch information
KungFuFurby committed Jan 7, 2021
1 parent c0f524c commit 3078e93
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
16 changes: 10 additions & 6 deletions src/AddmusicK/Music.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,11 @@ void Music::parseLDirective()
error("Error parsing \"l\" directive.");
}
defaultNoteLength = i;
return;
}
if (i == -1) error("Error parsing \"l\" directive.")
if (i < 1 || i > 192) error("Illegal value for \"l\" directive.")

defaultNoteLength = 192 / i;
else if (i == -1) error("Error parsing \"l\" directive.")
else if (i < 1 || i > 192) error("Illegal value for \"l\" directive.")
else {defaultNoteLength = 192 / i;}
defaultNoteLength = getNoteLengthModifier(defaultNoteLength);
}
void Music::parseGlobalVolumeCommand()
{
Expand Down Expand Up @@ -2815,6 +2814,10 @@ int Music::getNoteLength(int i)
else if (i < 1 || i > 192) i = defaultNoteLength;
else i = 192 / i;

return getNoteLengthModifier(i);
}

int Music::getNoteLengthModifier(int i) {
int frac = i;

int times = 0;
Expand All @@ -2829,9 +2832,10 @@ int Music::getNoteLength(int i)
//}
if (triplet)
i = (int)floor(((double)i * 2.0 / 3.0) + 0.5);
return i;
return i;
}


bool sortTempoPair(const std::pair<double, int> &p1, const std::pair<double, int> &p2)
{
if (p1.first == p2.first)
Expand Down
3 changes: 2 additions & 1 deletion src/AddmusicK/Music.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ class Music
int getIntWithNegative();
int getHex(bool anyLength = false);
int getPitch(int j);
int getNoteLength(int);
int getNoteLength(int);
int getNoteLengthModifier(int);

bool guessLength;
int resizedChannel;
Expand Down

0 comments on commit 3078e93

Please sign in to comment.