37 , mCurrentlyPlaying(false)
39 , mPlayAgainAfterSuspend(false)
41 , mOverallTempoFactor(1)
43 , mMillisecondsPerTick(10)
44 , mTicksPerQuarterNote(100)
90 LOGMESSAGE <<
"Request for loading file" << filename;
91 if (filename.size() == 0)
return;
111 QString filename = URL.toLocalFile();
112 if (filename.endsWith(
".mid") or
113 filename.endsWith(
".MID") or
114 filename.endsWith(
".midi"))
116 else LOGMESSAGE <<
"No Midi file:" << filename;
130 LOGMESSAGE <<
"MidiPlayer: Set tempo factor to value" << factor;
145 LOGMESSAGE <<
"Setting progress in percent manually:" << percent;
247 for (quint8 command = 0xB0U; command < 0xC0U; command++)
249 LOGSTATUS <<
"signal Midi Event:" <<
"\t\t\t" 250 << QString::number(command,16) << QString::number(123,16) <<
"0";
341 LOGMESSAGE <<
"MidiPlayer load file:" << filename;
344 QFile file(filename);
345 if (not file.open(QIODevice::ReadOnly))
346 {
reportError(
"Cannot open Midi file "+filename);
return; }
348 QByteArray data = file.readAll();
360 if (autostart)
play();
361 const QStringList parts = filename.split(
"/");
362 const QString barefilename = parts.at(parts.size()-1);
414 if (event.command == 0xFFU)
416 double millisecondsPerQuarterNote = 256.0*
event.
byte1 +
event.byte2;
418 << millisecondsPerQuarterNote <<
"msec per quarter note";
427 if (event.command < 0xE0 or event.command >= 0xF0)
431 LOGSTATUS <<
"signal Midi Event:" <<
"\t\t\t" 432 << QString::number (event.command,16)
433 << QString::number (event.byte1,16)
434 << QString::number (event.byte2,16);
435 signalMidiEvent (QMidiMessage(event.command, event.byte1, event.byte2));
443 else {
pause();
return; }
451 LOGSTATUS <<
"Let the timer wait for" << milliseconds <<
"msec";
bool mPlayAgainAfterSuspend
Flag for playing after resume.
void resume()
Resume from suspend mode.
quint32 getCumulativeTime() const
Return time of actual event (zero if iterator is at the end of the list).
void play()
Start or resume playing.
void setModuleName(const QString &name)
Specify the name of the class-specific module.
void reportError(QString msg)
Report an error.
void rewind()
Rewind: Move the iterator of the event list to the beginning.
void receiveTempoData(bool smpte, double parameter)
Receive tempo data from the parser.
void setDisplayedMidiFilename(QVariant filename)
bool mTimerActive
Flag indicating that player is waiting for timeout.
double mOverallTempoFactor
Time scaling factor (1 = 100% = recorded tempo)
int getVerbosity()
Get verbosity level.
void signalError(QVariant msg)
void setTempo(double factor)
Set tempo scale factor.
quint8 byte1
Midi first argument byte.
void advance()
Advance iterator in the list of events.
bool isPlaying() const
Find out whether the player is playing.
MidiPlayerEventList mEventList
void signalPlayingStatusChanged(QVariant playing)
void clear()
Clear the event list (clear all Midi data).
bool atEnd() const
Predicate, telling us whether we are already at the end of the list.
Structure used internally in the MidiPlayer to hold a Midi event.
quint64 mDeltaTicks
Elapsed time units (ticks) since the last event.
void loadFile(QString filename, bool autostart=false)
Load a midi file (*.mid) from disk.
bool mRepeatMode
Mode indicating that file shall be repeated.
const MidiPlayerEvent getEvent() const
Return a copy of the actual event (zero event if iterator is at the end of the list).
void loadUrl(QString url)
Load a midi file (*.mid) from disk (URL-Version)
bool mCurrentlyPlaying
Flag whether player is actually playing.
void suspend()
Suspend (stop playing, thread idle)
void setRepeatMode(bool on)
Switch repeat mode on and off.
void helperSignalToReadMidiFile(QString filename, bool autostart)
void pause()
Pause: Interrupt playing.
void rewind()
Rewind: Move the iterator back to the beginning of the Midi song.
void setTempoFactor(double tempo)
Modify the tempo scale factor.
void signalProgressInPercent(QVariant percent)
void midiTimeout()
Timer midiTimeout.
double getProgressInPercent() const
Get the playing progress in percent.
double mMillisecondsPerTick
Calculated number of milliseconds per tick.
void allNotesOff()
Turn all notes off.
double mAccumulatedTime
Accumulated time since last progress signal.
void togglePlayPause()
Toggle between play and pause.
double mTicksPerQuarterNote
Calculated number of ticks per quarter note.
void setProgress(double percent)
Set the EventList iterator according to a given progress in percent.
void setMidiProgress(double percent)
Set progress in pecent manually.
void setThreadName(const QString name)
Set thread name (Linux only)
bool stop()
Stop the player.
bool parse(QByteArray &data)
Parse a Midi file and store it in the EventList.
void signalMidiEvent(QMidiMessage event)
virtual bool stop()
Stop the thread.
void readAndParseMidiFile(QString filename, bool autostart)
Read and parse a Midi file.