From 64ec2f2a610afc8b014de67029524a82bc79d2a4 Mon Sep 17 00:00:00 2001 From: sasha Date: Thu, 4 Jul 2019 09:53:22 +0900 Subject: [PATCH 1/5] Patch for Feature Request Similar to (gtypist) Computer Touch-Typing --- src/Conductor.cpp | 58 +++++++++++++++++++ src/GuiMidiSetupDialog.cpp | 2 +- src/GuiPreferencesDialog.cpp | 2 + src/GuiPreferencesDialog.ui | 108 ++++++++++++++++++++++------------- src/Settings.cpp | 6 ++ src/Settings.h | 8 +++ 6 files changed, 144 insertions(+), 40 deletions(-) diff --git a/src/Conductor.cpp b/src/Conductor.cpp index 8252a74..f6fd0cc 100644 --- a/src/Conductor.cpp +++ b/src/Conductor.cpp @@ -744,6 +744,64 @@ void CConductor::pianistInput(CMidiEvent inputNote) m_piano->addPianistNote(hand, inputNote, false); m_rating.wrongNotes(1); + + if (m_settings->followThroughErrors() && m_playMode == PB_PLAY_MODE_followYou) // If the setting is checked, errors cause following too + { + if (m_chordDeltaTime <= -m_cfg_playZoneEarly) // We're hitting bad notes, but earlier than the zone (so ignore them) + { + m_piano->clear(); + m_savedNoteQueue->clear(); + m_savedNoteOffQueue->clear(); + } + else // Hitting bad notes within the zone (so register them) + { + // Register the wrong note in the ratings calculation (if not as missed notes, I don't believe it's factored in) + missedNotesColour(Cfg::pianoBadColour()); + m_rating.lateNotes(m_wantedChord.length() - m_goodPlayedNotes.length()); + setEventBits(EVENT_BITS_forceRatingRedraw); + fetchNextChord(); // Skip through the wrong note and continue to the next + + // Was the next note the one keyed by accident (dyslexia)? If so, validate it instead and continue as usual. + if (m_wantedChord.searchChord(inputNote.note(), m_transpose)) // replaces validatePianistNote ignoring out-of-zone + { + m_goodPlayedNotes.addNote(hand, inputNote.note()); + m_piano->addPianistNote(hand, inputNote,true); + int pianistTiming; + if ( ( cfg_timingMarkersFlag && m_followSkillAdvanced ) || m_playMode == PB_PLAY_MODE_rhythmTapping ) + pianistTiming = m_pianistTiming; + else + pianistTiming = NOT_USED; + m_scoreWin->setPlayedNoteColour(inputNote.note(), + (!m_followPlayingTimeOut)? Cfg::playedGoodColour():Cfg::playedBadColour(), + m_chordDeltaTime, pianistTiming); + + if (validatePianistChord() == true) + { + if (m_chordDeltaTime < 0) + m_tempo.removePlayingTicks(-m_chordDeltaTime); + + m_goodPlayedNotes.clear(); + fetchNextChord(); + // count the good notes so that the live percentage looks OK + m_rating.totalNotes(m_wantedChord.length()); + m_rating.calculateAccuracy(); + m_settings->pianistActive(); + if (m_rating.isAccuracyGood() || m_playMode == PB_PLAY_MODE_playAlong) + setFollowSkillAdvanced(true); // change the skill level only when they are good enough + else + setFollowSkillAdvanced(false); + setEventBits( EVENT_BITS_forceRatingRedraw); + } + } + + // Clear & ignore any further slips until in range of the next note's zone + m_piano->clear(); + m_savedNoteQueue->clear(); + m_savedNoteOffQueue->clear(); + + } + } + } else m_piano->addPianistNote(hand, inputNote, true); diff --git a/src/GuiMidiSetupDialog.cpp b/src/GuiMidiSetupDialog.cpp index 4270c62..daa0150 100644 --- a/src/GuiMidiSetupDialog.cpp +++ b/src/GuiMidiSetupDialog.cpp @@ -100,7 +100,7 @@ void GuiMidiSetupDialog::updateMidiInfoText() midiInfoText->append("" + tr("The use of Midi Through is not recommended!") + ""); else if (midiOutputCombo->currentText().contains("Microsoft GS Wavetable", Qt::CaseInsensitive)) midiInfoText->append("" + tr("Note: the Microsoft GS Wavetable Synth introduces an unwanted delay!.") + "\n" - + tr("(Try a latency fix of 150msc)") + ""); + + tr("(Try a latency fix of 150msc)") + ""); else midiInfoText->append("" + tr("Midi Output Device:") + " " + midiOutputCombo->currentText() +""); diff --git a/src/GuiPreferencesDialog.cpp b/src/GuiPreferencesDialog.cpp index 5c6add1..e930946 100644 --- a/src/GuiPreferencesDialog.cpp +++ b/src/GuiPreferencesDialog.cpp @@ -151,6 +151,7 @@ void GuiPreferencesDialog::init(CSong* song, CSettings* settings, CGLView * glVi showNoteNamesCheck->setChecked(m_settings->isNoteNamesEnabled()); courtesyAccidentalsCheck->setChecked(m_settings->displayCourtesyAccidentals()); showTutorPagesCheck->setChecked(m_settings->isTutorPagesEnabled()); + followThroughErrorsCheck->setChecked(m_settings->isFollowThroughErrorsEnabled()); followStopPointCombo->setCurrentIndex(m_song->cfg_stopPointMode); initLanguageCombo(); @@ -165,6 +166,7 @@ void GuiPreferencesDialog::accept() m_settings->setNoteNamesEnabled( showNoteNamesCheck->isChecked()); m_settings->setCourtesyAccidentals( courtesyAccidentalsCheck->isChecked()); m_settings->setTutorPagesEnabled( showTutorPagesCheck->isChecked()); + m_settings->setFollowThroughErrorsEnabled( followThroughErrorsCheck->isChecked()); m_song->cfg_stopPointMode = static_cast (followStopPointCombo->currentIndex()); m_settings->setValue("Score/StopPointMode", m_song->cfg_stopPointMode ); m_song->refreshScroll(); diff --git a/src/GuiPreferencesDialog.ui b/src/GuiPreferencesDialog.ui index ac45afc..c97e8e3 100644 --- a/src/GuiPreferencesDialog.ui +++ b/src/GuiPreferencesDialog.ui @@ -7,7 +7,7 @@ 0 0 339 - 368 + 386 @@ -25,30 +25,40 @@ Score Settings + + false + - - - - - 0 - 0 - - - - Timing Markers - - - - + Follow stop point: - + + + + Courtesy Accidentals + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + @@ -61,23 +71,10 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - + + - Show Note Names + Follow Through Errors @@ -94,10 +91,43 @@ - - + + + + + 0 + 0 + + - Courtesy Accidentals + Timing Markers + + + + + + + Show Note Names + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + CheckBox @@ -209,8 +239,8 @@ accept() - 248 - 254 + 257 + 385 157 @@ -225,8 +255,8 @@ reject() - 316 - 260 + 325 + 385 286 diff --git a/src/Settings.cpp b/src/Settings.cpp index 7fc685d..cbb123d 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -68,6 +68,7 @@ CSettings::CSettings(QtWindow *mainWindow) : QSettings(CSettings::IniFormat, CSe m_noteNamesEnabled = value("Score/NoteNames", true ).toBool(); m_tutorPagesEnabled = value("Tutor/TutorPages", true ).toBool(); CNotation::setCourtesyAccidentals(value("Score/CourtesyAccidentals", false ).toBool()); + m_followThroughErrorsEnabled = value("Score/FollowThroughErrors", true ).toBool(); } void CSettings::setDefaultValue(const QString & key, const QVariant & value ) @@ -104,6 +105,11 @@ void CSettings::setCourtesyAccidentals(bool value) { setValue("Score/CourtesyAccidentals", value ); } +void CSettings::setFollowThroughErrorsEnabled(bool value) { + m_followThroughErrorsEnabled = value; + setValue("Score/FollowThroughErrors", value ); +} + // Open a document if it exists or else create it (also delete an duplicates QDomElement CSettings::openDomElement(QDomElement parent, const QString & elementName, const QString & attributeName) { diff --git a/src/Settings.h b/src/Settings.h index 2ec8782..0b873e7 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -52,10 +52,12 @@ public: bool displayCourtesyAccidentals() { return CNotation::displayCourtesyAccidentals(); } bool isTutorPagesEnabled() { return m_tutorPagesEnabled; } + bool isFollowThroughErrorsEnabled() { return m_followThroughErrorsEnabled; } /// Saves in the .ini file whether the user wants to show the note names void setNoteNamesEnabled(bool value); void setTutorPagesEnabled(bool value); + void setFollowThroughErrorsEnabled(bool value); void setCourtesyAccidentals(bool value); void setAdvancedMode(bool value) { m_advancedMode = value;} @@ -65,6 +67,11 @@ public: return m_noteNamesEnabled; } + /// returns true if the user wants Follow Skill to ignore errors + bool followThroughErrors(){ + return m_followThroughErrorsEnabled; + } + void updateTutorPage(); void openSongFile(const QString & filename); QString getCurrentSongName() { return m_currentSongName; } @@ -144,6 +151,7 @@ private: bool m_noteNamesEnabled; bool m_tutorPagesEnabled; bool m_advancedMode; + bool m_followThroughErrorsEnabled; QString m_bookPath; QString m_currentBookName; QString m_currentSongName; From 0a5df9e38ce40bd0f842b7da6e085a9f0bc5994b Mon Sep 17 00:00:00 2001 From: AdmSasha Date: Thu, 4 Jul 2019 10:43:18 +0900 Subject: [PATCH 2/5] fixed fluidsynth device by qmake --- pianobooster.pro | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/pianobooster.pro b/pianobooster.pro index f0e6519..ba23576 100644 --- a/pianobooster.pro +++ b/pianobooster.pro @@ -18,14 +18,6 @@ INSTALL_ALL_LANGS="ON" TRANSLATIONS = $$files(translations/*.ts) -USE_FLUIDSYNTH { -# Note The FLUIDSYNTH_INPLACE_DIR dir is used mainly used when compiling on windows -# You normally do not need to set it -#FLUIDSYNTH_INPLACE_DIR = ../../fluidsynth-1.0.9 -message(building using fluidsynth) -DEFINES += PB_USE_FLUIDSYNTH -} - CONFIG(debug, debug|release): DEFINES += IS_DEBUG HEADERS = src/QtWindow.h \ @@ -120,16 +112,21 @@ unix { LIBS += -lasound -lpthread -lGL } -USE_FLUIDSYNTH { +contains (USE_FLUIDSYNTH, ON) { + message("building using fluidsynth") + DEFINES += PB_USE_FLUIDSYNTH + SOURCES += src/MidiDeviceFluidSynth.cpp !isEmpty(FLUIDSYNTH_INPLACE_DIR) { - !exists( $${FLUIDSYNTH_INPLACE_DIR}/include/fluidsynth.h ) { - error( "No $${FLUIDSYNTH_INPLACE_DIR}/include/fluidsynth.h file found" ) - } - message(fluidsynth FLUIDSYNTH_INPLACE_DIR = $${FLUIDSYNTH_INPLACE_DIR}) - INCLUDEPATH += $${FLUIDSYNTH_INPLACE_DIR}/include/ - win32:LIBS += $${FLUIDSYNTH_INPLACE_DIR}/src/.libs/libfluidsynth.dll.a - unix:LIBS += $${FLUIDSYNTH_INPLACE_DIR}/src/.libs/libfluidsynth.a + !exists( $${FLUIDSYNTH_INPLACE_DIR}/include/fluidsynth.h ) { + error( "No $${FLUIDSYNTH_INPLACE_DIR}/include/fluidsynth.h file found" ) + } + message(fluidsynth FLUIDSYNTH_INPLACE_DIR = $${FLUIDSYNTH_INPLACE_DIR}) + INCLUDEPATH += $${FLUIDSYNTH_INPLACE_DIR}/include/ + win32:LIBS += $${FLUIDSYNTH_INPLACE_DIR}/src/.libs/libfluidsynth.dll.a + unix:LIBS += $${FLUIDSYNTH_INPLACE_DIR}/src/.libs/libfluidsynth.a + }else{ + PKGCONFIG += fluidsynth } } From a68a1ac0d53522137d7fd5bd0d2f315252238b24 Mon Sep 17 00:00:00 2001 From: sasha Date: Thu, 4 Jul 2019 16:11:38 +0900 Subject: [PATCH 3/5] set path link dir for ftgl and jack by cmake --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fdc8545..09840bc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -212,6 +212,7 @@ ENDIF(WIN32) qt5_use_modules(pianobooster Core Gui Widgets LinguistTools OpenGL Xml) +target_link_directories(pianobooster PUBLIC ${FTGL_LIBRARY_DIRS} ${JACK_LIBRARY_DIRS}) target_link_libraries (pianobooster Qt5::Widgets Qt5::Xml Qt5::OpenGL ${OPENGL_LIBRARIES} ${FTGL_LIBRARY} ${RTMIDI_LIBRARY} ${JACK_LIBRARY}) INSTALL( FILES ../pianobooster.desktop DESTINATION share/applications ) From 46c46aa54705f3d33f392940687a83651da0f6d7 Mon Sep 17 00:00:00 2001 From: sasha Date: Thu, 4 Jul 2019 16:18:14 +0900 Subject: [PATCH 4/5] close line endif by cmake --- src/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 09840bc..1995ce9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -256,12 +256,12 @@ ENDIF (WIN32) if(USE_FONT) INSTALL ( FILES ${USE_FONT} DESTINATION share/games/pianobooster/fonts) -endif() +endif(USE_FONT) if(NOT USE_SYSTEM_FONT) INSTALL ( FILES fonts/DejaVuSans.ttf DESTINATION share/games/pianobooster/fonts) -endif() +endif(NOT USE_SYSTEM_FONT) if (NOT NO_LANGS) ADD_SUBDIRECTORY(../translations ../build/translations) -endif(NO_LANGS) +endif(NOT NO_LANGS) From 8e366d4bbcd6d06ad822ae307d3b0402bf9a76ea Mon Sep 17 00:00:00 2001 From: sasha Date: Thu, 4 Jul 2019 16:29:10 +0900 Subject: [PATCH 5/5] set policy cmake --- src/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1995ce9..f78e5f6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,6 +26,11 @@ ENDIF(WIN32) # set project's name PROJECT( pianobooster ) + +cmake_policy(SET CMP0020 NEW) +cmake_policy(SET CMP0043 NEW) + + # enable warnings add_compile_options(-Wall)