added --log --midi-input-dump formark.
git-svn-id: https://svn.code.sf.net/p/pianobooster/code/trunk@141 ba081f5d-443b-49a7-ac4b-446c3f91f371
This commit is contained in:
parent
c1de6bc5e2
commit
bc4f29f1ee
|
@ -40,6 +40,8 @@ int Cfg::m_appWidth;
|
||||||
int Cfg::m_appHeight;
|
int Cfg::m_appHeight;
|
||||||
bool Cfg::experimentalTempo = false;
|
bool Cfg::experimentalTempo = false;
|
||||||
bool Cfg::experimentalNoteLength = false;
|
bool Cfg::experimentalNoteLength = false;
|
||||||
|
bool Cfg::useLogFile = false;
|
||||||
|
bool Cfg::midiInputDump = false;
|
||||||
|
|
||||||
int Cfg::experimentalSwapInterval = -1;
|
int Cfg::experimentalSwapInterval = -1;
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,8 @@ public:
|
||||||
static bool experimentalTempo;
|
static bool experimentalTempo;
|
||||||
static bool experimentalNoteLength;
|
static bool experimentalNoteLength;
|
||||||
static int experimentalSwapInterval;
|
static int experimentalSwapInterval;
|
||||||
|
static bool useLogFile;
|
||||||
|
static bool midiInputDump;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static float m_staveEndX;
|
static float m_staveEndX;
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
#include "Cfg.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief xxxxx.
|
* @brief xxxxx.
|
||||||
*/
|
*/
|
||||||
|
@ -52,7 +54,7 @@ public:
|
||||||
|
|
||||||
virtual bool openMidiPort(midiType_t type, QString portName) = 0;
|
virtual bool openMidiPort(midiType_t type, QString portName) = 0;
|
||||||
virtual void closeMidiPort(midiType_t type, int index) = 0;
|
virtual void closeMidiPort(midiType_t type, int index) = 0;
|
||||||
|
|
||||||
// based on the fluid synth settings
|
// based on the fluid synth settings
|
||||||
virtual int midiSettingsSetStr(QString name, QString str) = 0;
|
virtual int midiSettingsSetStr(QString name, QString str) = 0;
|
||||||
virtual int midiSettingsSetNum(QString name, double val) = 0;
|
virtual int midiSettingsSetNum(QString name, double val) = 0;
|
||||||
|
|
|
@ -212,6 +212,15 @@ CMidiEvent CMidiDeviceRt::readMidiInput()
|
||||||
unsigned int channel;
|
unsigned int channel;
|
||||||
|
|
||||||
|
|
||||||
|
if (Cfg::midiInputDump)
|
||||||
|
{
|
||||||
|
QString str;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < m_inputMessage.size(); i++)
|
||||||
|
str += " 0x" + QString::number(m_inputMessage[i], 16) + ',';
|
||||||
|
ppLogInfo("midi input %s", qPrintable(str));
|
||||||
|
}
|
||||||
|
|
||||||
channel = m_inputMessage[0] & 0x0f;
|
channel = m_inputMessage[0] & 0x0f;
|
||||||
switch (m_inputMessage[0] & 0xf0 )
|
switch (m_inputMessage[0] & 0xf0 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -400,7 +400,7 @@ void CMidiTrack::noteOffEvent(CMidiEvent &event, int deltaTime, int channel, int
|
||||||
|
|
||||||
m_noteOnEventPtr[channel][pitch] = 0;
|
m_noteOnEventPtr[channel][pitch] = 0;
|
||||||
int duration = m_currentTime - noteOnEventPtr->getDuration();
|
int duration = m_currentTime - noteOnEventPtr->getDuration();
|
||||||
ppLogDebug ("NOTE OFF chan %d pitch %d currentTime %d Duration %d", channel + 1, pitch, m_currentTime, duration);
|
//ppLogDebug ("NOTE OFF chan %d pitch %d currentTime %d Duration %d", channel + 1, pitch, m_currentTime, duration);
|
||||||
noteOnEventPtr->setDuration(duration);
|
noteOnEventPtr->setDuration(duration);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -176,6 +176,9 @@ void QtWindow::displayUsage()
|
||||||
fprintf(stderr, " -L: Displays the note length (experimental)\n");
|
fprintf(stderr, " -L: Displays the note length (experimental)\n");
|
||||||
fprintf(stderr, " -h: --help: Displays this help message\n");
|
fprintf(stderr, " -h: --help: Displays this help message\n");
|
||||||
fprintf(stderr, " -v: Displays version number and then exits\n");
|
fprintf(stderr, " -v: Displays version number and then exits\n");
|
||||||
|
fprintf(stderr, " --log: write debug info to the \"pb.log\" log file\n");
|
||||||
|
fprintf(stderr, " --midi-input-dump: Displays the midi input in hex\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int QtWindow::decodeIntegerParam(QString arg, int defaultParam)
|
int QtWindow::decodeIntegerParam(QString arg, int defaultParam)
|
||||||
|
@ -252,6 +255,11 @@ void QtWindow::decodeCommandLine()
|
||||||
Cfg::quickStart = true;
|
Cfg::quickStart = true;
|
||||||
else if (arg.startsWith("-L"))
|
else if (arg.startsWith("-L"))
|
||||||
Cfg::experimentalNoteLength = true;
|
Cfg::experimentalNoteLength = true;
|
||||||
|
else if (arg.startsWith("--log"))
|
||||||
|
Cfg::useLogFile = true;
|
||||||
|
else if (arg.startsWith("--midi-input-dump"))
|
||||||
|
Cfg::midiInputDump = true;
|
||||||
|
|
||||||
else if (arg.startsWith("-X1"))
|
else if (arg.startsWith("-X1"))
|
||||||
Cfg::experimentalTempo = true;
|
Cfg::experimentalTempo = true;
|
||||||
else if (arg.startsWith("-Xswap"))
|
else if (arg.startsWith("-Xswap"))
|
||||||
|
|
|
@ -39,15 +39,40 @@
|
||||||
|
|
||||||
static QTime s_realtime;
|
static QTime s_realtime;
|
||||||
|
|
||||||
|
static FILE * logInfoFile = 0;
|
||||||
|
static FILE * logErrorFile = 0;
|
||||||
|
|
||||||
|
static void openLogFile() {
|
||||||
|
if (logInfoFile != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Cfg::useLogFile)
|
||||||
|
{
|
||||||
|
logInfoFile = fopen ("bp.log","w");
|
||||||
|
logErrorFile = logInfoFile;
|
||||||
|
if (logErrorFile == 0)
|
||||||
|
{
|
||||||
|
fputs("FATAL: cannot open the logfile", stderr);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logInfoFile = stdout;
|
||||||
|
logErrorFile = stderr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* prints an error message to stderr, and dies */
|
/* prints an error message to stderr, and dies */
|
||||||
void fatal(const char *msg, ...)
|
void fatal(const char *msg, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
openLogFile();
|
||||||
|
fputs("FATAL: ", logErrorFile);
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
vfprintf(stderr, msg, ap);
|
vfprintf(logErrorFile, msg, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fputc('\n', stderr);
|
fputc('\n', logErrorFile);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,11 +82,13 @@ void ppLog(logLevel_t level, const char *msg, ...)
|
||||||
if (Cfg::logLevel < level)
|
if (Cfg::logLevel < level)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
openLogFile();
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
vfprintf(stdout, msg, ap);
|
vfprintf(logInfoFile, msg, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fputc('\n', stdout);
|
fputc('\n', logInfoFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ppLogInfo(const char *msg, ...)
|
void ppLogInfo(const char *msg, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -70,12 +97,13 @@ void ppLogInfo(const char *msg, ...)
|
||||||
if (Cfg::logLevel < 1)
|
if (Cfg::logLevel < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fputs("Info: ", stdout);
|
openLogFile();
|
||||||
|
fputs("Info: ", logInfoFile);
|
||||||
|
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
vfprintf(stdout, msg, ap);
|
vfprintf(logInfoFile, msg, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fputc('\n', stdout);
|
fputc('\n', logInfoFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ppLogWarn(const char *msg, ...)
|
void ppLogWarn(const char *msg, ...)
|
||||||
|
@ -85,24 +113,26 @@ void ppLogWarn(const char *msg, ...)
|
||||||
if (Cfg::logLevel < 2)
|
if (Cfg::logLevel < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fputs("Warn: ", stdout);
|
openLogFile();
|
||||||
|
fputs("Warn: ", logInfoFile);
|
||||||
|
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
vfprintf(stdout, msg, ap);
|
vfprintf(logInfoFile, msg, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fputc('\n', stdout);
|
fputc('\n', logInfoFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ppLogTrace(const char *msg, ...)
|
void ppLogTrace(const char *msg, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
fputs("Trace: ", stdout);
|
openLogFile();
|
||||||
|
fputs("Trace: ", logInfoFile);
|
||||||
|
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
vfprintf(stdout, msg, ap);
|
vfprintf(logInfoFile, msg, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fputc('\n', stdout);
|
fputc('\n', logInfoFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,33 +143,36 @@ void ppLogDebug( const char *msg, ...)
|
||||||
if (Cfg::logLevel < 2)
|
if (Cfg::logLevel < 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fputs("Debug: ", stdout);
|
openLogFile();
|
||||||
|
fputs("Debug: ", logInfoFile);
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
vfprintf(stdout, msg, ap);
|
vfprintf(logInfoFile, msg, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fputc('\n', stdout);
|
fputc('\n', logInfoFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ppLogError(const char *msg, ...)
|
void ppLogError(const char *msg, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
fputs("ERROR: ", stdout);
|
openLogFile();
|
||||||
|
fputs("ERROR: ", logErrorFile);
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
vfprintf(stdout, msg, ap);
|
vfprintf(logErrorFile, msg, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fputc('\n', stdout);
|
fputc('\n', logErrorFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ppTiming(const char *msg, ...)
|
void ppTiming(const char *msg, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
|
openLogFile();
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
fprintf(stdout, "T %4d " , s_realtime.restart() );
|
fprintf(logInfoFile, "T %4d " , s_realtime.restart() );
|
||||||
vfprintf(stdout, msg, ap);
|
vfprintf(logInfoFile, msg, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fputc('\n', stdout);
|
fputc('\n', logInfoFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////// BENCH MARK //////////////////////
|
////////////////////// BENCH MARK //////////////////////
|
||||||
|
@ -213,11 +246,13 @@ void printResult(int i, benchData_t *pBench)
|
||||||
{
|
{
|
||||||
if (pBench->deltaCount == 0)
|
if (pBench->deltaCount == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
openLogFile();
|
||||||
if (i>=0)
|
if (i>=0)
|
||||||
fprintf(stdout, "Bench%2d: ", i);
|
fprintf(logInfoFile, "Bench%2d: ", i);
|
||||||
else
|
else
|
||||||
fputs("Bench : ", stdout);
|
fputs("Bench : ", logInfoFile);
|
||||||
fprintf(stdout, "ct %4d, min %2d, avg %4.3f, max %2d frame %4.3f %s\n", pBench->deltaCount, pBench->minDelta,
|
fprintf(logInfoFile, "ct %4d, min %2d, avg %4.3f, max %2d frame %4.3f %s\n", pBench->deltaCount, pBench->minDelta,
|
||||||
static_cast<double>(pBench->deltaTotal)/pBench->deltaCount,
|
static_cast<double>(pBench->deltaTotal)/pBench->deltaCount,
|
||||||
pBench->maxDelta,
|
pBench->maxDelta,
|
||||||
(static_cast<double>(pBench->frameRateCurrent - pBench->frameRatePrevious))/pBench->deltaCount,
|
(static_cast<double>(pBench->frameRateCurrent - pBench->frameRatePrevious))/pBench->deltaCount,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user