drumstick 2.9.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-2023, 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
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();
68 QueueInfo* clone();
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();
101 QueueStatus* clone();
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);
217 QueueInfo& getInfo();
218 QueueStatus& getStatus();
219 QueueTempo& getTempo();
220 QueueTimer& getTimer();
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
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
Queue management.
Definition: alsaqueue.h:201
Queue information container.
Definition: alsaqueue.h:60
Queue status container.
Definition: alsaqueue.h:93
Queue tempo container.
Definition: alsaqueue.h:130
Queue timer container.
Definition: alsaqueue.h:170
ALSA Timer identifier container.
Definition: alsatimer.h:96
Drumstick common.
Definition: alsaclient.cpp:68