drumstick
0.5.0
|
00001 /* 00002 MIDI Sequencer C++ library 00003 Copyright (C) 2006-2010, Pedro Lopez-Cabanillas <plcl@users.sf.net> 00004 00005 This library is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License along 00016 with this program; if not, write to the Free Software Foundation, Inc., 00017 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef DRUMSTICK_ALSAQUEUE_H 00021 #define DRUMSTICK_ALSAQUEUE_H 00022 00023 #include "drumstickcommon.h" 00031 namespace drumstick { 00032 00037 #define SKEW_BASE 0x10000 00038 00039 class MidiClient; 00040 class TimerId; 00041 00047 class DRUMSTICK_EXPORT QueueInfo 00048 { 00049 friend class MidiQueue; 00050 00051 public: 00052 QueueInfo(); 00053 QueueInfo(const QueueInfo& other); 00054 QueueInfo(snd_seq_queue_info_t* other); 00055 virtual ~QueueInfo(); 00056 QueueInfo* clone(); 00057 QueueInfo& operator=(const QueueInfo& other); 00058 int getInfoSize() const; 00059 00060 int getId(); 00061 QString getName(); 00062 int getOwner(); 00063 bool isLocked(); 00064 unsigned int getFlags(); 00065 00066 void setName(QString value); 00067 void setOwner(int value); 00068 void setLocked(bool locked); 00069 void setFlags(unsigned int value); 00070 00071 private: 00072 snd_seq_queue_info_t* m_Info; 00073 }; 00074 00080 class DRUMSTICK_EXPORT QueueStatus 00081 { 00082 friend class MidiQueue; 00083 00084 public: 00085 QueueStatus(); 00086 QueueStatus(const QueueStatus& other); 00087 QueueStatus(snd_seq_queue_status_t* other); 00088 virtual ~QueueStatus(); 00089 QueueStatus* clone(); 00090 QueueStatus& operator=(const QueueStatus& other); 00091 int getInfoSize() const; 00092 00093 int getId(); 00094 int getEvents(); 00095 const snd_seq_real_time_t* getRealtime(); 00096 unsigned int getStatusBits(); 00097 bool isRunning(); 00098 double getClockTime(); 00099 snd_seq_tick_time_t getTickTime(); 00100 00101 private: 00102 snd_seq_queue_status_t* m_Info; 00103 }; 00104 00117 class DRUMSTICK_EXPORT QueueTempo 00118 { 00119 friend class MidiQueue; 00120 00121 public: 00122 QueueTempo(); 00123 QueueTempo(const QueueTempo& other); 00124 QueueTempo(snd_seq_queue_tempo_t* other); 00125 virtual ~QueueTempo(); 00126 QueueTempo* clone(); 00127 QueueTempo& operator=(const QueueTempo& other); 00128 int getInfoSize() const; 00129 00130 int getId(); 00131 int getPPQ(); 00132 unsigned int getSkewValue(); 00133 unsigned int getSkewBase(); 00134 unsigned int getTempo(); 00135 void setPPQ(int value); 00136 void setSkewValue(unsigned int value); 00137 void setTempo(unsigned int value); 00138 00139 float getNominalBPM(); 00140 float getRealBPM(); 00141 void setTempoFactor(float value); 00142 void setNominalBPM(float value); 00143 00144 protected: 00145 void setSkewBase(unsigned int value); 00146 00147 private: 00148 snd_seq_queue_tempo_t* m_Info; 00149 }; 00150 00157 class DRUMSTICK_EXPORT QueueTimer 00158 { 00159 friend class MidiQueue; 00160 00161 public: 00162 QueueTimer(); 00163 QueueTimer(const QueueTimer& other); 00164 QueueTimer(snd_seq_queue_timer_t* other); 00165 virtual ~QueueTimer(); 00166 QueueTimer* clone(); 00167 QueueTimer& operator=(const QueueTimer& other); 00168 int getInfoSize() const; 00169 00170 int getQueueId(); 00171 snd_seq_queue_timer_type_t getType(); 00172 const snd_timer_id_t* getId(); 00173 unsigned int getResolution(); 00174 void setType(snd_seq_queue_timer_type_t value); 00175 void setId(snd_timer_id_t* value); 00176 void setId(const TimerId& id); 00177 void setResolution(unsigned int value); 00178 00179 private: 00180 snd_seq_queue_timer_t* m_Info; 00181 }; 00182 00188 class DRUMSTICK_EXPORT MidiQueue : public QObject 00189 { 00190 Q_OBJECT 00191 public: 00192 explicit MidiQueue(MidiClient* seq, QObject* parent = 0); 00193 MidiQueue(MidiClient* seq, const QueueInfo& info, QObject* parent = 0); 00194 MidiQueue(MidiClient* seq, const QString name, QObject* parent = 0); 00195 MidiQueue(MidiClient* seq, const int queue_id, QObject* parent = 0); 00196 virtual ~MidiQueue(); 00197 00198 int getId() const { return m_Id; } 00199 void start(); 00200 void stop(); 00201 void continueRunning(); 00202 void clear(); 00203 void setTickPosition(snd_seq_tick_time_t pos); 00204 void setRealTimePosition(snd_seq_real_time_t* pos); 00205 QueueInfo& getInfo(); 00206 QueueStatus& getStatus(); 00207 QueueTempo& getTempo(); 00208 QueueTimer& getTimer(); 00209 int getUsage(); 00210 void setInfo(const QueueInfo& value); 00211 void setTempo(const QueueTempo& value); 00212 void setTimer(const QueueTimer& value); 00213 void setUsage(int used); 00214 00215 private: 00216 bool m_allocated; 00217 int m_Id; 00218 MidiClient* m_MidiClient; 00219 QueueInfo m_Info; 00220 QueueTempo m_Tempo; 00221 QueueTimer m_Timer; 00222 QueueStatus m_Status; 00223 }; 00224 00225 } /* namespace drumstick */ 00226 00229 #endif //DRUMSTICK_ALSAQUEUE_H