work in progress

git-svn-id: https://svn.code.sf.net/p/pianobooster/code/trunk@73 ba081f5d-443b-49a7-ac4b-446c3f91f371
This commit is contained in:
louisjb 2009-10-17 11:19:13 +00:00
parent 1cda5c60e1
commit e6c21b417c
30 changed files with 346 additions and 172 deletions

View File

@ -30,7 +30,7 @@
#define OPTION_DEBUG_BAR 0
#if OPTION_DEBUG_BAR
#define ppDEBUG_BAR(args) ppDebug args
#define ppDEBUG_BAR(args) ppLogDebug args
#else
#define ppDEBUG_BAR(args)
#endif

View File

@ -72,17 +72,17 @@ IF(USE_FLUIDSYNTH)
MESSAGE("Building using fluidsynth")
SET( PB_BASE_SRCS MidiDeviceFluidSynth.cpp )
IF(FLUIDSYNTH_INPLACE_DIR)
INCLUDE_DIRECTORIES(${FLUIDSYNTH_INPLACE_DIR}/include/)
IF(WIN32)
LINK_LIBRARIES( ${FLUIDSYNTH_INPLACE_DIR}/src/.libs/libfluidsynth.dll.a)
ENDIF(WIN32)
IF(UNIX)
LINK_LIBRARIES(${FLUIDSYNTH_INPLACE_DIR}/src/.libs/libfluidsynth.so)
ENDIF(UNIX)
ELSEIF(FLUIDSYNTH_INPLACE_DIR)
LINK_LIBRARIES( fluidsynth)
ENDIF(FLUIDSYNTH_INPLACE_DIR)
IF(FLUIDSYNTH_INPLACE_DIR)
INCLUDE_DIRECTORIES(${FLUIDSYNTH_INPLACE_DIR}/include/)
IF(WIN32)
LINK_LIBRARIES( ${FLUIDSYNTH_INPLACE_DIR}/src/.libs/libfluidsynth.dll.a)
ENDIF(WIN32)
IF(UNIX)
LINK_LIBRARIES(${FLUIDSYNTH_INPLACE_DIR}/src/.libs/libfluidsynth.so)
ENDIF(UNIX)
ELSEIF(FLUIDSYNTH_INPLACE_DIR)
LINK_LIBRARIES( fluidsynth)
ENDIF(FLUIDSYNTH_INPLACE_DIR)
ENDIF(USE_FLUIDSYNTH)
@ -200,3 +200,20 @@ SET_TARGET_PROPERTIES(pianobooster PROPERTIES LINK_FLAGS "-mwindows")
IF (USE_PCH)
ADD_PRECOMPILED_HEADER( pianobooster ${CMAKE_CURRENT_SOURCE_DIR}/precompile/precompile.h )
ENDIF (USE_PCH)
INSTALL( FILES pianobooster.desktop DESTINATION share/applications )
INSTALL(TARGETS pianobooster RUNTIME DESTINATION bin)
#INSTALL( index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR kmidimon )
#INSTALL( FILES standards.ins DESTINATION ${DATA_INSTALL_DIR}/pianobooster
INSTALL ( FILES images/pianobooster.png DESTINATION share/pixmaps )
#/usr/games/pianobooster
#/usr/share/pixmaps/pianobooster.png
#/usr/share/applications/pianobooster.desktop
#/usr/share/doc/pianobooster/changelog.gz
#/usr/share/doc/pianobooster/copyright

View File

@ -40,7 +40,7 @@ int Cfg::m_appY;
int Cfg::m_appWidth;
int Cfg::m_appHeight;
bool Cfg::experimentalTempo = false;
bool Cfg::experimentalSwapInterval = false;
int Cfg::experimentalSwapInterval = -1;
const int Cfg::m_playZoneEarly = 25; // Was 25
const int Cfg::m_playZoneLate = 25;

View File

@ -137,7 +137,7 @@ public:
static bool smallScreen;
static bool quickStart;
static bool experimentalTempo;
static bool experimentalSwapInterval;
static int experimentalSwapInterval;
private:
static float m_staveEndX;

View File

@ -28,7 +28,7 @@
#define OPTION_DEBUG_CONDUCTOR 0
#if OPTION_DEBUG_CONDUCTOR
#define ppDEBUG_CONDUCTOR(args) ppDebug args
#define ppDEBUG_CONDUCTOR(args) ppLogDebug args
#else
#define ppDEBUG_CONDUCTOR(args)
#endif
@ -818,7 +818,7 @@ void CConductor::realTimeEngine(int mSecTicks)
else if (type == MIDI_PB_timeSignature)
{
m_bar.setTimeSig(m_nextMidiEvent.data1(), m_nextMidiEvent.data2());
ppDebug("Midi Time Signature %d/%d", m_nextMidiEvent.data1(),m_nextMidiEvent.data2());
ppLogDebug("Midi Time Signature %d/%d", m_nextMidiEvent.data1(),m_nextMidiEvent.data2());
}
else if ( type != MIDI_NONE ) // this marks the end of the piece of music
@ -845,7 +845,7 @@ void CConductor::realTimeEngine(int mSecTicks)
if (m_savedNoteOffQueue->space()>0)
m_savedNoteOffQueue->push(m_nextMidiEvent);
else
ppDebug("Warning the m_savedNoteOffQueue is full");
ppLogDebug("Warning the m_savedNoteOffQueue is full");
}
}
else

View File

@ -42,7 +42,7 @@ void CDraw::oneLine(float x1, float y1, float x2, float y2)
glVertex2f ((x1),(y1));
glVertex2f ((x2),(y2));
glEnd();
//ppTrace("oneLine %f %f %f %f", x1, y1, x2, y2);
//ppLogTrace("oneLine %f %f %f %f", x1, y1, x2, y2);
}
void CDraw::drawStaveExtentsion(CSymbol symbol, float x, int noteWidth, bool playable)
@ -269,8 +269,17 @@ void CDraw::checkAccidental(CSymbol symbol, float x, float y)
accidental = symbol.getStavePos().getAccidental();
if (symbol.getAccidentalModifer() == PB_ACCIDENTAL_MODIFER_suppress_accidental)
accidental = 0; // Suppress the accidental if it is the same bar
if (symbol.getAccidentalModifer() == PB_ACCIDENTAL_MODIFER_suppress)
accidental = 0; // Suppress the accidental if it is the same bar
if (symbol.getAccidentalModifer() == PB_ACCIDENTAL_MODIFER_force)
{
// Force the display of an accidental including naturals if it is the same bar
accidental = CStavePos::midiNote2Name(symbol.getNote()).accidental;
if (accidental == 0)
accidental = 2;
}
if (accidental != 0)
{
@ -409,7 +418,7 @@ void CDraw::drawSymbol(CSymbol symbol, float x, float y)
break;
case PB_SYMBOL_note:
//ppTrace("PB_SYMBOL_note x %f y %f", x, y);
//ppLogTrace("PB_SYMBOL_note x %f y %f", x, y);
if (!CChord::isNotePlayable(symbol.getNote(), 0))
{
colour = Cfg::noteColourDim();

View File

@ -53,7 +53,7 @@ CGLView::CGLView(Window* parent, CSettings* settings)
m_score = new CScore(m_settings);
m_midiTicks = 0;
m_scrollTicks = 0;
m_cfg_openGlOptimise = false;
m_cfg_openGlOptimise = true;
}
CGLView::~CGLView()

View File

@ -48,6 +48,7 @@ void GuiPreferencesDialog::init(CSong* song, CSettings* settings, CGLView * glVi
videoOptimiseCheck->setChecked(m_glView->m_cfg_openGlOptimise);
timingMarkersCheck->setChecked(m_song->cfg_timingMarkersFlag);
showNoteNamesCheck->setChecked(m_settings->isNoteNamesEnabled());
courtesyAccidentalsCheck->setChecked(m_settings->displayCourtesyAccidentals());
followStopPointCombo->addItem("Automatic (Recommended)");
followStopPointCombo->addItem("On the Beat");
followStopPointCombo->addItem("After the Beat");
@ -61,8 +62,10 @@ void GuiPreferencesDialog::accept()
m_song->cfg_timingMarkersFlag = timingMarkersCheck->isChecked();
m_settings->setValue("score/timingMarkers", m_song->cfg_timingMarkersFlag );
m_settings->setNoteNamesEnabled( showNoteNamesCheck->isChecked());
m_settings->setCourtesyAccidentals( courtesyAccidentalsCheck->isChecked());
m_song->cfg_stopPointMode = static_cast<stopPointMode_t> (followStopPointCombo->currentIndex());
m_settings->setValue("score/stopPointMode", m_song->cfg_stopPointMode );
m_song->refreshScroll();
this->QDialog::accept();
}

View File

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>332</width>
<height>239</height>
<width>362</width>
<height>267</height>
</rect>
</property>
<property name="windowTitle" >
@ -21,7 +21,7 @@
<layout class="QVBoxLayout" name="verticalLayout_3" >
<item>
<layout class="QGridLayout" name="gridLayout" >
<item row="1" column="0" >
<item row="2" column="0" >
<widget class="QCheckBox" name="timingMarkersCheck" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
@ -34,14 +34,14 @@
</property>
</widget>
</item>
<item row="2" column="0" >
<item row="3" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Follow stop point:</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<item row="3" column="1" >
<widget class="QComboBox" name="followStopPointCombo" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
@ -51,13 +51,13 @@
</property>
<property name="minimumSize" >
<size>
<width>150</width>
<width>100</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="1" column="1" >
<item row="2" column="1" >
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
@ -90,6 +90,13 @@
</property>
</spacer>
</item>
<item row="1" column="0" >
<widget class="QCheckBox" name="courtesyAccidentalsCheck" >
<property name="text" >
<string>Courtesy Accidentals</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -53,8 +53,8 @@ void GuiSidePanel::init(CSong* songObj, CTrackList* trackList, GuiTopBar* topBar
followYouRadio->setChecked(true);
bothHandsRadio->setChecked(true);
printf("left%d",leftHandRadio->isChecked());
printf("both%d",bothHandsRadio->isChecked());
ppLogTrace("left %d ",leftHandRadio->isChecked()); // fixme
ppLogTrace("both %d ",bothHandsRadio->isChecked());
boostSlider->setMinimum(-100);
boostSlider->setMaximum(100);

View File

@ -125,7 +125,7 @@ bool CMidiDeviceFluidSynth::openMidiPort(midiType_t type, QString portName)
{
//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_set_gain(m_synth, 0.4);
return true;
@ -176,7 +176,7 @@ void CMidiDeviceFluidSynth::playMidiEvent(const CMidiEvent & event)
case MIDI_CONTROL_CHANGE: //CONTROL_CHANGE:
fluid_synth_cc(m_synth, channel, event.data1(), event.data2());
//ppTrace("MIDI_CONTROL_CHANGE %d %d %d", channel, event.data1(), event.data2()); //fixme
//ppLogTrace("MIDI_CONTROL_CHANGE %d %d %d", channel, event.data1(), event.data2()); //fixme
break;
case MIDI_PROGRAM_CHANGE: //PROGRAM_CHANGE:
@ -228,50 +228,50 @@ CMidiEvent CMidiDeviceFluidSynth::readMidiInput()
int CMidiDeviceFluidSynth::midiSettingsSetStr(QString name, QString str)
{
if (!m_fluidSettings)
return 0;
if (!m_fluidSettings)
return 0;
return fluid_settings_setstr(m_fluidSettings, (char *)qPrintable(name), (char *)qPrintable(str));
return fluid_settings_setstr(m_fluidSettings, (char *)qPrintable(name), (char *)qPrintable(str));
}
int CMidiDeviceFluidSynth::midiSettingsSetNum(QString name, double val)
{
if (!m_fluidSettings)
return 0;
if (!m_fluidSettings)
return 0;
return fluid_settings_setnum(m_fluidSettings, (char *)qPrintable(name), val);
}
int CMidiDeviceFluidSynth::midiSettingsSetInt(QString name, int val)
{
if (!m_fluidSettings)
return 0;
if (!m_fluidSettings)
return 0;
return fluid_settings_setint(m_fluidSettings, (char *)qPrintable(name), val);
}
QString CMidiDeviceFluidSynth::midiSettingsGetStr(QString name)
{
char buffer[200];
if (!m_fluidSettings)
return QString();
//fluid_settings_getstr(m_fluidSettings, (char *)qPrintable(name), buffer );
return QString( buffer );
char buffer[200];
if (!m_fluidSettings)
return QString();
//fluid_settings_getstr(m_fluidSettings, (char *)qPrintable(name), buffer );
return QString( buffer );
}
double CMidiDeviceFluidSynth::midiSettingsGetNum(QString name)
{
if (!m_fluidSettings)
return 0.0;
double val;
if (!m_fluidSettings)
return 0.0;
double val;
fluid_settings_getnum(m_fluidSettings, (char *)qPrintable(name), &val);
return val;
}
int CMidiDeviceFluidSynth::midiSettingsGetInt(QString name)
{
if (!m_fluidSettings)
return 0;
int val = 0;
if (!m_fluidSettings)
return 0;
int val = 0;
fluid_settings_getint(m_fluidSettings, (char *)qPrintable(name),&val);
return val;
}

View File

@ -20,6 +20,8 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <QMessageBox>
#include "MidiFile.h"
int CMidiFile::m_ppqn = DEFAULT_PPQN;
@ -87,11 +89,15 @@ void CMidiFile::openMidiFile(string filename)
m_file.open(filename.c_str(), ios_base::in | ios_base::binary);
if (m_file.fail() == true)
{
ppError("Cannot open \"%s\"", filename.c_str());
QMessageBox::warning(0, "Midi File Error",
"Cannot open \"" + QString(filename.c_str()) + "\"");
midiError(SMF_CANNOT_OPEN_FILE);
return;
}
rewind();
if (getMidiError() != SMF_NO_ERROR)
QMessageBox::warning(0, "Midi File Error",
"Midi file\"" + QString(filename.c_str()) + "\" is corrupted");
}
void CMidiFile::rewind()
@ -110,13 +116,13 @@ void CMidiFile::rewind()
if (ntrks == 0)
{
midiError(SMF_CORRUPTED_MIDI_FILE);
ppError("Zero tracks in SMF file");
ppLogError("Zero tracks in SMF file");
return;
}
if (ntrks > arraySize(m_tracks))
{
midiError(SMF_ERROR_TOO_MANY_TRACK);
ppError("Too many tracks in SMF file");
ppLogError("Too many tracks in SMF file");
return;
}
for (trk = 0; trk < arraySize(m_tracks); trk++)
@ -134,8 +140,11 @@ void CMidiFile::rewind()
trackLength = m_tracks[trk]->init();
m_tracks[trk]->decodeTrack();
if (m_tracks[trk]->failed())
break;
{
midiError(m_tracks[trk]->getMidiError());
break;
}
//now move onto the next track
filePos += trackLength;
m_file.seekg (filePos, ios::beg);

View File

@ -65,6 +65,7 @@ public:
QString getSongTitle() {return m_songTitle;}
void setLogLevel(int level){CMidiTrack::setLogLevel(level);}
midiErrors_t getMidiError() { return m_midiError;}
private:
bool checkMidiEventFromStream(int streamIdx);

View File

@ -29,8 +29,9 @@
#include <stdarg.h>
#include "MidiTrack.h"
#include "Util.h"
#include "StavePosition.h"
#define OPTION_DEBUG_TRACK 1//fixme 0
#define OPTION_DEBUG_TRACK 0
#if OPTION_DEBUG_TRACK
#define ppDEBUG_TRACK(args) ppDebugTrack args
#else
@ -64,7 +65,7 @@ dword_t CMidiTrack::init()
{
if (m_file.get() !="MTrk"[i] )
{
ppError("No valid Midi tracks");
ppLogError("No valid Midi tracks");
errorFail(SMF_CORRUPTED_MIDI_FILE);
return 0;
}
@ -111,7 +112,7 @@ string CMidiTrack::readTextEvent()
length = readVarLen();
if (length >= 100)
{
ppError("Text Event too large %d", length);
ppLogError("Text Event too large %d", length);
errorFail(SMF_END_OF_FILE);
return text;
}
@ -216,7 +217,7 @@ void CMidiTrack::readKeySignatureEvent()
errorFail(SMF_CORRUPTED_MIDI_FILE);
return;
}
keySig = static_cast<char>(readByte()); // force sign converstion The key sig 0=middle C
keySig = static_cast<char>(readByte()); // force sign converstion The key sig 0=middle C
majorKey =readByte(); // Major or Minor
if (keySig >= 7 || keySig <= -7 )
{
@ -226,7 +227,9 @@ void CMidiTrack::readKeySignatureEvent()
event.metaEvent(readDelaTime(), MIDI_PB_keySignature, keySig, majorKey);
m_trackEventQueue->push(event);
ppDEBUG_TRACK((4,"Key Signature %d maj/min %d", keySig, majorKey));
ppDEBUG_TRACK((4,"Key Signature %d maj/min %d", keySig, majorKey));
if (CStavePos::getKeySignature() == NOT_USED)
CStavePos::setKeySignature(event.data1(), event.data2());
}
@ -295,8 +298,8 @@ void CMidiTrack::readMetaEvent(byte_t type)
break;
case METAKEYSIG: /* Key Signature */
readKeySignatureEvent();
break;
readKeySignatureEvent();
break;
case METATEXT: /* Text Event */
text = readTextEvent();
@ -476,7 +479,7 @@ void CMidiTrack::decodeTrack()
break;
if (m_trackEventQueue->space() <= 1)
{
ppError("Out of Space");
ppLogError("Out of Space");
break;
}
decodeMidiEvent();

View File

@ -87,6 +87,7 @@ public:
dword_t init();
void decodeTrack();
bool failed() { return (m_midiError != SMF_NO_ERROR) ? true : false;}
midiErrors_t getMidiError() { return m_midiError;}
int length() {return m_trackEventQueue->length();}
CMidiEvent pop() {return m_trackEventQueue->pop();}
@ -102,7 +103,7 @@ private:
{
m_midiError = error;
if (m_midiError != SMF_NO_ERROR)
ppError("Midi error %d", m_midiError);
ppLogError("Midi error %d", m_midiError);
}
}

View File

@ -30,6 +30,15 @@
#include "Notation.h"
#include "Cfg.h"
#define OPTION_DEBUG_NOTATION 0
#if OPTION_DEBUG_NOTATION
#define ppDEBUG_NOTATION(args) ppLogDebug args
#else
#define ppDEBUG_NOTATION(args)
#endif
#define MERGESLOT_NOTE_INDEX 0
#define MERGESLOT_BEATMARK_INDEX 1
@ -90,6 +99,8 @@ void CSlot::analyse()
}
}
bool CNotation::m_cfg_displayCourtesyAccidentals = false;
///////////////////////////////////////////////////////////////////////////
CSlot CNotation::nextBeatMarker()
@ -142,27 +153,52 @@ int CNotation::nextMergeSlot()
accidentalModifer_t CNotation::detectSuppressedNatural(int note)
{
accidentalModifer_t modifer = PB_ACCIDENTAL_MODIFER_noChange;
if (note <= 0 || note +1 >= MAX_MIDI_NOTES)
return PB_ACCIDENTAL_MODIFER_noChange;
if (note <= 0 || note +1 >= MAX_MIDI_NOTES)
return modifer;
while (m_earlyBarChangeDelta >= m_bar.getBarLength())
{
m_earlyBarChangeDelta -= m_bar.getBarLength();
accidentalModifer_t modifer = PB_ACCIDENTAL_MODIFER_noChange;
while (m_earlyBarChangeDelta >= m_bar.getBarLength())
{
m_earlyBarChangeDelta -= m_bar.getBarLength();
m_earlyBarChangeCounter++;
}
//int accidental = CStavePos::getStaveAccidental(note);
// check if this note has occured in this bar before
if (m_noteState[note].getBarChange() == m_earlyBarChangeCounter)
modifer = PB_ACCIDENTAL_MODIFER_suppress_accidental;
/*
if (m_noteState[note + 1].getBarChange() == m_earlyBarChangeCounter)
modifer = PB_ACCIDENTAL_MODIFER_above;
if (m_noteState[note - 1].getBarChange() == m_earlyBarChangeCounter)
modifer = PB_ACCIDENTAL_MODIFER_below;*/
m_noteState[note].setBarChange(m_earlyBarChangeCounter);
return modifer;
}
CNoteState * pNoteState = &m_noteState[note];
CNoteState * pBackLink = pNoteState->getBackLink();
int direction = -CStavePos::getStaveAccidentalDirection(note);
ppDEBUG_NOTATION(("Note %d %d %d", note, direction, pBackLink));
// check if this note has occured in this bar before
if (pNoteState->getBarChange() == m_earlyBarChangeCounter)
{
if (pBackLink)
{
ppDEBUG_NOTATION(("Force %d", note));
modifer = PB_ACCIDENTAL_MODIFER_force;
}
else if (direction != 0 && m_cfg_displayCourtesyAccidentals == false)
{
ppDEBUG_NOTATION(("Supress %d %d", note, direction));
modifer = PB_ACCIDENTAL_MODIFER_suppress;
}
}
if (direction != 0)
{
// we are display a accidental so force the note above (or below) to display
m_noteState[note + direction].setBackLink(pNoteState); // point back to this note
m_noteState[note + direction].setBarChange(m_earlyBarChangeCounter);
ppDEBUG_NOTATION(("setting backlink %d %d", note + direction, direction));
}
if (pBackLink)
{
pNoteState->setBackLink(0);
pBackLink->setBarChange(-1); // this prevents further suppression on the origianl note
}
pNoteState->setBarChange(m_earlyBarChangeCounter);
return modifer;
}
void CNotation::findNoteSlots()
@ -214,8 +250,8 @@ void CNotation::findNoteSlots()
CSymbol symbol(symbolType, hand, midi.note());
symbol.setColour(Cfg::noteColour());
// check if this note has occured in this bar before
symbol.setAccidentalModifer(detectSuppressedNatural(midi.note()));
// check if this note has occured in this bar before
symbol.setAccidentalModifer(detectSuppressedNatural(midi.note()));
if (m_currentSlot.addSymbol(symbol) == false) {
ppLogWarn("[%d] Over the Max symbols limit", m_displayChannel + 1); //fixme
@ -289,7 +325,7 @@ void CNotation::midiEventInsert(CMidiEvent event)
void CNotation::reset()
{
const int cfg_earlBarLead = CMidiFile::ppqnAdjust(8);
size_t i;
m_currentDeltaTime = 0;
m_midiInputQueue->clear();
@ -300,11 +336,11 @@ void CNotation::reset()
m_beatPerBarCounter=0;
m_earlyBarChangeCounter = 0;
m_earlyBarChangeDelta = cfg_earlBarLead; // We want to detect the bar change early
m_bar.reset();
m_findScrollerChord.reset();
for( i = 0; i < MAX_MIDI_NOTES; i++)
{
m_noteState[i].clear();
}
m_noteState[i].clear();
}
}

View File

@ -133,25 +133,30 @@ private:
class CNoteState
{
public:
CNoteState()
{
clear();
}
void clear()
{
m_barChangeCounter = 0;
m_accidentalState = PB_ACCIDENTAL_MODIFER_noChange;
m_noteLength = 0;
}
void setBarChange(int value){m_barChangeCounter = value;}
int getBarChange(){return m_barChangeCounter;}
void setAccidentalState(accidentalModifer_t value){m_accidentalState = value;}
accidentalModifer_t setAccidentalState(){return m_accidentalState;}
CNoteState()
{
clear();
}
void clear()
{
m_barChangeCounter = -1;
m_accidentalState = PB_ACCIDENTAL_MODIFER_noChange;
m_noteLength = 0;
m_backLink = 0;
}
void setBarChange(int value){m_barChangeCounter = value;}
int getBarChange(){return m_barChangeCounter;}
void setAccidentalState(accidentalModifer_t value){m_accidentalState = value;}
accidentalModifer_t getAccidentalState(){return m_accidentalState;}
void setBackLink(CNoteState * link){m_backLink = link;}
CNoteState * getBackLink(){return m_backLink;}
private:
int m_barChangeCounter;
accidentalModifer_t m_accidentalState;
int m_barChangeCounter;
accidentalModifer_t m_accidentalState;
int m_noteLength; // Used to determine the note length
CNoteState* m_backLink;
};
// Define a chord
@ -178,7 +183,11 @@ public:
CSlot nextSlot();
void midiEventInsert(CMidiEvent event);
int midiEventSpace() { return m_midiInputQueue->space();};
int midiEventSpace() { return m_midiInputQueue->space();}
static void setCourtesyAccidentals(bool setting){m_cfg_displayCourtesyAccidentals = setting;}
static bool displayCourtesyAccidentals(){return m_cfg_displayCourtesyAccidentals; }
private:
CSlot nextBeatMarker();
@ -199,7 +208,8 @@ private:
int m_displayChannel;
CFindChord m_findScrollerChord;
CBar m_bar;
CNoteState m_noteState[MAX_MIDI_NOTES];
CNoteState m_noteState[MAX_MIDI_NOTES];
static bool m_cfg_displayCourtesyAccidentals;
};
#endif // __NOTATION_H__

View File

@ -32,6 +32,7 @@ int main(int argc, char *argv[])
"This system does not support OpenGL which is needed to run Piano Booster.");
return -1;
}
Window window;
window.show();
return app.exec();

View File

@ -30,16 +30,6 @@
Window::Window()
{
decodeCommandLine();
if (Cfg::experimentalSwapInterval)
{
QGLFormat fmt;
fmt.setSwapInterval(100);
int value = fmt.swapInterval();
ppLogInfo("Open GL Swap Interval %d", value);
QGLFormat::setDefaultFormat(fmt);
}
QCoreApplication::setOrganizationName("PianoBooster");
@ -49,6 +39,18 @@ Window::Window()
setWindowIcon(QIcon(":/images/Logo32x32.png"));
setWindowTitle(tr("Piano Booster"));
decodeCommandLine();
if (Cfg::experimentalSwapInterval != -1)
{
QGLFormat fmt;
fmt.setSwapInterval(Cfg::experimentalSwapInterval);
int value = fmt.swapInterval();
ppLogInfo("Open GL Swap Interval %d", value);
QGLFormat::setDefaultFormat(fmt);
}
m_glWidget = new CGLView(this, m_settings);
m_song = m_glWidget->getSongObject();
@ -71,13 +73,6 @@ Window::Window()
m_song->init(m_score, m_settings);
m_glWidget->init();
/* fixme
// Set up gl display format
QGLFormat format = m_glWidget->format();
format.setSwapInterval(100);
m_glWidget->setFormat(format);
*/
m_sidePanel->init(m_song, m_song->getTrackList(), m_topBar);
m_topBar->init(m_song, m_song->getTrackList());
createActions();
@ -143,30 +138,78 @@ void Window::displayUsage()
fprintf(stderr, " -v: Displays version number and then exits\n");
}
int Window::decodeIntegerParam(QString arg, int defaultParam)
{
int n = arg.lastIndexOf('=');
if (n == -1 || (n + 1) >= arg.size())
return defaultParam;
bool ok;
int value = arg.mid(n+1).toInt(&ok);
if (ok)
return value;
return defaultParam;
}
void Window::decodeMidiFileArg(QString arg)
{
QFileInfo fileInfo(arg);
if (fileInfo.exists())
{
bool vaildMidiFile = true;
QFile file(fileInfo.absoluteFilePath());
if (!file.open(QIODevice::ReadOnly))
vaildMidiFile = false;
else
{
QByteArray bytes = file.read(4);
for (int i = 0; i < 4; i++)
{
if (bytes[i] !="MThd"[i] )
vaildMidiFile = false;
}
file.close();
}
if (vaildMidiFile == true)
m_settings->setValue("CurrentSong", fileInfo.absoluteFilePath());
else
ppLogError("Not a valid MIDI file \"%s\"\n", qPrintable(fileInfo.absoluteFilePath()) );
}
else
{
ppLogError("Cannot Open \"%s\"\n", qPrintable(fileInfo.absoluteFilePath()) );
exit(0);
}
}
void Window::decodeCommandLine()
{
bool hasMidiFile = false;
QStringList argList = QCoreApplication::arguments();
QString arg;
for (int i = 0; i < argList.size(); ++i)
{
if (argList.at(i).startsWith("-"))
arg = argList[i];
if (arg.startsWith("-"))
{
if (argList.at(i).startsWith("-d"))
if (arg.startsWith("-d"))
Cfg::logLevel++;
else if (argList.at(i).startsWith("-s"))
else if (arg.startsWith("-s"))
Cfg::smallScreen = true;
else if (argList.at(i).startsWith("-q"))
else if (arg.startsWith("-q"))
Cfg::quickStart = true;
else if (argList.at(i).startsWith("-X1"))
else if (arg.startsWith("-X1"))
Cfg::experimentalTempo = true;
else if (argList.at(i).startsWith("-X2"))
Cfg::experimentalSwapInterval = true;
else if (arg.startsWith("-Xswap"))
Cfg::experimentalSwapInterval = decodeIntegerParam(arg, 100);
else if (argList.at(i).startsWith("-h") || argList.at(i).startsWith("-?") ||argList.at(i).startsWith("--help"))
else if (arg.startsWith("-h") || arg.startsWith("-?") ||arg.startsWith("--help"))
{
displayUsage();
exit(0);
}
else if (argList.at(i).startsWith("-v"))
else if (arg.startsWith("-v"))
{
fprintf(stderr, "pianobooster Version " PB_VERSION"\n");
exit(0);
@ -178,6 +221,14 @@ void Window::decodeCommandLine()
exit(0);
}
}
else {
if ( hasMidiFile == false && i > 0)
{
hasMidiFile = true;
decodeMidiFileArg(arg);
}
}
}
}

View File

@ -117,6 +117,9 @@ protected:
private:
void decodeCommandLine();
int decodeIntegerParam(QString arg, int defaultParam);
void decodeMidiFileArg(QString arg);
void displayUsage();
void createActions();
void createMenus();

View File

@ -51,7 +51,7 @@ void CScroll::compileSlot(CSlotDisplayList info)
for (i=0; i < info.length(); i++)
{
stavePos.notePos(info.getSymbol(i).getHand(), info.getSymbol(i).getNote());
//ppTrace ("compileSlot len %d id %2d next %2d time %2d type %2d note %2d", info.length(), info.m_displayListId,
//ppLogTrace ("compileSlot len %d id %2d next %2d time %2d type %2d note %2d", info.length(), info.m_displayListId,
//info.m_nextDisplayListId, info.getDeltaTime(), info.getSymbol(i).getType(), info.getSymbol(i).getNote());
drawSymbol(info.getSymbol(i), 0.0, stavePos.getPosYRelative()); // we add this back when drawing this symbol
@ -134,7 +134,7 @@ void CScroll::removeSlots()
m_deltaTail += info.getDeltaTime() * SPEED_ADJUST_FACTOR;
//ppTrace("Remove slot id %2d time %2d type %2d note %2d", info.m_displayListId, info.getDeltaTime(), info.getSymbol(0).getType(), info.getSymbol(0).getNote());
//ppLogTrace("Remove slot id %2d time %2d type %2d note %2d", info.m_displayListId, info.getDeltaTime(), info.getSymbol(0).getType(), info.getSymbol(0).getNote());
if (info.m_displayListId)
glDeleteLists( info.m_displayListId, 1);

View File

@ -61,7 +61,8 @@ CSettings::CSettings(QWidget *mainWindow) : QSettings(CSettings::IniFormat, CSet
// It is all done in the initialisation list
m_advancedMode = false;
m_noteNamesEnabled = value("score/noteNames", false ).toBool();
m_noteNamesEnabled = value("score/noteNames", true ).toBool();
CNotation::setCourtesyAccidentals(value("score/courtesyAccidentals", false ).toBool());
}
void CSettings::init(CSong* song, GuiSidePanel* sidePanel, GuiTopBar* topBar)
@ -77,6 +78,10 @@ void CSettings::setNoteNamesEnabled(bool value) {
setValue("score/noteNames", value );
}
void CSettings::setCourtesyAccidentals(bool value) {
CNotation::setCourtesyAccidentals(value);
setValue("score/courtesyAccidentals", value );
}
// Open a document if it exists or else create it (also delete an duplicates
QDomElement CSettings::openDomElement(QDomElement parent, const QString & elementName, const QString & attributeName)
@ -136,7 +141,7 @@ void CSettings::loadSongSettings()
m_guiSidePanel->setCurrentHand(m_domSong.attribute("hand", "both" ));
// -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 right = m_domSong.attribute("rightHandMidiChannel", "-2").toInt();
@ -186,7 +191,7 @@ void CSettings::loadXmlFile()
if (file.open(QIODevice::ReadOnly))
{
if (!m_domDocument.setContent(&file)) {
ppError("Cannot setContent on XLM file");
ppLogError("Cannot setContent on XLM file");
}
file.close();
}
@ -214,7 +219,7 @@ void CSettings::saveXmlFile()
QFile file(m_bookPath + getCurrentBookName() + '/' + "pb.cfg");
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
ppError("Cannot save xml file %s", qPrintable(file.fileName()));
ppLogError("Cannot save xml file %s", qPrintable(file.fileName()));
return;
}

View File

@ -30,6 +30,7 @@
#include <QSettings>
#include <QDomDocument>
#include "Song.h"
#include "Notation.h"
class GuiSidePanel;
class GuiTopBar;
@ -45,9 +46,11 @@ public:
/// returns true if the users wants to see the note names
bool isNoteNamesEnabled() { return m_noteNamesEnabled; }
bool displayCourtesyAccidentals() { return CNotation::displayCourtesyAccidentals(); }
/// Saves in the .ini file whether the user wants to show the note names
void setNoteNamesEnabled(bool value);
void setNoteNamesEnabled(bool value);
void setCourtesyAccidentals(bool value);
void setAdvancedMode(bool value) { m_advancedMode = value;}
/// returns true if the users wants to see the note names

View File

@ -202,7 +202,7 @@ eventBits_t CSong::task(int ticks)
// Read the next events
CMidiEvent event = m_midiFile->readMidiEvent();
//ppTrace("Song event delta %d type 0x%x chan %d Note %d", event.deltaTime(), event.type(), event.channel(), event.note());
//ppLogTrace("Song event delta %d type 0x%x chan %d Note %d", event.deltaTime(), event.type(), event.channel(), event.note());
// Find the next chord
if (m_findChord.findChord(event, getActiveChannel(), PB_PART_both) == true)

View File

@ -56,7 +56,7 @@ void CStavePos::notePos(whichPart_t hand, int midiNote)
m_staveIndex += (midiNote/semitonesInAnOctive)*notesInAnOctive - notesInAnOctive*5 ;
m_accidental = lookUpItem->accidental;
//ppTrace("chan %d Note %2d - %2d (%d %d %d),\n", midiNote, m_staveIndex, m_accidental,
//ppLogTrace("chan %d Note %2d - %2d (%d %d %d),\n", midiNote, m_staveIndex, m_accidental,
//index%semitonesInAnOctive, lookUpItem->pianoNote, (midiNote/semitonesInAnOctive)*notesInAnOctive);
}
@ -90,7 +90,7 @@ void CStavePos::setKeySignature(int key, int majorMinor)
m_KeySignature = key;
m_KeySignatureMajorMinor = majorMinor;
if (key == NOT_USED)
key = 0;
key = 0;
m_staveLookUpTable = getstaveLookupTable(key);
CDraw::forceCompileRedraw();
}

View File

@ -39,6 +39,8 @@ typedef struct {
int accidental;
} staveLookup_t;
#define NOT_USED 0x7fffffff
#define MAX_STAVE_INDEX 16
#define MIN_STAVE_INDEX -16
@ -124,10 +126,23 @@ public:
static const staveLookup_t* getstaveLookupTable(int key);
// 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)
static int getStaveAccidental(int midiNote)
{
return m_staveLookUpTable[midiNote%12].accidental;
}
return m_staveLookUpTable[midiNote%12].accidental;
}
// returns 0 = none, 1=above, -1 =below, (a natural is either above or below)
static int getStaveAccidentalDirection(int midiNote)
{
int accidentalDirection = getStaveAccidental(midiNote);
if (accidentalDirection == 2) // A natural so change to above
accidentalDirection = 1;
else if (accidentalDirection == -2) // A natural so change to below
accidentalDirection = -1;
return accidentalDirection;
}
private:

View File

@ -33,7 +33,6 @@
#include "Cfg.h"
#include "StavePosition.h"
#define NOT_USED 0x7fffffff
typedef enum
{
@ -54,9 +53,9 @@ typedef enum
typedef enum {
PB_ACCIDENTAL_MODIFER_noChange,
PB_ACCIDENTAL_MODIFER_suppress_accidental,
PB_ACCIDENTAL_MODIFER_force_natural
PB_ACCIDENTAL_MODIFER_noChange,
PB_ACCIDENTAL_MODIFER_suppress,
PB_ACCIDENTAL_MODIFER_force // force a natural/accidental to be played
} accidentalModifer_t;
#define BEAT_MARKER_OFFSET 20 // used to ensure that beat markers are drawn under the note by drawing them early
@ -136,12 +135,12 @@ public:
//! @brief The accidental
//! return 0 = none, 1=sharp, -1 =flat, 2=natural.
int getAccidental() {
return getStavePos().getAccidental();
return getStavePos().getAccidental();
}
void setAccidentalModifer(accidentalModifer_t value) {m_accidentalModifer = value;}
accidentalModifer_t getAccidentalModifer() {return m_accidentalModifer;}
void setAccidentalModifer(accidentalModifer_t value) {m_accidentalModifer = value;}
accidentalModifer_t getAccidentalModifer() {return m_accidentalModifer;}
private:

View File

@ -93,7 +93,7 @@ void ppLogWarn(const char *msg, ...)
fputc('\n', stdout);
}
void ppTrace(const char *msg, ...)
void ppLogTrace(const char *msg, ...)
{
va_list ap;
@ -106,7 +106,7 @@ void ppTrace(const char *msg, ...)
}
void ppDebug( const char *msg, ...)
void ppLogDebug( const char *msg, ...)
{
va_list ap;
@ -117,11 +117,11 @@ void ppDebug( const char *msg, ...)
fputc('\n', stdout);
}
void ppError(const char *msg, ...)
void ppLogError(const char *msg, ...)
{
va_list ap;
fputs("Error: ", stdout);
fputs("ERROR: ", stdout);
va_start(ap, msg);
vfprintf(stdout, msg, ap);
va_end(ap);

View File

@ -45,7 +45,7 @@ typedef unsigned char byte;
#define arraySize(a) (sizeof(a)/sizeof(a[0])) /* Returns (at compile time) the number of elements in an array */
#define ppDEBUG(args) ppDebug args
#define ppDEBUG(args) ppLogDebug args
@ -58,12 +58,12 @@ typedef enum
} logLevel_t;
void fatal(const char *msg, ...);
void ppTrace(const char *msg, ...);
void ppDebug(const char *msg, ...);
void ppError(const char *msg, ...);
void ppLogTrace(const char *msg, ...);
void ppLogDebug(const char *msg, ...);
void ppLog(logLevel_t level, const char *msg, ...);
void ppLogInfo(const char *msg, ...);
void ppLogWarn(const char *msg, ...);
void ppLogError(const char *msg, ...);
void ppTiming(const char *msg, ...);
#define SPEED_ADJUST_FACTOR 1000

View File

@ -70,13 +70,13 @@ INCLUDEPATH += rtmidi
OBJECTS_DIR = tmp
win32 {
DEFINES += __WINDOWS_MM__ _WIN32
LIBS += $${FLUIDSYNTH_INPLACE_DIR}/src/.libs/libfluidsynth.dll.a libwinmm
DEFINES += __WINDOWS_MM__ _WIN32
LIBS += libwinmm
}
unix {
DEFINES += __LINUX_ALSASEQ__
LIBS += -lasound
DEFINES += __LINUX_ALSASEQ__
LIBS += -lasound
}
USE_FLUIDSYNTH {
@ -84,13 +84,14 @@ USE_FLUIDSYNTH {
SOURCES += MidiDeviceFluidSynth.cpp
!isEmpty(FLUIDSYNTH_INPLACE_DIR) {
!exists( $${FLUIDSYNTH_INPLACE_DIR}/include/fluidsynth.h ) {
error( "No $${FLUIDSYNTH_INPLACE_DIR}/include/fluidsynth.h file found" )
}
message(fluidsynth FLUIDSYNTH_INPLACE_DIR = $${FLUIDSYNTH_INPLACE_DIR})
INCLUDEPATH += $${FLUIDSYNTH_INPLACE_DIR}/include/
LIBS += $${FLUIDSYNTH_INPLACE_DIR}/src/.libs/libfluidsynth.a
!exists( $${FLUIDSYNTH_INPLACE_DIR}/include/fluidsynth.h ) {
error( "No $${FLUIDSYNTH_INPLACE_DIR}/include/fluidsynth.h file found" )
}
message(fluidsynth FLUIDSYNTH_INPLACE_DIR = $${FLUIDSYNTH_INPLACE_DIR})
INCLUDEPATH += $${FLUIDSYNTH_INPLACE_DIR}/include/
win32:LIBS += $${FLUIDSYNTH_INPLACE_DIR}/src/.libs/libfluidsynth.dll.a
unix:LIBS += $${FLUIDSYNTH_INPLACE_DIR}/src/.libs/libfluidsynth.a
}
}