drumstick 2.0.0
alsaqueue.h
Go to the documentation of this file.
1/*
2 MIDI Sequencer C++ library
3 Copyright (C) 2006-2020, 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 3 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
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef DRUMSTICK_ALSAQUEUE_H
20#define DRUMSTICK_ALSAQUEUE_H
21
22#include <QObject>
23
24extern "C" {
25 #include <alsa/asoundlib.h>
26}
27
28#include "macros.h"
29
30namespace drumstick { namespace ALSA {
31
36
37class MidiClient;
38class TimerId;
39
49class DRUMSTICK_EXPORT QueueInfo
50{
51 friend class MidiQueue;
52
53public:
54 QueueInfo();
55 QueueInfo(const QueueInfo& other);
56 explicit QueueInfo(snd_seq_queue_info_t* other);
57 virtual ~QueueInfo();
59 QueueInfo& operator=(const QueueInfo& other);
60 int getInfoSize() const;
61
62 int getId();
63 QString getName();
64 int getOwner();
65 bool isLocked();
66 unsigned int getFlags();
67
68 void setName(QString value);
69 void setOwner(int value);
70 void setLocked(bool locked);
71 void setFlags(unsigned int value);
72
73private:
74 snd_seq_queue_info_t* m_Info;
75};
76
82class DRUMSTICK_EXPORT QueueStatus
83{
84 friend class MidiQueue;
85
86public:
88 QueueStatus(const QueueStatus& other);
89 explicit QueueStatus(snd_seq_queue_status_t* other);
90 virtual ~QueueStatus();
92 QueueStatus& operator=(const QueueStatus& other);
93 int getInfoSize() const;
94
95 int getId();
96 int getEvents();
97 const snd_seq_real_time_t* getRealtime();
98 unsigned int getStatusBits();
99 bool isRunning();
100 double getClockTime();
101 snd_seq_tick_time_t getTickTime();
102
103private:
104 snd_seq_queue_status_t* m_Info;
105};
106
119class DRUMSTICK_EXPORT QueueTempo
120{
121 friend class MidiQueue;
122
123public:
124 QueueTempo();
125 QueueTempo(const QueueTempo& other);
126 explicit QueueTempo(snd_seq_queue_tempo_t* other);
127 virtual ~QueueTempo();
128 QueueTempo* clone();
129 QueueTempo& operator=(const QueueTempo& other);
130 int getInfoSize() const;
131
132 int getId();
133 int getPPQ();
134 unsigned int getSkewValue();
135 unsigned int getSkewBase();
136 unsigned int getTempo();
137 void setPPQ(int value);
138 void setSkewValue(unsigned int value);
139 void setTempo(unsigned int value);
140
141 float getNominalBPM();
142 float getRealBPM();
143 void setTempoFactor(float value);
144 void setNominalBPM(float value);
145
146protected:
147 void setSkewBase(unsigned int value);
148
149private:
150 snd_seq_queue_tempo_t* m_Info;
151};
152
159class DRUMSTICK_EXPORT QueueTimer
160{
161 friend class MidiQueue;
162
163public:
164 QueueTimer();
165 QueueTimer(const QueueTimer& other);
166 explicit QueueTimer(snd_seq_queue_timer_t* other);
167 virtual ~QueueTimer();
168 QueueTimer* clone();
169 QueueTimer& operator=(const QueueTimer& other);
170 int getInfoSize() const;
171
172 int getQueueId();
173 snd_seq_queue_timer_type_t getType();
174 const snd_timer_id_t* getId();
175 unsigned int getResolution();
176 void setType(snd_seq_queue_timer_type_t value);
177 void setId(snd_timer_id_t* value);
178 void setId(const TimerId& id);
179 void setResolution(unsigned int value);
180
181private:
182 snd_seq_queue_timer_t* m_Info;
183};
184
190class DRUMSTICK_EXPORT MidiQueue : public QObject
191{
192 Q_OBJECT
193public:
194 explicit MidiQueue(MidiClient* seq, QObject* parent = nullptr);
195 MidiQueue(MidiClient* seq, const QueueInfo& info, QObject* parent = nullptr);
196 MidiQueue(MidiClient* seq, const QString name, QObject* parent = nullptr);
197 MidiQueue(MidiClient* seq, const int queue_id, QObject* parent = nullptr);
198 virtual ~MidiQueue();
199
200 int getId() const { return m_Id; }
201 void start();
202 void stop();
203 void continueRunning();
204 void clear();
205 void setTickPosition(snd_seq_tick_time_t pos);
206 void setRealTimePosition(snd_seq_real_time_t* pos);
211 int getUsage();
212 void setInfo(const QueueInfo& value);
213 void setTempo(const QueueTempo& value);
214 void setTimer(const QueueTimer& value);
215 void setUsage(int used);
216
217private:
218 bool m_allocated;
219 int m_Id;
220 MidiClient* m_MidiClient;
221 QueueInfo m_Info;
222 QueueTempo m_Tempo;
223 QueueTimer m_Timer;
224 QueueStatus m_Status;
225};
226
228
229}} /* namespace drumstick::ALSA */
230
231#endif //DRUMSTICK_ALSAQUEUE_H
The QObject class is the base class of all Qt objects.
Client management.
Definition alsaclient.h:209
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.
MidiQueue(MidiClient *seq, QObject *parent=nullptr)
Constructor.
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.
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:50
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:67
int getId()
Gets the queue's numeric identifier.
QueueInfo * clone()
Copy the current object and return the copy.
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:83
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:120
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:160
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:86
Drumstick visibility macros.
Drumstick ALSA library wrapper.
Drumstick common.