Experiments with the timer

git-svn-id: https://svn.code.sf.net/p/pianobooster/code/trunk@9 ba081f5d-443b-49a7-ac4b-446c3f91f371
This commit is contained in:
louisjb 2008-12-10 08:20:50 +00:00
parent 18d2c96bb6
commit 0972eadd59
7 changed files with 68 additions and 15 deletions

View File

@ -1,6 +1,31 @@
== REQUIREMENTS ==
You need a MIDI piano Keyboard and low latency General Midi compatible sound source.
If you don't have a MIDI keyboard you can still try out PianoBooster using the PC keyboard,
'x' is middle C.
The use of the Microsoft GS Wavetable software synthesizer that comes with Windows XP is not
recommended due the unacceptable delay (latency) that this introduces between pressing a note and hearing the sound.
MIDI files
To run PianoBooster you will need some Midi files preferably with right and left piano parts on channels 4 and 3.
Some Demo MIDI files that are compatible with PianoBooster are available on the pianobooster download page.
Executable for Linux
This executable has been tested on Ubuntu 7.10, Ubuntu Studio, Xandros for the EEEPC. The only dependency is QT4. If it does not work for you then try compiling from source.
* PianoBooster-linux-0.5.0.tgz
Executable for Windows
Just unzip the zip file. There is no installer. To run PianoBooster and Click on the pianobooster.exe a console
starts immediately but wait several seconds for the for the application to start. Note: there is a bug (windows only).
After opening the MIDI file using File Open for the first time, exit and restart Piano Booster then every thing should be OK.
* PianoBooster-win32-0.5.0.zip
== TO COMPILE THE SOURCE CODE ==
In the PianoBooster directory type "cd build" to change to the "build" directory
then type "cmake ../src", followed by "make".
There is no installer yet (the command "make install" has not been tested)
Ths source code is available from
See compliling.txt for instructions

View File

@ -76,7 +76,7 @@ SET( PIANOBOOSTER_RCS
)
# enable warnings
ADD_DEFINITIONS( -Wall )
ADD_DEFINITIONS( -Wall)
# by default only QtCore and QtGui modules are enabled
# other modules must be enabled like this:
@ -110,7 +110,9 @@ ADD_EXECUTABLE( pianobooster ${PIANOBOOSTER_SRCS} ${PIANOBOOSTER_MOC_SRCS}
${PIANOBOOSTER_UI_HDRS}
)
SET_TARGET_PROPERTIES(pianobooster PROPERTIES COMPILE_FLAGS -DHAS_SCORE=1)
SET_TARGET_PROPERTIES(pianobooster PROPERTIES COMPILE_FLAGS "-DHAS_SCORE=1 -Wall")
SET_TARGET_PROPERTIES(pianobooster PROPERTIES LINK_FLAGS "-mwindows")
# last thing we have to do is to tell CMake what libraries our executable needs,
# luckily FIND_PACKAGE prepared QT_LIBRARIES variable for us:

View File

@ -34,7 +34,7 @@
float Cfg::m_staveEndX;
int Cfg::debugLevel;
bool Cfg::smallScreen = true;
bool Cfg::smallScreen = false;
bool Cfg::quickStart = false;
int Cfg::m_appX;
int Cfg::m_appY;

View File

@ -49,6 +49,8 @@ CGLView::CGLView(Window *parent)
m_song = new CSong();
m_score = new CScore();
m_midiTicks = 0;
m_scrollTicks = 0;
}
CGLView::~CGLView()
@ -88,6 +90,9 @@ void CGLView::paintGL()
m_score->drawScore(m_fullRedrawFlag);
if (m_fullRedrawFlag)
drawTimeSignature();
m_scrollTicks = 0;
m_midiTicks += m_realtime.restart();
}
void CGLView::drawTimeSignature()
@ -199,9 +204,17 @@ void CGLView::resizeGL(int width, int height)
int space = height - (heightAboveStave + heightBelowStave + minTitleHeight + minStaveGap);
//m_titleHeight = qBound(minTitleHeight, minTitleHeight + space/2, 70);
m_titleHeight = 60;
// staveGap = qBound(minStaveGap, minStaveGap+ space/2, static_cast<int>(CStavePos::staveHeight() * 3));
staveGap = static_cast<int>(CStavePos::staveHeight() * 3);
if (Cfg::smallScreen)
{
staveGap = minStaveGap;
m_titleHeight = minTitleHeight;
}
else
{
staveGap = static_cast<int>(CStavePos::staveHeight() * 3);
m_titleHeight = 60;
}
maxSoreHeight = heightAboveStave + heightBelowStave + staveGap + m_titleHeight;
int sizeX = qMin(width, maxSoreWidth);
int sizeY = qMin(height, maxSoreHeight);
@ -274,10 +287,10 @@ void CGLView::init()
setFocusPolicy(Qt::ClickFocus);
//m_timer->start(5); // todo increase the tick time for Midi handling
//m_timer.start(12, this );
//m_realtime.start();
m_timer.start(5, this ); // was 5
m_realtime.start();
startMediaTimer(12, this );
//startMediaTimer(12, this );
}
@ -286,7 +299,13 @@ void CGLView::timerEvent(QTimerEvent *event)
int eventBits;
if (event->timerId() == m_timer.timerId())
{
eventBits = m_song->task(m_realtime.restart());
int ticks;
ticks = m_realtime.restart();
m_midiTicks += ticks;
m_scrollTicks += ticks;
eventBits = m_song->task(m_midiTicks);
//if (m_midiTicks >= 20) ppTrace("m_midiTicks = %d", m_midiTicks); //fixme
m_midiTicks = 0;
m_fullRedrawFlag = false;
if (eventBits != 0)
@ -299,7 +318,8 @@ void CGLView::timerEvent(QTimerEvent *event)
m_fullRedrawFlag = true; //fixme
#endif
// if m_fullRedrawFlag is true it will redraw the eniter GL window
glDraw();
//if (m_scrollTicks>= 12)
glDraw();
m_fullRedrawFlag = true;
}
else
@ -310,6 +330,7 @@ m_fullRedrawFlag = true; //fixme
void CGLView::mediaTimerEvent(int deltaTime)
{
/*
int eventBits;
eventBits = m_song->task(deltaTime);
@ -326,4 +347,5 @@ m_fullRedrawFlag = true; //fixme
// if m_fullRedrawFlag is true it will redraw the eniter GL window
glDraw();
m_fullRedrawFlag = true;
*/
}

View File

@ -71,6 +71,8 @@ private:
CScore* m_score;
QBasicTimer m_timer;
QTime m_realtime;
int m_midiTicks;
int m_scrollTicks;
CRating* m_rating;
QFont m_timeSigFont;
QFont m_timeRatingFont;

View File

@ -80,6 +80,8 @@ void CMidiFile::openMidiFile(string filename)
{
if (m_file.is_open())
m_file.close();
m_file.clear(); // clear any errors
m_file.open(filename.c_str(), ios_base::in | ios_base::binary);
if (m_file.fail() == true)
{

View File

@ -125,7 +125,7 @@ void Window::decodeCommandLine()
if (argList.at(i).startsWith("-d"))
Cfg::debugLevel++;
else if (argList.at(i).startsWith("-s"))
CStavePos::setStaveCentralOffset(60);
Cfg::smallScreen = true;
else if (argList.at(i).startsWith("-q"))
Cfg::quickStart = true;
else if (argList.at(i).startsWith("-h") || argList.at(i).startsWith("-?") ||argList.at(i).startsWith("--help"))