Just Intonation  Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2016-2017 Karolin Stange, Christoph Wick, and Haye Hinrichsen
3  *
4  * This file is part of JustIntonation.
5  *
6  * JustIntonation is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * JustIntonation is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with JustIntonation. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
20 //=============================================================================
21 // Midi Player
22 //=============================================================================
24 #ifndef MIDIPLAYER_H
25 #define MIDIPLAYER_H
59 #include <QVariant>
60 #include <QTimer>
61 #include <QMidiMessage>
63 #include "midiplayereventlist.h"
64 #include "midiplayerparser.h"
65 #include "../../application/modules/system/threadbase.h"
84 class MidiPlayer : public ThreadBase
85 {
87 public:
88  MidiPlayer(); // Constructor
89  bool stop(); // Stop thread
90  bool isPlaying() const; // returns true if playing
91  void suspend();
92  void resume();
94 signals:
95  void signalMidiEvent (QMidiMessage event);
96  void signalPlayingStatusChanged (QVariant playing);
97  void signalProgressInPercent (QVariant percent);
98  void signalError (QVariant msg);
100 public slots:
101  void loadFile (QString filename, bool autostart=false); // Load a song from a file
102  void loadUrl (QString url); // Load a song from a file (specify url)
103  void setTempo (double factor); // Change tempo by a scale factor (1=100%)
104  void setMidiProgress(double percent);// Set progress
105  void rewind(); // Go back to beginning
106  void togglePlayPause(); // Toggle between play and pause
107  void setRepeatMode(bool on); // Repeat midi file if ended
108  void play();
109  void pause();
111  void receiveTempoData (bool smpte, double parameter);
112  void reportError (QString msg);
114 private slots:
115  void readAndParseMidiFile (QString filename, bool autostart);
116 signals:
117  void helperSignalToReadMidiFile (QString filename, bool autostart);
118  void setDisplayedMidiFilename (QVariant filename);
120 private:
121  void allNotesOff();
122  void setTempoFactor (double tempo);
123  void midiTimeout();
127  bool mRepeatMode;
131  quint64 mDeltaTicks;
135 };
137 #endif // MIDIPLAYER_H
bool mPlayAgainAfterSuspend
Flag for playing after resume.
Definition: midiplayer.h:128
void resume()
Resume from suspend mode.
Definition: midiplayer.cpp:290
Universal base class for threaded modules.
Definition: threadbase.h:60
void play()
Start or resume playing.
Definition: midiplayer.cpp:203
void reportError(QString msg)
Report an error.
Definition: midiplayer.cpp:321
void rewind()
Rewind: Move the iterator of the event list to the beginning.
Definition: midiplayer.cpp:158
void receiveTempoData(bool smpte, double parameter)
Receive tempo data from the parser.
Definition: midiplayer.cpp:384
void setDisplayedMidiFilename(QVariant filename)
bool mTimerActive
Flag indicating that player is waiting for timeout.
Definition: midiplayer.h:129
double mOverallTempoFactor
Time scaling factor (1 = 100% = recorded tempo)
Definition: midiplayer.h:130
Definition: midiplayer.cpp:35
void signalError(QVariant msg)
void setTempo(double factor)
Set tempo scale factor.
Definition: midiplayer.cpp:128
bool isPlaying() const
Find out whether the player is playing.
Definition: midiplayer.cpp:263
MidiPlayerEventList mEventList
Definition: midiplayer.h:125
Midi Player.
Definition: midiplayer.h:84
void signalPlayingStatusChanged(QVariant playing)
quint64 mDeltaTicks
Elapsed time units (ticks) since the last event.
Definition: midiplayer.h:131
void loadFile(QString filename, bool autostart=false)
Load a midi file (*.mid) from disk.
Definition: midiplayer.cpp:88
bool mRepeatMode
Mode indicating that file shall be repeated.
Definition: midiplayer.h:127
void loadUrl(QString url)
Load a midi file (*.mid) from disk (URL-Version)
Definition: midiplayer.cpp:108
bool mCurrentlyPlaying
Flag whether player is actually playing.
Definition: midiplayer.h:126
void suspend()
Suspend (stop playing, thread idle)
Definition: midiplayer.cpp:275
void setRepeatMode(bool on)
Switch repeat mode on and off.
Definition: midiplayer.cpp:187
void helperSignalToReadMidiFile(QString filename, bool autostart)
void pause()
Pause: Interrupt playing.
Definition: midiplayer.cpp:228
void setTempoFactor(double tempo)
Modify the tempo scale factor.
Definition: midiplayer.cpp:306
void signalProgressInPercent(QVariant percent)
void midiTimeout()
Timer midiTimeout.
Definition: midiplayer.cpp:404
double mMillisecondsPerTick
Calculated number of milliseconds per tick.
Definition: midiplayer.h:132
void allNotesOff()
Turn all notes off.
Definition: midiplayer.cpp:244
double mAccumulatedTime
Accumulated time since last progress signal.
Definition: midiplayer.h:134
void togglePlayPause()
Toggle between play and pause.
Definition: midiplayer.cpp:173
double mTicksPerQuarterNote
Calculated number of ticks per quarter note.
Definition: midiplayer.h:133
void setMidiProgress(double percent)
Set progress in pecent manually.
Definition: midiplayer.cpp:143
bool stop()
Stop the player.
Definition: midiplayer.cpp:68
void signalMidiEvent(QMidiMessage event)
Class managing the EventList in the MidiPlayer.
void readAndParseMidiFile(QString filename, bool autostart)
Read and parse a Midi file.
Definition: midiplayer.cpp:339