Merge pull request #160 from admsasha/master

Fixes
This commit is contained in:
glixx 2019-07-05 01:46:00 +03:00 committed by GitHub
commit 6ff3dfb9c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 166 additions and 59 deletions

View File

@ -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
}
}

View File

@ -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)
@ -212,6 +217,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 )
@ -255,12 +261,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)

View File

@ -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);

View File

@ -100,7 +100,7 @@ void GuiMidiSetupDialog::updateMidiInfoText()
midiInfoText->append("<span style=\"color:#FF6600\">" + tr("The use of Midi Through is not recommended!") + "</span>");
else if (midiOutputCombo->currentText().contains("Microsoft GS Wavetable", Qt::CaseInsensitive))
midiInfoText->append("<span style=\"color:#FF6600\">" + tr("Note: the Microsoft GS Wavetable Synth introduces an unwanted delay!.") + "\n"
+ tr("(Try a latency fix of 150msc)") + "</span>");
+ tr("(Try a latency fix of 150msc)") + "</span>");
else
midiInfoText->append("<span style=\"color:gray\">" + tr("Midi Output Device:") + " " + midiOutputCombo->currentText() +"</span>");

View File

@ -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<stopPointMode_t> (followStopPointCombo->currentIndex());
m_settings->setValue("Score/StopPointMode", m_song->cfg_stopPointMode );
m_song->refreshScroll();

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>339</width>
<height>368</height>
<height>386</height>
</rect>
</property>
<property name="sizePolicy">
@ -25,30 +25,40 @@
<property name="title">
<string>Score Settings</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QCheckBox" name="timingMarkersCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Timing Markers</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Follow stop point:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="1" column="0">
<widget class="QCheckBox" name="courtesyAccidentalsCheck">
<property name="text">
<string>Courtesy Accidentals</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="followStopPointCombo">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -61,23 +71,10 @@
</property>
</widget>
</item>
<item row="2" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="showNoteNamesCheck">
<item row="3" column="0">
<widget class="QCheckBox" name="followThroughErrorsCheck">
<property name="text">
<string>Show Note Names</string>
<string>Follow Through Errors</string>
</property>
</widget>
</item>
@ -94,10 +91,43 @@
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="courtesyAccidentalsCheck">
<item row="2" column="0">
<widget class="QCheckBox" name="timingMarkersCheck">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Courtesy Accidentals</string>
<string>Timing Markers</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="showNoteNamesCheck">
<property name="text">
<string>Show Note Names</string>
</property>
</widget>
</item>
<item row="3" column="1">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="checkBoxAAAA">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
@ -209,8 +239,8 @@
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
<x>257</x>
<y>385</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
@ -225,8 +255,8 @@
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
<x>325</x>
<y>385</y>
</hint>
<hint type="destinationlabel">
<x>286</x>

View File

@ -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)
{

View File

@ -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;