Just Intonation  Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
midiplayereventlist.h
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  *****************************************************************************/
19 
20 //=============================================================================
21 // Midi Player Events and Event List
22 //=============================================================================
23 
24 #ifndef MIDIPLAYEREVENTLIST_H
25 #define MIDIPLAYEREVENTLIST_H
26 
27 #include <QObject>
28 #include <QMutex>
29 #include <QMultiMap>
30 
31 #include "system/shared.h"
32 
41 
43 {
44  MidiPlayerEvent(quint8 track=0, double deltaticks=0,
45  quint8 command=0, quint8 byte1=0, quint8 byte2=0);
46 
47  quint8 track;
48  double deltaticks;
49  quint8 command;
50  quint8 byte1;
51  quint8 byte2;
52 };
53 
54 
64 
66 {
67 public:
69 
70  void clear(); // Clear all data
71  void insert (double time, // Insert a new midi event
72  const MidiPlayerEvent &event);
73  void rewind(); // Reset iterator
74  void advance(); // Advance iterator
75  bool atEnd() const; // Is iterator at the end?
76  const MidiPlayerEvent getEvent() const; // get iterator-pointed event
77  quint32 getCumulativeTime() const; // get cumulative time
78  int getSize() const; // get total number of all events
79 
80  double getProgressInPercent() const; // get actual playing process
81  void setProgress (double percent); // set iterator at a percentage
82 
83  void writeListInReadableForm (QString filename);
84 private:
85  typedef QMultiMap<double,MidiPlayerEvent> MidiEventList;
86 
87  MidiEventList mEventList;
88  quint32 mMaxTime;
89  MidiEventList::Iterator pEventIterator;
90  mutable QMutex mAccessMutex;
91 };
92 
93 #endif // MIDIPLAYEREVENTLIST_H
QMultiMap< double, MidiPlayerEvent > MidiEventList
double deltaticks
Time ticks elapsed since the last event.
quint8 byte2
Midi second argument byte (zero if none)
quint8 command
Midi command byte.
quint8 byte1
Midi first argument byte.
MidiEventList mEventList
Instance of the event list.
Structure used internally in the MidiPlayer to hold a Midi event.
quint8 track
Midi track number.
QMutex mAccessMutex
Mutex for access.
MidiEventList::Iterator pEventIterator
Iterator playing the notes.
quint32 mMaxTime
Maximum time at the end of the list.
Class managing the EventList in the MidiPlayer.
MidiPlayerEvent(quint8 track=0, double deltaticks=0, quint8 command=0, quint8 byte1=0, quint8 byte2=0)
Constructor for a MidiPlayerEvent, copying the arguments.