drumstick 2.10.0
C++ MIDI libraries using Qt objects, idioms, and style.
alsaqueue.h
Go to the documentation of this file.
1/*
2 MIDI Sequencer C++ library
3 Copyright (C) 2006-2024, 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
37#if defined(DRUMSTICK_STATIC)
38#define DRUMSTICK_ALSA_EXPORT
39#else
40#if defined(drumstick_alsa_EXPORTS)
41#define DRUMSTICK_ALSA_EXPORT Q_DECL_EXPORT
42#else
43#define DRUMSTICK_ALSA_EXPORT Q_DECL_IMPORT
44#endif
45#endif
46
47class MidiClient;
48class TimerId;
49
59class DRUMSTICK_ALSA_EXPORT QueueInfo
60{
61 friend class MidiQueue;
62
63public:
64 QueueInfo();
65 QueueInfo(const QueueInfo& other);
66 explicit QueueInfo(snd_seq_queue_info_t* other);
67 virtual ~QueueInfo();
69 QueueInfo& operator=(const QueueInfo& other);
70 int getInfoSize() const;
71
72 int getId();
73 QString getName();
74 int getOwner();
75 bool isLocked();
76 unsigned int getFlags();
77
78 void setName(QString value);
79 void setOwner(int value);
80 void setLocked(bool locked);
81 void setFlags(unsigned int value);
82
83private:
84 snd_seq_queue_info_t* m_Info;
85};
86
92class DRUMSTICK_ALSA_EXPORT QueueStatus
93{
94 friend class MidiQueue;
95
96public:
98 QueueStatus(const QueueStatus& other);
99 explicit QueueStatus(snd_seq_queue_status_t* other);
100 virtual ~QueueStatus();
102 QueueStatus& operator=(const QueueStatus& other);
103 int getInfoSize() const;
104
105 int getId();
106 int getEvents();
107 const snd_seq_real_time_t* getRealtime();
108 unsigned int getStatusBits();
109 bool isRunning();
110 double getClockTime();
111 snd_seq_tick_time_t getTickTime();
112
113private:
114 snd_seq_queue_status_t* m_Info;
115};
116
129class DRUMSTICK_ALSA_EXPORT QueueTempo
130{
131 friend class MidiQueue;
132
133public:
134 QueueTempo();
135 QueueTempo(const QueueTempo& other);
136 explicit QueueTempo(snd_seq_queue_tempo_t* other);
137 virtual ~QueueTempo();
138 QueueTempo* clone();
139 QueueTempo& operator=(const QueueTempo& other);
140 int getInfoSize() const;
141
142 int getId();
143 int getPPQ();
144 unsigned int getSkewValue();
145 unsigned int getSkewBase();
146 unsigned int getTempo();
147 void setPPQ(int value);
148 void setSkewValue(unsigned int value);
149 void setTempo(unsigned int value);
150
151 float getNominalBPM();
152 float getRealBPM();
153 void setTempoFactor(float value);
154 void setNominalBPM(float value);
155
156protected:
157 void setSkewBase(unsigned int value);
158
159private:
160 snd_seq_queue_tempo_t* m_Info;
161};
162
169class DRUMSTICK_ALSA_EXPORT QueueTimer
170{
171 friend class MidiQueue;
172
173public:
174 QueueTimer();
175 QueueTimer(const QueueTimer& other);
176 explicit QueueTimer(snd_seq_queue_timer_t* other);
177 virtual ~QueueTimer();
178 QueueTimer* clone();
179 QueueTimer& operator=(const QueueTimer& other);
180 int getInfoSize() const;
181
182 int getQueueId();
183 snd_seq_queue_timer_type_t getType();
184 const snd_timer_id_t* getId();
185 unsigned int getResolution();
186 void setType(snd_seq_queue_timer_type_t value);
187 void setId(snd_timer_id_t* value);
188 void setId(const TimerId& id);
189 void setResolution(unsigned int value);
190
191private:
192 snd_seq_queue_timer_t* m_Info;
193};
194
200class DRUMSTICK_ALSA_EXPORT MidiQueue : public QObject
201{
202 Q_OBJECT
203public:
204 explicit MidiQueue(MidiClient* seq, QObject* parent = nullptr);
205 MidiQueue(MidiClient* seq, const QueueInfo& info, QObject* parent = nullptr);
206 MidiQueue(MidiClient* seq, const QString name, QObject* parent = nullptr);
207 MidiQueue(MidiClient* seq, const int queue_id, QObject* parent = nullptr);
208 virtual ~MidiQueue();
209
210 int getId() const { return m_Id; }
211 void start();
212 void stop();
213 void continueRunning();
214 void clear();
215 void setTickPosition(snd_seq_tick_time_t pos);
216 void setRealTimePosition(snd_seq_real_time_t* pos);
221 int getUsage();
222 void setInfo(const QueueInfo& value);
223 void setTempo(const QueueTempo& value);
224 void setTimer(const QueueTimer& value);
225 void setUsage(int used);
226
227private:
228 bool m_allocated;
229 int m_Id;
230 MidiClient* m_MidiClient;
231 QueueInfo m_Info;
232 QueueTempo m_Tempo;
233 QueueTimer m_Timer;
234 QueueStatus m_Status;
235};
236
238
239}} /* namespace drumstick::ALSA */
240
241#endif //DRUMSTICK_ALSAQUEUE_H
The QObject class is the base class of all Qt objects.
Client management.
Definition alsaclient.h:219
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:60
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:93
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:130
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:170
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:96
Drumstick ALSA library wrapper.
Drumstick common.