Integrated fluidsynth as an build option.

This commit is contained in:
pianobooster 2020-04-02 19:33:44 +01:00
parent 8619e2f6f0
commit 9563ba84c8
65 changed files with 594 additions and 776 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
/build*/ /build*/
/debug*/ /debug*/
CMakeLists.txt.user

View File

@ -1,3 +1,8 @@
v0.7.3 (25 Feb 2020)
- Integrated fluidsynth as an build option.
- Changes necessary for AppImage.
- Added <System Language> to the manual langage selection.
v0.7.2b (25 Feb 2020) v0.7.2b (25 Feb 2020)
- Fixed a problem that prevented a connected MIDI piano keyboard from working. - Fixed a problem that prevented a connected MIDI piano keyboard from working.
- cmake with no options now works correctly (cmake .. && make). - cmake with no options now works correctly (cmake .. && make).

View File

@ -35,7 +35,6 @@
#define ppDEBUG_BAR(args) #define ppDEBUG_BAR(args)
#endif #endif
void CBar::setTimeSig(int top, int bottom) void CBar::setTimeSig(int top, int bottom)
{ {
m_currentTimeSigTop = top; m_currentTimeSigTop = top;
@ -111,7 +110,6 @@ void CBar::checkGotoBar()
} }
} }
void CBar::setPlayFromBar(double bar) void CBar::setPlayFromBar(double bar)
{ {
m_playFromBar = bar; m_playFromBar = bar;

View File

@ -29,10 +29,8 @@
#ifndef __BAR_H__ #ifndef __BAR_H__
#define __BAR_H__ #define __BAR_H__
#include "MidiFile.h" #include "MidiFile.h"
// The event bits can be ORed together // The event bits can be ORed together
#define EVENT_BITS_playingStopped 0x0001 // set when we reach the end of piece #define EVENT_BITS_playingStopped 0x0001 // set when we reach the end of piece
#define EVENT_BITS_forceFullRedraw 0x0002 // force the whole screen to be redrawn #define EVENT_BITS_forceFullRedraw 0x0002 // force the whole screen to be redrawn
@ -43,8 +41,6 @@
typedef unsigned long eventBits_t; typedef unsigned long eventBits_t;
// controls the bar numbers // controls the bar numbers
class CBar class CBar
{ {
@ -97,9 +93,11 @@ public:
// //
int getBarNumber(){ return m_barCounter;} int getBarNumber(){ return m_barCounter;}
double getCurrentBarPos() { return m_barCounter + static_cast<double>(m_beatCounter)/m_currentTimeSigBottom + double getCurrentBarPos()
static_cast<double>(m_deltaTime)/(m_beatLength * m_currentTimeSigBottom * SPEED_ADJUST_FACTOR); } {
return m_barCounter + static_cast<double>(m_beatCounter)/m_currentTimeSigBottom +
static_cast<double>(m_deltaTime)/(m_beatLength * m_currentTimeSigBottom * SPEED_ADJUST_FACTOR);
}
bool seekingBarNumber() { return m_seekingBarNumber;} bool seekingBarNumber() { return m_seekingBarNumber;}
@ -120,8 +118,6 @@ private:
m_enablePlayFromBar = (m_enableLooping || m_playFromBar > 0.0)?true:false; m_enablePlayFromBar = (m_enableLooping || m_playFromBar > 0.0)?true:false;
} }
int m_deltaTime; int m_deltaTime;
int m_beatLength; //in ppqn ticks int m_beatLength; //in ppqn ticks
int m_barLength; // m_beatLength * getTimeSigTop() (also in ppqn ticks) int m_barLength; // m_beatLength * getTimeSigTop() (also in ppqn ticks)

34
src/CMakeLists.txt Normal file → Executable file
View File

@ -1,9 +1,13 @@
# Cmake File for Piano Booster # Cmake File for Piano Booster
option(USE_FTGL "build with ftgl" ON) option(USE_FTGL "build with ftgl" ON)
option(USE_JACK "build with Jack (Only required of BSD Unix)" OFF) option(USE_JACK "build with Jack (Only required for BSD Unix)" OFF)
option(USE_BUNDLED_RTMIDI "build with bundled rtmidi (for older distributions only)" OFF)
option(USE_SYSTEM_FONT "build with system font" OFF) option(USE_SYSTEM_FONT "build with system font" OFF)
if(${CMAKE_SYSTEM} MATCHES "Linux")
option(USE_BUNDLED_RTMIDI "build with bundled rtmidi (for older distributions only)" OFF)
else()
option(USE_BUNDLED_RTMIDI "build with bundled rtmidi" ON)
endif()
cmake_minimum_required(VERSION 2.4) cmake_minimum_required(VERSION 2.4)
if(COMMAND cmake_policy) if(COMMAND cmake_policy)
@ -12,7 +16,6 @@ endif(COMMAND cmake_policy)
if(WIN32) if(WIN32)
MESSAGE("GUI system is WIN32 ${CMAKE_GENERATOR}") MESSAGE("GUI system is WIN32 ${CMAKE_GENERATOR}")
SET(CMAKE_COLOR_MAKEFILE OFF)
endif(WIN32) endif(WIN32)
# set project's name # set project's name
@ -45,8 +48,10 @@ MESSAGE("CMAKE_INSTALL_BINDIR: " ${CMAKE_INSTALL_BINDIR})
FIND_PACKAGE( OpenGL REQUIRED ) FIND_PACKAGE( OpenGL REQUIRED )
include(FindPkgConfig) if(NOT WIN32)
FIND_PACKAGE( PkgConfig REQUIRED ) include(FindPkgConfig)
FIND_PACKAGE( PkgConfig REQUIRED )
endif()
if(USE_FTGL) if(USE_FTGL)
pkg_check_modules(FTGL ftgl) pkg_check_modules(FTGL ftgl)
@ -92,21 +97,19 @@ if(EXPERIMENTAL_USE_FLUIDSYNTH)
MESSAGE("Building using fluidsynth") MESSAGE("Building using fluidsynth")
SET( PB_BASE_SRCS MidiDeviceFluidSynth.cpp ) SET( PB_BASE_SRCS MidiDeviceFluidSynth.cpp )
if(FLUIDSYNTH_INPLACE_DIR) if(DEFINED ENV{FLUIDSYNTH_INPLACE_DIR})
SET (FLUIDSYNTH_INPLACE_DIR = $ENV{FLUIDSYNTH_INPLACE_DIR})
INCLUDE_DIRECTORIES(${FLUIDSYNTH_INPLACE_DIR}/include/) INCLUDE_DIRECTORIES(${FLUIDSYNTH_INPLACE_DIR}/include/)
if(WIN32) if(WIN32)
LINK_LIBRARIES( ${FLUIDSYNTH_INPLACE_DIR}/src/.libs/libfluidsynth.dll.a) LINK_LIBRARIES( $ENV{FLUIDSYNTH_INPLACE_DIR}/lib/libfluidsynth.dll.a)
endif(WIN32) endif(WIN32)
if(UNIX) else()
LINK_LIBRARIES(${FLUIDSYNTH_INPLACE_DIR}/src/.libs/libfluidsynth.so)
endif(UNIX)
else(FLUIDSYNTH_INPLACE_DIR)
pkg_check_modules(FLUIDSYNTH fluidsynth) pkg_check_modules(FLUIDSYNTH fluidsynth)
if(NOT FLUIDSYNTH_FOUND) if(NOT FLUIDSYNTH_FOUND)
MESSAGE(FATAL_ERROR "FLUIDSYNTH was not found") MESSAGE(FATAL_ERROR "FLUIDSYNTH was not found")
endif(NOT FLUIDSYNTH_FOUND) endif(NOT FLUIDSYNTH_FOUND)
LINK_LIBRARIES( fluidsynth) LINK_LIBRARIES(fluidsynth)
endif(FLUIDSYNTH_INPLACE_DIR) endif()
endif(EXPERIMENTAL_USE_FLUIDSYNTH) endif(EXPERIMENTAL_USE_FLUIDSYNTH)
# we need this to be able to include headers produced by uic in our code # we need this to be able to include headers produced by uic in our code
@ -141,7 +144,10 @@ if(USE_BUNDLED_RTMIDI)
set(PB_BASE_SRCS ${PB_BASE_SRCS} 3rdparty/rtmidi/RtMidi.cpp) set(PB_BASE_SRCS ${PB_BASE_SRCS} 3rdparty/rtmidi/RtMidi.cpp)
set(PB_BASE_HDR ${PB_BASE_HDR} 3rdparty/rtmidi/RtMidi.h) set(PB_BASE_HDR ${PB_BASE_HDR} 3rdparty/rtmidi/RtMidi.h)
else() else()
pkg_check_modules(RTMIDI REQUIRED rtmidi) pkg_check_modules(RTMIDI rtmidi)
if(NOT RTMIDI_FOUND)
MESSAGE(FATAL_ERROR "rtmidi not found (Try building with option USE_BUNDLED_RTMIDI=ON)")
endif(NOT RTMIDI_FOUND)
include_directories(${RTMIDI_INCLUDE_DIRS}) include_directories(${RTMIDI_INCLUDE_DIRS})
link_directories(${RTMIDI_LIBRARY_DIRS}) link_directories(${RTMIDI_LIBRARY_DIRS})
endif() endif()

View File

@ -26,9 +26,6 @@
*/ */
/*********************************************************************************/ /*********************************************************************************/
#include "Cfg.h" #include "Cfg.h"
float Cfg::m_staveEndX; float Cfg::m_staveEndX;
@ -49,8 +46,3 @@ int Cfg::tickRate;
const int Cfg::m_playZoneEarly = 25; // Was 25 const int Cfg::m_playZoneEarly = 25; // Was 25
const int Cfg::m_playZoneLate = 25; const int Cfg::m_playZoneLate = 25;

View File

@ -6,7 +6,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman and others, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -40,13 +40,11 @@
#define BENCHMARK_RESULTS() #define BENCHMARK_RESULTS()
#endif #endif
class CColor class CColor
{ {
public: public:
CColor() { red = green = blue = 0; } CColor() { red = green = blue = 0; }
CColor(double r, double g, double b) CColor(double r, double g, double b)
{ {
red = static_cast<float>(r); red = static_cast<float>(r);
@ -86,11 +84,9 @@ public:
static int chordNoteGap() {return 10;} // all notes in a cord must be spaced less than this a gap static int chordNoteGap() {return 10;} // all notes in a cord must be spaced less than this a gap
static int chordMaxLength() {return 20;} // the max time between the start and end of a cord static int chordMaxLength() {return 20;} // the max time between the start and end of a cord
static CColor menuColor() {return CColor(0.1, 0.6, 0.6);} static CColor menuColor() {return CColor(0.1, 0.6, 0.6);}
static CColor menuSelectedColor(){return CColor(0.7, 0.7, 0.1);} static CColor menuSelectedColor(){return CColor(0.7, 0.7, 0.1);}
static CColor staveColor() {return CColor(0.1, 0.7, 0.1);} // green static CColor staveColor() {return CColor(0.1, 0.7, 0.1);} // green
static CColor staveColorDim() {return CColor(0.15, 0.40, 0.15);} // grey static CColor staveColorDim() {return CColor(0.15, 0.40, 0.15);} // grey
static CColor noteColor() {return CColor(0.1, 0.9, 0.1);} // green static CColor noteColor() {return CColor(0.1, 0.9, 0.1);} // green
@ -114,8 +110,6 @@ public:
#endif #endif
} }
static void setStaveEndX(float x) static void setStaveEndX(float x)
{ {
m_staveEndX = x; m_staveEndX = x;
@ -132,8 +126,6 @@ public:
m_appHeight = height; m_appHeight = height;
} }
static int defaultWrongPatch() {return 7;} // Starts at 1 static int defaultWrongPatch() {return 7;} // Starts at 1
static int defaultRightPatch() {return 1;} // Starts at 1 static int defaultRightPatch() {return 1;} // Starts at 1

View File

@ -68,7 +68,6 @@ whichPart_t CNote::findHand(int midiNote, int midiChannel, int whichChannel, whi
return hand; return hand;
} }
void CChord::addNote(whichPart_t part, int note, int duration) void CChord::addNote(whichPart_t part, int note, int duration)
{ {
if (m_length >= MAX_CHORD_NOTES) if (m_length >= MAX_CHORD_NOTES)
@ -166,7 +165,6 @@ bool CFindChord::findChord(CMidiEvent midi, int channel, whichPart_t part)
m_noteGapTime += midi.deltaTime(); m_noteGapTime += midi.deltaTime();
if ((m_noteGapTime >= m_cfg_ChordNoteGap || m_cordSpanGapTime > m_cfg_ChordMaxLength) if ((m_noteGapTime >= m_cfg_ChordNoteGap || m_cordSpanGapTime > m_cfg_ChordMaxLength)
&& m_currentChord.length() > 0 ) && m_currentChord.length() > 0 )
{ {

View File

@ -47,7 +47,6 @@ typedef enum
PB_PART_none, PB_PART_none,
} whichPart_t; } whichPart_t;
#define MAX_CHORD_NOTES 20 // The maximum notes in a chord well we only have 10 fingers #define MAX_CHORD_NOTES 20 // The maximum notes in a chord well we only have 10 fingers
class CNote class CNote
@ -127,7 +126,6 @@ public:
bool searchChord(int note, int transpose = 0); bool searchChord(int note, int transpose = 0);
int trimOutOfRangeNotes(int transpose); int trimOutOfRangeNotes(int transpose);
void transpose(int amount) void transpose(int amount)
{ {
for (int i = 0; i < m_length; i++) for (int i = 0; i < m_length; i++)
@ -165,10 +163,8 @@ private:
int m_length; int m_length;
static int m_cfg_highestPianoNote; // The highest note on the users piano keyboard; static int m_cfg_highestPianoNote; // The highest note on the users piano keyboard;
static int m_cfg_lowestPianoNote; static int m_cfg_lowestPianoNote;
}; };
// Define a chord // Define a chord
class CFindChord class CFindChord
{ {
@ -188,7 +184,6 @@ public:
m_cfg_ChordMaxLength = CMidiFile::ppqnAdjust(Cfg::chordMaxLength()); m_cfg_ChordMaxLength = CMidiFile::ppqnAdjust(Cfg::chordMaxLength());
} }
CChord getChord() CChord getChord()
{ {
CChord chord; CChord chord;

View File

@ -6,7 +6,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -33,7 +33,6 @@
#define ppDEBUG_CONDUCTOR(args) #define ppDEBUG_CONDUCTOR(args)
#endif #endif
#include "Conductor.h" #include "Conductor.h"
#include "Score.h" #include "Score.h"
#include "Piano.h" #include "Piano.h"
@ -45,9 +44,9 @@ CConductor::CConductor()
{ {
int i; int i;
m_scoreWin = 0; m_scoreWin = nullptr;
m_settings = 0; m_settings = nullptr;
m_piano = 0; m_piano = nullptr;
m_songEventQueue = new CQueue<CMidiEvent>(1000); m_songEventQueue = new CQueue<CMidiEvent>(1000);
m_wantedChordQueue = new CQueue<CChord>(1000); m_wantedChordQueue = new CQueue<CChord>(1000);
@ -104,7 +103,6 @@ void CConductor::reset()
} }
} }
//! add a midi event to be analysed and displayed on the score //! add a midi event to be analysed and displayed on the score
void CConductor::midiEventInsert(CMidiEvent event) void CConductor::midiEventInsert(CMidiEvent event)
{ {
@ -182,7 +180,6 @@ void CConductor::mutePart(int part, bool state)
return; return;
} }
for ( channel = 0; channel < MAX_MIDI_CHANNELS; channel++) for ( channel = 0; channel < MAX_MIDI_CHANNELS; channel++)
{ {
muteChannel( channel, state); muteChannel( channel, state);
@ -346,7 +343,6 @@ void CConductor::setPlayMode(playMode_t mode)
m_piano->setRhythmTapping(m_playMode == PB_PLAY_MODE_rhythmTapping); m_piano->setRhythmTapping(m_playMode == PB_PLAY_MODE_rhythmTapping);
} }
void CConductor::setActiveChannel(int channel) void CConductor::setActiveChannel(int channel)
{ {
m_activeChannel = channel; m_activeChannel = channel;
@ -356,7 +352,6 @@ void CConductor::setActiveChannel(int channel)
activatePianistMutePart(); activatePianistMutePart();
} }
void CConductor::outputPianoVolume() void CConductor::outputPianoVolume()
{ {
CMidiEvent event; CMidiEvent event;
@ -485,7 +480,7 @@ void CConductor::resetWantedChord()
// switch modes if we are playing well enough (i.e. don't slow down if we are playing late) // switch modes if we are playing well enough (i.e. don't slow down if we are playing late)
void CConductor::setFollowSkillAdvanced(bool enable) void CConductor::setFollowSkillAdvanced(bool enable)
{ {
if (m_settings==0 || m_scoreWin == 0) if (m_settings==nullptr || m_scoreWin == nullptr)
return; return;
m_settings-> setAdvancedMode(enable); m_settings-> setAdvancedMode(enable);
@ -507,7 +502,6 @@ void CConductor::setFollowSkillAdvanced(bool enable)
m_stopPoint = (enable) ? m_cfg_stopPointAdvanced: m_cfg_stopPointBeginner ; m_stopPoint = (enable) ? m_cfg_stopPointAdvanced: m_cfg_stopPointBeginner ;
} }
void CConductor::findSplitPoint() void CConductor::findSplitPoint()
{ {
// find the split point // find the split point
@ -637,7 +631,6 @@ void CConductor::expandPianistInput(CMidiEvent inputNote)
CChord chordForOneHand; CChord chordForOneHand;
int notesFound = 0; int notesFound = 0;
if (inputNote.type() == MIDI_NOTE_OFF) if (inputNote.type() == MIDI_NOTE_OFF)
{ {
chord = m_piano->removeSavedChord(inputNote.note()); chord = m_piano->removeSavedChord(inputNote.note());
@ -691,7 +684,6 @@ void CConductor::pianistInput(CMidiEvent inputNote)
// inputNote.transpose(+12); fixme // inputNote.transpose(+12); fixme
if (m_testWrongNoteSound) if (m_testWrongNoteSound)
goodSound = false; goodSound = false;
@ -702,7 +694,6 @@ void CConductor::pianistInput(CMidiEvent inputNote)
if ( inputNote.channel() == MIDI_DRUM_CHANNEL) if ( inputNote.channel() == MIDI_DRUM_CHANNEL)
hand = (inputNote.note() >= MIDDLE_C) ? PB_PART_right : PB_PART_left; hand = (inputNote.note() >= MIDDLE_C) ? PB_PART_right : PB_PART_left;
if (inputNote.type() == MIDI_NOTE_ON) if (inputNote.type() == MIDI_NOTE_ON)
{ {
@ -867,7 +858,6 @@ void CConductor::pianistInput(CMidiEvent inputNote)
playTrackEvent( inputNote ); playTrackEvent( inputNote );
} }
/* /*
// use the same channel for the right and wrong note // use the same channel for the right and wrong note
int pianoSound = (goodSound == true) ? m_cfg_rightNoteSound : m_cfg_wrongNoteSound; int pianoSound = (goodSound == true) ? m_cfg_rightNoteSound : m_cfg_wrongNoteSound;
@ -1001,7 +991,6 @@ void CConductor::realTimeEngine(int mSecTicks)
m_tempo.insertPlayingTicks(ticks); m_tempo.insertPlayingTicks(ticks);
if (m_pianistTiming > m_cfg_playZoneLate) if (m_pianistTiming > m_cfg_playZoneLate)
{ {
if (m_followPlayingTimeOut == false) if (m_followPlayingTimeOut == false)
@ -1032,7 +1021,6 @@ void CConductor::realTimeEngine(int mSecTicks)
m_tempo.adjustTempo(&ticks); m_tempo.adjustTempo(&ticks);
ticks = m_bar.addDeltaTime(ticks); ticks = m_bar.addDeltaTime(ticks);
if (seekingBarNumber()) if (seekingBarNumber())
@ -1164,6 +1152,7 @@ void CConductor::init2(CScore * scoreWin, CSettings* settings)
m_scoreWin = scoreWin; m_scoreWin = scoreWin;
m_settings = settings; m_settings = settings;
setQSettings(settings);
setFollowSkillAdvanced(false); setFollowSkillAdvanced(false);
@ -1179,6 +1168,5 @@ void CConductor::init2(CScore * scoreWin, CSettings* settings)
m_piano = m_scoreWin->getPianoObject(); m_piano = m_scoreWin->getPianoObject();
} }
rewind(); rewind();
} }

View File

@ -63,14 +63,12 @@ typedef enum {
PB_RHYTHM_TAP_drumsAndMellody PB_RHYTHM_TAP_drumsAndMellody
} rhythmTapping_t; } rhythmTapping_t;
typedef enum { typedef enum {
PB_STOP_POINT_MODE_automatic, PB_STOP_POINT_MODE_automatic,
PB_STOP_POINT_MODE_onTheBeat, PB_STOP_POINT_MODE_onTheBeat,
PB_STOP_POINT_MODE_afterTheBeat PB_STOP_POINT_MODE_afterTheBeat
} stopPointMode_t; } stopPointMode_t;
/*! /*!
* @brief xxxxx. * @brief xxxxx.
*/ */
@ -82,7 +80,6 @@ public:
void init2(CScore * scoreWin, CSettings* settings); void init2(CScore * scoreWin, CSettings* settings);
//! add a midi event to be analysed and played //! add a midi event to be analysed and played
void midiEventInsert(CMidiEvent event); void midiEventInsert(CMidiEvent event);
@ -207,7 +204,6 @@ public:
stopPointMode_t cfg_stopPointMode; stopPointMode_t cfg_stopPointMode;
rhythmTapping_t cfg_rhythmTapping; rhythmTapping_t cfg_rhythmTapping;
protected: protected:
CScore* m_scoreWin; CScore* m_scoreWin;
CSettings* m_settings; CSettings* m_settings;
@ -223,7 +219,6 @@ protected:
void resetWantedChord(); void resetWantedChord();
void playWantedChord (CChord chord, CMidiEvent inputNote); void playWantedChord (CChord chord, CMidiEvent inputNote);
bool validatePianistNote( const CMidiEvent& inputNote); bool validatePianistNote( const CMidiEvent& inputNote);
bool validatePianistChord(); bool validatePianistChord();
@ -231,10 +226,6 @@ protected:
int track2Channel(int track) {return m_track2ChannelLookUp[track];} int track2Channel(int track) {return m_track2ChannelLookUp[track];}
private: private:
void allSoundOff(); void allSoundOff();
void resetAllChannels(); void resetAllChannels();
@ -298,7 +289,6 @@ private:
CTempo m_tempo; CTempo m_tempo;
bool m_KeyboardLightsOn; bool m_KeyboardLightsOn;
int m_pianistSplitPoint; // Defines which notes go in the base and treble clef int m_pianistSplitPoint; // Defines which notes go in the base and treble clef
bool m_followSkillAdvanced; bool m_followSkillAdvanced;
int m_lastSound; int m_lastSound;

View File

@ -6,7 +6,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman and others, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -37,6 +37,45 @@ typedef unsigned char guint8;
whichPart_t CDraw::m_displayHand; whichPart_t CDraw::m_displayHand;
int CDraw::m_forceCompileRedraw; int CDraw::m_forceCompileRedraw;
CDraw::CDraw(CSettings* settings)
#ifndef NO_USE_FTGL
:font(nullptr)
#endif
{
#ifndef NO_USE_FTGL
QStringList listPathFonts;
#if defined(USE_FONT)
listPathFonts.push_back(USE_FONT);
#endif
listPathFonts.push_back(Util::dataDir()+"/fonts/DejaVuSans.ttf");
listPathFonts.push_back(QApplication::applicationDirPath() + "/fonts/DejaVuSans.ttf");
listPathFonts.push_back("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf");
listPathFonts.push_back("/usr/share/fonts/dejavu/DejaVuSans.ttf");
listPathFonts.push_back("/usr/share/fonts/TTF/dejavu/DejaVuSans.ttf");
listPathFonts.push_back("/usr/share/fonts/TTF/DejaVuSans.ttf");
listPathFonts.push_back("/usr/share/fonts/truetype/DejaVuSans.ttf");
listPathFonts.push_back("/usr/local/share/fonts/dejavu/DejaVuSans.ttf");
for (int i=0;i<listPathFonts.size();i++){
QFile file(listPathFonts.at(i));
if (file.exists()){
font = new FTGLPixmapFont(listPathFonts.at(i).toStdString().c_str());
break;
}
}
if (font==nullptr){
ppLogError("Font DejaVuSans.ttf was not found !");
exit(0);
}
font->FaceSize(FONT_SIZE, FONT_SIZE);
#endif
m_settings = settings;
m_displayHand = PB_PART_both;
m_forceCompileRedraw = 1;
m_scrollProperties = &m_scrollPropertiesHorizontal;
}
void CDraw::oneLine(float x1, float y1, float x2, float y2) void CDraw::oneLine(float x1, float y1, float x2, float y2)
{ {
glBegin(GL_LINES); glBegin(GL_LINES);
@ -245,7 +284,6 @@ void CDraw::drawNoteName(int midiNote, float x, float y, int type)
glEnd(); glEnd();
break; break;
default: default:
glBegin(GL_LINES); glBegin(GL_LINES);
glVertex2f( 3 + x, -15 + y); // 1 glVertex2f( 3 + x, -15 + y); // 1
@ -315,7 +353,6 @@ void CDraw::checkAccidental(CSymbol symbol, float x, float y)
accidental = symbol.getStavePos().getAccidental(); accidental = symbol.getStavePos().getAccidental();
if (symbol.getAccidentalModifer() == PB_ACCIDENTAL_MODIFER_suppress) if (symbol.getAccidentalModifer() == PB_ACCIDENTAL_MODIFER_suppress)
accidental = 0; // Suppress the accidental if it is the same bar accidental = 0; // Suppress the accidental if it is the same bar
@ -339,7 +376,6 @@ void CDraw::checkAccidental(CSymbol symbol, float x, float y)
} }
} }
bool CDraw::drawNote(CSymbol* symbol, float x, float y, CSlot* slot, CColor color, bool playable) bool CDraw::drawNote(CSymbol* symbol, float x, float y, CSlot* slot, CColor color, bool playable)
{ {
const float stemLength = 34.0; const float stemLength = 34.0;
@ -362,7 +398,6 @@ bool CDraw::drawNote(CSymbol* symbol, float x, float y, CSlot* slot, CColor colo
else if (symbol->getType() <= PB_SYMBOL_quaver) else if (symbol->getType() <= PB_SYMBOL_quaver)
stemFlagCount = 1; stemFlagCount = 1;
if (symbol->getType() <= PB_SYMBOL_crotchet) if (symbol->getType() <= PB_SYMBOL_crotchet)
solidNoteHead = true; solidNoteHead = true;
@ -784,8 +819,6 @@ void CDraw::drawSymbol(CSymbol symbol, float x)
drawSymbol(symbol, x, symbol.getStavePos().getPosY()); drawSymbol(symbol, x, symbol.getStavePos().getPosY());
} }
void CDraw::drawSlot(CSlot* slot) void CDraw::drawSlot(CSlot* slot)
{ {
CStavePos stavePos; CStavePos stavePos;
@ -800,7 +833,6 @@ void CDraw::drawSlot(CSlot* slot)
} }
} }
void CDraw::drawStaves(float startX, float endX) void CDraw::drawStaves(float startX, float endX)
{ {
int i; int i;
@ -827,7 +859,6 @@ void CDraw::drawStaves(float startX, float endX)
glEnd(); glEnd();
} }
void CDraw::drawKeySignature(int key) void CDraw::drawKeySignature(int key)
{ {
const int sharpLookUpRight[] = { 4, 1, 5, 2,-1, 3, 0}; const int sharpLookUpRight[] = { 4, 1, 5, 2,-1, 3, 0};

View File

@ -6,7 +6,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman and others, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -49,7 +49,6 @@
#include "Symbol.h" #include "Symbol.h"
class CSettings; class CSettings;
class CSlot; class CSlot;
@ -69,43 +68,8 @@ private:
class CDraw : public QObject class CDraw : public QObject
{ {
public: public:
CDraw(CSettings* settings)
#ifndef NO_USE_FTGL
:font(nullptr)
#endif
{
#ifndef NO_USE_FTGL
QStringList listPathFonts;
#if defined(USE_FONT)
listPathFonts.push_back(USE_FONT);
#endif
listPathFonts.push_back(QString(PREFIX)+"/"+QString(DATA_DIR)+"/fonts/DejaVuSans.ttf");
listPathFonts.push_back(QApplication::applicationDirPath() + "/fonts/DejaVuSans.ttf");
listPathFonts.push_back("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf");
listPathFonts.push_back("/usr/share/fonts/dejavu/DejaVuSans.ttf");
listPathFonts.push_back("/usr/share/fonts/TTF/dejavu/DejaVuSans.ttf");
listPathFonts.push_back("/usr/share/fonts/TTF/DejaVuSans.ttf");
listPathFonts.push_back("/usr/share/fonts/truetype/DejaVuSans.ttf");
listPathFonts.push_back("/usr/local/share/fonts/dejavu/DejaVuSans.ttf");
for (int i=0;i<listPathFonts.size();i++){ CDraw(CSettings* settings);
QFile file(listPathFonts.at(i));
if (file.exists()){
font = new FTGLPixmapFont(listPathFonts.at(i).toStdString().c_str());
break;
}
}
if (font==nullptr){
ppLogError("Font DejaVuSans.ttf was not found !");
exit(0);
}
font->FaceSize(FONT_SIZE, FONT_SIZE);
#endif
m_settings = settings;
m_displayHand = PB_PART_both;
m_forceCompileRedraw = 1;
m_scrollProperties = &m_scrollPropertiesHorizontal;
}
~CDraw(){ ~CDraw(){
#ifndef NO_USE_FTGL #ifndef NO_USE_FTGL

View File

@ -42,13 +42,12 @@
#define REDRAW_COUNT ((m_cfg_openGlOptimise >= 2) ? 1 : 2) // there are two gl buffers but redrawing once is best (set 2 with buggy gl drivers) #define REDRAW_COUNT ((m_cfg_openGlOptimise >= 2) ? 1 : 2) // there are two gl buffers but redrawing once is best (set 2 with buggy gl drivers)
CGLView::CGLView(QtWindow* parent, CSettings* settings) CGLView::CGLView(QtWindow* parent, CSettings* settings)
: QGLWidget(parent) : QGLWidget(parent)
{ {
m_qtWindow = parent; m_qtWindow = parent;
m_settings = settings; m_settings = settings;
m_rating = 0; m_rating = nullptr;
m_fullRedrawFlag = true; m_fullRedrawFlag = true;
m_forcefullRedraw = 0; m_forcefullRedraw = 0;
m_forceRatingRedraw = 0; m_forceRatingRedraw = 0;
@ -127,7 +126,6 @@ void CGLView::paintGL()
m_score->drawScroll(m_forcefullRedraw); m_score->drawScroll(m_forcefullRedraw);
BENCHMARK(10, "drawScroll"); BENCHMARK(10, "drawScroll");
if (m_forcefullRedraw) m_forcefullRedraw--; if (m_forcefullRedraw) m_forcefullRedraw--;
BENCHMARK(11, "exit"); BENCHMARK(11, "exit");
BENCHMARK_RESULTS(); BENCHMARK_RESULTS();
@ -144,7 +142,7 @@ void CGLView::drawTimeSignature()
float x,y; float x,y;
int topNumber, bottomNumber; int topNumber, bottomNumber;
if (m_song == 0) return; if (m_song == nullptr) return;
m_song->getTimeSig(&topNumber, &bottomNumber); m_song->getTimeSig(&topNumber, &bottomNumber);
if (topNumber == 0 ) return; if (topNumber == 0 ) return;
@ -179,7 +177,6 @@ void CGLView::drawAccurracyBar()
return; return;
m_forceRatingRedraw--; m_forceRatingRedraw--;
float accuracy; float accuracy;
CColor color; CColor color;
@ -197,7 +194,6 @@ void CGLView::drawAccurracyBar()
CDraw::drColor (Cfg::backgroundColor()); CDraw::drColor (Cfg::backgroundColor());
glRectf(x + width * accuracy, y - lineWidth, x + width, y + lineWidth); glRectf(x + width * accuracy, y - lineWidth, x + width, y + lineWidth);
glLineWidth (1); glLineWidth (1);
CDraw::drColor (CColor(1.0, 1.0, 1.0)); CDraw::drColor (CColor(1.0, 1.0, 1.0));
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
@ -210,7 +206,7 @@ void CGLView::drawAccurracyBar()
void CGLView::drawDisplayText() void CGLView::drawDisplayText()
{ {
if (m_rating == 0) if (m_rating == nullptr)
{ {
m_rating = m_song->getRating(); m_rating = m_song->getRating();
return; // don't run this func the first time it is called return; // don't run this func the first time it is called
@ -328,7 +324,6 @@ void CGLView::initializeGL()
glShadeModel (GL_FLAT); glShadeModel (GL_FLAT);
//glEnable(GL_TEXTURE_2D); // Enable Texture Mapping //glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
//from initCheck(); //from initCheck();
glShadeModel(GL_FLAT); glShadeModel(GL_FLAT);
//glEnable(GL_DEPTH_TEST); //glEnable(GL_DEPTH_TEST);
@ -364,7 +359,6 @@ void CGLView::initializeGL()
m_song->regenerateChordQueue(); m_song->regenerateChordQueue();
// increased the tick time for Midi handling // increased the tick time for Midi handling
m_timer.start(Cfg::tickRate, this ); m_timer.start(Cfg::tickRate, this );
@ -393,7 +387,6 @@ void CGLView::timerEvent(QTimerEvent *event)
return; return;
} }
updateMidiTask(); updateMidiTask();
BENCHMARK(1, "m_song task"); BENCHMARK(1, "m_song task");

View File

@ -71,7 +71,6 @@ private:
void drawBarNumber(); void drawBarNumber();
void updateMidiTask(); void updateMidiTask();
QColor m_backgroundColor; QColor m_backgroundColor;
QtWindow* m_qtWindow; // The parent Window QtWindow* m_qtWindow; // The parent Window
CSettings* m_settings; CSettings* m_settings;

View File

@ -6,7 +6,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman and others, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -36,7 +36,7 @@
GuiKeyboardSetupDialog::GuiKeyboardSetupDialog(QWidget *parent) GuiKeyboardSetupDialog::GuiKeyboardSetupDialog(QWidget *parent)
: QDialog(parent) : QDialog(parent)
{ {
m_song = 0; m_song = nullptr;
setupUi(this); setupUi(this);
setWindowTitle(tr("Piano Keyboard Settings")); setWindowTitle(tr("Piano Keyboard Settings"));
} }

View File

@ -34,7 +34,6 @@
#include "Song.h" #include "Song.h"
#include "Settings.h" #include "Settings.h"
#include "ui_GuiKeyboardSetupDialog.h" #include "ui_GuiKeyboardSetupDialog.h"
class GuiKeyboardSetupDialog : public QDialog, private Ui::GuiKeyboardSetupDialog class GuiKeyboardSetupDialog : public QDialog, private Ui::GuiKeyboardSetupDialog
@ -50,7 +49,6 @@ private slots:
void accept(); void accept();
void reject(); void reject();
void on_rightTestButton_pressed() { void on_rightTestButton_pressed() {
m_song->testWrongNoteSound(false); m_song->testWrongNoteSound(false);
m_song->pcKeyPress( 'x', true); m_song->pcKeyPress( 'x', true);

View File

@ -33,12 +33,11 @@ GuiLoopingPopup::GuiLoopingPopup(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
setupUi(this); setupUi(this);
m_song = 0; m_song = nullptr;
setWindowTitle(tr("Continuous Looping")); setWindowTitle(tr("Continuous Looping"));
setWindowFlags(Qt::Popup); setWindowFlags(Qt::Popup);
} }
void GuiLoopingPopup::init(CSong* song) void GuiLoopingPopup::init(CSong* song)
{ {
m_song = song; m_song = song;
@ -54,7 +53,6 @@ void GuiLoopingPopup::updateInfo()
loopingText->setText(tr("Repeat Bar is disabled")); loopingText->setText(tr("Repeat Bar is disabled"));
} }
void GuiLoopingPopup::on_loopBarsSpin_valueChanged(double bars) void GuiLoopingPopup::on_loopBarsSpin_valueChanged(double bars)
{ {
if (!m_song) return; if (!m_song) return;

View File

@ -29,12 +29,10 @@
#ifndef __GUILOOPINGPOPUP_H__ #ifndef __GUILOOPINGPOPUP_H__
#define __GUILOOPINGPOPUP_H__ #define __GUILOOPINGPOPUP_H__
#include <QtWidgets> #include <QtWidgets>
#include "Song.h" #include "Song.h"
#include "ui_GuiLoopingPopup.h" #include "ui_GuiLoopingPopup.h"
class CGLView; class CGLView;

281
src/GuiMidiSetupDialog.cpp Normal file → Executable file
View File

@ -5,7 +5,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman and others, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -28,12 +28,15 @@
#include "GuiMidiSetupDialog.h" #include "GuiMidiSetupDialog.h"
#if EXPERIMENTAL_USE_FLUIDSYNTH
#include "MidiDeviceFluidSynth.h"
#endif
GuiMidiSetupDialog::GuiMidiSetupDialog(QWidget *parent) GuiMidiSetupDialog::GuiMidiSetupDialog(QWidget *parent)
: QDialog(parent) : QDialog(parent)
{ {
m_song = 0; m_song = nullptr;
m_settings = 0; m_settings = nullptr;
setupUi(this); setupUi(this);
m_latencyFix = 0; m_latencyFix = 0;
m_latencyChanged = false; m_latencyChanged = false;
@ -53,67 +56,84 @@ void GuiMidiSetupDialog::init(CSong* song, CSettings* settings)
// Check inputs. // Check inputs.
QString portName; QString portName;
int i = 0;
m_latencyFix = m_song->getLatencyFix(); m_latencyFix = m_song->getLatencyFix();
midiInputCombo->addItem(tr("None (PC Keyboard)")); refreshMidiInputCombo();
refreshMidiOutputCombo();
masterGainSpin->setValue(40);
reverbCheck->setChecked(false);
chorusCheck->setChecked(false);
midiInputCombo->addItems(song->getMidiPortList(CMidiDevice::MIDI_INPUT)); sampleRateCombo->addItems({"22050", "44100","48000", "88200","96000"});
sampleRateCombo->setValidator(new QIntValidator(22050, 96000, this));
bufferSizeCombo->addItems({"64", "128", "512", "1024", "2024", "4096","8192"});
// Check outputs. bufferSizeCombo->setValidator(new QIntValidator(64, 8192, this));
midiOutputCombo->addItem(tr("None")); bufferSizeCombo->setCurrentIndex(1);
midiOutputCombo->addItems(song->getMidiPortList(CMidiDevice::MIDI_OUTPUT)); bufferCountCombo->addItems({"2","4", "8","16", "32", "64"});
i = midiInputCombo->findText(m_settings->value("Midi/Input").toString()); bufferCountCombo->setValidator(new QIntValidator(2, 64, this));
if (i!=-1) bufferCountCombo->setCurrentIndex(1);
midiInputCombo->setCurrentIndex(i);
i = midiOutputCombo->findText(m_settings->value("Midi/Output").toString());
if (i!=-1)
midiOutputCombo->setCurrentIndex(i);
sampleRateCombo->addItem("44100");
sampleRateCombo->addItem("22050");
sampleRateCombo->setValidator(new QIntValidator(0, 999999, this));
updateMidiInfoText(); updateMidiInfoText();
audioDriverCombo->clear(); audioDriverCombo->clear();
audioDriverCombo->addItem("");
audioDriverCombo->addItem("alsa");
audioDriverCombo->addItem("file");
audioDriverCombo->addItem("jack");
audioDriverCombo->addItem("oss");
audioDriverCombo->addItem("portaudio");
audioDriverCombo->addItem("pulseaudio");
setDefaultFluidSynth(); #if defined (Q_OS_LINUX)
audioDriverCombo->addItems({"alsa","pulseaudio"});
#elif defined (Q_OS_UNIX) || defined (Q_OS_DARWIN)
audioDriverCombo->addItems({"pulseaudio"});
#endif
connect(audioDriverCombo,SIGNAL(currentIndexChanged(int)),this,SLOT(on_audioDriverCombo_currentIndexChanged(int))); if (m_settings->getFluidSoundFontNames().size()>0){
masterGainSpin->setValue(m_settings->value("FluidSynth/masterGainSpin","40").toInt());
if (m_settings->getFluidSoundFontNames().size()!=0){
masterGainSpin->setValue(m_settings->value("FluidSynth/masterGainSpin","0.2").toDouble());
bufferSizeSpin->setValue(m_settings->value("FluidSynth/bufferSizeSpin","").toInt());
bufferCountsSpin->setValue(m_settings->value("FluidSynth/bufferCountsSpin","").toInt());
reverbCheck->setChecked(m_settings->value("FluidSynth/reverbCheck","false").toBool()); reverbCheck->setChecked(m_settings->value("FluidSynth/reverbCheck","false").toBool());
chorusCheck->setChecked(m_settings->value("FluidSynth/chorusCheck","false").toBool()); chorusCheck->setChecked(m_settings->value("FluidSynth/chorusCheck","false").toBool());
setComboFromSetting(audioDriverCombo, "FluidSynth/audioDriverCombo","alsa");
setComboFromSetting(sampleRateCombo, "FluidSynth/sampleRateCombo","22050");
setComboFromSetting(bufferSizeCombo, "FluidSynth/bufferSizeCombo","128");
setComboFromSetting(bufferCountCombo, "FluidSynth/bufferCountCombo","4");
}
audioDeviceLineEdit->setText(m_settings->value("FluidSynth/audioDeviceLineEdit","").toString()); updateFluidInfoStatus();
for (int i=0;i<audioDriverCombo->count();i++){ }
if (audioDriverCombo->itemText(i)==m_settings->value("FluidSynth/audioDriverCombo","").toString()){
audioDriverCombo->setCurrentIndex(i); void GuiMidiSetupDialog::setComboFromSetting(QComboBox *combo, const QString &key, const QVariant &defaultValue) {
break; QString value = m_settings->value(key, defaultValue).toString();
} int index = combo->findText(value);
}
sampleRateCombo->setCurrentText(m_settings->value("FluidSynth/sampleRateCombo").toString()); if ( index != -1 ) { // -1 for not found
combo->setCurrentIndex(index);
} else {
combo->setCurrentText(value);
} }
}
updateFluidInfoText(); void GuiMidiSetupDialog::refreshMidiInputCombo()
{
int i = 0;
midiInputCombo->clear();
midiInputCombo->addItem(tr("None (PC Keyboard)"));
midiInputCombo->addItems(m_song->getMidiPortList(CMidiDevice::MIDI_INPUT));
i = midiInputCombo->findText(m_settings->value("Midi/Input").toString());
if (i!=-1)
midiInputCombo->setCurrentIndex(i);
}
void GuiMidiSetupDialog::refreshMidiOutputCombo()
{
int i = 0;
// Check outputs.
midiOutputCombo->clear();
midiOutputCombo->addItem(tr("None"));
midiOutputCombo->addItems(m_song->getMidiPortList(CMidiDevice::MIDI_OUTPUT));
i = midiOutputCombo->findText(m_settings->value("Midi/Output").toString());
if (i!=-1)
midiOutputCombo->setCurrentIndex(i);
} }
void GuiMidiSetupDialog::updateMidiInfoText() void GuiMidiSetupDialog::updateMidiInfoText()
{ {
midiInfoText->clear(); midiInfoText->clear();
if (midiInputCombo->currentIndex() == 0) if (midiInputCombo->currentIndex() == 0)
@ -135,7 +155,7 @@ void GuiMidiSetupDialog::updateMidiInfoText()
latencyFixLabel->setText(tr("%1 mSec").arg(m_latencyFix)); latencyFixLabel->setText(tr("%1 mSec").arg(m_latencyFix));
updateFluidInfoText(); updateFluidInfoStatus();
} }
void GuiMidiSetupDialog::on_midiInputCombo_activated (int index) void GuiMidiSetupDialog::on_midiInputCombo_activated (int index)
@ -168,9 +188,23 @@ void GuiMidiSetupDialog::on_latencyFixButton_clicked ( bool checked )
} }
} }
void GuiMidiSetupDialog::accept() void GuiMidiSetupDialog::accept()
{ {
// save FluidSynth settings
if (m_settings->getFluidSoundFontNames().size()==0){
m_settings->remove("FluidSynth");
}else{
m_settings->setValue("FluidSynth/masterGainSpin",masterGainSpin->value());
m_settings->setValue("FluidSynth/bufferSizeCombo", bufferSizeCombo->currentText());
m_settings->setValue("FluidSynth/bufferCountCombo", bufferCountCombo->currentText());
m_settings->setValue("FluidSynth/reverbCheck",reverbCheck->isChecked());
m_settings->setValue("FluidSynth/chorusCheck",chorusCheck->isChecked());
m_settings->setValue("FluidSynth/audioDriverCombo",audioDriverCombo->currentText());
m_settings->setValue("FluidSynth/sampleRateCombo",sampleRateCombo->currentText());
}
m_settings->saveSoundFontSettings();
m_settings->setValue("Midi/Input", midiInputCombo->currentText()); m_settings->setValue("Midi/Input", midiInputCombo->currentText());
m_song->openMidiPort(CMidiDevice::MIDI_INPUT, midiInputCombo->currentText() ); m_song->openMidiPort(CMidiDevice::MIDI_INPUT, midiInputCombo->currentText() );
if (midiInputCombo->currentText().startsWith(tr("None"))) if (midiInputCombo->currentText().startsWith(tr("None")))
@ -210,132 +244,83 @@ void GuiMidiSetupDialog::accept()
m_latencyChanged = false; m_latencyChanged = false;
} }
// save FluidSynth settings
if (m_settings->getFluidSoundFontNames().size()==0){
m_settings->remove("FluidSynth");
}else{
m_settings->setValue("FluidSynth/masterGainSpin",QString::number(masterGainSpin->value(),'f',2));
m_settings->setValue("FluidSynth/bufferSizeSpin",bufferSizeSpin->value());
m_settings->setValue("FluidSynth/bufferCountsSpin",bufferCountsSpin->value());
m_settings->setValue("FluidSynth/reverbCheck",reverbCheck->isChecked());
m_settings->setValue("FluidSynth/chorusCheck",chorusCheck->isChecked());
m_settings->setValue("FluidSynth/audioDriverCombo",audioDriverCombo->currentText());
if (audioDriverCombo->currentText()=="alsa"){
m_settings->setValue("FluidSynth/audioDeviceLineEdit",audioDeviceLineEdit->text());
}else{
m_settings->setValue("FluidSynth/audioDeviceLineEdit","");
}
m_settings->setValue("FluidSynth/sampleRateCombo",sampleRateCombo->currentText());
}
this->QDialog::accept(); this->QDialog::accept();
} }
void GuiMidiSetupDialog::updateFluidInfoStatus()
void GuiMidiSetupDialog::updateFluidInfoText()
{ {
QStringList soundFontNames = m_settings->getFluidSoundFontNames(); QStringList soundFontNames = m_settings->getFluidSoundFontNames();
soundFontList->clear(); soundFontList->clear();
for (int i=0; i < soundFontNames.count(); i++) if (!m_settings->getFluidSoundFontNames().isEmpty())
{ {
int n = soundFontNames.at(i).lastIndexOf("/"); QFileInfo fileInfo = QFileInfo(m_settings->getFluidSoundFontNames().at(0));
soundFontList->addItem(soundFontNames.at(i).mid(n+1)); if (fileInfo.exists())
{
soundFontList->addItem(fileInfo.fileName());
}
} }
bool fontLoaded = (soundFontList->count() > 0) ? true : false; bool fontLoaded = (soundFontList->count() > 0) ? true : false;
fluidRemoveButton->setEnabled(fontLoaded); fluidClearButton->setEnabled(fontLoaded);
fluidAddButton->setEnabled(soundFontList->count() < 2 ? true : false); fluidLoadButton->setEnabled(soundFontList->count() < 2 ? true : false);
fluidSettingsGroupBox->setEnabled(fontLoaded); fluidSettingsGroupBox->setEnabled(fontLoaded);
} }
void GuiMidiSetupDialog::setDefaultFluidSynth(){ void GuiMidiSetupDialog::on_fluidLoadButton_clicked ( bool checked )
masterGainSpin->setValue(0.4);
bufferSizeSpin->setValue(128);
bufferCountsSpin->setValue(6);
reverbCheck->setChecked(false);
chorusCheck->setChecked(false);
#if defined (Q_OS_UNIX) || defined (Q_OS_DARWIN)
audioDriverCombo->setCurrentIndex(3);
audioDeviceLineEdit->setText("");
#endif
#if defined (Q_OS_LINUX)
audioDriverCombo->setCurrentIndex(1);
audioDeviceLineEdit->setText("plughw:0");
#endif
sampleRateCombo->setCurrentIndex(0);
}
void GuiMidiSetupDialog::on_fluidAddButton_clicked ( bool checked )
{ {
QStringList possibleSoundFontFolders; #if EXPERIMENTAL_USE_FLUIDSYNTH
QString lastSoundFont = m_settings->value("LastSoundFontDir","").toString();
if (lastSoundFont.isEmpty()) {
lastSoundFont = QDir::homePath();
QStringList possibleSoundFontFolders;
#if defined (Q_OS_LINUX) || defined (Q_OS_UNIX) #if defined (Q_OS_LINUX) || defined (Q_OS_UNIX)
possibleSoundFontFolders.push_back("/usr/share/soundfonts"); possibleSoundFontFolders.push_back("/usr/share/soundfonts");
possibleSoundFontFolders.push_back("/usr/share/sounds/sf2"); possibleSoundFontFolders.push_back("/usr/share/sounds/sf2");
#endif #endif
for (QString soundFontFolder:possibleSoundFontFolders){
QString lastSoundFont = QDir::homePath(); QDir dir(soundFontFolder);
if (dir.exists()){
for (QString soundFontFolder:possibleSoundFontFolders){ lastSoundFont=soundFontFolder;
QDir dir(soundFontFolder); break;
if (dir.exists()){ }
lastSoundFont=soundFontFolder;
break;
} }
} }
QFileInfo soundFontInfo = QFileDialog::getOpenFileName(this,tr("Open SoundFont File for fluidsynth"),
lastSoundFont, tr("SoundFont Files (*.sf2 *.sf3)"));
if (!soundFontInfo.isFile()) return;
QString soundFontName = QFileDialog::getOpenFileName(this,tr("Open SoundFont2 File for fluidsynth"), m_settings->setFluidSoundFontNames(soundFontInfo.filePath());
lastSoundFont, tr("SoundFont2 Files (*.sf2)")); m_settings->setValue("LastSoundFontDir", soundFontInfo.path());
if (soundFontName.isEmpty()) return;
m_settings->addFluidSoundFontName(soundFontName); if (m_settings->isNewSoundFontEntered())
{
updateFluidInfoText(); int i = midiOutputCombo->findText(CMidiDeviceFluidSynth::getFluidInternalName());
if (i==-1)
m_settings->setValue("FluidSynth/SoundFont2_1",""); midiOutputCombo->addItem(CMidiDeviceFluidSynth::getFluidInternalName());
m_settings->setValue("FluidSynth/SoundFont2_2",""); i = midiOutputCombo->findText(CMidiDeviceFluidSynth::getFluidInternalName());
for (int i=0;i<m_settings->getFluidSoundFontNames().size();i++){ if (i!=-1)
m_settings->setValue("FluidSynth/SoundFont2_"+QString::number(1+i),m_settings->getFluidSoundFontNames().at(i)); midiOutputCombo->setCurrentIndex(i);
}}
void GuiMidiSetupDialog::on_fluidRemoveButton_clicked ( bool checked ){
if (soundFontList->currentRow()==-1) return;
QStringList soundFontNames = m_settings->getFluidSoundFontNames();
m_settings->removeFluidSoundFontName(soundFontNames.at(soundFontList->currentRow()));
soundFontList->removeItemWidget(soundFontList->currentItem());
updateFluidInfoText();
m_settings->setValue("FluidSynth/SoundFont2_1","");
m_settings->setValue("FluidSynth/SoundFont2_2","");
for (int i=0;i<m_settings->getFluidSoundFontNames().size();i++){
m_settings->setValue("FluidSynth/SoundFont2_"+QString::number(1+i),m_settings->getFluidSoundFontNames().at(i));
} }
updateFluidInfoStatus();
if (m_settings->getFluidSoundFontNames().size()==0){ updateMidiInfoText();
setDefaultFluidSynth(); #endif
m_settings->remove("Fluid");
}
} }
void GuiMidiSetupDialog::on_audioDriverCombo_currentIndexChanged(int index){ void GuiMidiSetupDialog::on_fluidClearButton_clicked( bool checked ){
if (audioDriverCombo->currentText()=="alsa"){ #if EXPERIMENTAL_USE_FLUIDSYNTH
audioDeviceLineEdit->setEnabled(true); m_settings->clearFluidSoundFontNames();
if (audioDeviceLineEdit->text().isEmpty()){ int i = midiOutputCombo->findText(CMidiDeviceFluidSynth::getFluidInternalName());
audioDeviceLineEdit->setText("plughw:0"); if (i>=0)
} {
}else{ midiOutputCombo->removeItem(i);
audioDeviceLineEdit->setEnabled(false); midiOutputCombo->setCurrentIndex(0);
audioDeviceLineEdit->setText("");
} }
updateFluidInfoStatus();
#endif
} }

View File

@ -6,7 +6,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman and others, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -50,15 +50,15 @@ private slots:
void on_midiInputCombo_activated (int index); void on_midiInputCombo_activated (int index);
void on_midiOutputCombo_activated (int index); void on_midiOutputCombo_activated (int index);
void on_latencyFixButton_clicked ( bool checked ); void on_latencyFixButton_clicked ( bool checked );
void on_fluidAddButton_clicked ( bool checked ); void on_fluidLoadButton_clicked ( bool checked );
void on_fluidRemoveButton_clicked ( bool checked ); void on_fluidClearButton_clicked ( bool checked );
void on_audioDriverCombo_currentIndexChanged ( int index );
private: private:
void setComboFromSetting(QComboBox *combo, const QString &key, const QVariant &defaultValue = QVariant());
void updateMidiInfoText(); void updateMidiInfoText();
void updateFluidInfoText(); void refreshMidiInputCombo();
void setDefaultFluidSynth(); void refreshMidiOutputCombo();
void updateFluidInfoStatus();
CSettings* m_settings; CSettings* m_settings;
CSong* m_song; CSong* m_song;
int m_latencyFix; int m_latencyFix;

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>535</width> <width>562</width>
<height>439</height> <height>408</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -20,7 +20,7 @@
<enum>QTabWidget::Rounded</enum> <enum>QTabWidget::Rounded</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
@ -130,30 +130,50 @@
<string notr="true">FluidSynth</string> <string notr="true">FluidSynth</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QGroupBox" name="groupBox_3"> <widget class="QGroupBox" name="groupBox_3">
<property name="title"> <property name="title">
<string>Sound Fonts</string> <string>Sound Font</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_7">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QListWidget" name="soundFontList"/> <widget class="QListWidget" name="soundFontList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_5">
<item> <item>
<widget class="QPushButton" name="fluidAddButton"> <widget class="QPushButton" name="fluidLoadButton">
<property name="text"> <property name="text">
<string>Add</string> <string>Load</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="fluidRemoveButton"> <widget class="QPushButton" name="fluidClearButton">
<property name="text"> <property name="text">
<string>Remove</string> <string>Clear</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -182,132 +202,124 @@
<property name="title"> <property name="title">
<string>Settings</string> <string>Settings</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QGridLayout" name="gridLayout">
<item> <item row="0" column="2">
<layout class="QGridLayout" name="gridLayout"> <widget class="QCheckBox" name="reverbCheck">
<item row="3" column="1"> <property name="text">
<widget class="QCheckBox" name="chorusCheck"> <string>Reverb</string>
<property name="text"> </property>
<string>Chorus</string> </widget>
</property> </item>
</widget> <item row="0" column="3">
</item> <widget class="QCheckBox" name="chorusCheck">
<item row="2" column="2"> <property name="text">
<widget class="QLabel" name="label_9"> <string>Chorus</string>
<property name="text"> </property>
<string>Sample Rate:</string> </widget>
</property> </item>
<property name="alignment"> <item row="2" column="3">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <widget class="QComboBox" name="bufferCountCombo">
</property> <property name="editable">
</widget> <bool>true</bool>
</item> </property>
<item row="0" column="2"> </widget>
<widget class="QLabel" name="label_8"> </item>
<property name="text"> <item row="0" column="1">
<string>Audio Driver:</string> <widget class="QSpinBox" name="masterGainSpin">
</property> <property name="maximum">
<property name="alignment"> <number>200</number>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property>
</property> <property name="singleStep">
</widget> <number>5</number>
</item> </property>
<item row="1" column="2"> <property name="value">
<widget class="QLabel" name="label_7"> <number>100</number>
<property name="text"> </property>
<string>Audio Device:</string> </widget>
</property> </item>
<property name="alignment"> <item row="1" column="2">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <widget class="QLabel" name="label_9">
</property> <property name="text">
</widget> <string>Sample Rate:</string>
</item> </property>
<item row="2" column="4"> <property name="alignment">
<widget class="QComboBox" name="sampleRateCombo"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="editable"> </property>
<bool>true</bool> </widget>
</property> </item>
</widget> <item row="1" column="1">
</item> <widget class="QComboBox" name="audioDriverCombo"/>
<item row="2" column="0"> </item>
<widget class="QLabel" name="label_4"> <item row="2" column="2">
<property name="text"> <widget class="QLabel" name="label_4">
<string>Buffer Counts:</string> <property name="text">
</property> <string>Buffer Count:</string>
<property name="alignment"> </property>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <property name="alignment">
</property> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</widget> </property>
</item> </widget>
<item row="1" column="4"> </item>
<widget class="QLineEdit" name="audioDeviceLineEdit"> <item row="0" column="0">
<property name="minimumSize"> <widget class="QLabel" name="label_18">
<size> <property name="text">
<width>150</width> <string>Master Gain:</string>
<height>0</height> </property>
</size> <property name="alignment">
</property> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</widget> </property>
</item> </widget>
<item row="0" column="0"> </item>
<widget class="QLabel" name="label_18"> <item row="2" column="0">
<property name="text"> <widget class="QLabel" name="label_3">
<string>Master Gain:</string> <property name="text">
</property> <string>Buffer Size:</string>
<property name="alignment"> </property>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <property name="alignment">
</property> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</widget> </property>
</item> </widget>
<item row="1" column="1"> </item>
<widget class="QSpinBox" name="bufferSizeSpin"> <item row="1" column="0">
<property name="maximum"> <widget class="QLabel" name="label_8">
<number>999999999</number> <property name="text">
</property> <string>Audio Driver:</string>
</widget> </property>
</item> <property name="alignment">
<item row="3" column="0"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<widget class="QCheckBox" name="reverbCheck"> </property>
<property name="text"> </widget>
<string>Reverb</string> </item>
</property> <item row="1" column="3">
</widget> <widget class="QComboBox" name="sampleRateCombo">
</item> <property name="editable">
<item row="1" column="0"> <bool>true</bool>
<widget class="QLabel" name="label_3"> </property>
<property name="text"> </widget>
<string>Buffer Size:</string> </item>
</property> <item row="2" column="1">
<property name="alignment"> <widget class="QComboBox" name="bufferSizeCombo">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <property name="editable">
</property> <bool>true</bool>
</widget> </property>
</item> </widget>
<item row="0" column="4">
<widget class="QComboBox" name="audioDriverCombo"/>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="bufferCountsSpin">
<property name="maximum">
<number>999999999</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="masterGainSpin">
<property name="maximum">
<double>10.000000000000000</double>
</property>
<property name="value">
<double>0.200000000000000</double>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_3"> <widget class="QWidget" name="tab_3">
@ -369,8 +381,8 @@
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>248</x> <x>257</x>
<y>254</y> <y>429</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>157</x> <x>157</x>
@ -385,8 +397,8 @@
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>316</x> <x>325</x>
<y>260</y> <y>429</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>286</x> <x>286</x>

View File

@ -5,7 +5,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman and others, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -36,9 +36,9 @@ GuiPreferencesDialog::GuiPreferencesDialog(QWidget *parent)
: QDialog(parent) : QDialog(parent)
{ {
setupUi(this); setupUi(this);
m_song = 0; m_song = nullptr;
m_settings = 0; m_settings = nullptr;
m_glView = 0; m_glView = nullptr;
setWindowTitle(tr("Preferences")); setWindowTitle(tr("Preferences"));
followStopPointCombo->addItem(tr("Automatic (Recommended)")); followStopPointCombo->addItem(tr("Automatic (Recommended)"));
followStopPointCombo->addItem(tr("On the Beat")); followStopPointCombo->addItem(tr("On the Beat"));
@ -52,7 +52,7 @@ void GuiPreferencesDialog::initLanguageCombo(){
QFile fileTestLocale(localeDirectory); QFile fileTestLocale(localeDirectory);
if (!fileTestLocale.exists()){ if (!fileTestLocale.exists()){
localeDirectory=QString(PREFIX)+"/"+QString(DATA_DIR)+"/translations/"; localeDirectory=Util::dataDir()+"/translations/";
#ifdef Q_OS_DARWIN #ifdef Q_OS_DARWIN
localeDirectory=QApplication::applicationDirPath() + "/../Resources/translations/"; localeDirectory=QApplication::applicationDirPath() + "/../Resources/translations/";
#endif #endif
@ -80,13 +80,17 @@ void GuiPreferencesDialog::initLanguageCombo(){
// loading languages // loading languages
languageCombo->clear(); languageCombo->clear();
languageCombo->addItem("<"+tr("System Language")+">","");
languageCombo->addItem("English","en"); languageCombo->addItem("English","en");
if (m_settings->value("General/lang","").toString()=="en"){
languageCombo->setCurrentIndex(languageCombo->count()-1);
}
QDir dirLang(localeDirectory); QDir dirLang(localeDirectory);
dirLang.setFilter(QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot); dirLang.setFilter(QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot);
QFileInfoList listLang = dirLang.entryInfoList(); QFileInfoList listLang = dirLang.entryInfoList();
for (int i = 0; i < listLang.size(); ++i) { for (QFileInfo fileInfo : listLang) {
QFileInfo fileInfo = listLang.at(i);
QRegExp rx("(pianobooster_)(.*)(.qm)"); QRegExp rx("(pianobooster_)(.*)(.qm)");
if (rx.indexIn(fileInfo.fileName())!=-1){ if (rx.indexIn(fileInfo.fileName())!=-1){
QString lang_code = rx.cap(2); QString lang_code = rx.cap(2);
@ -119,7 +123,7 @@ void GuiPreferencesDialog::initLanguageCombo(){
} }
languageCombo->addItem(languageName,lang_code); languageCombo->addItem(languageName,lang_code);
if (m_settings->value("General/lang",QLocale::system().bcp47Name()).toString()==lang_code){ if (m_settings->value("General/lang","").toString()==lang_code){
languageCombo->setCurrentIndex(languageCombo->count()-1); languageCombo->setCurrentIndex(languageCombo->count()-1);
} }
} }
@ -163,7 +167,7 @@ void GuiPreferencesDialog::accept()
m_song->cfg_stopPointMode = static_cast<stopPointMode_t> (followStopPointCombo->currentIndex()); m_song->cfg_stopPointMode = static_cast<stopPointMode_t> (followStopPointCombo->currentIndex());
m_settings->setValue("Score/StopPointMode", m_song->cfg_stopPointMode ); m_settings->setValue("Score/StopPointMode", m_song->cfg_stopPointMode );
m_settings->setValue("General/lang",languageCombo->currentData().toString()); m_settings->setValue("General/lang", languageCombo->currentData().toString());
m_song->refreshScroll(); m_song->refreshScroll();

View File

@ -29,13 +29,11 @@
#ifndef __GUIPREFERENCESDIALOG_H__ #ifndef __GUIPREFERENCESDIALOG_H__
#define __GUIPREFERENCESDIALOG_H__ #define __GUIPREFERENCESDIALOG_H__
#include <QtWidgets> #include <QtWidgets>
#include "Song.h" #include "Song.h"
#include "Settings.h" #include "Settings.h"
#include "ui_GuiPreferencesDialog.h" #include "ui_GuiPreferencesDialog.h"
class CGLView; class CGLView;

View File

@ -33,21 +33,17 @@
#include "TrackList.h" #include "TrackList.h"
#include "Conductor.h" #include "Conductor.h"
GuiSidePanel::GuiSidePanel(QWidget *parent, CSettings* settings) GuiSidePanel::GuiSidePanel(QWidget *parent, CSettings* settings)
: QWidget(parent), m_parent(parent) : QWidget(parent), m_parent(parent)
{ {
m_song = 0; m_song = nullptr;
m_score = 0; m_score = nullptr;
m_trackList = 0; m_trackList = nullptr;
m_topBar = 0; m_topBar = nullptr;
m_settings = settings; m_settings = settings;
setupUi(this); setupUi(this);
} }
void GuiSidePanel::init(CSong* songObj, CTrackList* trackList, GuiTopBar* topBar) void GuiSidePanel::init(CSong* songObj, CTrackList* trackList, GuiTopBar* topBar)
{ {
m_song = songObj; m_song = songObj;
@ -87,7 +83,6 @@ void GuiSidePanel::init(CSong* songObj, CTrackList* trackList, GuiTopBar* topBar
on_rhythmTappingCombo_activated(m_settings->value("SidePanel/rhythmTapping",0).toInt()); on_rhythmTappingCombo_activated(m_settings->value("SidePanel/rhythmTapping",0).toInt());
rhythmTappingCombo->setCurrentIndex(m_song->cfg_rhythmTapping); rhythmTappingCombo->setCurrentIndex(m_song->cfg_rhythmTapping);
repeatSong->setChecked(m_settings->value("SidePanel/repeatSong",false).toBool()); repeatSong->setChecked(m_settings->value("SidePanel/repeatSong",false).toBool());
connect(repeatSong,SIGNAL(stateChanged(int)),this,SLOT(on_repeatSong_released())); connect(repeatSong,SIGNAL(stateChanged(int)),this,SLOT(on_repeatSong_released()));
@ -110,9 +105,6 @@ void GuiSidePanel::init(CSong* songObj, CTrackList* trackList, GuiTopBar* topBar
connect(act, SIGNAL(triggered()), this, SLOT(clearTrackPart())); connect(act, SIGNAL(triggered()), this, SLOT(clearTrackPart()));
trackListWidget->setContextMenuPolicy(Qt::ActionsContextMenu); trackListWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
} }
void GuiSidePanel::refresh() { void GuiSidePanel::refresh() {
@ -124,7 +116,6 @@ void GuiSidePanel::refresh() {
trackListWidget->addItems(m_trackList->getAllChannelProgramNames()); trackListWidget->addItems(m_trackList->getAllChannelProgramNames());
trackListWidget->setCurrentRow(m_trackList->getActiveItemIndex()); trackListWidget->setCurrentRow(m_trackList->getActiveItemIndex());
for (int i = 0; i < trackListWidget->count(); i++) for (int i = 0; i < trackListWidget->count(); i++)
@ -264,7 +255,6 @@ void GuiSidePanel::updateTranslate(){
listActionsRetranslateUi[w]=m; listActionsRetranslateUi[w]=m;
} }
} }
// retranslate UI // retranslate UI
@ -289,7 +279,6 @@ void GuiSidePanel::updateTranslate(){
retranslateUi(this); retranslateUi(this);
// --- smart resize panel --- // // --- smart resize panel --- //
int maxDeltaWidth=0; int maxDeltaWidth=0;
this->setMaximumWidth(300); // default this->setMaximumWidth(300); // default
@ -310,7 +299,6 @@ void GuiSidePanel::updateTranslate(){
this->setMaximumWidth(300+maxDeltaWidth); this->setMaximumWidth(300+maxDeltaWidth);
} }
void GuiSidePanel::on_rhythmTappingCombo_activated (int index) void GuiSidePanel::on_rhythmTappingCombo_activated (int index)
{ {
m_settings->setValue("SidePanel/rhythmTapping",index); m_settings->setValue("SidePanel/rhythmTapping",index);

View File

@ -143,7 +143,6 @@ private slots:
autoSetMuteYourPart(); autoSetMuteYourPart();
} }
void on_rhythmTappingCombo_activated (int index); void on_rhythmTappingCombo_activated (int index);
void on_muteYourPartCheck_toggled (bool checked) void on_muteYourPartCheck_toggled (bool checked)
@ -169,7 +168,6 @@ private slots:
m_song->refreshScroll(); m_song->refreshScroll();
} }
void clearTrackPart() { void clearTrackPart() {
int row = trackListWidget->currentRow(); int row = trackListWidget->currentRow();
m_trackList->setActiveHandsIndex( -1, -1); m_trackList->setActiveHandsIndex( -1, -1);
@ -177,7 +175,6 @@ private slots:
m_song->refreshScroll(); m_song->refreshScroll();
} }
private: private:
void autoSetMuteYourPart(); void autoSetMuteYourPart();

View File

@ -33,13 +33,12 @@ GuiSongDetailsDialog::GuiSongDetailsDialog(QWidget *parent)
: QDialog(parent) : QDialog(parent)
{ {
setupUi(this); setupUi(this);
m_song = 0; m_song = nullptr;
m_settings = 0; m_settings = nullptr;
m_trackList = 0; m_trackList = nullptr;
setWindowTitle(tr("Song Details")); setWindowTitle(tr("Song Details"));
} }
void GuiSongDetailsDialog::init(CSong* song, CSettings* settings) void GuiSongDetailsDialog::init(CSong* song, CSettings* settings)
{ {
m_song = song; m_song = song;
@ -56,7 +55,6 @@ void GuiSongDetailsDialog::init(CSong* song, CSettings* settings)
} }
void GuiSongDetailsDialog::updateSongInfoText() void GuiSongDetailsDialog::updateSongInfoText()
{ {
QString str; QString str;
@ -79,7 +77,6 @@ void GuiSongDetailsDialog::updateSongInfoText()
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(activateOkButton); buttonBox->button(QDialogButtonBox::Ok)->setEnabled(activateOkButton);
} }
void GuiSongDetailsDialog::on_leftHandChannelCombo_activated (int index) void GuiSongDetailsDialog::on_leftHandChannelCombo_activated (int index)
{ {
updateSongInfoText(); updateSongInfoText();

View File

@ -29,13 +29,11 @@
#ifndef __GUISONGDETAILSDIALOG_H__ #ifndef __GUISONGDETAILSDIALOG_H__
#define __GUISONGDETAILSDIALOG_H__ #define __GUISONGDETAILSDIALOG_H__
#include <QtWidgets> #include <QtWidgets>
#include "Song.h" #include "Song.h"
#include "Settings.h" #include "Settings.h"
#include "ui_GuiSongDetailsDialog.h" #include "ui_GuiSongDetailsDialog.h"
class CGLView; class CGLView;

View File

@ -32,13 +32,12 @@
#include "TrackList.h" #include "TrackList.h"
#include "GuiLoopingPopup.h" #include "GuiLoopingPopup.h"
GuiTopBar::GuiTopBar(QWidget *parent, CSettings* settings) GuiTopBar::GuiTopBar(QWidget *parent, CSettings* settings)
: QWidget(parent), m_settings(settings) : QWidget(parent), m_settings(settings)
{ {
m_atTheEndOfTheSong = false; m_atTheEndOfTheSong = false;
m_song = 0; m_song = nullptr;
setupUi(this); setupUi(this);
parent->installEventFilter(this); parent->installEventFilter(this);
@ -206,7 +205,6 @@ void GuiTopBar::updateTranslate(){
retranslateUi(this); retranslateUi(this);
} }
void GuiTopBar::on_playButton_clicked(bool clicked) void GuiTopBar::on_playButton_clicked(bool clicked)
{ {
if (!m_song) return; if (!m_song) return;
@ -246,8 +244,6 @@ void GuiTopBar::on_startBarSpin_valueChanged(double bar)
m_song->setPlayFromBar( bar); m_song->setPlayFromBar( bar);
} }
void GuiTopBar::on_saveBarButton_clicked(bool clicked) void GuiTopBar::on_saveBarButton_clicked(bool clicked)
{ {
if (!m_song) return; if (!m_song) return;
@ -255,7 +251,6 @@ void GuiTopBar::on_saveBarButton_clicked(bool clicked)
startBarSpin->setValue(barNumber); startBarSpin->setValue(barNumber);
} }
void GuiTopBar::on_loopingBarsPopupButton_clicked(bool clicked) void GuiTopBar::on_loopingBarsPopupButton_clicked(bool clicked)
{ {
if (!m_song) return; if (!m_song) return;

View File

@ -74,7 +74,6 @@ private slots:
void on_saveBarButton_clicked(bool clicked); void on_saveBarButton_clicked(bool clicked);
void on_loopingBarsPopupButton_clicked(bool clicked); void on_loopingBarsPopupButton_clicked(bool clicked);
private: private:
bool eventFilter(QObject *obj, QEvent *event); bool eventFilter(QObject *obj, QEvent *event);
void reloadKeyCombo(bool major); void reloadKeyCombo(bool major);

View File

@ -28,9 +28,6 @@
#include "Merge.h" #include "Merge.h"
void CMerge::initMergedEvents() void CMerge::initMergedEvents()
{ {
int i; int i;
@ -42,16 +39,15 @@ void CMerge::initMergedEvents()
} }
} }
int CMerge::nextMergedEvent() int CMerge::nextMergedEvent()
{ {
int nearestIndex = 0; int nearestIndex = 0;
int i; int i;
CMidiEvent* nearestEvent; CMidiEvent* nearestEvent;
int deltaTime; int deltaTime;
nearestEvent = 0; nearestEvent = nullptr;
// find the first active slot // find the first active slot
for( i = 0; i < m_mergeEvents.size(); i++) for( i = 0; i < m_mergeEvents.size(); i++)
{ {
@ -62,7 +58,7 @@ int CMerge::nextMergedEvent()
break; break;
} }
} }
if (nearestEvent == 0) if (nearestEvent == nullptr)
return 0; return 0;
// now search the remaining active slots // now search the remaining active slots
@ -89,11 +85,10 @@ int CMerge::nextMergedEvent()
if (m_mergeEvents[i].type() != MIDI_NONE) if (m_mergeEvents[i].type() != MIDI_NONE)
m_mergeEvents[i].addDeltaTime( deltaTime ); m_mergeEvents[i].addDeltaTime( deltaTime );
} }
return nearestIndex; return nearestIndex;
} }
CMidiEvent CMerge::readMidiEvent() CMidiEvent CMerge::readMidiEvent()
{ {
int mergeIdx; int mergeIdx;

View File

@ -6,7 +6,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -32,9 +32,6 @@
#include "MidiDeviceFluidSynth.h" #include "MidiDeviceFluidSynth.h"
#endif #endif
CMidiDevice::CMidiDevice() CMidiDevice::CMidiDevice()
{ {
m_rtMidiDevice = new CMidiDeviceRt(); m_rtMidiDevice = new CMidiDeviceRt();
@ -54,10 +51,12 @@ CMidiDevice::~CMidiDevice()
#endif #endif
} }
void CMidiDevice::init() void CMidiDevice::init()
{ {
#if EXPERIMENTAL_USE_FLUIDSYNTH
m_fluidSynthMidiDevice->setQSettings(qsettings);
#endif
} }
QStringList CMidiDevice::getMidiPortList(midiType_t type) QStringList CMidiDevice::getMidiPortList(midiType_t type)
@ -108,29 +107,27 @@ bool CMidiDevice::openMidiPort(midiType_t type, QString portName)
void CMidiDevice::closeMidiPort(midiType_t type, int index) void CMidiDevice::closeMidiPort(midiType_t type, int index)
{ {
if (m_selectedMidiOutputDevice == 0) if (m_selectedMidiOutputDevice == nullptr)
return; return;
m_selectedMidiOutputDevice->closeMidiPort(type, index); m_selectedMidiOutputDevice->closeMidiPort(type, index);
m_selectedMidiOutputDevice = nullptr;
m_selectedMidiOutputDevice = 0;
} }
//! add a midi event to be played immediately //! add a midi event to be played immediately
void CMidiDevice::playMidiEvent(const CMidiEvent & event) void CMidiDevice::playMidiEvent(const CMidiEvent & event)
{ {
if (m_selectedMidiOutputDevice == 0) if (m_selectedMidiOutputDevice == nullptr)
return; return;
m_selectedMidiOutputDevice->playMidiEvent(event); m_selectedMidiOutputDevice->playMidiEvent(event);
//event.printDetails(); // useful for debugging //event.printDetails(); // useful for debugging
} }
// Return the number of events waiting to be read from the midi device // Return the number of events waiting to be read from the midi device
int CMidiDevice::checkMidiInput() int CMidiDevice::checkMidiInput()
{ {
if (m_selectedMidiInputDevice == 0) if (m_selectedMidiInputDevice == nullptr)
return 0; return 0;
return m_selectedMidiInputDevice->checkMidiInput(); return m_selectedMidiInputDevice->checkMidiInput();
@ -142,7 +139,6 @@ CMidiEvent CMidiDevice::readMidiInput()
return m_selectedMidiInputDevice->readMidiInput(); return m_selectedMidiInputDevice->readMidiInput();
} }
int CMidiDevice::midiSettingsSetStr(QString name, QString str) int CMidiDevice::midiSettingsSetStr(QString name, QString str)
{ {
if (m_selectedMidiOutputDevice) if (m_selectedMidiOutputDevice)

View File

@ -6,7 +6,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman and others, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -63,7 +63,6 @@ public:
virtual int midiSettingsGetInt(QString name); virtual int midiSettingsGetInt(QString name);
private: private:
CMidiDeviceBase* m_rtMidiDevice; CMidiDeviceBase* m_rtMidiDevice;
#if EXPERIMENTAL_USE_FLUIDSYNTH #if EXPERIMENTAL_USE_FLUIDSYNTH
CMidiDeviceBase* m_fluidSynthMidiDevice; CMidiDeviceBase* m_fluidSynthMidiDevice;

View File

@ -6,7 +6,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman and others, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -28,19 +28,16 @@
#ifndef __MIDI_DEVICE_BASE_H__ #ifndef __MIDI_DEVICE_BASE_H__
#define __MIDI_DEVICE_BASE_H__ #define __MIDI_DEVICE_BASE_H__
#include <QObject>
#include <QStringList> #include <QStringList>
#include <qsettings.h>
#include "Util.h" #include "Util.h"
#include "Cfg.h" #include "Cfg.h"
/*!
* @brief xxxxx.
*/
#include "MidiEvent.h" #include "MidiEvent.h"
class CMidiDeviceBase : public QObject
class CMidiDeviceBase
{ {
public: public:
virtual void init() = 0; virtual void init() = 0;
@ -62,12 +59,15 @@ public:
virtual QString midiSettingsGetStr(QString name) = 0; virtual QString midiSettingsGetStr(QString name) = 0;
virtual double midiSettingsGetNum(QString name) = 0; virtual double midiSettingsGetNum(QString name) = 0;
virtual int midiSettingsGetInt(QString name) = 0; virtual int midiSettingsGetInt(QString name) = 0;
void setQSettings(QSettings* settings) {qsettings = settings;}
//you should always have a virtual destructor when using virtual functions //you should always have a virtual destructor when using virtual functions
virtual ~CMidiDeviceBase() {}; virtual ~CMidiDeviceBase() {};
protected:
QSettings* qsettings = nullptr;
private: private:
}; };
#endif //__MIDI_DEVICE_H__ #endif //__MIDI_DEVICE_H__

99
src/MidiDeviceFluidSynth.cpp Normal file → Executable file
View File

@ -6,7 +6,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -28,15 +28,11 @@
#include "MidiDeviceFluidSynth.h" #include "MidiDeviceFluidSynth.h"
#include <QString>
#include <QDir>
#include <string>
CMidiDeviceFluidSynth::CMidiDeviceFluidSynth() CMidiDeviceFluidSynth::CMidiDeviceFluidSynth()
{ {
m_synth = 0; m_synth = nullptr;
m_fluidSettings = 0; m_fluidSettings = nullptr;
m_audioDriver = 0; m_audioDriver = nullptr;
m_rawDataIndex = 0; m_rawDataIndex = 0;
} }
@ -45,35 +41,24 @@ CMidiDeviceFluidSynth::~CMidiDeviceFluidSynth()
closeMidiPort(MIDI_OUTPUT, -1); closeMidiPort(MIDI_OUTPUT, -1);
} }
void CMidiDeviceFluidSynth::init() void CMidiDeviceFluidSynth::init()
{ {
} }
QStringList CMidiDeviceFluidSynth::getMidiPortList(midiType_t type) QStringList CMidiDeviceFluidSynth::getMidiPortList(midiType_t type)
{ {
if (type != MIDI_OUTPUT) // Only has an output if (type != MIDI_OUTPUT) // Only has an output
return QStringList(); return QStringList();
//debugSettings(("getSongList %s + %d", qPrintable(getCurrentBookName()), qPrintable(m_bookPath))); if (qsettings==nullptr)
QDir dirSoundFont("soundfont"); return QStringList();
dirSoundFont.setFilter(QDir::Files);
QStringList fileNames = dirSoundFont.entryList();
QStringList portNames; QStringList fontList = qsettings->value("FluidSynth/SoundFont").toStringList();
for (int i = 0; i < fileNames.size(); i++) if (fontList.size() > 0){
{ return QStringList(getFluidInternalName());
if ( fileNames.at(i).endsWith(".sf2", Qt::CaseInsensitive ) )
{
portNames += fileNames.at(i);
}
} }
return fontList;
return portNames;
} }
bool CMidiDeviceFluidSynth::openMidiPort(midiType_t type, QString portName) bool CMidiDeviceFluidSynth::openMidiPort(midiType_t type, QString portName)
@ -85,51 +70,47 @@ bool CMidiDeviceFluidSynth::openMidiPort(midiType_t type, QString portName)
if (type == MIDI_INPUT) if (type == MIDI_INPUT)
return false; return false;
if (!portName.endsWith(FLUID_NAME)) return false;
if (getMidiPortList(type).size()==0) return false; if (getMidiPortList(type).size()==0) return false;
/* Create the settings. */ // Load a SoundFont
QStringList fontList = qsettings->value("FluidSynth/SoundFont").toStringList();
if (fontList.size() == 0) return false;
// Create the settings.
m_fluidSettings = new_fluid_settings(); m_fluidSettings = new_fluid_settings();
/* Change the settings if necessary*/ // Change the settings if necessary
fluid_settings_setnum(m_fluidSettings, "synth.sample-rate", qsettings->value("FluidSynth/sampleRateCombo",22050).toInt());
fluid_settings_setint(m_fluidSettings, "audio.period-size", qsettings->value("FluidSynth/bufferSizeCombo", 128).toInt());
fluid_settings_setint(m_fluidSettings, "audio.periods", qsettings->value("FluidSynth/bufferCountCombo", 4).toInt());
fluid_settings_setnum(m_fluidSettings, (char *)"synth.sample-rate", 22050.0); #if defined (Q_OS_LINUX)
fluid_settings_setint(m_fluidSettings, "audio.periods", 5); fluid_settings_setstr(m_fluidSettings, "audio.driver", qsettings->value("FluidSynth/audioDriverCombo", "alsa").toString().toStdString().c_str());
fluid_settings_setint(m_fluidSettings, "audio.period-size", 128); #endif
fluid_settings_setstr(m_fluidSettings, "audio.alsa.device", "plughw:0"); // Create the synthesizer.
/* Create the synthesizer. */
m_synth = new_fluid_synth(m_fluidSettings); m_synth = new_fluid_synth(m_fluidSettings);
fluid_synth_set_reverb_on(m_synth, 0); fluid_synth_set_reverb_on(m_synth, 0);
fluid_synth_set_chorus_on(m_synth, 0); fluid_synth_set_chorus_on(m_synth, 0);
// Create the audio driver.
/* Create the audio driver. The synthesizer starts playing as soon
as the driver is created. */
m_audioDriver = new_fluid_audio_driver(m_fluidSettings, m_synth); m_audioDriver = new_fluid_audio_driver(m_fluidSettings, m_synth);
/* Load a SoundFont*/ QString pathName = fontList.at(0);
m_soundFontId = fluid_synth_sfload(m_synth, "FluidR3_GM.sf2", 0); ppLogDebug("Sound font %s", qPrintable(pathName));
//m_soundFontId = fluid_synth_sfload(m_synth, "VintageDreamsWaves-v2.sf2", 0); m_soundFontId = fluid_synth_sfload(m_synth, qPrintable(pathName), 0);
if (m_soundFontId == -1)
/* Select bank 0 and preset 0 in the SoundFont we just loaded on return false;
channel 0 */
//fluid_synth_program_select(m_synth, 0, m_soundFontId, 0, 0);
for (int channel = 0; channel < MAX_MIDI_CHANNELS ; channel++) for (int channel = 0; channel < MAX_MIDI_CHANNELS ; channel++)
{ {
//fluid_synth_program_select(m_synth, channel, m_soundFontId, 0, GM_PIANO_PATCH); fluid_synth_program_change(m_synth, channel, GM_PIANO_PATCH);
fluid_synth_program_change(m_synth, channel, GM_PIANO_PATCH);
} }
fluid_synth_set_gain(m_synth, 0.4); fluid_synth_set_gain(m_synth, qsettings->value("FluidSynth/masterGainSpin", 40).toFloat()/100.0f );
return true; return true;
} }
@ -138,14 +119,14 @@ void CMidiDeviceFluidSynth::closeMidiPort(midiType_t type, int index)
if (type != MIDI_OUTPUT) if (type != MIDI_OUTPUT)
return; return;
if (m_fluidSettings == 0) if (m_fluidSettings == nullptr)
return; return;
/* Clean up */ /* Clean up */
delete_fluid_audio_driver(m_audioDriver); delete_fluid_audio_driver(m_audioDriver);
delete_fluid_synth(m_synth); delete_fluid_synth(m_synth);
delete_fluid_settings(m_fluidSettings); delete_fluid_settings(m_fluidSettings);
m_fluidSettings = 0; m_fluidSettings = nullptr;
m_rawDataIndex = 0; m_rawDataIndex = 0;
} }
@ -153,11 +134,10 @@ void CMidiDeviceFluidSynth::closeMidiPort(midiType_t type, int index)
//! add a midi event to be played immediately //! add a midi event to be played immediately
void CMidiDeviceFluidSynth::playMidiEvent(const CMidiEvent & event) void CMidiDeviceFluidSynth::playMidiEvent(const CMidiEvent & event)
{ {
if (m_synth == nullptr)
if (m_synth == 0)
return; return;
unsigned int channel; int channel;
channel = event.channel() & 0x0f; channel = event.channel() & 0x0f;
@ -212,7 +192,6 @@ void CMidiDeviceFluidSynth::playMidiEvent(const CMidiEvent & event)
//event.printDetails(); // useful for debugging //event.printDetails(); // useful for debugging
} }
// Return the number of events waiting to be read from the midi device // Return the number of events waiting to be read from the midi device
int CMidiDeviceFluidSynth::checkMidiInput() int CMidiDeviceFluidSynth::checkMidiInput()
{ {
@ -226,8 +205,6 @@ CMidiEvent CMidiDeviceFluidSynth::readMidiInput()
return midiEvent; return midiEvent;
} }
int CMidiDeviceFluidSynth::midiSettingsSetStr(QString name, QString str) int CMidiDeviceFluidSynth::midiSettingsSetStr(QString name, QString str)
{ {
if (!m_fluidSettings) if (!m_fluidSettings)

View File

@ -6,7 +6,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -29,12 +29,10 @@
#ifndef __MIDI_DEVICE_FLUIDSYNTH_H__ #ifndef __MIDI_DEVICE_FLUIDSYNTH_H__
#define __MIDI_DEVICE_FLUIDSYNTH_H__ #define __MIDI_DEVICE_FLUIDSYNTH_H__
#include "MidiDeviceBase.h" #include "MidiDeviceBase.h"
#include <fluidsynth.h> #include <fluidsynth.h>
class CMidiDeviceFluidSynth : public CMidiDeviceBase class CMidiDeviceFluidSynth : public CMidiDeviceBase
{ {
virtual void init(); virtual void init();
@ -59,9 +57,13 @@ public:
CMidiDeviceFluidSynth(); CMidiDeviceFluidSynth();
~CMidiDeviceFluidSynth(); ~CMidiDeviceFluidSynth();
static QString getFluidInternalName()
{
return QString(tr("Internal Sound") + " " + FLUID_NAME );
}
private: private:
static constexpr const char* FLUID_NAME = "(FluidSynth)";
unsigned char m_savedRawBytes[40]; // Raw data is used for used for a SYSTEM_EVENT unsigned char m_savedRawBytes[40]; // Raw data is used for used for a SYSTEM_EVENT
unsigned int m_rawDataIndex; unsigned int m_rawDataIndex;
@ -69,8 +71,6 @@ private:
fluid_synth_t* m_synth; fluid_synth_t* m_synth;
fluid_audio_driver_t* m_audioDriver; fluid_audio_driver_t* m_audioDriver;
int m_soundFontId; int m_soundFontId;
}; };
#endif //__MIDI_DEVICE_FLUIDSYNTH_H__ #endif //__MIDI_DEVICE_FLUIDSYNTH_H__

View File

@ -28,7 +28,6 @@
#include "MidiDeviceRt.h" #include "MidiDeviceRt.h"
CMidiDeviceRt::CMidiDeviceRt() CMidiDeviceRt::CMidiDeviceRt()
{ {
try { try {
@ -47,7 +46,6 @@ CMidiDeviceRt::CMidiDeviceRt()
exit(1); exit(1);
} }
m_midiPorts[0] = -1; m_midiPorts[0] = -1;
m_midiPorts[1] = -1; m_midiPorts[1] = -1;
m_rawDataIndex = 0; m_rawDataIndex = 0;
@ -97,7 +95,6 @@ QStringList CMidiDeviceRt::getMidiPortList(midiType_t type)
portNameList << name; portNameList << name;
} }
return portNameList; return portNameList;
} }
@ -107,7 +104,6 @@ bool CMidiDeviceRt::openMidiPort(midiType_t type, QString portName)
QString name; QString name;
RtMidi* midiDevice; RtMidi* midiDevice;
if (portName.length() == 0) if (portName.length() == 0)
return false; return false;
@ -152,7 +148,6 @@ void CMidiDeviceRt::closeMidiPort(midiType_t type, int index)
m_midiout->closePort(); m_midiout->closePort();
} }
//! add a midi event to be played immediately //! add a midi event to be played immediately
void CMidiDeviceRt::playMidiEvent(const CMidiEvent & event) void CMidiDeviceRt::playMidiEvent(const CMidiEvent & event)
{ {
@ -218,7 +213,7 @@ void CMidiDeviceRt::playMidiEvent(const CMidiEvent & event)
default: default:
return; return;
break;
} }
m_midiout->sendMessage( &message ); m_midiout->sendMessage( &message );
@ -226,7 +221,6 @@ void CMidiDeviceRt::playMidiEvent(const CMidiEvent & event)
//event.printDetails(); // useful for debugging //event.printDetails(); // useful for debugging
} }
// Return the number of events waiting to be read from the midi device // Return the number of events waiting to be read from the midi device
int CMidiDeviceRt::checkMidiInput() int CMidiDeviceRt::checkMidiInput()
{ {
@ -242,7 +236,6 @@ CMidiEvent CMidiDeviceRt::readMidiInput()
CMidiEvent midiEvent; CMidiEvent midiEvent;
unsigned int channel; unsigned int channel;
if (Cfg::midiInputDump) if (Cfg::midiInputDump)
{ {
QString str; QString str;
@ -298,7 +291,6 @@ CMidiEvent CMidiDeviceRt::readMidiInput()
return midiEvent; return midiEvent;
} }
int CMidiDeviceRt::midiSettingsSetStr(QString name, QString str) int CMidiDeviceRt::midiSettingsSetStr(QString name, QString str)
{ {
return 0; return 0;

View File

@ -47,7 +47,6 @@
#define MIDI_ALL_SOUND_OFF 120 #define MIDI_ALL_SOUND_OFF 120
#define MIDI_ALL_NOTES_OFF 123 //0x7B channel mode message #define MIDI_ALL_NOTES_OFF 123 //0x7B channel mode message
// now define some of our own events // now define some of our own events
#define MIDI_NONE 0x0ff0 #define MIDI_NONE 0x0ff0
#define MIDI_ERROR 0x0ff1 #define MIDI_ERROR 0x0ff1
@ -82,11 +81,8 @@
#define METAKEYSIG 0x59 #define METAKEYSIG 0x59
#define METASEQEVENT 0x7F #define METASEQEVENT 0x7F
#define GM_PIANO_PATCH 0 // The default grand piano sound #define GM_PIANO_PATCH 0 // The default grand piano sound
/*! /*!
* @brief xxxxx. * @brief xxxxx.
*/ */
@ -292,7 +288,6 @@ public:
return r; return r;
} }
void printDetails() void printDetails()
{ {
if (type() == MIDI_NOTE_ON) { if (type() == MIDI_NOTE_ON) {
@ -316,5 +311,4 @@ private:
int m_duration; int m_duration;
}; };
#endif //__MIDI_EVENT_H__ #endif //__MIDI_EVENT_H__

View File

@ -26,7 +26,6 @@
int CMidiFile::m_ppqn = DEFAULT_PPQN; int CMidiFile::m_ppqn = DEFAULT_PPQN;
/* Read 16 bits from the Standard MIDI file */ /* Read 16 bits from the Standard MIDI file */
int CMidiFile::readWord(void) int CMidiFile::readWord(void)
{ {
@ -79,7 +78,6 @@ int CMidiFile::readHeader(void)
return i; return i;
} }
void CMidiFile::openMidiFile(string filename) void CMidiFile::openMidiFile(string filename)
{ {
if (m_file.is_open()) if (m_file.is_open())
@ -89,14 +87,14 @@ void CMidiFile::openMidiFile(string filename)
m_file.open(filename.c_str(), ios_base::in | ios_base::binary); m_file.open(filename.c_str(), ios_base::in | ios_base::binary);
if (m_file.fail() == true) if (m_file.fail() == true)
{ {
QMessageBox::warning(0, QMessageBox::tr("Midi File Error"), QMessageBox::warning(nullptr, QMessageBox::tr("Midi File Error"),
QMessageBox::tr("Cannot open \"%1\"").arg(QString(filename.c_str()))); QMessageBox::tr("Cannot open \"%1\"").arg(QString(filename.c_str())));
midiError(SMF_CANNOT_OPEN_FILE); midiError(SMF_CANNOT_OPEN_FILE);
return; return;
} }
rewind(); rewind();
if (getMidiError() != SMF_NO_ERROR) if (getMidiError() != SMF_NO_ERROR)
QMessageBox::warning(0, QMessageBox::tr("Midi File Error"), QMessageBox::warning(nullptr, QMessageBox::tr("Midi File Error"),
QMessageBox::tr("Midi file \"%1\" is corrupted").arg(QString(filename.c_str()))); QMessageBox::tr("Midi file \"%1\" is corrupted").arg(QString(filename.c_str())));
} }
@ -127,10 +125,10 @@ void CMidiFile::rewind()
} }
for (trk = 0; trk < arraySize(m_tracks); trk++) for (trk = 0; trk < arraySize(m_tracks); trk++)
{ {
if (m_tracks[trk]!= 0) if (m_tracks[trk]!= nullptr)
{ {
delete (m_tracks[trk]); delete (m_tracks[trk]);
m_tracks[trk] = 0; m_tracks[trk] = nullptr;
} }
} }
filePos = m_file.tellg(); filePos = m_file.tellg();
@ -160,7 +158,7 @@ bool CMidiFile::checkMidiEventFromStream(int streamIdx)
assert("streamIdx out of range"); assert("streamIdx out of range");
return false; return false;
} }
if (m_tracks[streamIdx] != 0 && m_tracks[streamIdx]->length() > 0) if (m_tracks[streamIdx] != nullptr && m_tracks[streamIdx]->length() > 0)
return true; return true;
return false; return false;
} }

View File

@ -42,7 +42,7 @@ int CMidiTrack::m_logLevel;
CMidiTrack::CMidiTrack(fstream& file, int no) :m_file(file), m_trackNumber(no) CMidiTrack::CMidiTrack(fstream& file, int no) :m_file(file), m_trackNumber(no)
{ {
m_trackEventQueue = 0; m_trackEventQueue = nullptr;
m_savedRunningStatus = 0; m_savedRunningStatus = 0;
m_trackLengthCounter = 0; m_trackLengthCounter = 0;
m_deltaTime = 0; m_deltaTime = 0;
@ -51,7 +51,7 @@ CMidiTrack::CMidiTrack(fstream& file, int no) :m_file(file), m_trackNumber(no)
for ( int chan = 0; chan <MAX_MIDI_CHANNELS; chan++ ) for ( int chan = 0; chan <MAX_MIDI_CHANNELS; chan++ )
{ {
m_noteOnEventPtr[chan] = 0; m_noteOnEventPtr[chan] = nullptr;
} }
int i; int i;
@ -75,8 +75,6 @@ CMidiTrack::CMidiTrack(fstream& file, int no) :m_file(file), m_trackNumber(no)
m_trackEventQueue = new CQueue<CMidiEvent>(m_trackLength/3); // The minimum bytes per event is 3 m_trackEventQueue = new CQueue<CMidiEvent>(m_trackLength/3); // The minimum bytes per event is 3
} }
void CMidiTrack::ppDebugTrack(int level, const char *msg, ...) void CMidiTrack::ppDebugTrack(int level, const char *msg, ...)
{ {
va_list ap; va_list ap;
@ -91,7 +89,6 @@ void CMidiTrack::ppDebugTrack(int level, const char *msg, ...)
fputc('\n', stdout); fputc('\n', stdout);
} }
dword_t CMidiTrack::readVarLen() dword_t CMidiTrack::readVarLen()
{ {
dword_t value; dword_t value;
@ -247,8 +244,6 @@ void CMidiTrack::readKeySignatureEvent()
CStavePos::setKeySignature(event.data1(), event.data2()); CStavePos::setKeySignature(event.data1(), event.data2());
} }
void CMidiTrack::readMetaEvent(byte_t type) void CMidiTrack::readMetaEvent(byte_t type)
{ {
string text; string text;
@ -368,7 +363,6 @@ void CMidiTrack::readMetaEvent(byte_t type)
} }
} }
void CMidiTrack::decodeSystemMessage( byte_t status, byte_t data1 ) void CMidiTrack::decodeSystemMessage( byte_t status, byte_t data1 )
{ {
switch ( status ) switch ( status )
@ -408,8 +402,7 @@ void CMidiTrack::noteOffEvent(CMidiEvent &event, int deltaTime, int channel, int
{ {
ppLogWarn("Missing note off duration Chan %d Note off %d", channel + 1, pitch); ppLogWarn("Missing note off duration Chan %d Note off %d", channel + 1, pitch);
} }
m_noteOnEventPtr[channel][pitch] = 0; m_noteOnEventPtr[channel][pitch] = nullptr;
event.noteOffEvent(deltaTime, channel, pitch, velocity); event.noteOffEvent(deltaTime, channel, pitch, velocity);

View File

@ -36,8 +36,6 @@
using namespace std; using namespace std;
typedef enum typedef enum
{ {
SMF_NO_ERROR, SMF_NO_ERROR,
@ -48,8 +46,6 @@ typedef enum
SMF_END_OF_FILE SMF_END_OF_FILE
} midiErrors_t; } midiErrors_t;
typedef unsigned char byte_t; typedef unsigned char byte_t;
typedef unsigned short word_t; typedef unsigned short word_t;
typedef unsigned long dword_t; typedef unsigned long dword_t;
@ -91,7 +87,6 @@ public:
static void setLogLevel(int level){m_logLevel = level;} static void setLogLevel(int level){m_logLevel = level;}
private: private:
void errorFail(midiErrors_t error) void errorFail(midiErrors_t error)
{ {
@ -104,7 +99,6 @@ private:
} }
void midiFailReset() { m_midiError = SMF_NO_ERROR;} void midiFailReset() { m_midiError = SMF_NO_ERROR;}
void ppDebugTrack(int level, const char *msg, ...); void ppDebugTrack(int level, const char *msg, ...);
byte_t readByte(void) byte_t readByte(void)
@ -123,7 +117,6 @@ private:
return c; return c;
} }
word_t readWord(void) word_t readWord(void)
{ {
word_t value; word_t value;
@ -156,7 +149,6 @@ private:
void decodeSystemMessage( byte_t status, byte_t data1 ); void decodeSystemMessage( byte_t status, byte_t data1 );
void noteOffEvent(CMidiEvent &event, int deltaTime, int channel, int pitch, int velocity); void noteOffEvent(CMidiEvent &event, int deltaTime, int channel, int pitch, int velocity);
void createNoteEventPtr(int channel) void createNoteEventPtr(int channel)
{ {
if (m_noteOnEventPtr[channel] == 0) if (m_noteOnEventPtr[channel] == 0)

View File

@ -26,11 +26,9 @@
*/ */
/*********************************************************************************/ /*********************************************************************************/
#include "Notation.h" #include "Notation.h"
#include "Cfg.h" #include "Cfg.h"
#define OPTION_DEBUG_NOTATION 0 #define OPTION_DEBUG_NOTATION 0
#if OPTION_DEBUG_NOTATION #if OPTION_DEBUG_NOTATION
#define ppDEBUG_NOTATION(args) ppLogDebug args #define ppDEBUG_NOTATION(args) ppLogDebug args
@ -38,7 +36,6 @@
#define ppDEBUG_NOTATION(args) #define ppDEBUG_NOTATION(args)
#endif #endif
#define MERGESLOT_NOTE_INDEX 0 #define MERGESLOT_NOTE_INDEX 0
#define MERGESLOT_BEATMARK_INDEX 1 #define MERGESLOT_BEATMARK_INDEX 1
@ -193,7 +190,7 @@ accidentalModifer_t CNotation::detectSuppressedNatural(int note)
} }
if (pBackLink) if (pBackLink)
{ {
pNoteState->setBackLink(0); pNoteState->setBackLink(nullptr);
pBackLink->setBarChange(-1); // this prevents further suppression on the original note pBackLink->setBarChange(-1); // this prevents further suppression on the original note
} }
@ -212,7 +209,6 @@ void CNotation::setupNotationParamaters()
cfg_param[NOTATE_semibreveBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN*4 + 10); cfg_param[NOTATE_semibreveBoundary] = CMidiFile::ppqnAdjust(DEFAULT_PPQN*4 + 10);
} }
void CNotation::calculateScoreNoteLength() void CNotation::calculateScoreNoteLength()
{ {
if (!Cfg::experimentalNoteLength) if (!Cfg::experimentalNoteLength)

View File

@ -37,7 +37,6 @@
#include "Chord.h" #include "Chord.h"
#include "Bar.h" #include "Bar.h"
#define MAX_SYMBOLS 20 // The maximum number of symbols that can be stored in one slot #define MAX_SYMBOLS 20 // The maximum number of symbols that can be stored in one slot
class CSlot class CSlot
@ -79,7 +78,6 @@ public:
addSymbol(symbol); addSymbol(symbol);
} }
void transpose(int amount) void transpose(int amount)
{ {
for (int i = 0; i < m_length; i++) for (int i = 0; i < m_length; i++)
@ -152,7 +150,6 @@ public:
void setBackLink(CNoteState * link){m_backLink = link;} void setBackLink(CNoteState * link){m_backLink = link;}
CNoteState * getBackLink(){return m_backLink;} CNoteState * getBackLink(){return m_backLink;}
private: private:
int m_barChangeCounter; int m_barChangeCounter;
accidentalModifer_t m_accidentalState; accidentalModifer_t m_accidentalState;
@ -191,7 +188,6 @@ public:
void setChannel(int channel) {m_displayChannel = channel;} void setChannel(int channel) {m_displayChannel = channel;}
CSlot nextSlot(); CSlot nextSlot();
void midiEventInsert(CMidiEvent event); void midiEventInsert(CMidiEvent event);
@ -200,7 +196,6 @@ public:
static void setCourtesyAccidentals(bool setting){m_cfg_displayCourtesyAccidentals = setting;} static void setCourtesyAccidentals(bool setting){m_cfg_displayCourtesyAccidentals = setting;}
static bool displayCourtesyAccidentals(){return m_cfg_displayCourtesyAccidentals; } static bool displayCourtesyAccidentals(){return m_cfg_displayCourtesyAccidentals; }
private: private:
CSlot nextBeatMarker(); CSlot nextBeatMarker();
int nextMergeSlot(); int nextMergeSlot();
@ -211,7 +206,6 @@ private:
void calculateScoreNoteLength(); void calculateScoreNoteLength();
CQueue<CSlot>* m_slotQueue; // Queue of symbol slots that have not been read yet CQueue<CSlot>* m_slotQueue; // Queue of symbol slots that have not been read yet
CQueue<CMidiEvent>* m_midiInputQueue; // A Queue of midi events CQueue<CMidiEvent>* m_midiInputQueue; // A Queue of midi events
CSlot m_currentSlot; CSlot m_currentSlot;

View File

@ -38,7 +38,6 @@
static const float minNameGap = 14.0; static const float minNameGap = 14.0;
void CPiano::spaceNoteBunch(unsigned int bottomIndex, unsigned int topIndex) void CPiano::spaceNoteBunch(unsigned int bottomIndex, unsigned int topIndex)
{ {
unsigned int midPoint; unsigned int midPoint;
@ -110,7 +109,6 @@ void CPiano::drawPianoInputLines(CChord* chord, CColor color, int lineLength)
CStavePos stavePos; CStavePos stavePos;
for ( i = 0; i < chord->length(); i++) for ( i = 0; i < chord->length(); i++)
{ {
if (!m_rhythmTapping) if (!m_rhythmTapping)
@ -233,7 +231,6 @@ void CPiano::addPianistNote(whichPart_t part, CMidiEvent midiNote, bool good)
else else
m_badChord.addNote(part, note); m_badChord.addNote(part, note);
posY = stavePos.getPosYAccidental(); posY = stavePos.getPosYAccidental();
addNoteNameItem(posY, note, 0); addNoteNameItem(posY, note, 0);
} }

View File

@ -52,13 +52,11 @@ int main(int argc, char *argv[]){
QApplication app(argc, argv); QApplication app(argc, argv);
if (!QGLFormat::hasOpenGL()) { if (!QGLFormat::hasOpenGL()) {
QMessageBox::information(0, QMessageBox::tr("OpenGL support"), QMessageBox::information(nullptr, QMessageBox::tr("OpenGL support"),
QMessageBox::tr("This system does not support OpenGL which is needed to run Piano Booster.")); QMessageBox::tr("This system does not support OpenGL which is needed to run Piano Booster."));
return -1; return -1;
} }
QtWindow window; QtWindow window;
window.show(); window.show();
@ -67,4 +65,3 @@ int main(int argc, char *argv[]){
closeLogs(); closeLogs();
return value; return value;
} }

View File

@ -5,7 +5,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman and others, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -52,7 +52,6 @@ static int set_realtime_priority(int policy, int prio)
} }
#endif #endif
QtWindow::QtWindow() QtWindow::QtWindow()
{ {
m_settings = new CSettings(this); m_settings = new CSettings(this);
@ -73,9 +72,8 @@ QtWindow::QtWindow()
} }
for (int i = 0; i < MAX_RECENT_FILES; ++i) for (int i = 0; i < MAX_RECENT_FILES; ++i)
m_recentFileActs[i] = 0; m_recentFileActs[i] = nullptr;
m_separatorAct = 0; m_separatorAct = nullptr;
#if USE_REALTIME_PRIORITY #if USE_REALTIME_PRIORITY
int rt_prio = sched_get_priority_max(SCHED_FIFO); int rt_prio = sched_get_priority_max(SCHED_FIFO);
@ -88,7 +86,6 @@ QtWindow::QtWindow()
m_song = m_glWidget->getSongObject(); m_song = m_glWidget->getSongObject();
m_score = m_glWidget->getScoreObject(); m_score = m_glWidget->getScoreObject();
QHBoxLayout *mainLayout = new QHBoxLayout; QHBoxLayout *mainLayout = new QHBoxLayout;
QVBoxLayout *columnLayout = new QVBoxLayout; QVBoxLayout *columnLayout = new QVBoxLayout;
@ -133,7 +130,6 @@ QtWindow::QtWindow()
m_song->cfg_stopPointMode = static_cast<stopPointMode_t> (m_settings->value("Score/StopPointMode", m_song->cfg_stopPointMode ).toInt()); m_song->cfg_stopPointMode = static_cast<stopPointMode_t> (m_settings->value("Score/StopPointMode", m_song->cfg_stopPointMode ).toInt());
m_song->cfg_rhythmTapping = static_cast<rhythmTapping_t> (m_settings->value("Score/RtyhemTappingMode", m_song->cfg_rhythmTapping ).toInt()); m_song->cfg_rhythmTapping = static_cast<rhythmTapping_t> (m_settings->value("Score/RtyhemTappingMode", m_song->cfg_rhythmTapping ).toInt());
m_song->openMidiPort(CMidiDevice::MIDI_INPUT, midiInputName); m_song->openMidiPort(CMidiDevice::MIDI_INPUT, midiInputName);
m_song->openMidiPort(CMidiDevice::MIDI_OUTPUT,m_settings->value("Midi/Output").toString()); m_song->openMidiPort(CMidiDevice::MIDI_OUTPUT,m_settings->value("Midi/Output").toString());
@ -220,7 +216,7 @@ void QtWindow::decodeMidiFileArg(QString arg)
if (!fileInfo.exists() ) if (!fileInfo.exists() )
{ {
QMessageBox::warning(0, tr("PianoBooster Midi File Error"), QMessageBox::warning(nullptr, tr("PianoBooster Midi File Error"),
tr("Cannot open \"%1\"").arg(QString(fileInfo.absoluteFilePath()))); tr("Cannot open \"%1\"").arg(QString(fileInfo.absoluteFilePath())));
exit(1); exit(1);
} }
@ -228,7 +224,7 @@ void QtWindow::decodeMidiFileArg(QString arg)
fileInfo.fileName().endsWith(".midi", Qt::CaseInsensitive ) || fileInfo.fileName().endsWith(".midi", Qt::CaseInsensitive ) ||
fileInfo.fileName().endsWith(".kar", Qt::CaseInsensitive )) ) fileInfo.fileName().endsWith(".kar", Qt::CaseInsensitive )) )
{ {
QMessageBox::warning(0, tr("PianoBooster Midi File Error"), QMessageBox::warning(nullptr, tr("PianoBooster Midi File Error"),
tr("\"%1\" is not a Midi File").arg(QString(fileInfo.fileName()))); tr("\"%1\" is not a Midi File").arg(QString(fileInfo.fileName())));
exit(1); exit(1);
} }
@ -252,7 +248,7 @@ void QtWindow::decodeMidiFileArg(QString arg)
m_settings->setValue("CurrentSong", fileInfo.absoluteFilePath()); m_settings->setValue("CurrentSong", fileInfo.absoluteFilePath());
else else
{ {
QMessageBox::warning(0, tr("PianoBooster Midi File Error"), QMessageBox::warning(nullptr, tr("PianoBooster Midi File Error"),
tr("\"%1\" is not a valid Midi file").arg(QString(fileInfo.absoluteFilePath()))); tr("\"%1\" is not a valid Midi file").arg(QString(fileInfo.absoluteFilePath())));
exit(1); exit(1);
} }
@ -411,15 +407,12 @@ void QtWindow::createActions()
addShortcutAction("ShortCuts/NextBook", SLOT(on_nextBook())); addShortcutAction("ShortCuts/NextBook", SLOT(on_nextBook()));
addShortcutAction("ShortCuts/PreviousBook", SLOT(on_previousBook())); addShortcutAction("ShortCuts/PreviousBook", SLOT(on_previousBook()));
for (int i = 0; i < MAX_RECENT_FILES; ++i) { for (int i = 0; i < MAX_RECENT_FILES; ++i) {
m_recentFileActs[i] = new QAction(this); m_recentFileActs[i] = new QAction(this);
m_recentFileActs[i]->setVisible(false); m_recentFileActs[i]->setVisible(false);
connect(m_recentFileActs[i], SIGNAL(triggered()), connect(m_recentFileActs[i], SIGNAL(triggered()),
this, SLOT(openRecentFile())); this, SLOT(openRecentFile()));
} }
} }
void QtWindow::createMenus() void QtWindow::createMenus()
@ -467,9 +460,10 @@ void QtWindow::createMenus()
m_helpMenu->addAction(m_shortcutAct); m_helpMenu->addAction(m_shortcutAct);
m_helpMenu->addAction(m_aboutAct); m_helpMenu->addAction(m_aboutAct);
} }
void QtWindow::openRecentFile() void QtWindow::openRecentFile()
{ {
QAction *action = qobject_cast<QAction *>(sender()); QAction *action = qobject_cast<QAction *>(sender());
if (action) if (action)
m_settings->openSongFile(action->data().toString()); m_settings->openSongFile(action->data().toString());
} }
@ -503,7 +497,7 @@ void QtWindow::updateRecentFileActions()
for (int i = 0; i < numRecentFiles; ++i) { for (int i = 0; i < numRecentFiles; ++i) {
QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i])); QString text = tr("&%1 %2").arg(i + 1).arg(strippedName(files[i]));
if (m_recentFileActs[i] == 0) if (m_recentFileActs[i] == nullptr)
break; break;
m_recentFileActs[i]->setText(text); m_recentFileActs[i]->setText(text);
m_recentFileActs[i]->setData(files[i]); m_recentFileActs[i]->setData(files[i]);
@ -511,7 +505,7 @@ void QtWindow::updateRecentFileActions()
} }
for (int j = numRecentFiles; j < MAX_RECENT_FILES; ++j) { for (int j = numRecentFiles; j < MAX_RECENT_FILES; ++j) {
if (m_recentFileActs[j] == 0) if (m_recentFileActs[j] == nullptr)
break; break;
m_recentFileActs[j]->setVisible(false); m_recentFileActs[j]->setVisible(false);
} }
@ -662,7 +656,6 @@ void QtWindow::keyboardShortcuts()
msgBox.exec(); msgBox.exec();
} }
void QtWindow::open() void QtWindow::open()
{ {
m_glWidget->stopTimerEvent(); m_glWidget->stopTimerEvent();
@ -710,7 +703,6 @@ void QtWindow::closeEvent(QCloseEvent *event)
writeSettings(); writeSettings();
} }
void QtWindow::keyPressEvent ( QKeyEvent * event ) void QtWindow::keyPressEvent ( QKeyEvent * event )
{ {
if (event->text().length() == 0) if (event->text().length() == 0)
@ -771,8 +763,8 @@ void QtWindow::loadTutorHtml(const QString & name)
void QtWindow::refreshTranslate(){ void QtWindow::refreshTranslate(){
#ifndef NO_LANGS #ifndef NO_LANGS
QString appImagePath = qgetenv("APPIMAGE");
QString locale = m_settings->value("General/lang",QLocale::system().bcp47Name()).toString(); QString locale = m_settings->selectedLangauge();
qApp->removeTranslator(&translator); qApp->removeTranslator(&translator);
qApp->removeTranslator(&translatorMusic); qApp->removeTranslator(&translatorMusic);
@ -806,7 +798,7 @@ void QtWindow::refreshTranslate(){
QFile fileTestLocale(translationsDir); QFile fileTestLocale(translationsDir);
if (!fileTestLocale.exists()){ if (!fileTestLocale.exists()){
#if defined (Q_OS_LINUX) || defined (Q_OS_UNIX) #if defined (Q_OS_LINUX) || defined (Q_OS_UNIX)
translationsDir=QString(PREFIX)+"/"+QString(DATA_DIR)+"/translations/"; translationsDir=Util::dataDir()+"/translations/";
#endif #endif
#ifdef Q_OS_DARWIN #ifdef Q_OS_DARWIN
QApplication::applicationDirPath() + "/../Resources/translations/"; QApplication::applicationDirPath() + "/../Resources/translations/";
@ -825,16 +817,14 @@ void QtWindow::refreshTranslate(){
translatorMusic.load(QString("music_") + locale, QApplication::applicationDirPath()); translatorMusic.load(QString("music_") + locale, QApplication::applicationDirPath());
qApp->installTranslator(&translatorMusic); qApp->installTranslator(&translatorMusic);
// set translator for default widget's text (for example: QMessageBox's buttons) // set translator for default widget's text (for example: QMessageBox's buttons)
#ifdef __WIN32 #ifdef __WIN32
qtTranslator.load("qt_"+locale,translationsDir); qtTranslator.load("qt_"+locale, translationsDir);
#else #else
qtTranslator.load("qt_"+locale,QLibraryInfo::location(QLibraryInfo::TranslationsPath)); qtTranslator.load("qt_"+locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
#endif #endif
qApp->installTranslator(&qtTranslator); qApp->installTranslator(&qtTranslator);
// retranslate UI // retranslate UI
QList<QWidget*> l2 = this->findChildren<QWidget *>(); QList<QWidget*> l2 = this->findChildren<QWidget *>();
for (auto &w:l2){ for (auto &w:l2){

View File

@ -40,8 +40,6 @@
#include "GuiLoopingPopup.h" #include "GuiLoopingPopup.h"
#include "Settings.h" #include "Settings.h"
class CGLView; class CGLView;
class QAction; class QAction;
class QMenu; class QMenu;
@ -184,7 +182,6 @@ private:
QString strippedName(const QString &fullFileName); QString strippedName(const QString &fullFileName);
void refreshTranslate(); void refreshTranslate();
void displayUsage(); void displayUsage();
void createActions(); void createActions();
void createMenus(); void createMenus();

View File

@ -106,5 +106,3 @@ void CRating::calculateAccuracy()
} }
} }

View File

@ -72,8 +72,6 @@ private:
float m_factor; float m_factor;
CColor m_currentColor; CColor m_currentColor;
bool m_goodAccuracyFlag; bool m_goodAccuracyFlag;
}; };
#endif //__RATING_H__ #endif //__RATING_H__

View File

@ -35,7 +35,7 @@ CScore::CScore(CSettings* settings) : CDraw(settings)
{ {
size_t i; size_t i;
m_piano = new CPiano(settings); m_piano = new CPiano(settings);
m_rating = 0; m_rating = nullptr;
for (i=0; i< arraySize(m_scroll); i++) for (i=0; i< arraySize(m_scroll); i++)
{ {
m_scroll[i] = new CScroll(i, settings); m_scroll[i] = new CScroll(i, settings);
@ -242,6 +242,3 @@ void CScore::drawScore()
else else
glCallList(m_scoreDisplayListId); glCallList(m_scoreDisplayListId);
} }

View File

@ -26,8 +26,6 @@
*/ */
/*********************************************************************************/ /*********************************************************************************/
#ifndef _SCORE_H_ #ifndef _SCORE_H_
#define _SCORE_H_ #define _SCORE_H_
@ -35,7 +33,6 @@
#include "Piano.h" #include "Piano.h"
#include "Settings.h" #include "Settings.h"
class CScore : public CDraw class CScore : public CDraw
{ {
public: public:
@ -108,7 +105,6 @@ public:
m_scroll[m_activeScroll]->setPlayedNoteColor(note, color, wantedDelta, pianistTimming); m_scroll[m_activeScroll]->setPlayedNoteColor(note, color, wantedDelta, pianistTimming);
} }
void setActiveChannel(int channel) void setActiveChannel(int channel)
{ {
int newActiveSroll; int newActiveSroll;
@ -132,7 +128,6 @@ public:
m_scroll[m_activeScroll]->refresh(); m_scroll[m_activeScroll]->refresh();
} }
void setDisplayHand(whichPart_t hand) void setDisplayHand(whichPart_t hand)
{ {
CDraw::setDisplayHand(hand); CDraw::setDisplayHand(hand);
@ -146,7 +141,6 @@ public:
protected: protected:
CPiano* m_piano; CPiano* m_piano;
private: private:
CRating* m_rating; CRating* m_rating;
CScroll* m_scroll[MAX_MIDI_CHANNELS]; CScroll* m_scroll[MAX_MIDI_CHANNELS];

View File

@ -151,7 +151,6 @@ void CScroll::removeSlots()
} }
} }
//! Draw all the symbols that we have in the list //! Draw all the symbols that we have in the list
void CScroll::drawScrollingSymbols(bool show) void CScroll::drawScrollingSymbols(bool show)
{ {
@ -177,7 +176,6 @@ void CScroll::drawScrollingSymbols(bool show)
glPopMatrix(); glPopMatrix();
} }
void CScroll::scrollDeltaTime(int ticks) void CScroll::scrollDeltaTime(int ticks)
{ {
m_deltaHead -= ticks; m_deltaHead -= ticks;
@ -242,7 +240,6 @@ void CScroll::setPlayedNoteColor(int note, CColor color, int wantedDelta, int pi
compileSlot(m_scrollQueue->index(index)); compileSlot(m_scrollQueue->index(index));
} }
void CScroll::refresh() void CScroll::refresh()
{ {
int i; int i;
@ -324,7 +321,6 @@ void CScroll::showScroll(bool show)
if (m_symbolID == 0) if (m_symbolID == 0)
m_symbolID = glGenLists (1); m_symbolID = glGenLists (1);
// add in the missing GL display list // add in the missing GL display list
for ( i = 0; i < m_scrollQueue->length(); i++) for ( i = 0; i < m_scrollQueue->length(); i++)
{ {
@ -363,7 +359,6 @@ void CScroll::showScroll(bool show)
} }
} }
CScroll::CSlotDisplayList::CSlotDisplayList(const CSlot& slot, GLuint displayListId, GLuint nextDisplayListId) : CSlot(slot), CScroll::CSlotDisplayList::CSlotDisplayList(const CSlot& slot, GLuint displayListId, GLuint nextDisplayListId) : CSlot(slot),
m_displayListId(displayListId), m_nextDisplayListId(nextDisplayListId) m_displayListId(displayListId), m_nextDisplayListId(nextDisplayListId)
{ {

View File

@ -29,7 +29,6 @@
#ifndef __SCROLL_H__ #ifndef __SCROLL_H__
#define __SCROLL_H__ #define __SCROLL_H__
#include "Draw.h" #include "Draw.h"
#include "Song.h" #include "Song.h"
#include "Queue.h" #include "Queue.h"
@ -116,5 +115,4 @@ private:
float m_ppqnFactor; // if PulsesPerQuarterNote is 96 then the factor is 1.0 float m_ppqnFactor; // if PulsesPerQuarterNote is 96 then the factor is 1.0
}; };
#endif //__SCROLL_H__ #endif //__SCROLL_H__

View File

@ -5,7 +5,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman and others, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -49,6 +49,9 @@
#include "QtWindow.h" #include "QtWindow.h"
#include "version.txt" #include "version.txt"
#if EXPERIMENTAL_USE_FLUIDSYNTH
#include "MidiDeviceFluidSynth.h"
#endif
#define OPTION_DEBUG_SETTINGS 0 #define OPTION_DEBUG_SETTINGS 0
#if OPTION_DEBUG_SETTINGS #if OPTION_DEBUG_SETTINGS
@ -57,7 +60,6 @@
#define debugSettings(args) #define debugSettings(args)
#endif #endif
CSettings::CSettings(QtWindow *mainWindow) : QSettings(CSettings::IniFormat, CSettings::UserScope, "PianoBooster", "Piano Booster"), CSettings::CSettings(QtWindow *mainWindow) : QSettings(CSettings::IniFormat, CSettings::UserScope, "PianoBooster", "Piano Booster"),
m_mainWindow(mainWindow) m_mainWindow(mainWindow)
{ {
@ -71,15 +73,8 @@ CSettings::CSettings(QtWindow *mainWindow) : QSettings(CSettings::IniFormat, CSe
CNotation::setCourtesyAccidentals(value("Score/CourtesyAccidentals", false ).toBool()); CNotation::setCourtesyAccidentals(value("Score/CourtesyAccidentals", false ).toBool());
m_followThroughErrorsEnabled = value("Score/FollowThroughErrors", false ).toBool(); m_followThroughErrorsEnabled = value("Score/FollowThroughErrors", false ).toBool();
// load Fluid settings // load Fluid settings
setFluidSoundFontNames( value("FluidSynth/SoundFont").toStringList());
QString soundFontNames_1 = value("FluidSynth/SoundFont2_1","").toString();
if (!soundFontNames_1.isEmpty()) addFluidSoundFontName(soundFontNames_1);
QString soundFontNames_2 = value("FluidSynth/SoundFont2_2","").toString();
if (!soundFontNames_2.isEmpty()) addFluidSoundFontName(soundFontNames_2);
} }
void CSettings::setDefaultValue(const QString & key, const QVariant & value ) void CSettings::setDefaultValue(const QString & key, const QVariant & value )
@ -90,7 +85,6 @@ void CSettings::setDefaultValue(const QString & key, const QVariant & value )
setValue(key, value); setValue(key, value);
} }
void CSettings::init(CSong* song, GuiSidePanel* sidePanel, GuiTopBar* topBar) void CSettings::init(CSong* song, GuiSidePanel* sidePanel, GuiTopBar* topBar)
{ {
m_song = song; m_song = song;
@ -98,7 +92,6 @@ void CSettings::init(CSong* song, GuiSidePanel* sidePanel, GuiTopBar* topBar)
m_guiTopBar = topBar; m_guiTopBar = topBar;
} }
void CSettings::setNoteNamesEnabled(bool value) { void CSettings::setNoteNamesEnabled(bool value) {
m_noteNamesEnabled = value; m_noteNamesEnabled = value;
setValue("Score/NoteNames", value ); setValue("Score/NoteNames", value );
@ -115,7 +108,6 @@ void CSettings::setTutorPagesEnabled(bool value) {
updateTutorPage(); updateTutorPage();
} }
void CSettings::setCourtesyAccidentals(bool value) { void CSettings::setCourtesyAccidentals(bool value) {
CNotation::setCourtesyAccidentals(value); CNotation::setCourtesyAccidentals(value);
setValue("Score/CourtesyAccidentals", value ); setValue("Score/CourtesyAccidentals", value );
@ -186,7 +178,6 @@ void CSettings::loadSongSettings()
m_guiSidePanel->setCurrentHand(m_domSong.attribute("hand", "both" )); m_guiSidePanel->setCurrentHand(m_domSong.attribute("hand", "both" ));
m_guiTopBar->setSpeed(m_domSong.attribute("speed", "100" ).toInt()); m_guiTopBar->setSpeed(m_domSong.attribute("speed", "100" ).toInt());
// -1 means none and -2 means not set // -1 means none and -2 means not set
int left = m_domSong.attribute("leftHandMidiChannel", "-2").toInt(); int left = m_domSong.attribute("leftHandMidiChannel", "-2").toInt();
int right = m_domSong.attribute("rightHandMidiChannel", "-2").toInt(); int right = m_domSong.attribute("rightHandMidiChannel", "-2").toInt();
@ -195,7 +186,6 @@ void CSettings::loadSongSettings()
loadHandSettings(); loadHandSettings();
} }
void CSettings::saveSongSettings() void CSettings::saveSongSettings()
{ {
m_domSong.setAttribute("hand", partToHandString(m_song->getActiveHand())); m_domSong.setAttribute("hand", partToHandString(m_song->getActiveHand()));
@ -213,7 +203,6 @@ void CSettings::loadBookSettings()
m_currentSongName = lastSong; m_currentSongName = lastSong;
} }
void CSettings::saveBookSettings() void CSettings::saveBookSettings()
{ {
if (!m_currentBookName.isEmpty()) if (!m_currentBookName.isEmpty())
@ -224,7 +213,6 @@ void CSettings::saveBookSettings()
saveSongSettings(); saveSongSettings();
} }
void CSettings::loadXmlFile() void CSettings::loadXmlFile()
{ {
m_domDocument.documentElement().clear(); m_domDocument.documentElement().clear();
@ -288,7 +276,7 @@ void CSettings::updateTutorPage()
QString fileBase = fileInfo.absolutePath() + "/InfoPages/" + fileInfo.completeBaseName() + "_"; QString fileBase = fileInfo.absolutePath() + "/InfoPages/" + fileInfo.completeBaseName() + "_";
QString locale = value("General/lang",QLocale::system().bcp47Name()).toString(); QString locale = selectedLangauge();
if (m_tutorPagesEnabled) if (m_tutorPagesEnabled)
{ {
@ -321,7 +309,6 @@ void CSettings::updateTutorPage()
} }
} }
m_mainWindow->loadTutorHtml(QString()); m_mainWindow->loadTutorHtml(QString());
} }
void CSettings::openSongFile(const QString & filename) void CSettings::openSongFile(const QString & filename)
@ -366,7 +353,6 @@ QStringList CSettings::getSongList()
dirSongs.setFilter(QDir::Files); dirSongs.setFilter(QDir::Files);
QStringList fileNames = dirSongs.entryList(); QStringList fileNames = dirSongs.entryList();
QStringList songNames; QStringList songNames;
for (int i = 0; i < fileNames.size(); i++) for (int i = 0; i < fileNames.size(); i++)
{ {
@ -388,7 +374,6 @@ QStringList CSettings::getBookList()
return dirBooks.entryList(); return dirBooks.entryList();
} }
void CSettings::writeSettings() void CSettings::writeSettings()
{ {
@ -397,7 +382,6 @@ void CSettings::writeSettings()
saveXmlFile(); saveXmlFile();
} }
void CSettings::loadSettings() void CSettings::loadSettings()
{ {
unzipBoosterMusicBooks(); unzipBoosterMusicBooks();
@ -418,6 +402,8 @@ void CSettings::loadSettings()
// if (!songName.isEmpty()) // if (!songName.isEmpty())
// openSongFile( songName ); // openSongFile( songName );
setupDefaultSoundFont();
updateWarningMessages(); updateWarningMessages();
updateTutorPage(); updateTutorPage();
@ -428,7 +414,6 @@ void CSettings::unzipBoosterMusicBooks()
// Set default value // Set default value
const QString ZIPFILENAME("BoosterMusicBooks.zip"); const QString ZIPFILENAME("BoosterMusicBooks.zip");
if (value("PianoBooster/MusicRelease", 0).toInt() < MUSIC_RELEASE) if (value("PianoBooster/MusicRelease", 0).toInt() < MUSIC_RELEASE)
{ {
QString resourceDir = QApplication::applicationDirPath() + "/../music/"; QString resourceDir = QApplication::applicationDirPath() + "/../music/";
@ -442,7 +427,7 @@ void CSettings::unzipBoosterMusicBooks()
if (!QFile::exists(resourceDir + ZIPFILENAME)) if (!QFile::exists(resourceDir + ZIPFILENAME))
{ {
#if defined (Q_OS_LINUX) || defined (Q_OS_UNIX) #if defined (Q_OS_LINUX) || defined (Q_OS_UNIX)
resourceDir=QString(PREFIX)+"/"+QString(DATA_DIR)+"/music/"; resourceDir=Util::dataDir()+"/music/";
#endif #endif
#ifdef Q_OS_DARWIN #ifdef Q_OS_DARWIN
resourceDir = QApplication::applicationDirPath() + "/../Resources/music/"; resourceDir = QApplication::applicationDirPath() + "/../Resources/music/";
@ -452,7 +437,6 @@ void CSettings::unzipBoosterMusicBooks()
ppLogInfo(qPrintable("applicationDirPath=" + QApplication::applicationDirPath())); ppLogInfo(qPrintable("applicationDirPath=" + QApplication::applicationDirPath()));
ppLogTrace("resourceDir3 %s", qPrintable(resourceDir)); ppLogTrace("resourceDir3 %s", qPrintable(resourceDir));
QFileInfo zipFile(resourceDir + ZIPFILENAME); QFileInfo zipFile(resourceDir + ZIPFILENAME);
ppLogTrace("xx %s", qPrintable(zipFile.filePath())); ppLogTrace("xx %s", qPrintable(zipFile.filePath()));
@ -483,8 +467,6 @@ void CSettings::unzipBoosterMusicBooks()
return; return;
} }
QProcess unzip; QProcess unzip;
unzip.start("unzip", QStringList() << "-o" << zipFile.filePath() << "-d" << destMusicDir.path() ); unzip.start("unzip", QStringList() << "-o" << zipFile.filePath() << "-d" << destMusicDir.path() );
ppLogInfo(qPrintable("running unzip -o " + zipFile.filePath() + " -d " + destMusicDir.path()) ); ppLogInfo(qPrintable("running unzip -o " + zipFile.filePath() + " -d " + destMusicDir.path()) );
@ -498,7 +480,6 @@ void CSettings::unzipBoosterMusicBooks()
// the line is available in buf // the line is available in buf
} }
if (!unzip.waitForFinished()) if (!unzip.waitForFinished())
{ {
ppLogError("unzip failed"); ppLogError("unzip failed");
@ -562,3 +543,33 @@ void CSettings::updateWarningMessages()
m_warningMessage.clear(); m_warningMessage.clear();
} }
void CSettings::setupDefaultSoundFont(){
#if EXPERIMENTAL_USE_FLUIDSYNTH
if (getFluidSoundFontNames().empty() && !m_song->validMidiOutput())
{
QString appPath = qEnvironmentVariable("APPIMAGE");
if (appPath.isEmpty())
{
appPath = QApplication::applicationDirPath();
}
QDir directory(appPath);
directory.cd("SoundFont");
QStringList dirList = directory.entryList(QStringList(),QDir::AllEntries);
foreach(QString filename, dirList)
{
// Find the first sound fount file
if ( filename.endsWith(".sf2", Qt::CaseInsensitive ) )
{
setFluidSoundFontNames(directory.filePath(filename));
setValue("Midi/Output",CMidiDeviceFluidSynth::getFluidInternalName() );
setValue("LastSoundFontDir", directory.path());
saveSoundFontSettings();
m_song->openMidiPort(CMidiDevice::MIDI_OUTPUT, CMidiDeviceFluidSynth::getFluidInternalName());
break;
}
}
}
#endif
}

View File

@ -5,7 +5,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman and others, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -105,6 +105,14 @@ public:
{ {
return m_fluidSoundFontNames; return m_fluidSoundFontNames;
} }
void setFluidSoundFontNames(QStringList names)
{
m_fluidSoundFontNames = names;
}
void setFluidSoundFontNames(QString names)
{
m_fluidSoundFontNames = QStringList(names);
}
void addFluidSoundFontName(QString sfName) void addFluidSoundFontName(QString sfName)
{ {
m_fluidSoundFontNames.append(sfName); m_fluidSoundFontNames.append(sfName);
@ -113,6 +121,24 @@ public:
{ {
m_fluidSoundFontNames.removeAll(sfName); m_fluidSoundFontNames.removeAll(sfName);
} }
void clearFluidSoundFontNames()
{
m_fluidSoundFontNames.clear();
}
void saveSoundFontSettings()
{
setValue("FluidSynth/SoundFont", getFluidSoundFontNames());
}
// has a new sound fount been entered that is not the same as the old sound font
bool isNewSoundFontEntered()
{
if (getFluidSoundFontNames().isEmpty())
return false;
return getFluidSoundFontNames() != value("FluidSynth/SoundFont").toStringList();
}
void pianistActive() { m_pianistActive = true;} void pianistActive() { m_pianistActive = true;}
void setActiveHand(whichPart_t hand); void setActiveHand(whichPart_t hand);
@ -122,6 +148,14 @@ public:
QString getWarningMessage() {return m_warningMessage;} QString getWarningMessage() {return m_warningMessage;}
void updateWarningMessages(); void updateWarningMessages();
QString selectedLangauge() {
QString locale = value("General/lang","").toString();
if (locale.isEmpty()) {
locale = QLocale::system().bcp47Name();
}
return locale;
}
private: private:
Q_OBJECT Q_OBJECT
@ -137,7 +171,7 @@ private:
void loadXmlFile(); void loadXmlFile();
void saveXmlFile(); void saveXmlFile();
void setDefaultValue(const QString & key, const QVariant & value ); void setDefaultValue(const QString & key, const QVariant & value );
void setupDefaultSoundFont();
// returns either 'left' 'right' or 'both' // returns either 'left' 'right' or 'both'
const QString partToHandString(whichPart_t part) const QString partToHandString(whichPart_t part)
@ -168,7 +202,7 @@ private:
QString m_currentBookName; QString m_currentBookName;
QString m_currentSongName; QString m_currentSongName;
QString m_warningMessage; QString m_warningMessage;
QStringList m_fluidSoundFontNames; QStringList m_fluidSoundFontNames = QStringList();
bool m_pianistActive; bool m_pianistActive;
}; };

View File

@ -6,7 +6,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman and others, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -29,7 +29,6 @@
#include "Song.h" #include "Song.h"
#include "Score.h" #include "Score.h"
void CSong::init2(CScore * scoreWin, CSettings* settings) void CSong::init2(CScore * scoreWin, CSettings* settings)
{ {
@ -72,7 +71,6 @@ void CSong::loadSong(const QString & filename)
} }
// read the file ahead to collect info about the song first // read the file ahead to collect info about the song first
void CSong::midiFileInfo() void CSong::midiFileInfo()
{ {
@ -118,7 +116,6 @@ void CSong::setActiveHand(whichPart_t hand)
m_scoreWin->setDisplayHand(hand); m_scoreWin->setDisplayHand(hand);
} }
void CSong::setActiveChannel(int chan) void CSong::setActiveChannel(int chan)
{ {
this->CConductor::setActiveChannel(chan); this->CConductor::setActiveChannel(chan);
@ -165,7 +162,6 @@ eventBits_t CSong::task(int ticks)
{ {
realTimeEngine(ticks); realTimeEngine(ticks);
while (true) while (true)
{ {
if (m_reachedMidiEof == true) if (m_reachedMidiEof == true)
@ -196,7 +192,6 @@ eventBits_t CSong::task(int ticks)
// send the events to the other end // send the events to the other end
midiEventInsert(event); midiEventInsert(event);
if (event.type() == MIDI_PB_EOF) if (event.type() == MIDI_PB_EOF)
{ {
m_reachedMidiEof = true; m_reachedMidiEof = true;
@ -212,7 +207,6 @@ eventBits_t CSong::task(int ticks)
} }
else else
break; break;
} }
exitTask: exitTask:
@ -258,7 +252,6 @@ bool CSong::pcKeyPress(int key, bool down)
if (key == 't') // the tab key on the PC fakes good notes if (key == 't') // the tab key on the PC fakes good notes
{ {
if (down) if (down)
m_fakeChord = getWantedChord(); m_fakeChord = getWantedChord();
for (i = 0; i < m_fakeChord.length(); i++) for (i = 0; i < m_fakeChord.length(); i++)

View File

@ -76,8 +76,6 @@ public:
playMusic(true); playMusic(true);
} }
void setActiveHand(whichPart_t hand); void setActiveHand(whichPart_t hand);
whichPart_t getActiveHand(){return CNote::getActiveHand();} whichPart_t getActiveHand(){return CNote::getActiveHand();}
@ -86,13 +84,11 @@ public:
CTrackList* getTrackList() {return m_trackList;} CTrackList* getTrackList() {return m_trackList;}
void refreshScroll(); void refreshScroll();
QString getSongTitle() {return m_songTitle;} QString getSongTitle() {return m_songTitle;}
private: private:
void midiFileInfo(); void midiFileInfo();
CMidiFile * m_midiFile; CMidiFile * m_midiFile;
CFindChord m_findChord; CFindChord m_findChord;
bool m_reachedMidiEof; bool m_reachedMidiEof;

View File

@ -26,7 +26,6 @@
*/ */
/*********************************************************************************/ /*********************************************************************************/
#include "StavePosition.h" #include "StavePosition.h"
#include "Draw.h" #include "Draw.h"

View File

@ -88,7 +88,6 @@ public:
void notePos(whichPart_t hand, int midiNote); void notePos(whichPart_t hand, int midiNote);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//! @brief Sets which stave the note will appear on //! @brief Sets which stave the note will appear on
//! return The position on the stave. //! return The position on the stave.
@ -125,7 +124,7 @@ public:
// convert the midi note to the note name A B C D E F G // convert the midi note to the note name A B C D E F G
static staveLookup_t midiNote2Name(int midiNote); static staveLookup_t midiNote2Name(int midiNote);
static const staveLookup_t* getstaveLookupTable(int key); static const staveLookup_t* getstaveLookupTable(int key);
// do we show a sharp or a flat for this key signature // do we show a sharp or a flat for this key signature
// returns 0 = none, 1=sharp, -1 =flat, 2=natural (# Key) , -2=natural (b Key) // returns 0 = none, 1=sharp, -1 =flat, 2=natural (# Key) , -2=natural (b Key)
static int getStaveAccidental(int midiNote) static int getStaveAccidental(int midiNote)
@ -140,12 +139,11 @@ public:
if (accidentalDirection == 2) // A natural so change to above if (accidentalDirection == 2) // A natural so change to above
accidentalDirection = 1; accidentalDirection = 1;
else if (accidentalDirection == -2) // A natural so change to below else if (accidentalDirection == -2) // A natural so change to below
accidentalDirection = -1; accidentalDirection = -1;
return accidentalDirection; return accidentalDirection;
} }
private: private:
// fixme TODO This could be improved as the calculations could a done in the constructor // 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, int8_t m_staveIndex; // 0 central line, 5 = top line, -5 the bottom line,
@ -153,7 +151,6 @@ private:
float m_offsetY; float m_offsetY;
whichPart_t m_hand; whichPart_t m_hand;
static int m_KeySignature; static int m_KeySignature;
static int m_KeySignatureMajorMinor; static int m_KeySignatureMajorMinor;
static const staveLookup_t* m_staveLookUpTable; static const staveLookup_t* m_staveLookUpTable;

View File

@ -33,7 +33,6 @@
#include "Cfg.h" #include "Cfg.h"
#include "StavePosition.h" #include "StavePosition.h"
typedef enum typedef enum
{ {
PB_SYMBOL_none, PB_SYMBOL_none,
@ -49,7 +48,6 @@ typedef enum
PB_SYMBOL_playingZone, PB_SYMBOL_playingZone,
PB_SYMBOL_theEndMarker, PB_SYMBOL_theEndMarker,
PB_SYMBOL_noteHead, // ONLY ADD NOTES BELOW THIS MAKER PB_SYMBOL_noteHead, // ONLY ADD NOTES BELOW THIS MAKER
PB_SYMBOL_demisemiquaver, // Demisemiquaver / Thirty-second note PB_SYMBOL_demisemiquaver, // Demisemiquaver / Thirty-second note
PB_SYMBOL_semiquaver, // Semiquaver / Sixteenth note PB_SYMBOL_semiquaver, // Semiquaver / Sixteenth note
@ -61,7 +59,6 @@ typedef enum
} musicalSymbol_t; } musicalSymbol_t;
typedef enum { typedef enum {
PB_ACCIDENTAL_MODIFER_noChange, PB_ACCIDENTAL_MODIFER_noChange,
PB_ACCIDENTAL_MODIFER_suppress, PB_ACCIDENTAL_MODIFER_suppress,
@ -100,8 +97,6 @@ public:
m_hand = stavePos.getHand(); m_hand = stavePos.getHand();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//@brief Get the type of symbol //@brief Get the type of symbol
musicalSymbol_t getType(){return m_symbolType;} musicalSymbol_t getType(){return m_symbolType;}
@ -160,11 +155,9 @@ public:
return getStavePos().getAccidental(); return getStavePos().getAccidental();
} }
void setAccidentalModifer(accidentalModifer_t value) {m_accidentalModifer = value;} void setAccidentalModifer(accidentalModifer_t value) {m_accidentalModifer = value;}
accidentalModifer_t getAccidentalModifer() {return m_accidentalModifer;} accidentalModifer_t getAccidentalModifer() {return m_accidentalModifer;}
private: private:
void init() void init()
{ {
@ -190,8 +183,4 @@ private:
int m_total; // the number of the notes per hand; int m_total; // the number of the notes per hand;
}; };
#endif // _SYMBOL_H_ #endif // _SYMBOL_H_

View File

@ -26,13 +26,11 @@
*/ */
/*********************************************************************************/ /*********************************************************************************/
#include "Tempo.h" #include "Tempo.h"
int CTempo::m_cfg_followTempoAmount = 0; int CTempo::m_cfg_followTempoAmount = 0;
int CTempo::m_cfg_maxJumpAhead = 0; int CTempo::m_cfg_maxJumpAhead = 0;
void CTempo::enableFollowTempo(bool enable) void CTempo::enableFollowTempo(bool enable)
{ {
if (enable) if (enable)
@ -65,7 +63,3 @@ void CTempo::adjustTempo(int * ticks)
m_jumpAheadDelta = 0; m_jumpAheadDelta = 0;
} }
} }

View File

@ -46,7 +46,6 @@ public:
} }
void setSavedWantedChord(CChord * savedWantedChord) { m_savedWantedChord = savedWantedChord; } void setSavedWantedChord(CChord * savedWantedChord) { m_savedWantedChord = savedWantedChord; }
void reset() void reset()
{ {
// 120 beats per minute is the default // 120 beats per minute is the default
@ -89,18 +88,16 @@ public:
if (m_cfg_maxJumpAhead != 0) if (m_cfg_maxJumpAhead != 0)
m_jumpAheadDelta = ticks; m_jumpAheadDelta = ticks;
} }
void clearPlayingTicks() void clearPlayingTicks()
{ {
m_jumpAheadDelta = 0; m_jumpAheadDelta = 0;
} }
void adjustTempo(int * ticks); void adjustTempo(int * ticks);
static void enableFollowTempo(bool enable); static void enableFollowTempo(bool enable);
private: private:
float m_userSpeed; // controls the speed of the piece playing float m_userSpeed; // controls the speed of the piece playing
float m_midiTempo; // controls the speed of the piece playing float m_midiTempo; // controls the speed of the piece playing
@ -109,7 +106,6 @@ private:
static int m_cfg_followTempoAmount; static int m_cfg_followTempoAmount;
CChord *m_savedWantedChord; // A copy of the wanted chord complete with both left and right parts CChord *m_savedWantedChord; // A copy of the wanted chord complete with both left and right parts
}; };
#endif // __TEMPO_H__ #endif // __TEMPO_H__

View File

@ -49,7 +49,6 @@ public:
int midiChannel; int midiChannel;
}; };
class CTrackList : public QObject class CTrackList : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -69,7 +68,6 @@ public:
// Find an unused channel // Find an unused channel
int findFreeChannel(int startChannel); int findFreeChannel(int startChannel);
void currentRowChanged(int currentRow); void currentRowChanged(int currentRow);
void examineMidiEvent(CMidiEvent event); void examineMidiEvent(CMidiEvent event);
bool pianoPartConvetionTest(); bool pianoPartConvetionTest();

View File

@ -31,16 +31,14 @@
#include <stdarg.h> #include <stdarg.h>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <QTime>
#include "Util.h" #include "Util.h"
#include "Cfg.h" #include "Cfg.h"
#include <QTime>
static QTime s_realtime; static QTime s_realtime;
static FILE * logInfoFile = 0; static FILE * logInfoFile = nullptr;
static FILE * logErrorFile = 0; static FILE * logErrorFile = nullptr;
static bool logsOpened = false; static bool logsOpened = false;
@ -52,7 +50,7 @@ static void openLogFile() {
{ {
logInfoFile = fopen ("pb.log","w"); logInfoFile = fopen ("pb.log","w");
logErrorFile = logInfoFile; logErrorFile = logInfoFile;
if (logErrorFile == 0) if (logErrorFile == nullptr)
{ {
fputs("FATAL: cannot open the logfile", stderr); fputs("FATAL: cannot open the logfile", stderr);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -69,7 +67,6 @@ static void openLogFile() {
} }
} }
static void flushLogs() static void flushLogs()
{ {
if (logInfoFile != stdout && logsOpened) if (logInfoFile != stdout && logsOpened)
@ -167,7 +164,6 @@ void ppLogTrace(const char *msg, ...)
#endif #endif
} }
void ppLogDebug( const char *msg, ...) void ppLogDebug( const char *msg, ...)
{ {
va_list ap; va_list ap;
@ -213,8 +209,6 @@ void ppTiming(const char *msg, ...)
} }
////////////////////// BENCH MARK ////////////////////// ////////////////////// BENCH MARK //////////////////////
static QTime s_benchMarkTime; static QTime s_benchMarkTime;
static int s_previousTime; static int s_previousTime;
static int s_previousFrameTime; static int s_previousFrameTime;
@ -244,7 +238,6 @@ void benchMarkReset(benchData_t *pBench)
pBench->frameRatePrevious = pBench->frameRateCurrent; pBench->frameRatePrevious = pBench->frameRateCurrent;
} }
void benchMarkInit() void benchMarkInit()
{ {
s_benchMarkTime.start(); s_benchMarkTime.start();
@ -311,3 +304,18 @@ void benchMarkResults()
printResult(i, &s_benchData[i]); printResult(i, &s_benchData[i]);
} }
} }
// Returns the location of where the data is stored
// for an AppImage the dataDir is must be relative to the applicationDirPath
QString Util::dataDir() {
QString appImagePath = qgetenv("APPIMAGE");
if (appImagePath.isEmpty() )
return QString(PREFIX)+"/"+QString(DATA_DIR);
QString appImageInternalPath = QApplication::applicationDirPath();
int i = appImageInternalPath.lastIndexOf(PREFIX);
appImageInternalPath.truncate(i);
return (appImageInternalPath+QString(PREFIX)+"/"+QString(DATA_DIR));
}

View File

@ -6,7 +6,7 @@
@author L. J. Barman @author L. J. Barman
Copyright (c) 2008-2013, L. J. Barman, all rights reserved Copyright (c) 2008-2020, L. J. Barman and others, all rights reserved
This file is part of the PianoBooster application This file is part of the PianoBooster application
@ -32,6 +32,7 @@
#include <assert.h> #include <assert.h>
#include <string> #include <string>
#include <QString> #include <QString>
#include <QApplication>
using namespace std; using namespace std;
@ -51,8 +52,6 @@ typedef unsigned char byte;
#define ppDEBUG(args) ppLogDebug args #define ppDEBUG(args) ppLogDebug args
typedef enum typedef enum
{ {
PB_LOG_error, PB_LOG_error,
@ -71,7 +70,6 @@ void ppLogError(const char *msg, ...);
void ppTiming(const char *msg, ...); void ppTiming(const char *msg, ...);
void closeLogs(); void closeLogs();
#define SPEED_ADJUST_FACTOR 1000 #define SPEED_ADJUST_FACTOR 1000
#define deltaAdjust(delta) ((delta)/SPEED_ADJUST_FACTOR ) #define deltaAdjust(delta) ((delta)/SPEED_ADJUST_FACTOR )
@ -79,5 +77,9 @@ void benchMarkInit();
void benchMark(unsigned int id, QString message); void benchMark(unsigned int id, QString message);
void benchMarkResults(); void benchMarkResults();
class Util {
public:
static QString dataDir();
};
#endif //__UTIL_H__ #endif //__UTIL_H__