Fix several warnings

* Avoid many implicit type conversions or make them at least explicit
    * Use range-based for loops instead of an explicit index where possible
      to eliminate the problematic variable/comparison completely
    * Use float literals to avoid implicit conversions to double (and then
      back to float)
    * Replace some macros with constexpr functions that return the correct
      type
* Port away from deprecated FluidSynth and Qt classes and functions, most
  notably:
    * Use QElapsedTimer instead of QTime and change the type used to store
      ticks to qint64 accordingly
* Declare unused functions parameters as such explicitly to silence related
  warnings
This commit is contained in:
Martchus 2022-12-20 18:16:18 +01:00 committed by Fabien Givors
parent 642f85802e
commit 3948644150
44 changed files with 647 additions and 644 deletions

View File

@ -55,7 +55,7 @@ void CBar::setTimeSig(int top, int bottom)
m_barLength = m_beatLength * getTimeSigTop();
}
int CBar::addDeltaTime(int ticks)
qint64 CBar::addDeltaTime(qint64 ticks)
{
if (m_flushTicks == true && ticks != 0) // ignore this set of ticks
{
@ -82,15 +82,11 @@ int CBar::addDeltaTime(int ticks)
return ticks;
}
int CBar::goToBarNumer()
qint64 CBar::goToBarNumer()
{
int ticks;
ticks = static_cast<int>((m_playFromBar - getCurrentBarPos()) * m_beatLength * SPEED_ADJUST_FACTOR + 1);
const auto ticks = static_cast<qint64>(m_playFromBar - getCurrentBarPos()) * m_beatLength * SPEED_ADJUST_FACTOR + 1;
addDeltaTime(ticks);
return ticks;
}
void CBar::checkGotoBar()
@ -120,6 +116,8 @@ void CBar::setPlayFromBar(double bar)
void CBar::setPlayFromBar(int bar, int beat, int ticks)
{
Q_UNUSED(beat)
Q_UNUSED(ticks)
double playFromBar = bar;
setPlayFromBar( playFromBar);
}

View File

@ -53,8 +53,8 @@ public:
void setTimeSig(int top, int bottom);
int getTimeSigTop() {return m_currentTimeSigTop;} // The Numerator
int getBeatLength() {return m_beatLength;}
int getBarLength() {return m_barLength;} // in ppqn
qint64 getBeatLength() {return m_beatLength;}
qint64 getBarLength() {return m_barLength;} // in ppqn
void setPlayFromBar(double bar);
void setPlayFromBar(int bar, int beat = 0, int ticks = 0);
@ -88,15 +88,15 @@ public:
}
//return true if bar number has changed
int addDeltaTime(int ticks);
qint64 addDeltaTime(qint64 ticks);
//
int getBarNumber(){ return m_barCounter;}
double getCurrentBarPos()
{
return m_barCounter + static_cast<double>(m_beatCounter)/m_currentTimeSigBottom +
static_cast<double>(m_deltaTime)/(m_beatLength * m_currentTimeSigBottom * SPEED_ADJUST_FACTOR);
return m_barCounter + static_cast<double>(m_beatCounter)/static_cast<double>(m_currentTimeSigBottom) +
static_cast<double>(m_deltaTime)/static_cast<double>(m_beatLength * m_currentTimeSigBottom * SPEED_ADJUST_FACTOR);
}
bool seekingBarNumber() { return m_seekingBarNumber;}
@ -108,7 +108,7 @@ public:
return bits;
}
int goToBarNumer();
qint64 goToBarNumer();
private:
void checkGotoBar();
@ -118,9 +118,9 @@ private:
m_enablePlayFromBar = (m_enableLooping || m_playFromBar > 0.0)?true:false;
}
int m_deltaTime;
int m_beatLength; //in ppqn ticks
int m_barLength; // m_beatLength * getTimeSigTop() (also in ppqn ticks)
qint64 m_deltaTime;
qint64 m_beatLength; //in ppqn ticks
qint64 m_barLength; // m_beatLength * getTimeSigTop() (also in ppqn ticks)
int m_startTimeSigTop; // The time Sig at the start of the piece
int m_startTimeSigBottom;

View File

@ -196,8 +196,8 @@ public:
m_cordSpanGapTime = 0;
m_completeChord.clear();
m_currentChord.clear();
m_cfg_ChordNoteGap = CMidiFile::ppqnAdjust(Cfg::chordNoteGap());
m_cfg_ChordMaxLength = CMidiFile::ppqnAdjust(Cfg::chordMaxLength());
m_cfg_ChordNoteGap = CMidiFile::ppqnAdjust(static_cast<float>(Cfg::chordNoteGap()));
m_cfg_ChordMaxLength = CMidiFile::ppqnAdjust(static_cast<float>(Cfg::chordMaxLength()));
}
CChord getChord()

View File

@ -344,9 +344,9 @@ void CConductor::playMusic(bool start)
/*
const unsigned char gsModeEnterData[] = {0xf0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7f, 0x00, 0x41, 0xf7};
for (size_t i = 0; i < arraySize(gsModeEnterData); i++)
for (auto &d : gsModeEnterData)
{
event.collateRawByte(0, gsModeEnterData[i]);
event.collateRawByte(0, d);
playTrackEvent(event);
}
event.outputCollatedRawBytes(0);
@ -641,7 +641,7 @@ void CConductor::pianistInput(CMidiEvent inputNote)
{
m_goodPlayedNotes.addNote(hand, inputNote.note());
m_piano->addPianistNote(hand, inputNote,true);
int pianistTiming;
qint64 pianistTiming;
if ( ( cfg_timingMarkersFlag && m_followSkillAdvanced ) || m_playMode == PB_PLAY_MODE_rhythmTapping )
pianistTiming = m_pianistTiming;
else
@ -698,7 +698,7 @@ void CConductor::pianistInput(CMidiEvent inputNote)
{
m_goodPlayedNotes.addNote(hand, inputNote.note());
m_piano->addPianistNote(hand, inputNote,true);
int pianistTiming;
qint64 pianistTiming;
if ( ( cfg_timingMarkersFlag && m_followSkillAdvanced ) || m_playMode == PB_PLAY_MODE_rhythmTapping )
pianistTiming = m_pianistTiming;
else
@ -814,7 +814,7 @@ void CConductor::pianistInput(CMidiEvent inputNote)
}
void CConductor::addDeltaTime(int ticks)
void CConductor::addDeltaTime(qint64 ticks)
{
m_scoreWin->scrollDeltaTime(ticks);
m_playingDeltaTime += ticks;
@ -834,14 +834,14 @@ void CConductor::followPlaying()
if (seekingBarNumber())
{
if (deltaAdjust(m_chordDeltaTime) > -m_stopPoint )
if (deltaAdjustL(m_chordDeltaTime) > -m_stopPoint )
fetchNextChord();
}
else if ( m_playMode == PB_PLAY_MODE_followYou || m_playMode == PB_PLAY_MODE_rhythmTapping )
{
if (deltaAdjust(m_chordDeltaTime) > -m_cfg_earlyNotesPoint )
if (deltaAdjustL(m_chordDeltaTime) > -m_cfg_earlyNotesPoint )
m_followState = PB_FOLLOW_earlyNotes;
if (deltaAdjust(m_chordDeltaTime) > -m_stopPoint )
if (deltaAdjustL(m_chordDeltaTime) > -m_stopPoint )
{
m_followState = PB_FOLLOW_waiting;
// Throw away the time past the stop point (by adding a negative ticks)
@ -858,7 +858,7 @@ void CConductor::followPlaying()
setEventBits( EVENT_BITS_forceRatingRedraw);
}
}
if (deltaAdjust(m_chordDeltaTime) > -m_cfg_earlyNotesPoint )
if (deltaAdjustL(m_chordDeltaTime) > -m_cfg_earlyNotesPoint )
turnOnKeyboardLights(true);
}
@ -871,14 +871,11 @@ void CConductor::outputSavedNotesOff()
// untangle the sound in case there is any notes off just after we have stopped
void CConductor::findImminentNotesOff()
{
int i;
CMidiEvent event;
int aheadDelta = 0;
i = 0;
CMidiEvent event = m_nextMidiEvent;
int i = 0;
qint64 aheadDelta = 0;
event = m_nextMidiEvent;
while (deltaAdjust(m_playingDeltaTime) + aheadDelta > m_cfg_imminentNotesOffPoint)
while (deltaAdjustL(m_playingDeltaTime) + aheadDelta > m_cfg_imminentNotesOffPoint)
{
if (event.type() == MIDI_NOTE_OFF )
m_savedNoteOffQueue->push(event);
@ -902,15 +899,9 @@ void CConductor::missedNotesColor(CColor color)
}
}
void CConductor::realTimeEngine(int mSecTicks)
void CConductor::realTimeEngine(qint64 mSecTicks)
{
int type;
int ticks; // MIDI ticks
//mSecTicks = 2; // for debugging only
ticks = m_tempo.mSecToTicks(mSecTicks);
auto ticks = m_tempo.mSecToTicks(mSecTicks);
if (!m_followPlayingTimeOut)
m_pianistTiming += ticks;
@ -979,6 +970,7 @@ void CConductor::realTimeEngine(int mSecTicks)
addDeltaTime(ticks);
followPlaying();
int type;
while ( m_playingDeltaTime >= m_leadLagAdjust)
{
type = m_nextMidiEvent.type();
@ -1082,8 +1074,8 @@ void CConductor::rewind()
// Annie song 25
m_cfg_playZoneEarly = CMidiFile::ppqnAdjust(Cfg::playZoneEarly()) * SPEED_ADJUST_FACTOR; // when playing along
m_cfg_playZoneLate = CMidiFile::ppqnAdjust(Cfg::playZoneLate()) * SPEED_ADJUST_FACTOR;
m_cfg_playZoneEarly = CMidiFile::ppqnAdjust(static_cast<float>(Cfg::playZoneEarly())) * SPEED_ADJUST_FACTOR; // when playing along
m_cfg_playZoneLate = CMidiFile::ppqnAdjust(static_cast<float>(Cfg::playZoneLate())) * SPEED_ADJUST_FACTOR;
}
void CConductor::init2(CScore * scoreWin, CSettings* settings)

View File

@ -97,7 +97,7 @@ public:
//! rest the conductor between each song
void reset();
void realTimeEngine(int mSecTicks);
void realTimeEngine(qint64 mSecTicks);
void playMusic(bool start);
bool playingMusic() {return m_playing;}
void reconnectMidi();
@ -247,11 +247,11 @@ private:
int calcBoostVolume(int chan, int volume);
void addDeltaTime(int ticks);
void addDeltaTime(qint64 ticks);
void turnOnKeyboardLights(bool on);
int m_playingDeltaTime;
int m_chordDeltaTime;
qint64 m_playingDeltaTime;
qint64 m_chordDeltaTime;
bool m_playing;
int m_transpose; // the number of semitones to transpose the music
@ -273,8 +273,8 @@ private:
CPiano* m_piano;
CBar m_bar;
int m_leadLagAdjust; // Synchronise the sound with the video
int m_silenceTimeOut; // used to create silence if the student stops for toooo long
qint64 m_leadLagAdjust; // Synchronise the sound with the video
qint64 m_silenceTimeOut; // used to create silence if the student stops for toooo long
CChord m_wantedChord; // The chord the pianist needs to play
CChord m_savedWantedChord; // A copy of the wanted chord complete with both left and right parts
CChord m_goodPlayedNotes; // The good notes the pianist plays
@ -284,22 +284,22 @@ private:
int m_pianistSplitPoint; // Defines which notes go in the base and treble clef
bool m_followSkillAdvanced;
int m_lastSound;
int m_stopPoint; // Were we stop the music if the pianist is late
qint64 m_stopPoint; // Were we stop the music if the pianist is late
int m_cfg_rightNoteSound;
int m_cfg_wrongNoteSound;
int m_pianistGoodChan;
int m_pianistBadChan;
int m_cfg_earlyNotesPoint; // don't press the note too early
int m_cfg_stopPointAdvanced; // Were we stop the music if the pianist is late
int m_cfg_stopPointBeginner; // Were we stop the music if the pianist is late
int m_cfg_imminentNotesOffPoint;
int m_cfg_playZoneEarly; // when playing along
int m_cfg_playZoneLate;
qint64 m_cfg_earlyNotesPoint; // don't press the note too early
qint64 m_cfg_stopPointAdvanced; // Were we stop the music if the pianist is late
qint64 m_cfg_stopPointBeginner; // Were we stop the music if the pianist is late
qint64 m_cfg_imminentNotesOffPoint;
qint64 m_cfg_playZoneEarly; // when playing along
qint64 m_cfg_playZoneLate;
int m_cfg_rhythmTapLeftHandDrumSound;
int m_cfg_rhythmTapRightHandDrumSound;
int m_pianistTiming; //measure whether the pianist is playing early or late
qint64 m_pianistTiming; //measure whether the pianist is playing early or late
bool m_followPlayingTimeOut; // O dear, the student is too slow
bool m_testWrongNoteSound;

View File

@ -102,8 +102,8 @@ void CDraw::drawStaveExtentsion(CSymbol symbol, float x, int noteWidth, bool pl
while (index >= 6 || index <= -6)
{
glVertex2f (x - noteWidth/2 - 4, CStavePos(hand, index).getPosYRelative());
glVertex2f (x + noteWidth/2 + 4, CStavePos(hand, index).getPosYRelative());
glVertex2f (x - static_cast<float>(noteWidth)/2.0f - 4.0f, CStavePos(hand, index).getPosYRelative());
glVertex2f (x + static_cast<float>(noteWidth)/2.0f + 4.0f, CStavePos(hand, index).getPosYRelative());
// Move the index closer to the stave centre
if (index > 0)
@ -114,13 +114,13 @@ void CDraw::drawStaveExtentsion(CSymbol symbol, float x, int noteWidth, bool pl
glEnd();
}
#define scaleGlVertex(xa, xb, ya, yb) glVertex2f( ((xa) * 1.2) + (xb), ((ya) * 1.2) + (yb))
#define scaleGlVertex(xa, xb, ya, yb) glVertex2f( ((xa) * 1.2f) + (xb), ((ya) * 1.2f) + (yb))
#ifndef NO_USE_FTGL
void CDraw::renderText(float x, float y, const char* s)
{
double w = font->Advance(s);
double h = font->Descender();
const auto w = font->Advance(s);
const auto h = font->Descender();
glRasterPos2f(x - w/2, y - h);
font->Render(s);
}
@ -128,6 +128,7 @@ void CDraw::renderText(float x, float y, const char* s)
void CDraw::drawNoteName(int midiNote, float x, float y, int type)
{
Q_UNUSED(type)
// Ignore note that are too high
if (midiNote > MIDI_TOP_C + 6)
return;
@ -147,14 +148,14 @@ void CDraw::drawNoteName(int midiNote, float x, float y, int type)
{
glBegin(GL_LINES);
// letterSharp4
scaleGlVertex( -1.317895, x, 5.794585, y); // 1
scaleGlVertex( -1.265845, x, -6.492455, y); // 2
scaleGlVertex( 1.252305, x, 6.492455, y); // 3
scaleGlVertex( 1.322655, x, -5.422335, y); // 4
scaleGlVertex( -2.645765, x, 1.967805, y); // 5
scaleGlVertex( 2.648325, x, 3.625485, y); // 6
scaleGlVertex( -2.648325, x, -3.306965, y); // 7
scaleGlVertex( 2.596205, x, -1.675765, y); // 8
scaleGlVertex( -1.317895f, x, 5.794585f, y); // 1
scaleGlVertex( -1.265845f, x, -6.492455f, y); // 2
scaleGlVertex( 1.252305f, x, 6.492455f, y); // 3
scaleGlVertex( 1.322655f, x, -5.422335f, y); // 4
scaleGlVertex( -2.645765f, x, 1.967805f, y); // 5
scaleGlVertex( 2.648325f, x, 3.625485f, y); // 6
scaleGlVertex( -2.648325f, x, -3.306965f, y); // 7
scaleGlVertex( 2.596205f, x, -1.675765f, y); // 8
glEnd();
}
@ -162,15 +163,15 @@ void CDraw::drawNoteName(int midiNote, float x, float y, int type)
{
glBegin(GL_LINE_STRIP);
// letterFlat
scaleGlVertex( -2.52933, x, 6.25291, y); // 1
scaleGlVertex( -2.50344, x, -6.25291, y); // 2
scaleGlVertex( 0.76991, x, -3.63422, y); // 3
scaleGlVertex( 2.07925, x, -1.67021, y); // 4
scaleGlVertex( 2.52933, x, 0.25288, y); // 5
scaleGlVertex( 1.42458, x, 1.07122, y); // 6
scaleGlVertex( -0.53943, x, 0.90755, y); // 7
scaleGlVertex( -2.46252, x, -1.01554, y); // 8
scaleGlVertex( -2.50344, x, -1.67021, y); // 9
scaleGlVertex( -2.52933f, x, 6.25291f, y); // 1
scaleGlVertex( -2.50344f, x, -6.25291f, y); // 2
scaleGlVertex( 0.76991f, x, -3.63422f, y); // 3
scaleGlVertex( 2.07925ff, x, -1.67021f, y); // 4
scaleGlVertex( 2.52933f, x, 0.25288f, y); // 5
scaleGlVertex( 1.42458f, x, 1.07122f, y); // 6
scaleGlVertex( -0.53943f, x, 0.90755f, y); // 7
scaleGlVertex( -2.46252f, x, -1.01554f, y); // 8
scaleGlVertex( -2.50344f, x, -1.67021f, y); // 9
glEnd();
}
@ -182,54 +183,54 @@ void CDraw::drawNoteName(int midiNote, float x, float y, int type)
case 1:
glBegin(GL_LINE_STRIP);
// letterC
scaleGlVertex( 3.513445, x, 2.17485, y); // 1
scaleGlVertex( 1.880175, x, 4.47041, y); // 2
scaleGlVertex( -1.598825, x, 4.4321, y); // 3
scaleGlVertex( -3.692215, x, 2.26571, y); // 4
scaleGlVertex( -3.702055, x, -1.88958, y); // 5
scaleGlVertex( -1.630675, x, -4.47041, y); // 6
scaleGlVertex( 1.932545, x, -4.44064, y); // 7
scaleGlVertex( 3.702055, x, -1.88554, y); // 8
scaleGlVertex( 3.513445f, x, 2.17485f, y); // 1
scaleGlVertex( 1.880175f, x, 4.47041f, y); // 2
scaleGlVertex( -1.598825f, x, 4.4321f, y); // 3
scaleGlVertex( -3.692215f, x, 2.26571f, y); // 4
scaleGlVertex( -3.702055f, x, -1.88958f, y); // 5
scaleGlVertex( -1.630675f, x, -4.47041f, y); // 6
scaleGlVertex( 1.932545f, x, -4.44064f, y); // 7
scaleGlVertex( 3.702055f, x, -1.88554f, y); // 8
glEnd();
break;
case 2:
glBegin(GL_LINE_STRIP);
// letterD
scaleGlVertex( -3.30696, x, 4.31878, y); // 1
scaleGlVertex( -3.3428, x, -4.31878, y); // 2
scaleGlVertex( 0.9425, x, -4.28164, y); // 3
scaleGlVertex( 3.31415, x, -1.42302, y); // 4
scaleGlVertex( 3.3428, x, 1.66626, y); // 5
scaleGlVertex( 0.70825, x, 4.31317, y); // 6
scaleGlVertex( -3.22083, x, 4.29495, y); // 7
scaleGlVertex( -3.30696f, x, 4.31878f, y); // 1
scaleGlVertex( -3.3428f, x, -4.31878f, y); // 2
scaleGlVertex( 0.9425f, x, -4.28164f, y); // 3
scaleGlVertex( 3.31415f, x, -1.42302f, y); // 4
scaleGlVertex( 3.3428f, x, 1.66626f, y); // 5
scaleGlVertex( 0.70825f, x, 4.31317f, y); // 6
scaleGlVertex( -3.22083f, x, 4.29495f, y); // 7
glEnd();
break;
case 3: // E
glBegin(GL_LINE_STRIP);
// letterE2
scaleGlVertex( 2.966065, x, 4.416055, y); // 1
scaleGlVertex( -3.007275, x, 4.403495, y); // 2
scaleGlVertex( -3.037615, x, -4.416055, y); // 3
scaleGlVertex( 3.037615, x, -4.415435, y); // 4
scaleGlVertex( 2.966065f, x, 4.416055f, y); // 1
scaleGlVertex( -3.007275f, x, 4.403495f, y); // 2
scaleGlVertex( -3.037615f, x, -4.416055f, y); // 3
scaleGlVertex( 3.037615f, x, -4.415435f, y); // 4
glEnd();
glBegin(GL_LINES);
scaleGlVertex( 3.011705, x, 0.197675, y); // 5
scaleGlVertex( -2.990845, x, 0.196615, y); // 6
scaleGlVertex( 3.011705f, x, 0.197675f, y); // 5
scaleGlVertex( -2.990845f, x, 0.196615f, y); // 6
glEnd();
break;
case 4: // F
glBegin(GL_LINE_STRIP);
// letterF2
scaleGlVertex( -2.55172, x, -4.434285, y); // 1
scaleGlVertex( -2.51956, x, 4.433665, y); // 2
scaleGlVertex( 2.39942, x, 4.434285, y); // 3
scaleGlVertex( -2.55172f, x, -4.434285f, y); // 1
scaleGlVertex( -2.51956f, x, 4.433665ff, y); // 2
scaleGlVertex( 2.39942f, x, 4.434285f, y); // 3
glEnd();
glBegin(GL_LINES);
scaleGlVertex( 2.58143, x, 0.244465, y); // 4
scaleGlVertex( -2.58143, x, 0.243405, y); // 5
scaleGlVertex( 2.58143f, x, 0.244465f, y); // 4
scaleGlVertex( -2.58143f, x, 0.243405f, y); // 5
glEnd();
break;
@ -237,29 +238,29 @@ void CDraw::drawNoteName(int midiNote, float x, float y, int type)
case 5:
glBegin(GL_LINE_STRIP);
// letterG
scaleGlVertex( 0.58123, x, -0.34005, y); // 1
scaleGlVertex( 3.66047, x, -0.48722, y); // 2
scaleGlVertex( 3.70461, x, -3.23595, y); // 3
scaleGlVertex( 1.96234, x, -4.41694, y); // 4
scaleGlVertex( -0.96712, x, -4.57846, y); // 5
scaleGlVertex( -3.70461, x, -2.29011, y); // 6
scaleGlVertex( -3.67245, x, 2.14034, y); // 7
scaleGlVertex( -1.25347, x, 4.57846, y); // 8
scaleGlVertex( 1.90018, x, 4.55293, y); // 9
scaleGlVertex( 3.54236, x, 2.38612, y); // 10
scaleGlVertex( 0.58123f, x, -0.34005f, y); // 1
scaleGlVertex( 3.66047f, x, -0.48722f, y); // 2
scaleGlVertex( 3.70461f, x, -3.23595f, y); // 3
scaleGlVertex( 1.96234f, x, -4.41694f, y); // 4
scaleGlVertex( -0.96712f, x, -4.57846f, y); // 5
scaleGlVertex( -3.70461f, x, -2.29011f, y); // 6
scaleGlVertex( -3.67245f, x, 2.14034f, y); // 7
scaleGlVertex( -1.25347f, x, 4.57846f, y); // 8
scaleGlVertex( 1.90018f, x, 4.55293f, y); // 9
scaleGlVertex( 3.54236f, x, 2.38612f, y); // 10
glEnd();
break;
case 6: // A
glBegin(GL_LINE_STRIP);
// letterA2
scaleGlVertex( -3.91146, x, -4.907395, y); // 1
scaleGlVertex( 0.06571, x, 4.907395, y); // 2
scaleGlVertex( 3.91146, x, -4.803315, y); // 3
scaleGlVertex( -3.91146f, x, -4.907395f, y); // 1
scaleGlVertex( 0.06571f, x, 4.907395f, y); // 2
scaleGlVertex( 3.91146f, x, -4.803315f, y); // 3
glEnd();
glBegin(GL_LINES);
scaleGlVertex( 2.60111, x, -1.400435, y); // 4
scaleGlVertex( -2.56175, x, -1.357305, y); // 5
scaleGlVertex( 2.60111f, x, -1.400435f, y); // 4
scaleGlVertex( -2.56175f, x, -1.357305f, y); // 5
glEnd();
break;
@ -267,34 +268,34 @@ void CDraw::drawNoteName(int midiNote, float x, float y, int type)
case 7:
glBegin(GL_LINE_STRIP);
// letterB
scaleGlVertex( 1.038555, x, 0.105285, y); // 1
scaleGlVertex( -3.001935, x, 0.121925, y); // 2
scaleGlVertex( -3.027615, x, 4.417905, y); // 3
scaleGlVertex( 1.325925, x, 4.451255, y); // 4
scaleGlVertex( 2.737985, x, 3.048615, y); // 5
scaleGlVertex( 2.721765, x, 1.366235, y); // 6
scaleGlVertex( 1.022635, x, 0.120235, y); // 7
scaleGlVertex( 3.026015, x, -1.282295, y); // 8
scaleGlVertex( 3.027615, x, -3.046285, y); // 9
scaleGlVertex( 1.176815, x, -4.451255, y); // 10
scaleGlVertex( -2.981475, x, -4.445735, y); // 11
scaleGlVertex( -3.021355, x, 0.176035, y); // 12
scaleGlVertex( 1.038555f, x, 0.105285f, y); // 1
scaleGlVertex( -3.001935f, x, 0.121925f, y); // 2
scaleGlVertex( -3.027615f, x, 4.417905f, y); // 3
scaleGlVertex( 1.325925f, x, 4.451255f, y); // 4
scaleGlVertex( 2.737985f, x, 3.048615f, y); // 5
scaleGlVertex( 2.721765f, x, 1.366235f, y); // 6
scaleGlVertex( 1.022635f, x, 0.120235f, y); // 7
scaleGlVertex( 3.026015f, x, -1.282295f, y); // 8
scaleGlVertex( 3.027615f, x, -3.046285f, y); // 9
scaleGlVertex( 1.176815f, x, -4.451255f, y); // 10
scaleGlVertex( -2.981475f, x, -4.445735f, y); // 11
scaleGlVertex( -3.021355f, x, 0.176035f, y); // 12
glEnd();
break;
default:
glBegin(GL_LINES);
glVertex2f( 3 + x, -15 + y); // 1
glVertex2f( 3 + x, 8 + y); // 2
glVertex2f( 3.0f + x, -15.0f + y); // 1
glVertex2f( 3.0f + x, 8.0f + y); // 2
glVertex2f( -3 + x, -8 + y); // 3
glVertex2f( -3 + x, 15 + y); // 4
glVertex2f( -3.0f + x, -8.0f + y); // 3
glVertex2f( -3.0f + x, 15.0f + y); // 4
glVertex2f( 3 + x, 8 + y); // 5
glVertex2f( -3 + x, 2 + y); // 6
glVertex2f( 3.0f + x, 8.0f + y); // 5
glVertex2f( -3.0f + x, 2.0f + y); // 6
glVertex2f( 3 + x, -2 + y); // 7
glVertex2f( -3 + x, -8 + y); // 8
glVertex2f( 3.0f + x, -2.0f + y); // 7
glVertex2f( -3.0f + x, -8.0f + y); // 8
glEnd();
break;
}
@ -376,8 +377,9 @@ void CDraw::checkAccidental(CSymbol symbol, float x, float y)
bool CDraw::drawNote(CSymbol* symbol, float x, float y, CSlot* slot, CColor color, bool playable)
{
const float stemLength = 34.0;
float noteWidth = 6.0;
Q_UNUSED(slot)
const float stemLength = 34.0f;
float noteWidth = 6.0f;
//ppLogTrace("PB_SYMBOL_noteHead x %f y %f", x, y);
if (!CChord::isNotePlayable(symbol->getNote(), 0))
@ -405,22 +407,22 @@ bool CDraw::drawNote(CSymbol* symbol, float x, float y, CSlot* slot, CColor colo
if (showNoteStem)
{
if (!solidNoteHead)
noteWidth += 1.0;
glLineWidth(2.0);
noteWidth += 1.0f;
glLineWidth(2.0f);
glBegin(GL_LINE_STRIP);
glVertex2f(noteWidth + x, 0.0 + y); // 1
glVertex2f(noteWidth + x, 0.0f + y); // 1
glVertex2f(noteWidth + x, stemLength + y); // 2
glEnd();
}
int offset = stemLength;
float offset = stemLength;
while (stemFlagCount>0)
{
glLineWidth(2.0);
glBegin(GL_LINE_STRIP);
glVertex2f(noteWidth + x, offset + y); // 1
glVertex2f(noteWidth + 8 + x, offset - 16 + y); // 2
glVertex2f(noteWidth + 8.0f + x, offset - 16.0f + y); // 2
glEnd();
offset -= 8;
stemFlagCount--;
@ -429,36 +431,36 @@ bool CDraw::drawNote(CSymbol* symbol, float x, float y, CSlot* slot, CColor colo
if (solidNoteHead)
{
glBegin(GL_POLYGON);
glVertex2f(-7.0 + x, 2.0 + y); // 1
glVertex2f(-5.0 + x, 4.0 + y); // 2
glVertex2f(-1.0 + x, 6.0 + y); // 3
glVertex2f( 4.0 + x, 6.0 + y); // 4
glVertex2f( 7.0 + x, 4.0 + y); // 5
glVertex2f( 7.0 + x, 1.0 + y); // 6
glVertex2f( 6.0 + x, -2.0 + y); // 7
glVertex2f( 4.0 + x, -4.0 + y); // 8
glVertex2f( 0.0 + x, -6.0 + y); // 9
glVertex2f(-4.0 + x, -6.0 + y); // 10
glVertex2f(-8.0 + x, -3.0 + y); // 11
glVertex2f(-8.0 + x, -0.0 + y); // 12
glVertex2f(-7.0f + x, 2.0f + y); // 1
glVertex2f(-5.0f + x, 4.0f + y); // 2
glVertex2f(-1.0f + x, 6.0f + y); // 3
glVertex2f( 4.0f + x, 6.0f + y); // 4
glVertex2f( 7.0f + x, 4.0f + y); // 5
glVertex2f( 7.0f + x, 1.0f + y); // 6
glVertex2f( 6.0f + x, -2.0f + y); // 7
glVertex2f( 4.0f + x, -4.0f + y); // 8
glVertex2f( 0.0f + x, -6.0f + y); // 9
glVertex2f(-4.0f + x, -6.0f + y); // 10
glVertex2f(-8.0f + x, -3.0f + y); // 11
glVertex2f(-8.0f + x, -0.0f + y); // 12
glEnd();
}
else
{
glLineWidth(2.0);
glBegin(GL_LINE_STRIP);
glVertex2f(-7.0 + x, 2.0 + y); // 1
glVertex2f(-5.0 + x, 4.0 + y); // 2
glVertex2f(-1.0 + x, 6.0 + y); // 3
glVertex2f( 4.0 + x, 6.0 + y); // 4
glVertex2f( 7.0 + x, 4.0 + y); // 5
glVertex2f( 7.0 + x, 1.0 + y); // 6
glVertex2f( 6.0 + x, -2.0 + y); // 7
glVertex2f( 4.0 + x, -4.0 + y); // 8
glVertex2f( 0.0 + x, -6.0 + y); // 9
glVertex2f(-4.0 + x, -6.0 + y); // 10
glVertex2f(-8.0 + x, -3.0 + y); // 11
glVertex2f(-8.0 + x, -0.0 + y); // 12
glVertex2f(-7.0f + x, 2.0f + y); // 1
glVertex2f(-5.0f + x, 4.0f + y); // 2
glVertex2f(-1.0f + x, 6.0f + y); // 3
glVertex2f( 4.0f + x, 6.0f + y); // 4
glVertex2f( 7.0f + x, 4.0f + y); // 5
glVertex2f( 7.0f + x, 1.0f + y); // 6
glVertex2f( 6.0f + x, -2.0f + y); // 7
glVertex2f( 4.0f + x, -4.0f + y); // 8
glVertex2f( 0.0f + x, -6.0f + y); // 9
glVertex2f(-4.0f + x, -6.0f + y); // 10
glVertex2f(-8.0f + x, -3.0f + y); // 11
glVertex2f(-8.0f + x, -0.0f + y); // 12
glEnd();
}
@ -486,57 +488,57 @@ void CDraw::drawSymbol(CSymbol symbol, float x, float y, CSlot* slot)
case PB_SYMBOL_gClef: // The Treble Clef
y += 4;
drColor(color);
glLineWidth (3.0);
glLineWidth (3.0f);
glBegin(GL_LINE_STRIP);
glVertex2f( -0.011922 + x, -16.11494 + y); // 1
glVertex2f( -3.761922 + x, -12.48994 + y); // 2
glVertex2f( -4.859633 + x, -8.85196 + y); // 3
glVertex2f( -4.783288 + x, -5.42815 + y); // 4
glVertex2f( -0.606711 + x, -1.11108 + y); // 5
glVertex2f( 5.355545 + x, 0.48711 + y); // 6
glVertex2f( 10.641104 + x, -1.6473 + y); // 7
glVertex2f( 14.293812 + x, -6.18241 + y); // 8
glVertex2f( 14.675578 + x, -11.42744 + y); // 9
glVertex2f( 12.550578 + x, -17.30244 + y); // 10
glVertex2f( 7.912166 + x, -20.944 + y); // 11
glVertex2f( 3.049705 + x, -21.65755 + y); // 12
glVertex2f( -1.711005 + x, -21.36664 + y); // 13
glVertex2f( -6.283661 + x, -19.66739 + y); // 14
glVertex2f( -10.123329 + x, -16.79162 + y); // 15
glVertex2f( -13.363008 + x, -12.28184 + y); // 16
glVertex2f( -14.675578 + x, -5.79969 + y); // 17
glVertex2f( -13.66821 + x, 0.20179 + y); // 18
glVertex2f( -10.385341 + x, 6.27562 + y); // 19
glVertex2f( 5.539491 + x, 20.32671 + y); // 20
glVertex2f( 10.431588 + x, 28.20584 + y); // 21
glVertex2f( 11.00141 + x, 34.71585 + y); // 22
glVertex2f( 9.204915 + x, 39.62875 + y); // 23
glVertex2f( 7.854166 + x, 42.08262 + y); // 24
glVertex2f( 5.481415 + x, 42.66649 + y); // 25
glVertex2f( 3.57972 + x, 41.4147 + y); // 26
glVertex2f( 1.507889 + x, 37.35642 + y); // 27
glVertex2f( -0.381338 + x, 31.14317 + y); // 28
glVertex2f( -0.664306 + x, 25.51354 + y); // 29
glVertex2f( 8.296044 + x, -32.22694 + y); // 30
glVertex2f( 8.050507 + x, -36.6687 + y); // 31
glVertex2f( 6.496615 + x, -39.52999 + y); // 32
glVertex2f( 3.368583 + x, -41.7968 + y); // 33
glVertex2f( 0.253766 + x, -42.66649 + y); // 34
glVertex2f( -3.599633 + x, -42.23514 + y); // 35
glVertex2f( -8.098754 + x, -39.46637 + y); // 36
glVertex2f( -9.463279 + x, -35.49796 + y); // 37
glVertex2f( -7.08037 + x, -31.36512 + y); // 38
glVertex2f( -3.336421 + x, -31.14057 + y); // 39
glVertex2f( -1.360313 + x, -34.07738 + y); // 40
glVertex2f( -1.608342 + x, -37.11828 + y); // 41
glVertex2f( -5.729949 + x, -39.24759 + y); // 42
glVertex2f( -7.480646 + x, -36.2136 + y); // 43
glVertex2f( -6.826918 + x, -33.36919 + y); // 44
glVertex2f( -4.069083 + x, -32.9226 + y); // 45
glVertex2f( -3.040669 + x, -34.433 + y); // 46
glVertex2f( -3.737535 + x, -36.38759 + y); // 47
glVertex2f( -5.496558 + x, -36.97633 + y); // 48
glVertex2f( -5.295932 + x, -34.01951 + y); // 49
glVertex2f( -0.011922f + x, -16.11494f + y); // 1
glVertex2f( -3.761922f + x, -12.48994f + y); // 2
glVertex2f( -4.859633f + x, -8.85196f + y); // 3
glVertex2f( -4.783288f + x, -5.42815f + y); // 4
glVertex2f( -0.606711f + x, -1.11108f + y); // 5
glVertex2f( 5.355545f + x, 0.48711f + y); // 6
glVertex2f( 10.641104f + x, -1.6473f + y); // 7
glVertex2f( 14.293812f + x, -6.18241f + y); // 8
glVertex2f( 14.675578f + x, -11.42744f + y); // 9
glVertex2f( 12.550578f + x, -17.30244f + y); // 10
glVertex2f( 7.912166f + x, -20.944f + y); // 11
glVertex2f( 3.049705f + x, -21.65755f + y); // 12
glVertex2f( -1.711005f + x, -21.36664f + y); // 13
glVertex2f( -6.283661f + x, -19.66739f + y); // 14
glVertex2f( -10.123329f + x, -16.79162f + y); // 15
glVertex2f( -13.363008f + x, -12.28184f + y); // 16
glVertex2f( -14.675578f + x, -5.79969f + y); // 17
glVertex2f( -13.66821f + x, 0.20179f + y); // 18
glVertex2f( -10.385341f + x, 6.27562f + y); // 19
glVertex2f( 5.539491f + x, 20.32671f + y); // 20
glVertex2f( 10.431588f + x, 28.20584f + y); // 21
glVertex2f( 11.00141f + x, 34.71585f + y); // 22
glVertex2f( 9.204915f + x, 39.62875f + y); // 23
glVertex2f( 7.854166f + x, 42.08262f + y); // 24
glVertex2f( 5.481415f + x, 42.66649f + y); // 25
glVertex2f( 3.57972f + x, 41.4147f + y); // 26
glVertex2f( 1.507889f + x, 37.35642f + y); // 27
glVertex2f( -0.381338f + x, 31.14317f + y); // 28
glVertex2f( -0.664306f + x, 25.51354f + y); // 29
glVertex2f( 8.296044f + x, -32.22694f + y); // 30
glVertex2f( 8.050507f + x, -36.6687f + y); // 31
glVertex2f( 6.496615f + x, -39.52999f + y); // 32
glVertex2f( 3.368583f + x, -41.7968f + y); // 33
glVertex2f( 0.253766f + x, -42.66649f + y); // 34
glVertex2f( -3.599633f + x, -42.23514f + y); // 35
glVertex2f( -8.098754f + x, -39.46637f + y); // 36
glVertex2f( -9.463279f + x, -35.49796f + y); // 37
glVertex2f( -7.08037f + x, -31.36512f + y); // 38
glVertex2f( -3.336421f + x, -31.14057f + y); // 39
glVertex2f( -1.360313f + x, -34.07738f + y); // 40
glVertex2f( -1.608342f + x, -37.11828f + y); // 41
glVertex2f( -5.729949f + x, -39.24759f + y); // 42
glVertex2f( -7.480646f + x, -36.2136f + y); // 43
glVertex2f( -6.826918f + x, -33.36919f + y); // 44
glVertex2f( -4.069083f + x, -32.9226f + y); // 45
glVertex2f( -3.040669f + x, -34.433f + y); // 46
glVertex2f( -3.737535f + x, -36.38759f + y); // 47
glVertex2f( -5.496558f + x, -36.97633f + y); // 48
glVertex2f( -5.295932f + x, -34.01951f + y); // 49
glEnd();
@ -544,49 +546,49 @@ void CDraw::drawSymbol(CSymbol symbol, float x, float y, CSlot* slot)
case PB_SYMBOL_fClef: // The Base Clef
drColor(color);
glLineWidth (3.0);
glLineWidth (3.0f);
glBegin(GL_LINE_STRIP);
glVertex2f( -15.370325 + x, -17.42068 + y); // 1
glVertex2f( -7.171025 + x, -13.75432 + y); // 2
glVertex2f( -2.867225 + x, -10.66642 + y); // 3
glVertex2f( 0.925165 + x, -7.03249 + y); // 4
glVertex2f( 4.254425 + x, -0.65527 + y); // 5
glVertex2f( 4.762735 + x, 7.77848 + y); // 6
glVertex2f( 2.693395 + x, 13.92227 + y); // 7
glVertex2f( -1.207935 + x, 16.80317 + y); // 8
glVertex2f( -5.526425 + x, 17.42068 + y); // 9
glVertex2f( -10.228205 + x, 15.65609 + y); // 10
glVertex2f( -13.453995 + x, 10.7128 + y); // 11
glVertex2f( -13.133655 + x, 5.43731 + y); // 12
glVertex2f( -9.475575 + x, 3.00714 + y); // 13
glVertex2f( -5.846445 + x, 4.72159 + y); // 14
glVertex2f( -5.395545 + x, 9.72918 + y); // 15
glVertex2f( -8.850025 + x, 11.64372 + y); // 16
glVertex2f( -11.519385 + x, 10.35816 + y); // 17
glVertex2f( -11.706365 + x, 6.8704 + y); // 18
glVertex2f( -9.463505 + x, 5.01391 + y); // 19
glVertex2f( -7.172075 + x, 5.81649 + y); // 20
glVertex2f( -7.189565 + x, 8.62975 + y); // 21
glVertex2f( -9.175055 + x, 9.82019 + y); // 22
glVertex2f( -10.696425 + x, 8.08395 + y); // 23
glVertex2f( -8.843065 + x, 6.66726 + y); // 24
glVertex2f( -8.995775 + x, 8.71136 + y); // 25
glVertex2f( -15.370325f + x, -17.42068f + y); // 1
glVertex2f( -7.171025f + x, -13.75432f + y); // 2
glVertex2f( -2.867225f + x, -10.66642f + y); // 3
glVertex2f( 0.925165f + x, -7.03249f + y); // 4
glVertex2f( 4.254425f + x, -0.65527f + y); // 5
glVertex2f( 4.762735f + x, 7.77848f + y); // 6
glVertex2f( 2.693395f + x, 13.92227f + y); // 7
glVertex2f( -1.207935f + x, 16.80317f + y); // 8
glVertex2f( -5.526425f + x, 17.42068f + y); // 9
glVertex2f( -10.228205f + x, 15.65609f + y); // 10
glVertex2f( -13.453995f + x, 10.7128f + y); // 11
glVertex2f( -13.133655f + x, 5.43731f + y); // 12
glVertex2f( -9.475575f + x, 3.00714f + y); // 13
glVertex2f( -5.846445f + x, 4.72159f + y); // 14
glVertex2f( -5.395545f + x, 9.72918f + y); // 15
glVertex2f( -8.850025f + x, 11.64372f + y); // 16
glVertex2f( -11.519385f + x, 10.35816f + y); // 17
glVertex2f( -11.706365f + x, 6.8704f + y); // 18
glVertex2f( -9.463505f + x, 5.01391f + y); // 19
glVertex2f( -7.172075f + x, 5.81649f + y); // 20
glVertex2f( -7.189565f + x, 8.62975f + y); // 21
glVertex2f( -9.175055f + x, 9.82019f + y); // 22
glVertex2f( -10.696425f + x, 8.08395f + y); // 23
glVertex2f( -8.843065f + x, 6.66726f + y); // 24
glVertex2f( -8.995775f + x, 8.71136f + y); // 25
glEnd();
glBegin(GL_POLYGON);
glVertex2f( 10 + x, 14 + y); // 26
glVertex2f( 14 + x, 14 + y); // 27
glVertex2f( 14 + x, 10 + y); // 28
glVertex2f( 10 + x, 10 + y); // 29
glVertex2f( 10 + x, 14 + y); // 30
glVertex2f( 10.0f + x, 14.0f + y); // 26
glVertex2f( 14.0f + x, 14.0f + y); // 27
glVertex2f( 14.0f + x, 10.0f + y); // 28
glVertex2f( 10.0f + x, 10.0f + y); // 29
glVertex2f( 10.0f + x, 14.0f + y); // 30
glEnd();
glBegin(GL_POLYGON);
glVertex2f( 10 + x, 4 + y); // 31
glVertex2f( 14 + x, 4 + y); // 32
glVertex2f( 14 + x, 0 + y); // 33
glVertex2f( 10 + x, 0 + y); // 34
glVertex2f( 10 + x, 4 + y); // 35
glVertex2f( 10.0f + x, 4.0f + y); // 31
glVertex2f( 14.0f + x, 4.0f + y); // 32
glVertex2f( 14.0f + x, 0.0f + y); // 33
glVertex2f( 10.0f + x, 0.0f + y); // 34
glVertex2f( 10.0f + x, 4.0f + y); // 35
glEnd();
break;
@ -649,23 +651,23 @@ void CDraw::drawSymbol(CSymbol symbol, float x, float y, CSlot* slot)
drColor(color);
glBegin(GL_POLYGON);
glVertex2f(-7.0 + x, 2.0 + y); // 1
glVertex2f(-5.0 + x, 4.0 + y); // 2
glVertex2f(-1.0 + x, 6.0 + y); // 3
glVertex2f( 4.0 + x, 6.0 + y); // 4
glVertex2f( 7.0 + x, 4.0 + y); // 5
glVertex2f( 7.0 + x, 1.0 + y); // 6
glVertex2f( 6.0 + x, -2.0 + y); // 7
glVertex2f( 4.0 + x, -4.0 + y); // 8
glVertex2f( 0.0 + x, -6.0 + y); // 9
glVertex2f(-4.0 + x, -6.0 + y); // 10
glVertex2f(-8.0 + x, -3.0 + y); // 11
glVertex2f(-8.0 + x, -0.0 + y); // 12
glVertex2f(-7.0f + x, 2.0f + y); // 1
glVertex2f(-5.0f + x, 4.0f + y); // 2
glVertex2f(-1.0f + x, 6.0f + y); // 3
glVertex2f( 4.0f + x, 6.0f + y); // 4
glVertex2f( 7.0f + x, 4.0f + y); // 5
glVertex2f( 7.0f + x, 1.0f + y); // 6
glVertex2f( 6.0f + x, -2.0f + y); // 7
glVertex2f( 4.0f + x, -4.0f + y); // 8
glVertex2f( 0.0f + x, -6.0f + y); // 9
glVertex2f(-4.0f + x, -6.0f + y); // 10
glVertex2f(-8.0f + x, -3.0f + y); // 11
glVertex2f(-8.0f + x, -0.0f + y); // 12
glEnd();
/*
// shows the MIDI Duration (but not very useful)
glLineWidth(4.0);
glLineWidth(4.0f);
drColor(CColor(0.3, 0.4, 0.4));
glBegin(GL_LINE_STRIP);
glVertex2f(x, y);
@ -681,67 +683,67 @@ void CDraw::drawSymbol(CSymbol symbol, float x, float y, CSlot* slot)
if (!CChord::isNotePlayable(symbol.getNote(), 0))
color = Cfg::noteColorDim();
drColor(color);
glLineWidth (3.0);
glLineWidth (3.0f);
glBegin(GL_LINES);
glVertex2f( 5.0 + x,-5.0 + y);
glVertex2f(-5.0 + x, 5.0 + y);
glVertex2f(-5.0 + x,-5.0 + y);
glVertex2f( 5.0 + x, 5.0 + y);
glVertex2f( 5.0f + x,-5.0f + y);
glVertex2f(-5.0f + x, 5.0f + y);
glVertex2f(-5.0f + x,-5.0f + y);
glVertex2f( 5.0f + x, 5.0f + y);
glEnd();
checkAccidental(symbol, x, y);
break;
case PB_SYMBOL_sharp:
glLineWidth (2.0);
glLineWidth (2.0f);
glBegin(GL_LINES);
glVertex2f(-2.0 + x, -14.0 + y);
glVertex2f(-2.0 + x, 14.0 + y);
glVertex2f(-2.0f + x, -14.0f + y);
glVertex2f(-2.0f + x, 14.0f + y);
glVertex2f( 2.0 + x, -13.0 + y);
glVertex2f( 2.0 + x, 15.0 + y);
glVertex2f( 2.0f + x, -13.0f + y);
glVertex2f( 2.0f + x, 15.0f + y);
glVertex2f(-5.0 + x, 4.0 + y);
glVertex2f( 5.0 + x, 7.0 + y);
glVertex2f(-5.0f + x, 4.0f + y);
glVertex2f( 5.0f + x, 7.0f + y);
glVertex2f(-5.0 + x, -6.0 + y);
glVertex2f( 5.0 + x, -3.0 + y);
glVertex2f(-5.0f + x, -6.0f + y);
glVertex2f( 5.0f + x, -3.0f + y);
glEnd();
break;
case PB_SYMBOL_flat:
glLineWidth (2.0);
glLineWidth (2.0f);
glBegin(GL_LINE_STRIP);
glVertex2f(-4.0 + x, 17.0 + y); // 1
glVertex2f(-4.0 + x, -6.0 + y); // 2
glVertex2f( 2.0 + x, -2.0 + y); // 3
glVertex2f( 5.0 + x, 2.0 + y); // 4
glVertex2f( 5.0 + x, 4.0 + y); // 5
glVertex2f( 3.0 + x, 5.0 + y); // 6
glVertex2f( 0.0 + x, 5.0 + y); // 7
glVertex2f(-4.0 + x, 2.0 + y); // 8
glVertex2f(-4.0f + x, 17.0f + y); // 1
glVertex2f(-4.0f + x, -6.0f + y); // 2
glVertex2f( 2.0f + x, -2.0f + y); // 3
glVertex2f( 5.0f + x, 2.0f + y); // 4
glVertex2f( 5.0f + x, 4.0f + y); // 5
glVertex2f( 3.0f + x, 5.0f + y); // 6
glVertex2f( 0.0f + x, 5.0f + y); // 7
glVertex2f(-4.0f + x, 2.0f + y); // 8
glEnd();
break;
case PB_SYMBOL_natural:
glLineWidth (2.0);
glLineWidth (2.0f);
glBegin(GL_LINES);
glVertex2f( 3 + x, -15 + y); // 1
glVertex2f( 3 + x, 8 + y); // 2
glVertex2f( 3.0f + x, -15.0f + y); // 1
glVertex2f( 3.0f + x, 8.0f + y); // 2
glVertex2f( -3 + x, -8 + y); // 3
glVertex2f( -3 + x, 15 + y); // 4
glVertex2f( -3.0f + x, -8.0f + y); // 3
glVertex2f( -3.0f + x, 15.0f + y); // 4
glVertex2f( 3 + x, 8 + y); // 5
glVertex2f( -3 + x, 2 + y); // 6
glVertex2f( 3.0f + x, 8.0f + y); // 5
glVertex2f( -3.0f + x, 2.0f + y); // 6
glVertex2f( 3 + x, -2 + y); // 7
glVertex2f( -3 + x, -8 + y); // 8
glVertex2f( 3.0f + x, -2.0f + y); // 7
glVertex2f( -3.0f + x, -8.0f + y); // 8
glEnd();
break;
case PB_SYMBOL_barLine:
x += BEAT_MARKER_OFFSET * HORIZONTAL_SPACING_FACTOR; // the beat markers where entered early so now move them correctly
glLineWidth (4.0);
glLineWidth (4.0f);
drColor ((m_displayHand == PB_PART_left) ? Cfg::staveColorDim() : Cfg::staveColor());
oneLine(x, CStavePos(PB_PART_right, 4).getPosYRelative(), x, CStavePos(PB_PART_right, -4).getPosYRelative());
drColor ((m_displayHand == PB_PART_right) ? Cfg::staveColorDim() : Cfg::staveColor());
@ -750,7 +752,7 @@ void CDraw::drawSymbol(CSymbol symbol, float x, float y, CSlot* slot)
case PB_SYMBOL_barMarker:
x += BEAT_MARKER_OFFSET * HORIZONTAL_SPACING_FACTOR; // the beat markers where entered early so now move them correctly
glLineWidth (5.0);
glLineWidth (5.0f);
drColor(Cfg::barMarkerColor());
oneLine(x, CStavePos(PB_PART_right, m_beatMarkerHeight).getPosYRelative(), x, CStavePos(PB_PART_left, -m_beatMarkerHeight).getPosYRelative());
glDisable (GL_LINE_STIPPLE);
@ -768,16 +770,16 @@ void CDraw::drawSymbol(CSymbol symbol, float x, float y, CSlot* slot)
{
float topY = CStavePos(PB_PART_right, m_beatMarkerHeight).getPosY();
float bottomY = CStavePos(PB_PART_left, -m_beatMarkerHeight).getPosY();
float early = Cfg::playZoneEarly() * HORIZONTAL_SPACING_FACTOR;
float late = Cfg::playZoneLate() * HORIZONTAL_SPACING_FACTOR;
//glColor3f (0.7, 1.0, 0.7);
glColor3f (0.0, 0.0, 0.3);
float early = static_cast<float>(Cfg::playZoneEarly()) * HORIZONTAL_SPACING_FACTOR;
float late = static_cast<float>(Cfg::playZoneLate()) * HORIZONTAL_SPACING_FACTOR;
//glColor3f (0.7f, 1.0f, 0.7f);
glColor3f (0.0f, 0.0f, 0.3f);
glRectf(x-late, topY, x + early, bottomY);
glLineWidth (2.0);
glColor3f (0.0, 0.0, 0.8);
glLineWidth (2.0f);
glColor3f (0.0f, 0.0f, 0.8f);
oneLine(x, topY, x, bottomY );
glLineWidth (1.0);
glColor3f (0.0, 0.0, 0.6);
glLineWidth (1.0f);
glColor3f (0.0f, 0.0f, 0.6f);
oneLine(x-late, topY, x-late, bottomY );
oneLine(x+early, topY, x+early, bottomY );
}
@ -794,17 +796,17 @@ void CDraw::drawSymbol(CSymbol symbol, float x, float y, CSlot* slot)
if (symbol.getType() >= PB_SYMBOL_noteHead)
{
float pianistX = symbol.getPianistTiming();
if ( pianistX != NOT_USED)
if ( symbol.getPianistTiming() != NOT_USED)
{
auto pianistX = static_cast<float>(symbol.getPianistTiming());
pianistX = x + pianistX * HORIZONTAL_SPACING_FACTOR;
drColor(CColor(1.0, 1.0, 1.0));
glLineWidth (2.0);
glLineWidth (2.0f);
glBegin(GL_LINES);
glVertex2f( 4.0 + pianistX, 4.0 + y);
glVertex2f(-5.0 + pianistX,-5.0 + y);
glVertex2f( 4.0 + pianistX,-4.0 + y); // draw pianist note timing markers
glVertex2f(-5.0 + pianistX, 5.0 + y);
glVertex2f( 4.0f + pianistX, 4.0f + y);
glVertex2f(-5.0f + pianistX,-5.0f + y);
glVertex2f( 4.0f + pianistX,-4.0f + y); // draw pianist note timing markers
glVertex2f(-5.0f + pianistX, 5.0f + y);
glEnd();
}
if ( playable )
@ -859,18 +861,17 @@ void CDraw::drawStaves(float startX, float endX)
void CDraw::drawKeySignature(int key)
{
const int sharpLookUpRight[] = { 4, 1, 5, 2,-1, 3, 0};
const int sharpLookUpLeft[] = { 2,-1, 3, 0,-3, 1,-2};
const int flatLookUpRight[] = { 0, 3,-1, 2,-2, 1,-3};
const int flatLookUpLeft[] = {-2, 1,-3, 0,-4,-1,-5};
const int gapX = 11;
static constexpr int sharpLookUpRight[] = { 4, 1, 5, 2,-1, 3, 0};
static constexpr int sharpLookUpLeft[] = { 2,-1, 3, 0,-3, 1,-2};
static constexpr int flatLookUpRight[] = { 0, 3,-1, 2,-2, 1,-3};
static constexpr int flatLookUpLeft[] = {-2, 1,-3, 0,-4,-1,-5};
static constexpr float gapX = 11.0f;
CStavePos pos;
size_t i;
if (key == NOT_USED)
return;
i = 0;
int i = 0;
while (key != 0 )
{
if (key > 0)
@ -879,13 +880,13 @@ void CDraw::drawKeySignature(int key)
{
drColor ((m_displayHand != PB_PART_left) ? Cfg::noteColor() : Cfg::noteColorDim());
pos = CStavePos(PB_PART_right, sharpLookUpRight[i]);
drawSymbol( CSymbol(PB_SYMBOL_sharp, pos), Cfg::keySignatureX() + gapX*i );
drawSymbol( CSymbol(PB_SYMBOL_sharp, pos), Cfg::keySignatureX() + gapX * static_cast<float>(i) );
}
if (i < arraySize(sharpLookUpLeft))
{
drColor ((m_displayHand != PB_PART_right) ? Cfg::noteColor() : Cfg::noteColorDim());
pos = CStavePos(PB_PART_left, sharpLookUpLeft[i]);
drawSymbol( CSymbol(PB_SYMBOL_sharp, pos), Cfg::keySignatureX() + gapX*i );
drawSymbol( CSymbol(PB_SYMBOL_sharp, pos), Cfg::keySignatureX() + gapX * static_cast<float>(i) );
}
key--;
}
@ -895,13 +896,13 @@ void CDraw::drawKeySignature(int key)
{
drColor ((m_displayHand != PB_PART_left) ? Cfg::noteColor() : Cfg::noteColorDim());
pos = CStavePos(PB_PART_right, flatLookUpRight[i]);
drawSymbol( CSymbol(PB_SYMBOL_flat, pos), Cfg::keySignatureX() + gapX*i );
drawSymbol( CSymbol(PB_SYMBOL_flat, pos), Cfg::keySignatureX() + gapX * static_cast<float>(i) );
}
if (i < arraySize(flatLookUpLeft))
{
drColor ((m_displayHand != PB_PART_right) ? Cfg::noteColor() : Cfg::noteColorDim());
pos = CStavePos(PB_PART_left, flatLookUpLeft[i]);
drawSymbol( CSymbol(PB_SYMBOL_flat, pos), Cfg::keySignatureX() + gapX*i );
drawSymbol( CSymbol(PB_SYMBOL_flat, pos), Cfg::keySignatureX() + gapX * static_cast<float>(i) );
}
key++;

View File

@ -46,7 +46,7 @@
#include <QFile>
#include <QApplication>
#define HORIZONTAL_SPACING_FACTOR (0.75) // defines the speed of the scrolling
#define HORIZONTAL_SPACING_FACTOR (0.75f) // defines the speed of the scrolling
#define FONT_SIZE 16
#include "StavePosition.h"

View File

@ -180,8 +180,8 @@ void CGLView::drawAccurracyBar()
float accuracy;
CColor color;
float y = Cfg::getAppHeight() - 14;
const float x = accuracyBarStart;
float y = static_cast<float>(Cfg::getAppHeight() - 14);
const float x = static_cast<float>(accuracyBarStart);
const int width = 360;
const int lineWidth = 8/2;
@ -219,12 +219,12 @@ void CGLView::drawDisplayText()
if (!m_settings->getWarningMessage().isEmpty())
{
glColor3f(1.0,0.2,0.0);
glColor3f(1.0f,0.2f,0.0f);
renderText(TEXT_LEFT_MARGIN, y-4, 0, m_settings->getWarningMessage(), m_timeRatingFont);
return;
}
glColor3f(1.0,1.0,1.0);
glColor3f(1.0f,1.0f,1.0f);
if (m_song->getPlayMode() != PB_PLAY_MODE_listen) {
if (accuracyBarStart == 0) {
@ -257,13 +257,13 @@ void CGLView::drawBarNumber()
return;
m_forceBarRedraw--;
float y = Cfg::getAppHeight() - m_titleHeight - 34;
float x = TEXT_LEFT_MARGIN;
const auto y = static_cast<float>(Cfg::getAppHeight() - m_titleHeight - 34);
const auto x = static_cast<float>(TEXT_LEFT_MARGIN);
//CDraw::drColor (Cfg::backgroundColor());
//CDraw::drColor (Cfg::noteColorDim());
//glRectf(x+30+10, y-2, x + 80, y + 16);
glColor3f(1.0,1.0,1.0);
glColor3f(1.0f,1.0f,1.0f);
renderText(x, y, 0, tr("Bar:") + " " + QString::number(m_song->getBarNumber()), m_timeRatingFont);
}
@ -298,30 +298,29 @@ void CGLView::resizeGL(int width, int height)
}
int sizeX = qMin(width, maxSoreWidth);
int sizeY = qMin(height, maxSoreHeight);
int x = (width - sizeX)/2;
int y = (height - sizeY)/2;
y = (height - sizeY) - 5;
x = 0;
int x = 0;
int y = (height - sizeY) - 5;
glViewport (x, y, sizeX, sizeY);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, sizeX, 0, sizeY, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
CStavePos::setStaveCenterY(sizeY - maxSoreHeight/2 - m_titleHeight/2);
CStavePos::setStaveCenterY(static_cast<float>(sizeY) - static_cast<float>(maxSoreHeight)/2.0f - static_cast<float>(m_titleHeight)/2.0f);
Cfg::setAppDimentions(x, y, sizeX, sizeY);
Cfg::setStaveEndX(sizeX - staveEndGap);
CStavePos::setStaveCentralOffset(staveGap/2);
Cfg::setStaveEndX(static_cast<float>(sizeX - staveEndGap));
CStavePos::setStaveCentralOffset(static_cast<float>(staveGap)/2.0f);
CDraw::forceCompileRedraw();
}
void CGLView::mousePressEvent(QMouseEvent *event)
{
Q_UNUSED(event)
}
void CGLView::mouseMoveEvent(QMouseEvent *event)
{
Q_UNUSED(event)
}
void CGLView::initializeGL()
@ -378,8 +377,7 @@ void CGLView::initializeGL()
void CGLView::updateMidiTask()
{
int ticks;
ticks = m_realtime.restart();
const auto ticks = m_realtime.restart();
m_displayUpdateTicks += ticks;
m_eventBits |= m_song->task(ticks);
}
@ -431,6 +429,7 @@ void CGLView::timerEvent(QTimerEvent *event)
void CGLView::mediaTimerEvent(int ticks)
{
Q_UNUSED(ticks)
}
#ifndef QT_OPENGL_ES
@ -595,7 +594,7 @@ void CGLView::renderText(double x, double y, double z, const QString &str, const
} else if (use_scissor_testing) {
funcs->glEnable(GL_SCISSOR_TEST);
}
funcs->glViewport(0, 0, width * dpr, height * dpr);
funcs->glViewport(0, 0, static_cast<GLsizei>(width * dpr), static_cast<GLsizei>(height * dpr));
gl1funcs->glAlphaFunc(GL_GREATER, 0.0);
funcs->glEnable(GL_ALPHA_TEST);
if (use_depth_testing)

View File

@ -29,6 +29,7 @@
#define __GLVIEW_H__
#include <QTime>
#include <QBasicTimer>
#include <QElapsedTimer>
#include <QOpenGLWidget>
#include "Song.h"
#include "Score.h"
@ -81,8 +82,8 @@ private:
CSong* m_song;
CScore* m_score;
QBasicTimer m_timer;
QTime m_realtime;
int m_displayUpdateTicks;
QElapsedTimer m_realtime;
qint64 m_displayUpdateTicks;
CRating* m_rating;
QFont m_timeSigFont;
QFont m_timeRatingFont;

View File

@ -65,13 +65,14 @@ private slots:
}
void on_resetButton_clicked(bool clicked) {
Q_UNUSED(clicked)
lowestNoteEdit->setText("0");
highestNoteEdit->setText("127");
updateInfoText();
}
void on_rightSoundCombo_activated (int index){ updateSounds(); }
void on_wrongSoundCombo_activated (int index){ updateSounds(); }
void on_rightSoundCombo_activated (int index){ Q_UNUSED(index) updateSounds(); }
void on_wrongSoundCombo_activated (int index){ Q_UNUSED(index) updateSounds(); }
void on_lowestNoteEdit_editingFinished(){updateInfoText();}
void on_highestNoteEdit_editingFinished(){updateInfoText();}
private:

View File

@ -63,6 +63,7 @@ void GuiLoopingPopup::on_loopBarsSpin_valueChanged(double bars)
void GuiLoopingPopup::closeEvent(QCloseEvent *event)
{
Q_UNUSED(event)
QPushButton* parent = static_cast<QPushButton*> (parentWidget());
if (parent)
parent->setChecked(false);

View File

@ -164,16 +164,19 @@ void GuiMidiSetupDialog::updateMidiInfoText()
void GuiMidiSetupDialog::on_midiInputCombo_activated (int index)
{
Q_UNUSED(index)
updateMidiInfoText();
}
void GuiMidiSetupDialog::on_midiOutputCombo_activated (int index)
{
Q_UNUSED(index)
updateMidiInfoText();
}
void GuiMidiSetupDialog::on_latencyFixButton_clicked ( bool checked )
{
Q_UNUSED(checked)
bool ok;
int latencyFix = QInputDialog::getInt(this, tr("Enter a value for the latency fix in milliseconds"),
tr(
@ -274,6 +277,7 @@ void GuiMidiSetupDialog::updateFluidInfoStatus()
void GuiMidiSetupDialog::on_fluidLoadButton_clicked ( bool checked )
{
Q_UNUSED(checked)
#if WITH_INTERNAL_FLUIDSYNTH
QString lastSoundFont = m_settings->value("LastSoundFontDir","").toString();
@ -286,9 +290,8 @@ void GuiMidiSetupDialog::on_fluidLoadButton_clicked ( bool checked )
possibleSoundFontFolders.push_back("/usr/share/soundfonts");
possibleSoundFontFolders.push_back("/usr/share/sounds/sf2");
#endif
for (QString soundFontFolder:possibleSoundFontFolders){
QDir dir(soundFontFolder);
if (dir.exists()){
for (const QString &soundFontFolder : possibleSoundFontFolders){
if (QDir(soundFontFolder).exists()){
lastSoundFont=soundFontFolder;
break;
}
@ -317,6 +320,7 @@ void GuiMidiSetupDialog::on_fluidLoadButton_clicked ( bool checked )
}
void GuiMidiSetupDialog::on_fluidClearButton_clicked( bool checked ){
Q_UNUSED(checked)
#if WITH_INTERNAL_FLUIDSYNTH
m_settings->clearFluidSoundFontNames();
int i = midiOutputCombo->findText(CMidiDeviceFluidSynth::getFluidInternalName());

View File

@ -111,16 +111,11 @@ void GuiSidePanel::refresh() {
if (m_trackList)
{
m_trackList->refresh();
trackListWidget->clear();
trackListWidget->addItems(m_trackList->getAllChannelProgramNames());
trackListWidget->setCurrentRow(m_trackList->getActiveItemIndex());
for (int i = 0; i < trackListWidget->count(); i++)
m_trackList->changeListWidgetItemView(i, trackListWidget->item(i));
}
autoSetMuteYourPart();
}
@ -162,6 +157,7 @@ void GuiSidePanel::on_bookCombo_activated (int index)
void GuiSidePanel::on_songCombo_activated(int index)
{
Q_UNUSED(index)
m_settings->setCurrentSongName(songCombo->currentText());
}
@ -285,11 +281,11 @@ void GuiSidePanel::updateTranslate(){
int delta = 0;
QFontMetrics fm(w->font());
QLabel *lb = dynamic_cast<QLabel*>(w);
if (lb) delta=fm.width(lb->text())-lb->width();
auto *const lb = qobject_cast<QLabel*>(w);
if (lb) delta=fm.horizontalAdvance(lb->text())-lb->width();
QRadioButton *rb = dynamic_cast<QRadioButton*>(w);
if (rb) delta=fm.width(rb->text())-(rb->width()-32);
auto *const rb = qobject_cast<QRadioButton*>(w);
if (rb) delta=fm.horizontalAdvance(rb->text())-(rb->width()-32);
if (delta>maxDeltaWidth) maxDeltaWidth=delta;
}

View File

@ -79,11 +79,13 @@ void GuiSongDetailsDialog::updateSongInfoText()
void GuiSongDetailsDialog::on_leftHandChannelCombo_activated (int index)
{
Q_UNUSED(index)
updateSongInfoText();
}
void GuiSongDetailsDialog::on_rightHandChannelCombo_activated (int index)
{
Q_UNUSED(index)
updateSongInfoText();
}

View File

@ -126,7 +126,7 @@ void GuiTopBar::on_keyCombo_activated(int index)
void GuiTopBar::on_transposeSpin_valueChanged(int value)
{
unsigned int i; //C Db D Eb E F F# G Ab A Bb B
int i; //C Db D Eb E F F# G Ab A Bb B
const int nextKey[] = { 0, -5, 2, -3, 4, -1, 6, 1, -4, 3, -2, 5};
const int nextKeySize = arraySize(nextKey);
if (!m_song) return;
@ -208,6 +208,7 @@ void GuiTopBar::updateTranslate(){
void GuiTopBar::on_playButton_clicked(bool clicked)
{
Q_UNUSED(clicked)
if (!m_song) return;
if (m_atTheEndOfTheSong)
@ -221,6 +222,7 @@ void GuiTopBar::on_playButton_clicked(bool clicked)
void GuiTopBar::on_playFromStartButton_clicked(bool clicked)
{
Q_UNUSED(clicked)
if (!m_song) return;
m_atTheEndOfTheSong = false;
@ -231,7 +233,7 @@ void GuiTopBar::on_playFromStartButton_clicked(bool clicked)
void GuiTopBar::on_speedSpin_valueChanged(int speed)
{
if (!m_song) return;
m_song->setSpeed(speed/100.0);
m_song->setSpeed(static_cast<float>(speed) / 100.0f);
}
void GuiTopBar::on_startBarSpin_valueChanged(double bar)
@ -254,6 +256,7 @@ void GuiTopBar::stopMuiscPlaying()
void GuiTopBar::on_saveBarButton_clicked(bool clicked)
{
Q_UNUSED(clicked)
if (!m_song) return;
double barNumber = m_song->getCurrentBarPos();
startBarSpin->setValue(barNumber);
@ -261,6 +264,7 @@ void GuiTopBar::on_saveBarButton_clicked(bool clicked)
void GuiTopBar::on_loopingBarsPopupButton_clicked(bool clicked)
{
Q_UNUSED(clicked)
if (!m_song) return;
m_song->playMusic(false);

View File

@ -38,6 +38,8 @@ static void debug_settings_foreach_func (void *data,
#endif
int type)
{
Q_UNUSED(data)
Q_UNUSED(type)
char buffer[300];
fluid_settings_copystr(s_debug_fluid_settings, name, buffer, sizeof (buffer));
ppLogDebug("settings_foreach_func %s : %s", name , buffer );
@ -54,7 +56,7 @@ CMidiDeviceFluidSynth::CMidiDeviceFluidSynth()
CMidiDeviceFluidSynth::~CMidiDeviceFluidSynth()
{
closeMidiPort(MIDI_OUTPUT, -1);
CMidiDeviceFluidSynth::closeMidiPort(MIDI_OUTPUT, -1); // not possible to make virtual call in d'tor
}
void CMidiDeviceFluidSynth::init()
@ -109,9 +111,8 @@ bool CMidiDeviceFluidSynth::openMidiPort(midiType_t type, QString portName)
// Create the synthesizer.
m_synth = new_fluid_synth(m_fluidSettings);
fluid_synth_set_reverb_on(m_synth, 0);
fluid_synth_set_chorus_on(m_synth, 0);
fluid_synth_reverb_on(m_synth, -1, 0);
fluid_synth_chorus_on(m_synth, -1, 0);
// Create the audio driver.
m_audioDriver = new_fluid_audio_driver(m_fluidSettings, m_synth);
@ -137,6 +138,7 @@ bool CMidiDeviceFluidSynth::openMidiPort(midiType_t type, QString portName)
void CMidiDeviceFluidSynth::closeMidiPort(midiType_t type, int index)
{
Q_UNUSED(index)
m_validConnection = false;
if (type != MIDI_OUTPUT)
@ -160,10 +162,7 @@ void CMidiDeviceFluidSynth::playMidiEvent(const CMidiEvent & event)
if (m_synth == nullptr)
return;
int channel;
channel = event.channel() & 0x0f;
int channel = event.channel() & 0x0f;
switch(event.type())
{
case MIDI_NOTE_OFF: // NOTE_OFF
@ -196,8 +195,8 @@ void CMidiDeviceFluidSynth::playMidiEvent(const CMidiEvent & event)
break;
case MIDI_PB_collateRawMidiData: //used for a SYSTEM_EVENT
if (m_rawDataIndex < arraySize(m_savedRawBytes))
m_savedRawBytes[m_rawDataIndex++] = event.data1();
if (m_rawDataIndex < arraySizeAs<unsigned int>(m_savedRawBytes))
m_savedRawBytes[m_rawDataIndex++] = static_cast<unsigned char>(event.data1());
return; // Don't output any thing yet so just return
case MIDI_PB_outputRawMidiData: //used for a SYSTEM_EVENT
@ -248,11 +247,13 @@ int CMidiDeviceFluidSynth::midiSettingsSetInt(QString name, int val)
QString CMidiDeviceFluidSynth::midiSettingsGetStr(QString name)
{
char buffer[200];
if (!m_fluidSettings)
return QString();
Q_UNUSED(name)
//char buffer[200];
//if (!m_fluidSettings)
// return QString();
//fluid_settings_getstr(m_fluidSettings, (char *)qPrintable(name), buffer );
return QString( buffer );
//return QString( buffer );
return QString(); // FIXME: buffer is never initialized here, let's just return QString() for now
}
double CMidiDeviceFluidSynth::midiSettingsGetNum(QString name)

View File

@ -28,6 +28,8 @@
#include "MidiDeviceRt.h"
#include <limits>
CMidiDeviceRt::CMidiDeviceRt()
{
m_validConnection = false;
@ -77,7 +79,7 @@ void CMidiDeviceRt::init()
}
}
QString CMidiDeviceRt::addIndexToString(QString name, int index)
QString CMidiDeviceRt::addIndexToString(const QString &name, int index)
{
QString ret;
QString idx;
@ -105,10 +107,10 @@ QStringList CMidiDeviceRt::getMidiPortList(midiType_t type)
nPorts = midiDevice->getPortCount();
for(unsigned int i=0; i< nPorts; i++)
for(unsigned int i=0; i< nPorts && i < std::numeric_limits<int>::max(); ++i)
{
// kotechnology creating indexed string from the post name
name = addIndexToString(midiDevice->getPortName(i).c_str(),i);
name = addIndexToString(midiDevice->getPortName(i).c_str(), static_cast<int>(i));
if (name.contains("RtMidi Output Client"))
continue;
if (name.contains("RtMidi Input Client"))
@ -147,16 +149,16 @@ bool CMidiDeviceRt::openMidiPort(midiType_t type, QString portName)
nPorts = midiDevice->getPortCount();
for(unsigned int i=0; i< nPorts; i++)
for(unsigned int i=0; i< nPorts && i <= std::numeric_limits<int>::max(); i++)
{
// kotechnology creating indexed string from the post name
name = addIndexToString(midiDevice->getPortName(i).c_str(),i);
name = addIndexToString(midiDevice->getPortName(i).c_str(), static_cast<int>(i));
if (name == portName) // Test for a match
{
if (m_midiPorts[dev] >= 0)
midiDevice->closePort();
m_midiPorts[dev] = i;
m_midiPorts[dev] = static_cast<int>(i);
m_rawDataIndex = 0;
midiDevice->openPort( i );
@ -169,6 +171,7 @@ bool CMidiDeviceRt::openMidiPort(midiType_t type, QString portName)
void CMidiDeviceRt::closeMidiPort(midiType_t type, int index)
{
Q_UNUSED(index)
m_validConnection = false;
if (type == MIDI_INPUT)
m_midiin->closePort();
@ -190,47 +193,47 @@ void CMidiDeviceRt::playMidiEvent(const CMidiEvent & event)
switch(event.type())
{
case MIDI_NOTE_OFF: // NOTE_OFF
message.push_back( channel | MIDI_NOTE_OFF );
message.push_back( event.note());
message.push_back( event.velocity());
message.push_back(static_cast<unsigned char>(channel | MIDI_NOTE_OFF));
message.push_back(static_cast<unsigned char>(event.note()));
message.push_back(static_cast<unsigned char>(event.velocity()));
break;
case MIDI_NOTE_ON: // NOTE_ON
message.push_back( channel | MIDI_NOTE_ON );
message.push_back( event.note());
message.push_back( event.velocity());
message.push_back(static_cast<unsigned char>(channel | MIDI_NOTE_ON));
message.push_back(static_cast<unsigned char>(event.note()));
message.push_back(static_cast<unsigned char>(event.velocity()));
break;
case MIDI_NOTE_PRESSURE: //POLY_AFTERTOUCH: 3 bytes
message.push_back( channel | MIDI_NOTE_PRESSURE);
message.push_back( event.data1());
message.push_back( event.data2());
message.push_back(static_cast<unsigned char>(channel | MIDI_NOTE_PRESSURE));
message.push_back(static_cast<unsigned char>(event.data1()));
message.push_back(static_cast<unsigned char>(event.data2()));
break;
case MIDI_CONTROL_CHANGE: //CONTROL_CHANGE:
message.push_back( channel | MIDI_CONTROL_CHANGE);
message.push_back( event.data1());
message.push_back( event.data2());
message.push_back(static_cast<unsigned char>(channel | MIDI_CONTROL_CHANGE));
message.push_back(static_cast<unsigned char>(event.data1()));
message.push_back(static_cast<unsigned char>(event.data2()));
break;
case MIDI_PROGRAM_CHANGE: //PROGRAM_CHANGE:
message.push_back( channel | MIDI_PROGRAM_CHANGE);
message.push_back( event.programme());
message.push_back(static_cast<unsigned char>(channel | MIDI_PROGRAM_CHANGE));
message.push_back(static_cast<unsigned char>(event.programme()));
break;
case MIDI_CHANNEL_PRESSURE: //AFTERTOUCH: 2 bytes only
message.push_back( channel | MIDI_CHANNEL_PRESSURE);
message.push_back( event.data1());
message.push_back(static_cast<unsigned char>(channel | MIDI_CHANNEL_PRESSURE));
message.push_back(static_cast<unsigned char>(event.data1()));
break;
case MIDI_PITCH_BEND: //PITCH_BEND:
message.push_back( channel | MIDI_PITCH_BEND);
message.push_back( event.data1());
message.push_back( event.data2());
message.push_back(static_cast<unsigned char>(channel | MIDI_PITCH_BEND));
message.push_back(static_cast<unsigned char>(event.data1()));
message.push_back(static_cast<unsigned char>(event.data2()));
break;
case MIDI_PB_collateRawMidiData: //used for a SYSTEM_EVENT
if (m_rawDataIndex < arraySize(m_savedRawBytes))
m_savedRawBytes[m_rawDataIndex++] = event.data1();
if (m_rawDataIndex < arraySizeAs<unsigned int>(m_savedRawBytes))
m_savedRawBytes[m_rawDataIndex++] = static_cast<unsigned char>(event.data1());
return; // Don't output any thing yet so just return
case MIDI_PB_outputRawMidiData: //used for a SYSTEM_EVENT
@ -269,14 +272,13 @@ int CMidiDeviceRt::checkMidiInput()
return 0;
}
return m_inputMessage.size();
return m_inputMessage.size() > std::numeric_limits<int>::max() ? std::numeric_limits<int>::max() : static_cast<int>(m_inputMessage.size());
}
// reads the real midi event
CMidiEvent CMidiDeviceRt::readMidiInput()
{
CMidiEvent midiEvent;
unsigned int channel;
if (Cfg::midiInputDump)
{
@ -287,7 +289,7 @@ CMidiEvent CMidiDeviceRt::readMidiInput()
ppLogInfo("midi input %f : %s", m_stamp, qPrintable(str));
}
channel = m_inputMessage[0] & 0x0f;
int channel = m_inputMessage[0] & 0x0f;
switch (m_inputMessage[0] & 0xf0 )
{
case MIDI_NOTE_ON:
@ -328,30 +330,39 @@ CMidiEvent CMidiDeviceRt::readMidiInput()
int CMidiDeviceRt::midiSettingsSetStr(QString name, QString str)
{
Q_UNUSED(name)
Q_UNUSED(str)
return 0;
}
int CMidiDeviceRt::midiSettingsSetNum(QString name, double val)
{
Q_UNUSED(name)
Q_UNUSED(val)
return 0;
}
int CMidiDeviceRt::midiSettingsSetInt(QString name, int val)
{
Q_UNUSED(name)
Q_UNUSED(val)
return 0;
}
QString CMidiDeviceRt::midiSettingsGetStr(QString name)
{
Q_UNUSED(name)
return QString();
}
double CMidiDeviceRt::midiSettingsGetNum(QString name)
{
Q_UNUSED(name)
return 0.0;
}
int CMidiDeviceRt::midiSettingsGetInt(QString namel)
int CMidiDeviceRt::midiSettingsGetInt(QString name)
{
Q_UNUSED(name)
return 0;
}

View File

@ -72,7 +72,7 @@ private:
unsigned int m_rawDataIndex;
// kotechnology added function to create indexed string. Format: "1 - Example"
QString addIndexToString(QString name, int index);
QString addIndexToString(const QString &name, int index);
bool m_validConnection;
};

View File

@ -233,7 +233,7 @@ public:
////////////////////////////////////////////////////////////////////////////////
//@brief how long the midi note was played for
long getDuration(){return m_duration;}
int getDuration(){return m_duration;}
/**
* This merges two MidiEvents (this and the other MidiEvent)

View File

@ -36,9 +36,7 @@ int CMidiFile::readWord(void)
int CMidiFile::readHeader(void)
{
size_t i;
int c;
int i, c;
for ( i=0; i < 4; i++)
{
c = m_file.get();
@ -99,8 +97,6 @@ void CMidiFile::openMidiFile(string filename)
void CMidiFile::rewind()
{
m_numberOfTracks = 0;
size_t ntrks;
size_t trk;
dword_t trackLength;
streampos filePos;
@ -109,30 +105,27 @@ void CMidiFile::rewind()
m_file.seekg (0, ios::beg);
ntrks = readHeader();
const auto ntrks = readHeader();
if (ntrks == 0)
{
midiError(SMF_CORRUPTED_MIDI_FILE);
ppLogError("Zero tracks in SMF file");
return;
}
if (ntrks > arraySize(m_tracks))
if (ntrks < 0 || ntrks > arraySize(m_tracks))
{
midiError(SMF_ERROR_TOO_MANY_TRACK);
ppLogError("Too many tracks in SMF file");
return;
}
m_numberOfTracks = ntrks;
for (trk = 0; trk < arraySize(m_tracks); trk++)
for (int trk = 0; trk < arraySize(m_tracks); ++trk)
{
if (m_tracks[trk]!= nullptr)
{
delete (m_tracks[trk]);
m_tracks[trk] = nullptr;
}
delete m_tracks[trk];
m_tracks[trk] = nullptr;
}
filePos = m_file.tellg();
for (trk = 0; trk < ntrks; trk++)
for (auto trk = 0; trk < ntrks; ++trk)
{
m_tracks[trk] = new CMidiTrack(m_file, trk);
trackLength = m_tracks[trk]->getTrackLength();
@ -144,7 +137,7 @@ void CMidiFile::rewind()
break;
}
//now move onto the next track
filePos += trackLength;
filePos += static_cast<streamoff>(trackLength);
m_file.seekg (filePos, ios::beg);
}
m_songTitle = m_tracks[0]->getTrackName();

View File

@ -46,11 +46,10 @@ class CMidiFile : public CMerge
public:
CMidiFile()
{
size_t i;
midiError(SMF_NO_ERROR);
m_ppqn = DEFAULT_PPQN;
setSize(MAX_TRACKS);
for (i = 0; i < arraySize(m_tracks); i++)
for (int i = 0; i < arraySize(m_tracks); i++)
m_tracks[i] = 0;
m_numberOfTracks = 0;
}

View File

@ -30,6 +30,8 @@
#include "Util.h"
#include "StavePosition.h"
#include <limits>
#define OPTION_DEBUG_TRACK 1
#if OPTION_DEBUG_TRACK
#define __dt(X) X
@ -71,7 +73,12 @@ CMidiTrack::CMidiTrack(fstream& file, int no) :m_file(file), m_trackNumber(no)
m_filePos = m_file.tellg();
m_trackLength = m_trackLengthCounter + 8; // 4 bytes for the "MTrk" + 4 bytes for the track length
m_trackEventQueue = new CQueue<CMidiEvent>(m_trackLength/3); // The minimum bytes per event is 3
if (m_trackLength > static_cast<dword_t>(std::numeric_limits<int>::max())) {
ppLogError("The track length is too big.");
errorFail(SMF_ERROR_TOO_MANY_TRACK);
return;
}
m_trackEventQueue = new CQueue<CMidiEvent>(static_cast<int>(m_trackLength/3ul)); // The minimum bytes per event is 3
}
void CMidiTrack::ppDebugTrack(int level, const char *msg, ...)
@ -131,7 +138,7 @@ string CMidiTrack::readTextEvent()
{
if (failed() == true)
return text;
text += readByte();
text += static_cast<char>(readByte());
}
return text;
}
@ -181,13 +188,12 @@ void CMidiTrack::ignoreSysexEvent(byte_t data)
/* Time Signature */
void CMidiTrack::readTimeSignatureEvent()
{
byte_t len;
byte_t timeSigNumerator;
byte_t timeSigDenominator;
CMidiEvent event;
byte_t b3, b4;
len = readVarLen();
const auto len = readVarLen();
if (len!=4)
{
errorFail(SMF_CORRUPTED_MIDI_FILE);
@ -205,7 +211,7 @@ void CMidiTrack::readTimeSignatureEvent()
errorFail(SMF_CORRUPTED_MIDI_FILE);
return;
}
len = (1<<timeSigDenominator);
//len = (1<<timeSigDenominator);
b3 = readByte(); /* Ignore the last bytes */
b4 = readByte(); /* Ignore the last bytes */
@ -217,12 +223,11 @@ void CMidiTrack::readTimeSignatureEvent()
/* Key Signature */
void CMidiTrack::readKeySignatureEvent()
{
byte_t len;
CMidiEvent event;
int keySig;
int majorKey;
len = readVarLen();
const auto len = readVarLen();
if (len!=2)
{
errorFail(SMF_CORRUPTED_MIDI_FILE);
@ -283,20 +288,17 @@ void CMidiTrack::readMetaEvent(byte_t type)
case METATEMPO: /* Set Tempo */
{
byte_t b1,b2, b3;
int tempo;
b1 = readVarLen();
auto b1 = readVarLen();
if (b1 != 3)
{
errorFail(SMF_CORRUPTED_MIDI_FILE);
break;
}
b1 = readByte();
b2 = readByte();
b3 = readByte();
tempo = b1 << 16 | b2 << 8 | b3; // microseconds per quarter-note#
event.metaEvent(readDelaTime(), MIDI_PB_tempo, tempo, 0);
const auto b2 = readByte();
const auto b3 = readByte();
const auto tempo = b1 << 16 | b2 << 8 | b3; // microseconds per quarter-note#
event.metaEvent(readDelaTime(), MIDI_PB_tempo, static_cast<int>(tempo), 0);
m_trackEventQueue->push(event);
__dt(ppDebugTrack(2,"Set Tempo %d", tempo));
break;
@ -412,15 +414,19 @@ void CMidiTrack::noteOffEvent(CMidiEvent &event, int deltaTime, int channel, int
void CMidiTrack::decodeMidiEvent()
{
CMidiEvent event;
byte_t c;
byte_t status, data1, data2;
int channel;
int deltaTicks = readVarLen();
const auto readDeltaTicks = readVarLen();
if (readDeltaTicks > std::numeric_limits<int>::max()) {
errorFail(SMF_CORRUPTED_MIDI_FILE);
return;
}
const auto deltaTicks = static_cast<int>(readDeltaTicks);
m_deltaTime += deltaTicks;
m_currentTime += deltaTicks;
c = readByte();
const auto c = readByte();
if ((c & 0x80) == 0 )
{
status = m_savedRunningStatus;
@ -428,8 +434,7 @@ void CMidiTrack::decodeMidiEvent()
}
else
{
status = c;
m_savedRunningStatus = status;
m_savedRunningStatus = status = c;
data1=readByte();
if ((data1 & 0x80) != 0) {
errorFail(SMF_CORRUPTED_MIDI_FILE);

View File

@ -104,11 +104,11 @@ private:
byte_t readByte(void)
{
int c;
auto c = byte_t();
if (m_trackLengthCounter != 0 )
{
c = m_file.get();
c = static_cast<byte_t>(m_file.get());
if (m_file.fail() == true)
errorFail(SMF_END_OF_FILE);
m_trackLengthCounter--;
@ -120,19 +120,15 @@ private:
word_t readWord(void)
{
word_t value;
value = (readByte()&0x0ff) <<8 ;
value |= readByte()&0x0ff;
word_t value = readByte() << 8;
value |= readByte();
return value;
}
dword_t readDWord(void)
{
dword_t value;
value = (readWord()&0x0ffff) <<16 ;
value |= readWord()&0x0ffff;
dword_t value = readWord() << 16;
value |= readWord();
return value;
}
@ -167,7 +163,7 @@ private:
dword_t m_trackLength;
dword_t m_trackLengthCounter;
CQueue<CMidiEvent>* m_trackEventQueue;
int m_savedRunningStatus;
byte_t m_savedRunningStatus;
int m_deltaTime;
int m_currentTime; // The current time (all the delta times added up)
midiErrors_t m_midiError;

View File

@ -122,13 +122,9 @@ CSlot CNotation::nextBeatMarker()
int CNotation::nextMergeSlot()
{
size_t i;
CSlot nearestSlot;
size_t nearestIndex;
nearestSlot = m_mergeSlots[0];
nearestIndex = 0;
for( i = 1; i < arraySize(m_mergeSlots); i++)
int nearestIndex = 0;
CSlot nearestSlot = m_mergeSlots[0];
for(int i = 1; i < arraySize(m_mergeSlots); i++)
{
// find the slot with the lowest delta time
if (m_mergeSlots[i].getDeltaTime() < nearestSlot.getDeltaTime())
@ -139,7 +135,7 @@ int CNotation::nextMergeSlot()
}
// Now subtract the delta time from all the others
for( i = 0; i < arraySize(m_mergeSlots); i++)
for(int i = 0; i < arraySize(m_mergeSlots); ++i)
{
if (i == nearestIndex)
continue;
@ -367,12 +363,11 @@ void CNotation::reset()
{
const int cfg_earlBarLead = CMidiFile::ppqnAdjust(8);
size_t i;
m_currentDeltaTime = 0;
m_midiInputQueue->clear();
m_slotQueue->clear();
for( i = 0; i < arraySize(m_mergeSlots); i++)
m_mergeSlots[i].clear();
for (auto &slot : m_mergeSlots)
slot.clear();
m_currentSlot.clear();
m_beatPerBarCounter=0;
m_earlyBarChangeCounter = 0;
@ -380,9 +375,7 @@ void CNotation::reset()
m_bar.reset();
m_findScrollerChord.reset();
for( i = 0; i < MAX_MIDI_NOTES; i++)
{
m_noteState[i].clear();
}
for (auto &noteState : m_noteState)
noteState.clear();
setupNotationParamaters();
}

View File

@ -59,10 +59,10 @@ public:
CSymbol* getSymbolPtr(int index) {return &m_symbols[index];}
musicalSymbol_t getSymbolType(int index) {return m_symbols[index].getType();}
int length() {return m_length;}
void setDeltaTime(int delta) {m_deltaTime = delta;}
void addDeltaTime(int delta) {m_deltaTime += delta;}
int getDeltaTime() {return m_deltaTime;}
int getLeftSideDeltaTime() {return m_deltaTime + m_maxLeftEdge;}
void setDeltaTime(qint64 delta) {m_deltaTime = delta;}
void addDeltaTime(qint64 delta) {m_deltaTime += delta;}
qint64 getDeltaTime() {return m_deltaTime;}
qint64 getLeftSideDeltaTime() {return m_deltaTime + m_maxLeftEdge;}
void setAv8Left(int val) {m_av8Left = val;}
int getAv8Left() {return m_av8Left;}
@ -71,7 +71,7 @@ public:
bool addSymbol(CSymbol symbol);
void analyse();
void setSymbol(int delta, CSymbol symbol)
void setSymbol(qint64 delta, CSymbol symbol)
{
clear();
setDeltaTime(delta);
@ -95,7 +95,7 @@ public:
}
}
void setNoteTimming(int note, int timing)
void setNoteTimming(int note, qint64 timing)
{
for (int i = 0; i < m_length; i++)
{
@ -118,13 +118,13 @@ public:
protected:
private:
int m_deltaTime;
qint64 m_deltaTime;
CSymbol m_symbols[MAX_SYMBOLS];
int m_length;
int m_av8Left;
int m_av8Right;
int m_maxLeftEdge; // the furthest the note will appear on the left hand edge (used when removing the note)
qint64 m_maxLeftEdge; // the furthest the note will appear on the left hand edge (used when removing the note)
};
// remembers the state of a running accidental
@ -209,10 +209,10 @@ private:
CQueue<CSlot>* m_slotQueue; // Queue of symbol slots that have not been read yet
CQueue<CMidiEvent>* m_midiInputQueue; // A Queue of midi events
CSlot m_currentSlot;
int m_currentDeltaTime; // time difference between this and the previous slot
qint64 m_currentDeltaTime; // time difference between this and the previous slot
int m_beatPerBarCounter;
int m_earlyBarChangeCounter;
int m_earlyBarChangeDelta; // Counts the ppqn in one bar
qint64 m_earlyBarChangeDelta; // Counts the ppqn in one bar
CSlot m_mergeSlots[2];
int m_displayChannel;
CFindChord m_findScrollerChord;

View File

@ -40,19 +40,15 @@ static const float minNameGap = 14.0;
void CPiano::spaceNoteBunch(unsigned int bottomIndex, unsigned int topIndex)
{
unsigned int midPoint;
int i;
float lastY;
float gap;
int range;
range = topIndex - bottomIndex;
const long long range = static_cast<long long>(topIndex) - static_cast<long long>(bottomIndex);
if (range <= 1)
return;
midPoint = range/2 + bottomIndex;
const long long midPoint = range/2 + bottomIndex;
if (midPoint >= arraySizeAs<long long>(m_noteNameList))
return;
float gap;
if (range%2 == 0) // test for an even number of notes
{
gap = m_noteNameList[midPoint].posY - m_noteNameList[midPoint -1].posY;
@ -64,10 +60,9 @@ void CPiano::spaceNoteBunch(unsigned int bottomIndex, unsigned int topIndex)
}
}
lastY = m_noteNameList[midPoint].posY;
// Search from the middle upwards
for (i = midPoint + 1; i < static_cast<int>(topIndex); i++)
float lastY = m_noteNameList[midPoint].posY;
for (auto i = midPoint + 1; i < static_cast<int>(topIndex); i++)
{
gap = m_noteNameList[i].posY - lastY;
// If the gap is too small make it bigger
@ -79,7 +74,7 @@ void CPiano::spaceNoteBunch(unsigned int bottomIndex, unsigned int topIndex)
lastY = m_noteNameList[midPoint].posY;
// now go the other way
for (i = midPoint - 1; i >= 0; i--)
for (auto i = midPoint - 1; i >= 0; i--)
{
gap = lastY - m_noteNameList[i].posY;
if (gap < minNameGap)
@ -125,10 +120,8 @@ void CPiano::drawPianoInputLines(CChord* chord, CColor color, int lineLength)
glLineWidth (3.0);
}
float posY;
posY = stavePos.getPosYAccidental();
oneLine(Cfg::playZoneX() - lineLength, posY, Cfg::playZoneX(), posY);
float posY = stavePos.getPosYAccidental();
oneLine(Cfg::playZoneX() - static_cast<float>(lineLength), posY, Cfg::playZoneX(), posY);
glDisable (GL_LINE_STIPPLE);
}
else
@ -186,18 +179,17 @@ void CPiano::spaceNoteNames()
void CPiano::addNoteNameItem(float posY, int pitch, int type)
{
noteNameItem_t noteNameItem;
int i;
if (m_noteNameListLength >= arraySize(m_noteNameList))
if (m_noteNameListLength >= arraySizeAs<decltype(m_noteNameListLength)>(m_noteNameList))
return;
noteNameItem_t noteNameItem;
noteNameItem.posY = noteNameItem.posYOriginal = posY;
noteNameItem.type = type;
noteNameItem.pitch = pitch;
// Sort the entries low to high
for (i = m_noteNameListLength - 1; i >= 0; i--)
int i;
for (i = static_cast<int>(m_noteNameListLength) - 1; i >= 0; i--)
{
if (m_noteNameList[i].pitch <= pitch)
break;
@ -282,8 +274,8 @@ void CPiano::clear()
m_goodChord.clear();
m_badChord.clear();
noteNameListClear();
for (unsigned int i = 0; i < arraySize(m_savedChordLookUp); i++)
m_savedChordLookUp[i].pitchKey = 0;
for (auto &chord : m_savedChordLookUp)
chord.pitchKey = 0;
}
void CPiano::drawPianoInput()
@ -304,24 +296,21 @@ void CPiano::drawPianoInput()
void CPiano::addSavedChord(CMidiEvent midiNote, CChord chord)
{
int key = midiNote.note();
for (unsigned int i = 0; i < arraySize(m_savedChordLookUp); i++)
{
for (auto &savedChord : m_savedChordLookUp) {
if (midiNote.type() == MIDI_NOTE_ON)
{
if (m_savedChordLookUp[i].pitchKey == 0 )
if (savedChord.pitchKey == 0 )
{
m_savedChordLookUp[i].pitchKey = key;
m_savedChordLookUp[i].savedNoteOffChord = chord;
savedChord.pitchKey = key;
savedChord.savedNoteOffChord = chord;
return;
}
}
else if (midiNote.type() == MIDI_NOTE_OFF)
{
if (m_savedChordLookUp[i].pitchKey == key )
if (savedChord.pitchKey == key )
{
m_savedChordLookUp[i].pitchKey = 0;
savedChord.pitchKey = 0;
return;
}
}
@ -331,8 +320,8 @@ void CPiano::addSavedChord(CMidiEvent midiNote, CChord chord)
CChord CPiano::removeSavedChord(int key)
{
unsigned int i;
for (i = 0; i < arraySize(m_savedChordLookUp); i++)
int i = 0;
for (; i < arraySize(m_savedChordLookUp); ++i)
{
if (m_savedChordLookUp[i].pitchKey == key )
{
@ -340,7 +329,7 @@ CChord CPiano::removeSavedChord(int key)
return m_savedChordLookUp[i].savedNoteOffChord;
}
}
i--;
--i;
m_savedChordLookUp[i].savedNoteOffChord.clear();
return m_savedChordLookUp[i].savedNoteOffChord;

View File

@ -479,7 +479,7 @@ void QtWindow::updateRecentFileActions()
QStringList files = m_settings->value("RecentFileList").toStringList();
int numRecentFiles = qMin(files.size(), (int)MAX_RECENT_FILES);
int numRecentFiles = qMin(files.size(), MAX_RECENT_FILES);
for (int i = 0; i < numRecentFiles; ++i) {
QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
@ -681,6 +681,7 @@ void QtWindow::writeSettings()
void QtWindow::closeEvent(QCloseEvent *event)
{
Q_UNUSED(event)
if (m_song->playingMusic())
{
m_song->playMusic(false);

View File

@ -58,7 +58,7 @@ public:
void init();
void songEventUpdated(int eventBits)
void songEventUpdated(eventBits_t eventBits)
{
if ((eventBits & EVENT_BITS_playingStopped) != 0){
if (m_sidePanel->isRepeatSong()){
@ -150,16 +150,16 @@ private slots:
void on_playPause() { m_topBar->on_playButton_clicked(true); }
void on_faster() {
float speed = m_song->getSpeed() + 0.04;
float speed = m_song->getSpeed() + 0.04f;
m_song->setSpeed(speed);
speed = m_song->getSpeed();
m_topBar->setSpeed(static_cast<int>(speed*100 + 0.5));
m_topBar->setSpeed(static_cast<int>(speed * 100.0f + 0.5f));
}
void on_slower() {
float speed = m_song->getSpeed() - 0.04;
float speed = m_song->getSpeed() - 0.04f;
m_song->setSpeed(speed);
speed = m_song->getSpeed();
m_topBar->setSpeed(static_cast<int>(speed*100 + 0.5));
m_topBar->setSpeed(static_cast<int>(speed * 100.0f + 0.5f));
}
void on_nextSong() { m_sidePanel->nextSong(+1); }
void on_previousSong() { m_sidePanel->nextSong(-1); }
@ -226,7 +226,7 @@ private:
CScore* m_score;
QAction *m_separatorAct;
enum { MAX_RECENT_FILES = 20 };
static constexpr int MAX_RECENT_FILES = 20;
QAction *m_recentFileActs[MAX_RECENT_FILES];
};

View File

@ -68,11 +68,11 @@ void CRating::calculateAccuracy()
} accuracyItem_t;
const accuracyItem_t accuracyTable[] =
{
{1.00, 0.01, -0.08, CColor(0.5, 0.5, 1.0)}, // Only the color is used on the top score
{0.75, 0.01, -0.07, CColor(0.7, 0.3, 1.0)},
{0.50, 0.01, -0.05, CColor(1.0, 0.6, 0.4)},
{0.25, 0.01, -0.03, CColor(1.0, 0.3, 1.0)},
{0.0 , 0.015, -0.02, CColor(1.0, 0.4, 0.2)}
{1.00f, 0.01f, -0.08f, CColor(0.5, 0.5, 1.0)}, // Only the color is used on the top score
{0.75f, 0.01f, -0.07f, CColor(0.7, 0.3, 1.0)},
{0.50f, 0.01f, -0.05f, CColor(1.0, 0.6, 0.4)},
{0.25f, 0.01f, -0.03f, CColor(1.0, 0.3, 1.0)},
{0.00f, 0.015f, -0.02f, CColor(1.0, 0.4, 0.2)}
};
size_t i;

View File

@ -32,10 +32,9 @@
CScore::CScore(CSettings* settings) : CDraw(settings)
{
size_t i;
m_piano = new CPiano(settings);
m_rating = nullptr;
for (i=0; i< arraySize(m_scroll); i++)
for (int i=0; i< arraySize(m_scroll); i++)
{
m_scroll[i] = new CScroll(i, settings);
m_scroll[i]->setChannel(i);
@ -49,9 +48,8 @@ CScore::CScore(CSettings* settings) : CDraw(settings)
CScore::~CScore()
{
delete m_piano;
size_t i;
for (i=0; i< arraySize(m_scroll); i++)
delete m_scroll[i];
for (auto *const scroll : m_scroll)
delete scroll;
if (m_scoreDisplayListId != 0)
glDeleteLists(m_scoreDisplayListId, 1);
@ -73,7 +71,7 @@ void CScore::drawScroll(bool refresh)
float topY = CStavePos(PB_PART_right, MAX_STAVE_INDEX).getPosY();
float bottomY = CStavePos(PB_PART_left, MIN_STAVE_INDEX).getPosY();
drColor (Cfg::backgroundColor());
glRectf(Cfg::scrollStartX(), topY, Cfg::getAppWidth(), bottomY);
glRectf(Cfg::scrollStartX(), topY, static_cast<float>(Cfg::getAppWidth()), bottomY);
}
if (m_stavesDisplayListId == 0)
@ -126,13 +124,13 @@ void CScore::drawPianoKeyboard(){
void drawBlackKey(int i, int k) {
glPushMatrix();
float yBlackShift = ySize / 2.5;
float yBlackShift = ySize / 2.5f;
float yBlackSize = ySize - yBlackShift;
glScalef(1, 1.4, 1);
glTranslatef(Cfg::staveStartX() + xPlaceSize * i - xPlaceSize / 3,
yStart + yBlackShift, 0.0);
glScalef(1.0f, 1.4f, 1.0f);
glTranslatef(Cfg::staveStartX() + xPlaceSize * static_cast<float>(i) - xPlaceSize / 3.0f,
yStart + yBlackShift, 0.0f);
float xKeySize = this->xKeySize / 1.5;
float xKeySize = this->xKeySize / 1.5f;
CDraw::drColor (CColor(0.0, 0.0, 0.0));
if(state[k]==1) CDraw::drColor(stopped ? Cfg::playedStoppedColor() : Cfg::noteColor());
@ -150,8 +148,8 @@ void CScore::drawPianoKeyboard(){
void drawWhiteKey() {
glPushMatrix();
glScalef(1, 1.4, 1);
glTranslatef(Cfg::staveStartX() + xPlaceSize * i++, yStart, 0.0);
glScalef(1.0f, 1.4f, 1.0f);
glTranslatef(Cfg::staveStartX() + xPlaceSize * static_cast<float>(i++), yStart, 0.0f);
CDraw::drColor (CColor(1.0, 1.0, 1.0));
if(state[k]==1) CDraw::drColor(stopped ? Cfg::playedStoppedColor() : Cfg::noteColor());
@ -207,10 +205,10 @@ void CScore::drawPianoKeyboard(){
pianoKeyboard.state[k] = 2;
}
for(size_t i=0; i<arraySize(m_scroll); ++i) {
for (auto *const scroll : m_scroll) {
int notes[64];
memset(notes, 0, sizeof(notes));
bool stopped = m_scroll[i]->getKeyboardInfo(notes);
bool stopped = scroll->getKeyboardInfo(notes);
for(int *note=notes; *note; ++note) {
pianoKeyboard.stopped = stopped;
int k = *note - 21;

View File

@ -45,8 +45,8 @@ public:
//! add a midi event to be analysed and displayed on the score
void midiEventInsert(CMidiEvent event)
{ size_t i;
for (i=0; i < arraySize(m_scroll); i++)
{
for (int i=0; i < arraySize(m_scroll); i++)
{
m_scroll[i]->midiEventInsert(event);
}
@ -55,13 +55,10 @@ public:
//! first check if there is space to add a midi event
int midiEventSpace()
{
size_t i;
int minSpace;
int space;
minSpace = 1000;
for (i=0; i< arraySize(m_scroll); i++) // this maybe slow
int minSpace = 1000;
for (auto *const scroll : m_scroll) // this maybe slow
{
space = m_scroll[i]->midiEventSpace();
int space = scroll->midiEventSpace();
if (space < minSpace)
minSpace = space;
}
@ -69,27 +66,27 @@ public:
}
void transpose(int semitones)
{ size_t i;
for (i=0; i< arraySize(m_scroll); i++)
m_scroll[i]->transpose(semitones);
{
for (auto *const scroll : m_scroll)
scroll->transpose(semitones);
}
void reset()
{ size_t i;
for (i=0; i< arraySize(m_scroll); i++)
m_scroll[i]->reset();
{
for (auto *const scroll : m_scroll)
scroll->reset();
}
void drawScrollingSymbols(bool show = true)
{ size_t i;
for (i=0; i< arraySize(m_scroll); i++)
m_scroll[i]->drawScrollingSymbols(show);
{
for (auto *const scroll : m_scroll)
scroll->drawScrollingSymbols(show);
}
void scrollDeltaTime(int ticks)
{ size_t i;
for (i=0; i< arraySize(m_scroll); i++)
m_scroll[i]->scrollDeltaTime(ticks);
void scrollDeltaTime(qint64 ticks)
{
for (auto *const scroll : m_scroll)
scroll->scrollDeltaTime(ticks);
}
void setRatingObject(CRating* rating)
@ -99,7 +96,7 @@ public:
CPiano* getPianoObject() { return m_piano;}
void setPlayedNoteColor(int note, CColor color, int wantedDelta, int pianistTimming = NOT_USED)
void setPlayedNoteColor(int note, CColor color, qint64 wantedDelta, qint64 pianistTimming = NOT_USED)
{
if (m_activeScroll>=0)
m_scroll[m_activeScroll]->setPlayedNoteColor(note, color, wantedDelta, pianistTimming);
@ -109,7 +106,7 @@ public:
{
int newActiveSroll;
if (channel < 0 || channel >= static_cast<int>(arraySize(m_scroll)))
if (channel < 0 || channel >= arraySize(m_scroll))
return;
newActiveSroll = channel;

View File

@ -42,7 +42,7 @@ void CScroll::compileSlot(CSlotDisplayList info)
return;
glNewList (info.m_displayListId, GL_COMPILE);
glTranslatef (info.getDeltaTime() * m_noteSpacingFactor, 0.0, 0.0); /* move position */
glTranslatef (static_cast<float>(info.getDeltaTime()) * m_noteSpacingFactor, 0.0f, 0.0f); /* move position */
info.transpose(m_transpose);
drawSlot(&info);
@ -77,8 +77,8 @@ bool CScroll::insertSlots()
while (true)
{
float headDelta = deltaAdjust(m_deltaHead) * m_noteSpacingFactor;
float slotDetlta = Cfg::staveEndX() - Cfg::playZoneX() - m_headSlot.getDeltaTime() * m_noteSpacingFactor - NOTE_BEHIND_GAP;
float headDelta = deltaAdjustF(m_deltaHead) * m_noteSpacingFactor;
float slotDetlta = Cfg::staveEndX() - Cfg::playZoneX() - static_cast<float>(m_headSlot.getDeltaTime()) * m_noteSpacingFactor - NOTE_BEHIND_GAP;
if (headDelta > slotDetlta)
break;
@ -113,16 +113,16 @@ bool CScroll::insertSlots()
void CScroll::removeEarlyTimingMakers()
{
float delta = deltaAdjust(m_deltaTail) * m_noteSpacingFactor + Cfg::playZoneX() - Cfg::scrollStartX() - NOTE_AHEAD_GAP;
float delta = deltaAdjustF(m_deltaTail) * m_noteSpacingFactor + Cfg::playZoneX() - Cfg::scrollStartX() - NOTE_AHEAD_GAP;
// only look a few steps (10) into the scroll queue
for (int i = 0; i < 10 && i < m_scrollQueue->length(); i++ )
{
if (delta < -(m_scrollQueue->index(i).getLeftSideDeltaTime() * m_noteSpacingFactor))
if (delta < -(static_cast<float>(m_scrollQueue->index(i).getLeftSideDeltaTime()) * m_noteSpacingFactor))
{
m_scrollQueue->indexPtr(i)->clearAllNoteTimmings();
compileSlot(m_scrollQueue->index(i));
}
delta += m_scrollQueue->index(i).getDeltaTime() * m_noteSpacingFactor;
delta += static_cast<float>(m_scrollQueue->index(i).getDeltaTime()) * m_noteSpacingFactor;
}
}
@ -130,7 +130,7 @@ void CScroll::removeSlots()
{
while (m_scrollQueue->length() > 0)
{
if (deltaAdjust(m_deltaTail) * m_noteSpacingFactor > -Cfg::playZoneX() + Cfg::scrollStartX() + NOTE_AHEAD_GAP -(m_scrollQueue->index(0).getLeftSideDeltaTime() * m_noteSpacingFactor) )
if (deltaAdjustF(m_deltaTail) * m_noteSpacingFactor > -Cfg::playZoneX() + Cfg::scrollStartX() + NOTE_AHEAD_GAP -(static_cast<float>(m_scrollQueue->index(0).getLeftSideDeltaTime()) * m_noteSpacingFactor) )
break;
CSlotDisplayList info = m_scrollQueue->pop();
@ -165,7 +165,7 @@ void CScroll::drawScrollingSymbols(bool show)
return;
glPushMatrix();
glTranslatef (Cfg::playZoneX() + deltaAdjust(m_deltaTail) * m_noteSpacingFactor, CStavePos::getStaveCenterY(), 0.0);
glTranslatef (Cfg::playZoneX() + deltaAdjustF(m_deltaTail) * m_noteSpacingFactor, CStavePos::getStaveCenterY(), 0.0f);
BENCHMARK(8, "glTranslatef");
@ -176,7 +176,7 @@ void CScroll::drawScrollingSymbols(bool show)
glPopMatrix();
}
void CScroll::scrollDeltaTime(int ticks)
void CScroll::scrollDeltaTime(qint64 ticks)
{
m_deltaHead -= ticks;
m_deltaTail -= ticks;
@ -204,8 +204,9 @@ bool CScroll::validPianistChord(int index)
return false;
}
int CScroll::findWantedChord(int note, CColor color, int wantedDelta)
int CScroll::findWantedChord(int note, CColor color, qint64 wantedDelta)
{
Q_UNUSED(note)
if (color == Cfg::playedBadColor()) // fixme should be an enum
return m_wantedIndex;
{
@ -223,7 +224,7 @@ int CScroll::findWantedChord(int note, CColor color, int wantedDelta)
return m_wantedIndex;
}
void CScroll::setPlayedNoteColor(int note, CColor color, int wantedDelta, int pianistTimming)
void CScroll::setPlayedNoteColor(int note, CColor color, qint64 wantedDelta, qint64 pianistTimming)
{
int index;
if (m_wantedIndex >= m_scrollQueue->length())
@ -233,7 +234,7 @@ void CScroll::setPlayedNoteColor(int note, CColor color, int wantedDelta, int pi
m_scrollQueue->indexPtr(index)->setNoteColor(note, color);
if (pianistTimming != NOT_USED)
{
pianistTimming = deltaAdjust(pianistTimming) * DEFAULT_PPQN / CMidiFile::getPulsesPerQuarterNote();
pianistTimming = deltaAdjustL(pianistTimming) * DEFAULT_PPQN / CMidiFile::getPulsesPerQuarterNote();
m_scrollQueue->indexPtr(index)->setNoteTimming(note, pianistTimming);
}
@ -383,6 +384,6 @@ void CScroll::reset()
m_symbolID = 0;
m_scrollQueue->clear();
m_ppqnFactor = static_cast<float>(DEFAULT_PPQN) / CMidiFile::getPulsesPerQuarterNote();
m_ppqnFactor = static_cast<float>(DEFAULT_PPQN) / static_cast<float>(CMidiFile::getPulsesPerQuarterNote());
m_noteSpacingFactor = m_ppqnFactor * HORIZONTAL_SPACING_FACTOR;
}

View File

@ -60,10 +60,10 @@ public:
delete m_notation;
}
void reset();
void scrollDeltaTime(int ticks);
void scrollDeltaTime(qint64 ticks);
void transpose(int transpose);
void refresh();
void setPlayedNoteColor(int note, CColor color, int wantedDelta, int pianistTimming);
void setPlayedNoteColor(int note, CColor color, qint64 wantedDelta, qint64 pianistTimming);
void setChannel(int chan)
{
m_notation->setChannel( chan );
@ -95,19 +95,19 @@ private:
bool insertSlots();
void removeSlots();
void removeEarlyTimingMakers();
int findWantedChord(int note, CColor color, int wantedDelta);
int findWantedChord(int note, CColor color, qint64 wantedDelta);
int m_id; // There are lots of these class running but each class has a unique id
CNotation *m_notation;
int m_deltaHead;
int m_deltaTail;
qint64 m_deltaHead;
qint64 m_deltaTail;
GLuint m_symbolID; // the next Display List name (or ID) to use
CSlot m_headSlot; // The next slot to be put in at the head of the queue;
int m_transpose;
int m_wantedIndex; // The index number of the wanted call in the scrollQueue
int m_wantedDelta; // The running delta time of the wanted chord
qint64 m_wantedDelta; // The running delta time of the wanted chord
CQueue<CSlotDisplayList>* m_scrollQueue; // The current active display list of notes/chords on the screen
bool m_show; // set to true to show on the screen

View File

@ -159,7 +159,7 @@ void CSong::refreshScroll()
forceScoreRedraw();
}
eventBits_t CSong::task(int ticks)
eventBits_t CSong::task(qint64 ticks)
{
realTimeEngine(ticks);

View File

@ -63,7 +63,7 @@ public:
}
void init2(CScore * scoreWin, CSettings* settings);
eventBits_t task(int ticks);
eventBits_t task(qint64 ticks);
bool pcKeyPress(int key, bool down);
void loadSong(const QString &filename);
void regenerateChordQueue();

View File

@ -1,4 +1,4 @@
/*********************************************************************************/
/*********************************************************************************/
/*!
@file StavePos.h

View File

@ -90,14 +90,14 @@ public:
//! return The position on the stave.
float getPosY()
{
return verticalNoteSpacing() * m_staveIndex + m_offsetY ;
return verticalNoteSpacing() * static_cast<float>(m_staveIndex) + m_offsetY;
}
float getPosYAccidental() {
int accidental = m_accidental;
if (accidental == 2) accidental = 1;
else if (accidental == -2) accidental = -1;
return getPosY() + accidental*verticalNoteSpacing()/2;
return getPosY() + static_cast<float>(accidental) * verticalNoteSpacing() / 2;
}
float getPosYRelative() { return getPosY() - m_staveCenterY;} // get the Y position relative to the stave centre
@ -143,7 +143,7 @@ public:
private:
// fixme TODO This could be improved as the calculations could a done in the constructor
int8_t m_staveIndex; // 0 central line, 5 = top line, -5 the bottom line,
int m_staveIndex; // 0 central line, 5 = top line, -5 the bottom line,
int m_accidental; // 0 = none, 1=sharp, -1 =flat, 2=natural
float m_offsetY;
whichPart_t m_hand;

View File

@ -128,8 +128,8 @@ public:
void setColor(CColor color){ m_color = color;}
CColor getColor(){return m_color;}
void setPianistTiming(int timing){ m_pianistTiming = timing;}
int getPianistTiming(){ return m_pianistTiming; }
void setPianistTiming(qint64 timing){ m_pianistTiming = timing;}
qint64 getPianistTiming(){ return m_pianistTiming; }
void transpose(int amount)
{
@ -172,13 +172,13 @@ private:
CStavePos m_stavePos;
musicalSymbol_t m_symbolType;
byte_t m_midiNote;
int m_midiNote;
accidentalModifer_t m_accidentalModifer; // Used to suppress the second sharp in the same bar
int m_midiDuration;
whichPart_t m_hand;
CColor m_color;
int m_pianistTiming;
qint64 m_pianistTiming;
int m_index; // the number of the note per hand starting from the bottom.
int m_total; // the number of the notes per hand;
};

View File

@ -45,7 +45,7 @@ void CTempo::enableFollowTempo(bool enable)
}
}
void CTempo::adjustTempo(int * ticks)
void CTempo::adjustTempo(qint64 * ticks)
{
if (m_jumpAheadDelta && m_cfg_maxJumpAhead && m_savedWantedChord)
{
@ -53,11 +53,11 @@ void CTempo::adjustTempo(int * ticks)
*ticks += m_jumpAheadDelta;
// Automatically adjust the speed
m_userSpeed = m_userSpeed + m_userSpeed * m_jumpAheadDelta * 0.00002;
m_userSpeed = m_userSpeed + m_userSpeed * static_cast<float>(m_jumpAheadDelta) * 0.00002f;
if (m_userSpeed> 2.0) m_userSpeed = 2.0;
if (m_userSpeed < 0.2) m_userSpeed = 0.2;
printf("%03.0f %5d\r",m_userSpeed *100, m_jumpAheadDelta );
if (m_userSpeed> 2.0f) m_userSpeed = 2.0f;
if (m_userSpeed < 0.2f) m_userSpeed = 0.2f;
printf("%03.0f %5lld\r", static_cast<double>(m_userSpeed) * 100.0, m_jumpAheadDelta);
fflush(stdout);
m_jumpAheadDelta = 0;

View File

@ -33,7 +33,7 @@
#include "MidiFile.h"
#include "Chord.h"
#define MICRO_SECOND 1000000.0
#define MICRO_SECOND 1000000.0f
// Define a chord
class CTempo
@ -56,8 +56,8 @@ public:
// Tempo, microseconds-per-MIDI-quarter-note
void setMidiTempo(int tempo)
{
m_midiTempo = (static_cast<float>(tempo) * DEFAULT_PPQN) / CMidiFile::getPulsesPerQuarterNote();
ppLogWarn("MIDI Tempo %f ppqn %d %d", m_midiTempo, CMidiFile::getPulsesPerQuarterNote(), tempo);
m_midiTempo = (static_cast<float>(tempo) * DEFAULT_PPQN) / static_cast<float>(CMidiFile::getPulsesPerQuarterNote());
ppLogWarn("MIDI Tempo %f ppqn %d %d", static_cast<double>(m_midiTempo), CMidiFile::getPulsesPerQuarterNote(), tempo);
}
void setSpeed(float speed)
@ -71,19 +71,19 @@ public:
}
float getSpeed() {return m_userSpeed;}
int mSecToTicks(int mSec)
qint64 mSecToTicks(qint64 mSec)
{
return static_cast<int>(mSec * m_userSpeed * (100.0 * MICRO_SECOND) /m_midiTempo);
return static_cast<qint64>(static_cast<float>(mSec) * m_userSpeed * (100.0f * MICRO_SECOND) / m_midiTempo);
}
void insertPlayingTicks(int ticks)
void insertPlayingTicks(qint64 ticks)
{
m_jumpAheadDelta -= ticks;
if (m_jumpAheadDelta < CMidiFile::ppqnAdjust(-10)*SPEED_ADJUST_FACTOR)
m_jumpAheadDelta = CMidiFile::ppqnAdjust(-10)*SPEED_ADJUST_FACTOR;
}
void removePlayingTicks(int ticks)
void removePlayingTicks(qint64 ticks)
{
if (m_cfg_maxJumpAhead != 0)
m_jumpAheadDelta = ticks;
@ -94,14 +94,14 @@ public:
m_jumpAheadDelta = 0;
}
void adjustTempo(int * ticks);
void adjustTempo(qint64 *ticks);
static void enableFollowTempo(bool enable);
private:
float m_userSpeed; // controls the speed of the piece playing
float m_midiTempo; // controls the speed of the piece playing
int m_jumpAheadDelta;
qint64 m_jumpAheadDelta;
static int m_cfg_maxJumpAhead;
static int m_cfg_followTempoAmount;
CChord *m_savedWantedChord; // A copy of the wanted chord complete with both left and right parts

View File

@ -366,7 +366,7 @@ int CTrackList::getHandTrackIndex(whichPart_t whichPart)
return -1;
}
void CTrackList::changeListWidgetItemView( unsigned int index, QListWidgetItem* listWidgetItem )
void CTrackList::changeListWidgetItemView( int index, QListWidgetItem* listWidgetItem )
{
int chan = m_partsList[index].midiChannel();
if ( CNote::hasPianoPart( chan ))
@ -534,7 +534,7 @@ QString CTrackList::getProgramName(int program)
/* 128. */ QT_TR_NOOP("Gunshot"),
};
if (program >= 0 && program < static_cast<int>(arraySize(gmInstrumentNames)))
if (program >= 0 && program < arraySize(gmInstrumentNames))
return tr(gmInstrumentNames[program]);
else
return QString();

View File

@ -185,7 +185,7 @@ public:
int getHandTrackIndex(whichPart_t whichPart);
void changeListWidgetItemView(unsigned int index, QListWidgetItem* listWidgetItem);
void changeListWidgetItemView(int index, QListWidgetItem* listWidgetItem);
double averageNotePitch(int chan) {
int totalNoteCount = 0;

View File

@ -28,7 +28,10 @@
#include <fstream>
#include <sstream>
#include <QElapsedTimer>
#include <QTime>
#include "Util.h"
#include "Cfg.h"
@ -156,6 +159,8 @@ void ppLogTrace(const char *msg, ...)
va_end(ap);
fputc('\n', logInfoFile);
flushLogs();
#else
Q_UNUSED(msg)
#endif
}
@ -204,24 +209,26 @@ void ppTiming(const char *msg, ...)
va_end(ap);
fputc('\n', logInfoFile);
flushLogs();
#else
Q_UNUSED(msg)
#endif
}
////////////////////// BENCH MARK //////////////////////
static QTime s_benchMarkTime;
static int s_previousTime;
static int s_previousFrameTime;
static QElapsedTimer s_benchMarkTime;
static qint64 s_previousTime;
static qint64 s_previousFrameTime;
typedef struct
{
int time;
qint64 time;
QString msg;
int deltaTotal;
int deltaCount;
int maxDelta;
int minDelta;
int frameRatePrevious;
int frameRateCurrent;
qint64 deltaTotal;
qint64 deltaCount;
qint64 maxDelta;
qint64 minDelta;
qint64 frameRatePrevious;
qint64 frameRateCurrent;
} benchData_t;
@ -249,10 +256,10 @@ void benchMarkInit()
s_frameRate.msg = " *** Frame Rate ***";
}
int benchMarkUpdate(benchData_t *pBench, int previousTime)
static qint64 benchMarkUpdate(benchData_t *pBench, qint64 previousTime)
{
int time = s_benchMarkTime.elapsed();
int delta = time - previousTime;
auto time = s_benchMarkTime.elapsed();
auto delta = time - previousTime;
pBench->deltaTotal += delta;
pBench->deltaCount++;
pBench->frameRateCurrent = time;
@ -281,10 +288,10 @@ void printResult(int i, benchData_t *pBench)
fprintf(logInfoFile, "Bench%2d: ", i);
else
fputs("Bench : ", logInfoFile);
fprintf(logInfoFile, "ct %4d, min %2d, avg %4.3f, max %2d frame %4.3f %s\n", pBench->deltaCount, pBench->minDelta,
static_cast<double>(pBench->deltaTotal)/pBench->deltaCount,
fprintf(logInfoFile, "ct %4lld, min %2lld, avg %4.3f, max %2lld frame %4.3f %s\n", pBench->deltaCount, pBench->minDelta,
static_cast<double>(pBench->deltaTotal)/static_cast<double>(pBench->deltaCount),
pBench->maxDelta,
(static_cast<double>(pBench->frameRateCurrent - pBench->frameRatePrevious))/pBench->deltaCount,
(static_cast<double>(pBench->frameRateCurrent - pBench->frameRatePrevious))/static_cast<double>(pBench->deltaCount),
qPrintable(pBench->msg));
benchMarkReset(pBench);
flushLogs();
@ -292,13 +299,11 @@ void printResult(int i, benchData_t *pBench)
void benchMarkResults()
{
int ticks;
ticks = s_benchMarkTime.elapsed();
const auto ticks = s_benchMarkTime.elapsed();
if ( (ticks - s_previousFrameTime) < 5000)
return;
s_previousFrameTime = ticks;
for (unsigned int i=0; i < arraySize( s_benchData ); i++)
for (int i=0; i < arraySize(s_benchData); i++)
{
printResult(i, &s_benchData[i]);
}

View File

@ -29,8 +29,10 @@
#ifndef __UTIL_H__
#define __UTIL_H__
#include <assert.h>
#include <cassert>
#include <string>
#include <limits>
#include <QString>
#include <QApplication>
@ -48,7 +50,18 @@ using namespace std;
#define MAX_MIDI_TRACKS 32 // This will allow us to map midi track on to midi channels
typedef unsigned char byte_t;
#define arraySize(a) (sizeof(a)/sizeof(a[0])) /* Returns (at compile time) the number of elements in an array */
template <typename As, typename T, std::size_t N>
[[nodiscard]] constexpr auto arraySizeAs(const T (&)[N]) noexcept
{
static_assert(N >= 0 && N <= std::numeric_limits<As>::max());
return static_cast<As>(N);
}
template <typename T, std::size_t N>
[[nodiscard]] constexpr auto arraySize(const T (&a)[N]) noexcept
{
return arraySizeAs<int>(a);
}
#define ppDEBUG(args) ppLogDebug args
@ -70,8 +83,10 @@ void ppLogError(const char *msg, ...);
void ppTiming(const char *msg, ...);
void closeLogs();
#define SPEED_ADJUST_FACTOR 1000
#define deltaAdjust(delta) ((delta)/SPEED_ADJUST_FACTOR )
constexpr int SPEED_ADJUST_FACTOR = 1000;
constexpr int deltaAdjust (int delta) { return delta / SPEED_ADJUST_FACTOR; }
constexpr qint64 deltaAdjustL (qint64 delta) { return delta / SPEED_ADJUST_FACTOR; }
constexpr float deltaAdjustF (qint64 delta) { return static_cast<float>(delta) / static_cast<float>(SPEED_ADJUST_FACTOR); }
void benchMarkInit();
void benchMark(unsigned int id, QString message);