drumstick 0.5.0
alsaqueue.h
Go to the documentation of this file.
1/*
2 MIDI Sequencer C++ library
3 Copyright (C) 2006-2010, Pedro Lopez-Cabanillas <plcl@users.sf.net>
4
5 This library is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18*/
19
20#ifndef DRUMSTICK_ALSAQUEUE_H
21#define DRUMSTICK_ALSAQUEUE_H
22
23#include "drumstickcommon.h"
30
31namespace drumstick {
32
37#define SKEW_BASE 0x10000
38
39class MidiClient;
40class TimerId;
41
47class DRUMSTICK_EXPORT QueueInfo
48{
49 friend class MidiQueue;
50
51public:
52 QueueInfo();
53 QueueInfo(const QueueInfo& other);
54 QueueInfo(snd_seq_queue_info_t* other);
55 virtual ~QueueInfo();
57 QueueInfo& operator=(const QueueInfo& other);
58 int getInfoSize() const;
59
60 int getId();
61 QString getName();
62 int getOwner();
63 bool isLocked();
64 unsigned int getFlags();
65
66 void setName(QString value);
67 void setOwner(int value);
68 void setLocked(bool locked);
69 void setFlags(unsigned int value);
70
71private:
72 snd_seq_queue_info_t* m_Info;
73};
74
80class DRUMSTICK_EXPORT QueueStatus
81{
82 friend class MidiQueue;
83
84public:
86 QueueStatus(const QueueStatus& other);
87 QueueStatus(snd_seq_queue_status_t* other);
88 virtual ~QueueStatus();
90 QueueStatus& operator=(const QueueStatus& other);
91 int getInfoSize() const;
92
93 int getId();
94 int getEvents();
95 const snd_seq_real_time_t* getRealtime();
96 unsigned int getStatusBits();
97 bool isRunning();
98 double getClockTime();
99 snd_seq_tick_time_t getTickTime();
100
101private:
102 snd_seq_queue_status_t* m_Info;
103};
104
117class DRUMSTICK_EXPORT QueueTempo
118{
119 friend class MidiQueue;
120
121public:
122 QueueTempo();
123 QueueTempo(const QueueTempo& other);
124 QueueTempo(snd_seq_queue_tempo_t* other);
125 virtual ~QueueTempo();
126 QueueTempo* clone();
127 QueueTempo& operator=(const QueueTempo& other);
128 int getInfoSize() const;
129
130 int getId();
131 int getPPQ();
132 unsigned int getSkewValue();
133 unsigned int getSkewBase();
134 unsigned int getTempo();
135 void setPPQ(int value);
136 void setSkewValue(unsigned int value);
137 void setTempo(unsigned int value);
138
139 float getNominalBPM();
140 float getRealBPM();
141 void setTempoFactor(float value);
142 void setNominalBPM(float value);
143
144protected:
145 void setSkewBase(unsigned int value);
146
147private:
148 snd_seq_queue_tempo_t* m_Info;
149};
150
157class DRUMSTICK_EXPORT QueueTimer
158{
159 friend class MidiQueue;
160
161public:
162 QueueTimer();
163 QueueTimer(const QueueTimer& other);
164 QueueTimer(snd_seq_queue_timer_t* other);
165 virtual ~QueueTimer();
166 QueueTimer* clone();
167 QueueTimer& operator=(const QueueTimer& other);
168 int getInfoSize() const;
169
170 int getQueueId();
171 snd_seq_queue_timer_type_t getType();
172 const snd_timer_id_t* getId();
173 unsigned int getResolution();
174 void setType(snd_seq_queue_timer_type_t value);
175 void setId(snd_timer_id_t* value);
176 void setId(const TimerId& id);
177 void setResolution(unsigned int value);
178
179private:
180 snd_seq_queue_timer_t* m_Info;
181};
182
188class DRUMSTICK_EXPORT MidiQueue : public QObject
189{
190 Q_OBJECT
191public:
192 explicit MidiQueue(MidiClient* seq, QObject* parent = 0);
193 MidiQueue(MidiClient* seq, const QueueInfo& info, QObject* parent = 0);
194 MidiQueue(MidiClient* seq, const QString name, QObject* parent = 0);
195 MidiQueue(MidiClient* seq, const int queue_id, QObject* parent = 0);
196 virtual ~MidiQueue();
197
198 int getId() const { return m_Id; }
199 void start();
200 void stop();
201 void continueRunning();
202 void clear();
203 void setTickPosition(snd_seq_tick_time_t pos);
204 void setRealTimePosition(snd_seq_real_time_t* pos);
209 int getUsage();
210 void setInfo(const QueueInfo& value);
211 void setTempo(const QueueTempo& value);
212 void setTimer(const QueueTimer& value);
213 void setUsage(int used);
214
215private:
216 bool m_allocated;
217 int m_Id;
218 MidiClient* m_MidiClient;
219 QueueInfo m_Info;
220 QueueTempo m_Tempo;
221 QueueTimer m_Timer;
222 QueueStatus m_Status;
223};
224
225} /* namespace drumstick */
226
228
229#endif //DRUMSTICK_ALSAQUEUE_H
The QObject class is the base class of all Qt objects.
Client management.
Definition alsaclient.h:199
void setTimer(const QueueTimer &value)
Applies q QueueTimer object to the queue.
void setInfo(const QueueInfo &value)
Applies a QueueInfo object to the queue.
int getUsage()
Gets the queue usage flag.
void setTickPosition(snd_seq_tick_time_t pos)
Sets the queue position in musical time (ticks).
void continueRunning()
Start the queue without resetting the last position.
QueueTimer & getTimer()
Gets a QueueTimer object reference.
QueueStatus & getStatus()
Gets a QueueStatus object reference.
void start()
Start the queue.
void stop()
Stop the queue.
void setRealTimePosition(snd_seq_real_time_t *pos)
Sets the queue position in real time (clock) units: seconds and nanoseconds.
void clear()
Clear the queue, dropping any scheduled events.
MidiQueue(MidiClient *seq, QObject *parent=0)
Constructor.
QueueInfo & getInfo()
Gets a QueueInfo object reference.
QueueTempo & getTempo()
Gets a QueueTempo object reference.
void setUsage(int used)
Sets the queue usage flag.
void setTempo(const QueueTempo &value)
Applies a QueueTempo object to the queue.
Queue information container.
Definition alsaqueue.h:48
bool isLocked()
Returns the locking status of the queue.
int getInfoSize() const
Gets the size of the ALSA queue info object.
unsigned int getFlags()
Gets the flags of the queue.
void setLocked(bool locked)
Sets the locked status of the queue.
int getOwner()
Gets the owner's client id of the queue.
QueueInfo()
Default constructor.
Definition alsaqueue.cpp:60
int getId()
Gets the queue's numeric identifier.
QueueInfo * clone()
Copy the current object and return the copy.
Definition alsaqueue.cpp:97
void setFlags(unsigned int value)
Sets the bit flags of the queue.
QString getName()
Gets the queue name.
void setName(QString value)
Sets the queue name.
QueueInfo & operator=(const QueueInfo &other)
Assignment operator.
void setOwner(int value)
Sets the client ID of the owner.
Queue status container.
Definition alsaqueue.h:81
int getInfoSize() const
Gets the size of the ALSA status object.
bool isRunning()
Gets the queue's running state.
int getEvents()
Gets the number of queued events.
int getId()
Gets the queue's numeric identifier.
QueueStatus * clone()
Copy the current object and return the copy.
const snd_seq_real_time_t * getRealtime()
Gets the real time (secods and nanoseconds) of the queue.
QueueStatus()
Default constructor.
snd_seq_tick_time_t getTickTime()
Gets the musical time (ticks) of the queue.
double getClockTime()
Gets the clock time in seconds of the queue.
QueueStatus & operator=(const QueueStatus &other)
Assignment operator.
unsigned int getStatusBits()
Gets the running status bits.
Queue tempo container.
Definition alsaqueue.h:118
int getInfoSize() const
Gets the size of the ALSA queue tempo object.
void setSkewValue(unsigned int value)
Sets the tempo skew numerator.
int getId()
Gets the queue's numeric identifier.
void setPPQ(int value)
Sets the queue resolution in parts per quarter note.
unsigned int getTempo()
Gets the queue's tempo in microseconds per beat.
QueueTempo()
Default constructor.
void setTempo(unsigned int value)
Sets the queue tempo in microseconds per beat.
float getRealBPM()
Gets the queue's real BPM tempo in beats per minute.
unsigned int getSkewValue()
Gets the tempo skew numerator.
float getNominalBPM()
Gets the queue's nominal BPM tempo (in beats per minute)
unsigned int getSkewBase()
Gets the tempo skew base.
QueueTempo * clone()
Copy the current object returning the copied object.
void setSkewBase(unsigned int value)
Sets the tempo skew base.
void setNominalBPM(float value)
Sets the queue's nominal tempo in BPM (beats per minute).
int getPPQ()
Gets the PPQ (parts per quarter note) resolution of the queue.
QueueTempo & operator=(const QueueTempo &other)
Assignment operator.
void setTempoFactor(float value)
Sets the queue's tempo skew factor.
Queue timer container.
Definition alsaqueue.h:158
int getInfoSize() const
Gets the size of the ALSA queue timer object.
snd_seq_queue_timer_type_t getType()
Gets the timer type.
const snd_timer_id_t * getId()
Gets the timer identifier record.
QueueTimer()
Default constructor.
QueueTimer & operator=(const QueueTimer &other)
Assignment operator.
void setResolution(unsigned int value)
Sets the timer resolution.
QueueTimer * clone()
Copy the current object and return the copy.
unsigned int getResolution()
Gets the timer resolution.
int getQueueId()
The queue's numeric identifier.
void setId(snd_timer_id_t *value)
Sets the timer identifier record.
void setType(snd_seq_queue_timer_type_t value)
Sets the timer type.
ALSA Timer identifier container.
Definition alsatimer.h:80
Common functionality.