drumstick 2.9.0
C++ MIDI libraries using Qt objects, idioms, and style.
alsaport.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_ALSAPORT_H
20#define DRUMSTICK_ALSAPORT_H
21
22#include "subscription.h"
23#include <QObject>
24
25namespace drumstick { namespace ALSA {
26
32#if defined(DRUMSTICK_STATIC)
33#define DRUMSTICK_ALSA_EXPORT
34#else
35#if defined(drumstick_alsa_EXPORTS)
36#define DRUMSTICK_ALSA_EXPORT Q_DECL_EXPORT
37#else
38#define DRUMSTICK_ALSA_EXPORT Q_DECL_IMPORT
39#endif
40#endif
41
42class MidiClient;
43
51class DRUMSTICK_ALSA_EXPORT PortInfo
52{
53 friend class MidiPort;
54 friend class ClientInfo;
55 friend class MidiClient;
56
57public:
58 PortInfo();
59 PortInfo(const PortInfo& other);
60 explicit PortInfo(snd_seq_port_info_t* other);
61 PortInfo(MidiClient* seq, const int client, const int port);
62 PortInfo(MidiClient* seq, const int port);
63 virtual ~PortInfo();
64 PortInfo* clone();
65 PortInfo& operator=(const PortInfo& other);
66 int getSizeOfInfo() const;
67
68 int getClient();
69 int getPort();
70 QString getClientName() const;
71 const snd_seq_addr_t* getAddr();
72 QString getName();
73 unsigned int getCapability();
74 unsigned int getType();
75 int getMidiChannels();
76 int getMidiVoices();
77 int getSynthVoices();
78 int getReadUse();
79 int getWriteUse();
80 int getPortSpecified();
81 void setClient(int client);
82 void setPort(int port);
83 void setAddr(const snd_seq_addr_t* addr);
84 void setName( QString const& name );
85 void setCapability(unsigned int capability);
86 void setType(unsigned int type);
87 void setMidiChannels(int channels);
88 void setMidiVoices(int voices);
89 void setSynthVoices(int voices);
90 void setPortSpecified(int val);
91 SubscribersList getReadSubscribers() const;
92 SubscribersList getWriteSubscribers() const;
93
94 bool getTimestamping();
95 bool getTimestampReal();
96 int getTimestampQueue();
97 void setTimestamping(bool value);
98 void setTimestampReal(bool value);
99 void setTimestampQueue(int queueId);
100
101protected:
102 void readSubscribers(MidiClient* seq);
103 void freeSubscribers();
104 void setClientName(QString name);
105
106private:
107 snd_seq_port_info_t* m_Info;
108 QString m_ClientName;
109 SubscribersList m_ReadSubscribers;
110 SubscribersList m_WriteSubscribers;
111};
112
113
117typedef QList<PortInfo> PortInfoList;
118
124class DRUMSTICK_ALSA_EXPORT MidiPort : public QObject
125{
126 Q_OBJECT
127 friend class MidiClient;
128
129public:
130 explicit MidiPort( QObject* parent = nullptr );
131 virtual ~MidiPort();
132
133 void attach( MidiClient* seq );
134 void detach();
135 void subscribe( Subscription* subs );
136 void unsubscribe( Subscription* subs );
137 void unsubscribeAll();
138 void unsubscribeTo( QString const& name );
139 void unsubscribeTo( PortInfo* port );
140 void unsubscribeTo( const snd_seq_addr_t* addr );
141 void unsubscribeFrom( QString const& name );
142 void unsubscribeFrom( PortInfo* port );
143 void unsubscribeFrom( const snd_seq_addr_t* addr );
144 void subscribeTo( PortInfo* port);
145 void subscribeTo( int client, int port );
146 void subscribeTo( QString const& name );
147 void subscribeFrom( PortInfo* port );
148 void subscribeFrom( int client, int port );
149 void subscribeFrom( QString const& name );
150 void subscribeFromAnnounce();
151 void updateSubscribers();
152 SubscriptionsList getSubscriptions() const;
153 PortInfoList getReadSubscribers();
154 PortInfoList getWriteSubscribers();
155 void updateConnectionsTo(const PortInfoList& desired);
156 void updateConnectionsFrom(const PortInfoList& desired);
157
158 static bool containsAddress(const snd_seq_addr_t* addr, const PortInfoList& lst);
159
160 void applyPortInfo();
161 QString getPortName();
162 void setPortName( QString const& newName);
163 int getPortId();
164 unsigned int getCapability();
165 void setCapability( unsigned int newValue);
166 unsigned int getPortType();
167 void setPortType( unsigned int newValue);
168 int getMidiChannels();
169 void setMidiChannels(int newValue);
170 int getMidiVoices();
171 void setMidiVoices(int newValue);
172 int getSynthVoices();
173 void setSynthVoices(int newValue);
174 bool getTimestamping();
175 bool getTimestampReal();
176 int getTimestampQueue();
177 void setTimestamping(bool value);
178 void setTimestampReal(bool value);
179 void setTimestampQueue(int queueId);
180
181Q_SIGNALS:
204
205protected:
206 PortInfo* getPortInfo();
207 void freeSubscriptions();
208 void setMidiClient( MidiClient* seq );
209
210private:
211 MidiClient* m_MidiClient;
212 PortInfo m_Info;
213 bool m_Attached;
214 SubscriptionsList m_Subscriptions;
215};
216
220typedef QList<MidiPort*> MidiPortList;
221
224}} /* namespace drumstick::ALSA */
225
226#endif //DRUMSTICK_ALSAPORT_H
The QObject class is the base class of all Qt objects.
Client information.
Definition: alsaclient.h:71
Client management.
Definition: alsaclient.h:219
Port management.
Definition: alsaport.h:125
void detached(drumstick::ALSA::MidiPort *port)
Signal emitted when the port is detached from a MidiClient.
void attached(drumstick::ALSA::MidiPort *port)
Signal emitted when the port is attached to a MidiClient.
void subscribed(drumstick::ALSA::MidiPort *port, drumstick::ALSA::Subscription *subs)
Signal emitted when an internal subscription is done.
void midiClientChanged(drumstick::ALSA::MidiPort *port, drumstick::ALSA::MidiClient *seq)
Signal emitted when the MidiClient has changed.
Port information container.
Definition: alsaport.h:52
Subscription management.
Definition: subscription.h:97
QList< MidiPort * > MidiPortList
List of Ports instances.
Definition: alsaport.h:220
QList< PortInfo > PortInfoList
List of port information objects.
Definition: alsaport.h:117
QList< Subscription > SubscriptionsList
List of subscriptions.
Definition: subscription.h:133
QList< Subscriber > SubscribersList
List of subscribers.
Definition: subscription.h:138
Drumstick common.
Definition: alsaclient.cpp:68
Classes managing ALSA sequencer subscriptions.