Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
Martchus | 860e4f47c2 | |
Martchus | a158151134 |
40
src/Draw.cpp
40
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);
|
||||
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;
|
||||
else if (symbol->getType() <= PB_SYMBOL_quaver)
|
||||
else if (noteLength <= PB_SYMBOL_quaver)
|
||||
stemFlagCount = 1;
|
||||
|
||||
if (symbol->getType() <= PB_SYMBOL_crotchet)
|
||||
if (noteLength <= PB_SYMBOL_crotchet)
|
||||
solidNoteHead = true;
|
||||
|
||||
if (symbol->getType() <= PB_SYMBOL_threequater)
|
||||
if (noteLength <= PB_SYMBOL_threequater)
|
||||
showNoteStem = true;
|
||||
|
||||
if (showNoteStem)
|
||||
{
|
||||
if (showNoteStem) {
|
||||
if (!solidNoteHead)
|
||||
noteWidth += 1.0f;
|
||||
glLineWidth(2.0f);
|
||||
|
@ -403,9 +403,7 @@ bool CDraw::drawNote(CSymbol* symbol, float x, float y, CSlot* slot, CColor colo
|
|||
}
|
||||
|
||||
float offset = stemLength;
|
||||
while (stemFlagCount>0)
|
||||
{
|
||||
|
||||
while (stemFlagCount > 0) {
|
||||
glLineWidth(2.0);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2f(noteWidth + x, offset + y); // 1
|
||||
|
@ -415,8 +413,7 @@ bool CDraw::drawNote(CSymbol* symbol, float x, float y, CSlot* slot, CColor colo
|
|||
stemFlagCount--;
|
||||
}
|
||||
|
||||
if (solidNoteHead)
|
||||
{
|
||||
if (solidNoteHead) {
|
||||
glBegin(GL_POLYGON);
|
||||
glVertex2f(-7.0f + x, 2.0f + y); // 1
|
||||
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, -0.0f + y); // 12
|
||||
glEnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
glLineWidth(2.0);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
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
|
||||
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;
|
||||
x += 15.0f;
|
||||
glBegin(GL_POLYGON);
|
||||
|
@ -681,16 +677,14 @@ void CDraw::drawSymbol(CSymbol symbol, float x, float y, CSlot* slot)
|
|||
glVertex2f(-8.0f + x, -0.0f + y); // 12
|
||||
glEnd();
|
||||
|
||||
/*
|
||||
// shows the MIDI Duration (but not very useful)
|
||||
glLineWidth(4.0f);
|
||||
drColor(CColor(0.3, 0.4, 0.4));
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2f(x, y);
|
||||
glVertex2f(x + CMidiFile::ppqnAdjust<float>(static_cast<float>(symbol.getMidiDuration())) * HORIZONTAL_SPACING_FACTOR, y);
|
||||
glVertex2f(x + CMidiFile::ppqnAdjust<float>(static_cast<float>(symbol.getMidiDuration())) / 32.f, y);
|
||||
glEnd();
|
||||
drColor(color);
|
||||
*/
|
||||
|
||||
checkAccidental(symbol, x, y);
|
||||
break;
|
||||
|
|
|
@ -198,12 +198,17 @@ int CNotation::cfg_param[NOTATE_MAX_PARAMS];
|
|||
|
||||
void CNotation::setupNotationParamaters()
|
||||
{
|
||||
cfg_param[NOTATE_semiquaverBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN/4 + 10);
|
||||
cfg_param[NOTATE_quaverBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN/2 + 10);
|
||||
cfg_param[NOTATE_crotchetBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN + 10);
|
||||
cfg_param[NOTATE_minimBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN*2 + 10);
|
||||
cfg_param[NOTATE_threequaterBoundary]= CMidiFile::ppqnAdjust(DEFAULT_PPQN*3 + 10);
|
||||
cfg_param[NOTATE_semibreveBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN*4 + 10);
|
||||
cfg_param[NOTATE_demisemiquaverBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN/8 + DEFAULT_PPQN/8 + 1);
|
||||
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_threeeighthBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN + 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_semibreveBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN*4 + 10);
|
||||
}
|
||||
|
||||
void CNotation::calculateScoreNoteLength()
|
||||
|
@ -221,20 +226,17 @@ void CNotation::calculateScoreNoteLength()
|
|||
|
||||
// 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.
|
||||
long midiDuration = symbol->getMidiDuration();
|
||||
|
||||
if (midiDuration < cfg_param[NOTATE_semiquaverBoundary] )
|
||||
symbol->setNoteLength(PB_SYMBOL_semiquaver);
|
||||
if (midiDuration < cfg_param[NOTATE_quaverBoundary] )
|
||||
symbol->setNoteLength(PB_SYMBOL_quaver);
|
||||
else if (midiDuration < cfg_param[NOTATE_crotchetBoundary] )
|
||||
symbol->setNoteLength(PB_SYMBOL_crotchet);
|
||||
else if (midiDuration < cfg_param[NOTATE_minimBoundary] )
|
||||
symbol->setNoteLength(PB_SYMBOL_minim);
|
||||
else if (midiDuration < cfg_param[NOTATE_threequaterBoundary] )
|
||||
symbol->setNoteLength(PB_SYMBOL_threequater);
|
||||
else
|
||||
symbol->setNoteLength(PB_SYMBOL_semibreve);
|
||||
auto midiDuration = symbol->getMidiDuration();
|
||||
auto param = static_cast<int>(NOTATE_demisemiquaverBoundary);
|
||||
auto noteLength = static_cast<int>(PB_SYMBOL_noteHead) + 1;
|
||||
for (; param != NOTATE_MAX_PARAMS; ++param, ++noteLength) {
|
||||
if (midiDuration < cfg_param[param]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (param != NOTATE_MAX_PARAMS) {
|
||||
symbol->setNoteLength(static_cast<musicalSymbol_t>(noteLength));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -159,14 +159,18 @@ private:
|
|||
|
||||
enum {
|
||||
NOTATE_demisemiquaverBoundary, // Demisemiquaver / Thirty-second note
|
||||
NOTATE_threesixtyforthBoundary, // Three-sixtyforth note (thirty-second note with dot)
|
||||
NOTATE_semiquaverBoundary, // Semiquaver / Sixteenth note
|
||||
NOTATE_threethirtysecondBoundary, // Three-thirty-second note (sixteenth note with dot)
|
||||
NOTATE_quaverBoundary, // Quaver / Eighth note
|
||||
NOTATE_threesixteenthBoundary, // Three-sixteenth note (eighth note with dot)
|
||||
NOTATE_crotchetBoundary, // Crotchet / Quarter note
|
||||
NOTATE_threeeighthBoundary, // Three-eighth note (quarter note with dot)
|
||||
NOTATE_minimBoundary, // Minim / Half note
|
||||
NOTATE_threequaterBoundary, // Three-quater note (half note with dot)
|
||||
NOTATE_semibreveBoundary, // Semibreve / Whole note
|
||||
NOTATE_breveBoundary, // Breve / Double whole note
|
||||
NOTATE_MAX_PARAMS // == MUST BE LAST ===
|
||||
NOTATE_MAX_PARAMS // == MUST BE LAST ===
|
||||
};
|
||||
|
||||
// Define a chord
|
||||
|
|
|
@ -50,11 +50,15 @@ typedef enum
|
|||
|
||||
PB_SYMBOL_noteHead, // ONLY ADD NOTES BELOW THIS MAKER
|
||||
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_threethirtysecond, // Three-thirty-second note (sixteenth note with dot)
|
||||
PB_SYMBOL_quaver, // Quaver / Eighth note
|
||||
PB_SYMBOL_threesixteenth, // Three-sixteenth note (eighth note with dot)
|
||||
PB_SYMBOL_crotchet, // Crotchet / Quarter note
|
||||
PB_SYMBOL_threeeighth, // Three-eighth note (quarter note with dot)
|
||||
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_breve, // Breve / Double whole note
|
||||
|
||||
|
|
Loading…
Reference in New Issue