Just Intonation
Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
|
#include <midiplayer.h>
Public Slots | |
void | loadFile (QString filename, bool autostart=false) |
Load a midi file (*.mid) from disk. More... | |
void | loadUrl (QString url) |
Load a midi file (*.mid) from disk (URL-Version) More... | |
void | setTempo (double factor) |
Set tempo scale factor. More... | |
void | setMidiProgress (double percent) |
Set progress in pecent manually. More... | |
void | rewind () |
Rewind: Move the iterator of the event list to the beginning. More... | |
void | togglePlayPause () |
Toggle between play and pause. More... | |
void | setRepeatMode (bool on) |
Switch repeat mode on and off. More... | |
void | play () |
Start or resume playing. More... | |
void | pause () |
Pause: Interrupt playing. More... | |
void | receiveTempoData (bool smpte, double parameter) |
Receive tempo data from the parser. More... | |
void | reportError (QString msg) |
Report an error. More... | |
Signals | |
void | signalMidiEvent (QMidiMessage event) |
void | signalPlayingStatusChanged (QVariant playing) |
void | signalProgressInPercent (QVariant percent) |
void | signalError (QVariant msg) |
void | helperSignalToReadMidiFile (QString filename, bool autostart) |
void | setDisplayedMidiFilename (QVariant filename) |
Public Member Functions | |
MidiPlayer () | |
Constructor. More... | |
bool | stop () |
Stop the player. More... | |
bool | isPlaying () const |
Find out whether the player is playing. More... | |
void | suspend () |
Suspend (stop playing, thread idle) More... | |
void | resume () |
Resume from suspend mode. More... | |
virtual bool | init () |
Virtual initialization function (no functionality here) More... | |
virtual bool | exit () |
Virtual exit function (no functionality here) More... | |
virtual bool | start () |
Start the thread. More... | |
bool | isActive () const |
Return true if thread is running and not suspended. More... | |
void | setVerbosity (int verbosity) |
Set verbosity level of messages. More... | |
int | getVerbosity () |
Get verbosity level. More... | |
QString | getThreadName () const |
Get thread name. More... | |
Protected Member Functions | |
virtual void | initiallyCalledWorker () |
Virtual worker function called when the thread is starting. More... | |
virtual void | finallyCalledWorker () |
Virtual worker function called when the thread stops. More... | |
virtual void | periodicallyCalledWorker () |
Virtual worker function called periodically from the timer. More... | |
void | setPriority (const QThread::Priority p) |
Set thread priority. More... | |
void | setTimerInterval (const int msec, const int firstMsec=0) |
Set timer interval for the periodically called worker. More... | |
void | setThreadName (const QString name) |
Set thread name (Linux only) More... | |
bool | isInterruptionRequested () const |
Return true if the thread was requested to interrupt or terminate. More... | |
Private Slots | |
void | readAndParseMidiFile (QString filename, bool autostart) |
Read and parse a Midi file. More... | |
Private Member Functions | |
void | allNotesOff () |
Turn all notes off. More... | |
void | setTempoFactor (double tempo) |
Modify the tempo scale factor. More... | |
void | midiTimeout () |
Timer midiTimeout. More... | |
Private Attributes | |
MidiPlayerEventList | mEventList |
bool | mCurrentlyPlaying |
Flag whether player is actually playing. More... | |
bool | mRepeatMode |
Mode indicating that file shall be repeated. More... | |
bool | mPlayAgainAfterSuspend |
Flag for playing after resume. More... | |
bool | mTimerActive |
Flag indicating that player is waiting for timeout. More... | |
double | mOverallTempoFactor |
Time scaling factor (1 = 100% = recorded tempo) More... | |
quint64 | mDeltaTicks |
Elapsed time units (ticks) since the last event. More... | |
double | mMillisecondsPerTick |
Calculated number of milliseconds per tick. More... | |
double | mTicksPerQuarterNote |
Calculated number of ticks per quarter note. More... | |
double | mAccumulatedTime |
Accumulated time since last progress signal. More... | |
Midi Player.
The MidiPlayer reads a Midi file, stores it in an event list and transmits them in real time to the synthesizer. This class comprises all functions which are needed to actually play the Midi file in real time. Its main part is the function timeout() which calls itself again and again via timer signals. Whenever timeout() is called it emits the corresponding Midi signals, calculates the timespan between the current and the next event in milliseconds, and restarts the timer. In addition, the class provides a basic control like play() and pause().
Definition at line 84 of file midiplayer.h.
MidiPlayer::MidiPlayer | ( | ) |
Constructor.
Definition at line 35 of file midiplayer.cpp.
|
private |
Turn all notes off.
Definition at line 244 of file midiplayer.cpp.
|
inlinevirtualinherited |
Virtual exit function (no functionality here)
Reimplemented in AudioOutput.
Definition at line 71 of file threadbase.h.
|
inlineprotectedvirtualinherited |
Virtual worker function called when the thread stops.
Reimplemented in Tuner, and AudioOutput.
Definition at line 87 of file threadbase.h.
|
inherited |
Get thread name.
Definition at line 132 of file threadbase.cpp.
|
inlineinherited |
Get verbosity level.
Definition at line 80 of file threadbase.h.
|
signal |
|
inlinevirtualinherited |
Virtual initialization function (no functionality here)
Reimplemented in Tuner, AudioOutput, and SoundGenerator.
Definition at line 70 of file threadbase.h.
|
inlineprotectedvirtualinherited |
Virtual worker function called when the thread is starting.
Reimplemented in Tuner, and AudioOutput.
Definition at line 85 of file threadbase.h.
|
inherited |
Return true if thread is running and not suspended.
Definition at line 136 of file threadbase.cpp.
|
protectedinherited |
Return true if the thread was requested to interrupt or terminate.
Definition at line 128 of file threadbase.cpp.
bool MidiPlayer::isPlaying | ( | ) | const |
Find out whether the player is playing.
Definition at line 263 of file midiplayer.cpp.
|
slot |
Load a midi file (*.mid) from disk.
This function requests the MidiPlayer to load a file. The loading process is carried out in the independent thread, meaning that this function returns immediately.
filename | : Name of the file (including path) |
autostart | : Flag indicating that Midi player should start after loading |
Definition at line 88 of file midiplayer.cpp.
|
slot |
Load a midi file (*.mid) from disk (URL-Version)
This function requests the MidiPlayer to load a file. The loading process is carried out in the independent thread, meaning that this function returns immediately.
url | : URL of the file ( file//:...) |
Definition at line 108 of file midiplayer.cpp.
|
private |
Timer midiTimeout.
This is the heart of the Midi player. It reads an event from the EventList and transmits it by a signal to the Midi device. The time difference between the current and the next event is calculated. If this difference is zero, the function repeats itself recursively, handling the next event in the queue. If the difference is non-zero, a QTimer is started in the one-shot mode, returning to this function on midiTimeout.
Definition at line 404 of file midiplayer.cpp.
|
slot |
Pause: Interrupt playing.
This function interrupts the playing loop without resetting the iterator. In order to switch off all notes, the corresponding codes are sent directly to the Midi device.
Definition at line 228 of file midiplayer.cpp.
|
inlineprotectedvirtualinherited |
Virtual worker function called periodically from the timer.
Reimplemented in Tuner, and AudioDeviceGuard.
Definition at line 89 of file threadbase.h.
|
slot |
Start or resume playing.
This function starts the timer to begin playback after 20 msec. Reading continues at the last position, e.g. after calling pause().
Definition at line 203 of file midiplayer.cpp.
|
privateslot |
Read and parse a Midi file.
This function reads a Midi file (*.mid) from the device, parses its content and stores the extracted events in a time-ordered EventList.
filename | : Name of the file |
autostart | : Flag for immediate playback after loading |
Definition at line 339 of file midiplayer.cpp.
|
slot |
Receive tempo data from the parser.
Most Midi files contain meta information about the tempo. When the parser finds this information the present function is called. It informs the MidiPlayer aboout the timing mode. In the Midi norm there are two timing norms, an absolute so-called SMPTE timing and a quarter-note varying timing. In both cases the transmitted parameter has a different meaning.
smpte | : True if SMPTE timing, false otherwise |
parameter | : For SMPTE milliseconds per ticks, otherwise ticks per quarter note. |
Definition at line 384 of file midiplayer.cpp.
|
slot |
Report an error.
If the verbosity level is nonzero the error is written to qCritical(). Moreover, the function calls the signal sendError(msg) in the MidiPlayer.
msg | : Error string |
Definition at line 321 of file midiplayer.cpp.
|
virtual |
Resume from suspend mode.
Reimplemented from ThreadBase.
Definition at line 290 of file midiplayer.cpp.
|
slot |
Rewind: Move the iterator of the event list to the beginning.
Definition at line 158 of file midiplayer.cpp.
|
signal |
|
slot |
Set progress in pecent manually.
percent |
Definition at line 143 of file midiplayer.cpp.
|
protectedinherited |
Set thread priority.
Definition at line 109 of file threadbase.cpp.
|
slot |
Switch repeat mode on and off.
Definition at line 187 of file midiplayer.cpp.
|
slot |
Set tempo scale factor.
factor | : Scale factor (1 = 100% = neutral) |
Definition at line 128 of file midiplayer.cpp.
|
private |
Modify the tempo scale factor.
factor | : Scale factor (1 = 100%) |
Definition at line 306 of file midiplayer.cpp.
|
protectedinherited |
Set thread name (Linux only)
Definition at line 121 of file threadbase.cpp.
|
protectedinherited |
Set timer interval for the periodically called worker.
Definition at line 117 of file threadbase.cpp.
|
inherited |
Set verbosity level of messages.
Definition at line 113 of file threadbase.cpp.
|
signal |
|
signal |
|
signal |
|
signal |
|
virtualinherited |
Start the thread.
Starts the thread. If the thread is suspended it will resume. If the thread is already started the function does nothing.
Reimplemented in Tuner, and AudioOutput.
Definition at line 64 of file threadbase.cpp.
|
virtual |
Stop the player.
This function stops the player so that it is no longer playing or listening to its slots. Loaded MIDI data is not cancelled so that the same music can be played again after restarting the player.
Reimplemented from ThreadBase.
Definition at line 68 of file midiplayer.cpp.
|
virtual |
Suspend (stop playing, thread idle)
Reimplemented from ThreadBase.
Definition at line 275 of file midiplayer.cpp.
|
slot |
Toggle between play and pause.
Definition at line 173 of file midiplayer.cpp.
|
private |
Accumulated time since last progress signal.
Definition at line 134 of file midiplayer.h.
|
private |
Flag whether player is actually playing.
Definition at line 126 of file midiplayer.h.
|
private |
Elapsed time units (ticks) since the last event.
Definition at line 131 of file midiplayer.h.
|
private |
Definition at line 125 of file midiplayer.h.
|
private |
Calculated number of milliseconds per tick.
Definition at line 132 of file midiplayer.h.
|
private |
Time scaling factor (1 = 100% = recorded tempo)
Definition at line 130 of file midiplayer.h.
|
private |
Flag for playing after resume.
Definition at line 128 of file midiplayer.h.
|
private |
Mode indicating that file shall be repeated.
Definition at line 127 of file midiplayer.h.
|
private |
Calculated number of ticks per quarter note.
Definition at line 133 of file midiplayer.h.
|
private |
Flag indicating that player is waiting for timeout.
Definition at line 129 of file midiplayer.h.