Show note length of all dotted notes
This commit is contained in:
parent
514f6c1593
commit
dfc69f143f
36
src/Draw.cpp
36
src/Draw.cpp
|
@ -376,23 +376,23 @@ bool CDraw::drawNote(CSymbol* symbol, float x, float y, CSlot* slot, CColor colo
|
||||||
}
|
}
|
||||||
drawStaveExtentsion(*symbol, x, 16, playable);
|
drawStaveExtentsion(*symbol, x, 16, playable);
|
||||||
drColor(color);
|
drColor(color);
|
||||||
bool solidNoteHead = false;
|
|
||||||
bool showNoteStem = false;
|
|
||||||
int stemFlagCount = 0;
|
|
||||||
|
|
||||||
if (symbol->getType() <= PB_SYMBOL_semiquaver)
|
const auto noteLength = symbol->getType();
|
||||||
|
auto solidNoteHead = false;
|
||||||
|
auto showNoteStem = false;
|
||||||
|
auto stemFlagCount = 0;
|
||||||
|
if (noteLength <= PB_SYMBOL_demisemiquaver)
|
||||||
|
stemFlagCount = 3;
|
||||||
|
else if (noteLength <= PB_SYMBOL_semiquaver)
|
||||||
stemFlagCount = 2;
|
stemFlagCount = 2;
|
||||||
else if (symbol->getType() <= PB_SYMBOL_quaver)
|
else if (noteLength <= PB_SYMBOL_quaver)
|
||||||
stemFlagCount = 1;
|
stemFlagCount = 1;
|
||||||
|
if (noteLength <= PB_SYMBOL_crotchet)
|
||||||
if (symbol->getType() <= PB_SYMBOL_crotchet)
|
|
||||||
solidNoteHead = true;
|
solidNoteHead = true;
|
||||||
|
if (noteLength <= PB_SYMBOL_threequater)
|
||||||
if (symbol->getType() <= PB_SYMBOL_threequater)
|
|
||||||
showNoteStem = true;
|
showNoteStem = true;
|
||||||
|
|
||||||
if (showNoteStem)
|
if (showNoteStem) {
|
||||||
{
|
|
||||||
if (!solidNoteHead)
|
if (!solidNoteHead)
|
||||||
noteWidth += 1.0f;
|
noteWidth += 1.0f;
|
||||||
glLineWidth(2.0f);
|
glLineWidth(2.0f);
|
||||||
|
@ -403,9 +403,7 @@ bool CDraw::drawNote(CSymbol* symbol, float x, float y, CSlot* slot, CColor colo
|
||||||
}
|
}
|
||||||
|
|
||||||
float offset = stemLength;
|
float offset = stemLength;
|
||||||
while (stemFlagCount>0)
|
while (stemFlagCount > 0) {
|
||||||
{
|
|
||||||
|
|
||||||
glLineWidth(2.0);
|
glLineWidth(2.0);
|
||||||
glBegin(GL_LINE_STRIP);
|
glBegin(GL_LINE_STRIP);
|
||||||
glVertex2f(noteWidth + x, offset + y); // 1
|
glVertex2f(noteWidth + x, offset + y); // 1
|
||||||
|
@ -415,8 +413,7 @@ bool CDraw::drawNote(CSymbol* symbol, float x, float y, CSlot* slot, CColor colo
|
||||||
stemFlagCount--;
|
stemFlagCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (solidNoteHead)
|
if (solidNoteHead) {
|
||||||
{
|
|
||||||
glBegin(GL_POLYGON);
|
glBegin(GL_POLYGON);
|
||||||
glVertex2f(-7.0f + x, 2.0f + y); // 1
|
glVertex2f(-7.0f + x, 2.0f + y); // 1
|
||||||
glVertex2f(-5.0f + x, 4.0f + y); // 2
|
glVertex2f(-5.0f + x, 4.0f + y); // 2
|
||||||
|
@ -431,9 +428,7 @@ bool CDraw::drawNote(CSymbol* symbol, float x, float y, CSlot* slot, CColor colo
|
||||||
glVertex2f(-8.0f + x, -3.0f + y); // 11
|
glVertex2f(-8.0f + x, -3.0f + y); // 11
|
||||||
glVertex2f(-8.0f + x, -0.0f + y); // 12
|
glVertex2f(-8.0f + x, -0.0f + y); // 12
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
glLineWidth(2.0);
|
glLineWidth(2.0);
|
||||||
glBegin(GL_LINE_STRIP);
|
glBegin(GL_LINE_STRIP);
|
||||||
glVertex2f(-7.0f + x, 2.0f + y); // 1
|
glVertex2f(-7.0f + x, 2.0f + y); // 1
|
||||||
|
@ -452,7 +447,8 @@ bool CDraw::drawNote(CSymbol* symbol, float x, float y, CSlot* slot, CColor colo
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw a circle after the half note to make it a three-quater note
|
// draw a circle after the half note to make it a three-quater note
|
||||||
if (symbol->getType() == PB_SYMBOL_threequater) {
|
const auto isDottedNote = (noteLength < PB_SYMBOL_breve) && ((noteLength - PB_SYMBOL_noteHead) % 2 == 0);
|
||||||
|
if (isDottedNote) {
|
||||||
static constexpr auto radius = 4.0f;
|
static constexpr auto radius = 4.0f;
|
||||||
x += 15.0f;
|
x += 15.0f;
|
||||||
glBegin(GL_POLYGON);
|
glBegin(GL_POLYGON);
|
||||||
|
|
|
@ -198,9 +198,14 @@ int CNotation::cfg_param[NOTATE_MAX_PARAMS];
|
||||||
|
|
||||||
void CNotation::setupNotationParamaters()
|
void CNotation::setupNotationParamaters()
|
||||||
{
|
{
|
||||||
cfg_param[NOTATE_semiquaverBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN/4 + 10);
|
cfg_param[NOTATE_demisemiquaverBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN/8 + DEFAULT_PPQN/8 + 1);
|
||||||
cfg_param[NOTATE_quaverBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN/2 + 10);
|
cfg_param[NOTATE_threesixtyforthBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN/8 + DEFAULT_PPQN/16 + 1);
|
||||||
|
cfg_param[NOTATE_semiquaverBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN/4 + 2);
|
||||||
|
cfg_param[NOTATE_threethirtysecondBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN/4 + DEFAULT_PPQN/8 + 2);
|
||||||
|
cfg_param[NOTATE_quaverBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN/2 + 5);
|
||||||
|
cfg_param[NOTATE_threesixteenthBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN/2 + DEFAULT_PPQN/4 + 5);
|
||||||
cfg_param[NOTATE_crotchetBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN + 10);
|
cfg_param[NOTATE_crotchetBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN + 10);
|
||||||
|
cfg_param[NOTATE_threeeighthBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN + DEFAULT_PPQN/2 + 10);
|
||||||
cfg_param[NOTATE_minimBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN*2 + 10);
|
cfg_param[NOTATE_minimBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN*2 + 10);
|
||||||
cfg_param[NOTATE_threequaterBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN*3 + 10);
|
cfg_param[NOTATE_threequaterBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN*3 + 10);
|
||||||
cfg_param[NOTATE_semibreveBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN*4 + 10);
|
cfg_param[NOTATE_semibreveBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN*4 + 10);
|
||||||
|
@ -221,20 +226,17 @@ void CNotation::calculateScoreNoteLength()
|
||||||
|
|
||||||
// you may get better results assuming all the notes are legato
|
// you may get better results assuming all the notes are legato
|
||||||
// ie assume that this note ends at the exact time the following note starts.
|
// ie assume that this note ends at the exact time the following note starts.
|
||||||
long midiDuration = symbol->getMidiDuration();
|
auto midiDuration = symbol->getMidiDuration();
|
||||||
|
auto param = static_cast<int>(NOTATE_demisemiquaverBoundary);
|
||||||
if (midiDuration < cfg_param[NOTATE_semiquaverBoundary] )
|
auto noteLength = static_cast<int>(PB_SYMBOL_noteHead) + 1;
|
||||||
symbol->setNoteLength(PB_SYMBOL_semiquaver);
|
for (; param != NOTATE_MAX_PARAMS; ++param, ++noteLength) {
|
||||||
if (midiDuration < cfg_param[NOTATE_quaverBoundary] )
|
if (midiDuration < cfg_param[param]) {
|
||||||
symbol->setNoteLength(PB_SYMBOL_quaver);
|
break;
|
||||||
else if (midiDuration < cfg_param[NOTATE_crotchetBoundary] )
|
}
|
||||||
symbol->setNoteLength(PB_SYMBOL_crotchet);
|
}
|
||||||
else if (midiDuration < cfg_param[NOTATE_minimBoundary] )
|
if (param != NOTATE_MAX_PARAMS) {
|
||||||
symbol->setNoteLength(PB_SYMBOL_minim);
|
symbol->setNoteLength(static_cast<musicalSymbol_t>(noteLength));
|
||||||
else if (midiDuration < cfg_param[NOTATE_threequaterBoundary] )
|
}
|
||||||
symbol->setNoteLength(PB_SYMBOL_threequater);
|
|
||||||
else
|
|
||||||
symbol->setNoteLength(PB_SYMBOL_semibreve);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,9 +159,13 @@ private:
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
NOTATE_demisemiquaverBoundary, // Demisemiquaver / Thirty-second note
|
NOTATE_demisemiquaverBoundary, // Demisemiquaver / Thirty-second note
|
||||||
|
NOTATE_threesixtyforthBoundary, // Three-sixtyforth note (thirty-second note with dot)
|
||||||
NOTATE_semiquaverBoundary, // Semiquaver / Sixteenth note
|
NOTATE_semiquaverBoundary, // Semiquaver / Sixteenth note
|
||||||
|
NOTATE_threethirtysecondBoundary, // Three-thirty-second note (sixteenth note with dot)
|
||||||
NOTATE_quaverBoundary, // Quaver / Eighth note
|
NOTATE_quaverBoundary, // Quaver / Eighth note
|
||||||
|
NOTATE_threesixteenthBoundary, // Three-sixteenth note (eighth note with dot)
|
||||||
NOTATE_crotchetBoundary, // Crotchet / Quarter note
|
NOTATE_crotchetBoundary, // Crotchet / Quarter note
|
||||||
|
NOTATE_threeeighthBoundary, // Three-eighth note (quarter note with dot)
|
||||||
NOTATE_minimBoundary, // Minim / Half note
|
NOTATE_minimBoundary, // Minim / Half note
|
||||||
NOTATE_threequaterBoundary, // Three-quater note (half note with dot)
|
NOTATE_threequaterBoundary, // Three-quater note (half note with dot)
|
||||||
NOTATE_semibreveBoundary, // Semibreve / Whole note
|
NOTATE_semibreveBoundary, // Semibreve / Whole note
|
||||||
|
|
|
@ -50,11 +50,15 @@ typedef enum
|
||||||
|
|
||||||
PB_SYMBOL_noteHead, // ONLY ADD NOTES BELOW THIS MAKER
|
PB_SYMBOL_noteHead, // ONLY ADD NOTES BELOW THIS MAKER
|
||||||
PB_SYMBOL_demisemiquaver, // Demisemiquaver / Thirty-second note
|
PB_SYMBOL_demisemiquaver, // Demisemiquaver / Thirty-second note
|
||||||
|
PB_SYMBOL_threesixtyforth, // Three-sixtyforth note (thirty-second note with dot)
|
||||||
PB_SYMBOL_semiquaver, // Semiquaver / Sixteenth note
|
PB_SYMBOL_semiquaver, // Semiquaver / Sixteenth note
|
||||||
|
PB_SYMBOL_threethirtysecond, // Three-thirty-second note (sixteenth note with dot)
|
||||||
PB_SYMBOL_quaver, // Quaver / Eighth note
|
PB_SYMBOL_quaver, // Quaver / Eighth note
|
||||||
|
PB_SYMBOL_threesixteenth, // Three-sixteenth note (eighth note with dot)
|
||||||
PB_SYMBOL_crotchet, // Crotchet / Quarter note
|
PB_SYMBOL_crotchet, // Crotchet / Quarter note
|
||||||
|
PB_SYMBOL_threeeighth, // Three-eighth note (quarter note with dot)
|
||||||
PB_SYMBOL_minim, // Minim / Half note
|
PB_SYMBOL_minim, // Minim / Half note
|
||||||
PB_SYMBOL_threequater, // Three-quater note
|
PB_SYMBOL_threequater, // Three-quater note (half note with dot)
|
||||||
PB_SYMBOL_semibreve, // Semibreve / Whole note
|
PB_SYMBOL_semibreve, // Semibreve / Whole note
|
||||||
PB_SYMBOL_breve, // Breve / Double whole note
|
PB_SYMBOL_breve, // Breve / Double whole note
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue