drumstick 1.1.3
alsaport.h
Go to the documentation of this file.
1/*
2 MIDI Sequencer C++ library
3 Copyright (C) 2006-2019, 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
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
32namespace drumstick {
33
34class MidiClient;
35
39class DRUMSTICK_EXPORT PortInfo
40{
41 friend class MidiPort;
42 friend class ClientInfo;
43 friend class MidiClient;
44
45public:
46 PortInfo();
47 PortInfo(const PortInfo& other);
48 PortInfo(snd_seq_port_info_t* other);
49 PortInfo(MidiClient* seq, const int client, const int port);
50 PortInfo(MidiClient* seq, const int port);
51 virtual ~PortInfo();
52 PortInfo* clone();
53 PortInfo& operator=(const PortInfo& other);
54 int getSizeOfInfo() const;
55
56 int getClient();
57 int getPort();
59 QString getClientName() const { return m_ClientName; }
60 const snd_seq_addr_t* getAddr();
61 QString getName();
62 unsigned int getCapability();
63 unsigned int getType();
64 int getMidiChannels();
65 int getMidiVoices();
66 int getSynthVoices();
67 int getReadUse();
68 int getWriteUse();
69 int getPortSpecified();
70 void setClient(int client);
71 void setPort(int port);
72 void setAddr(const snd_seq_addr_t* addr);
73 void setName( QString const& name );
74 void setCapability(unsigned int capability);
75 void setType(unsigned int type);
76 void setMidiChannels(int channels);
77 void setMidiVoices(int voices);
78 void setSynthVoices(int voices);
79 void setPortSpecified(int val);
80 SubscribersList getReadSubscribers() const;
81 SubscribersList getWriteSubscribers() const;
82
83 bool getTimestamping();
84 bool getTimestampReal();
85 int getTimestampQueue();
86 void setTimestamping(bool value);
87 void setTimestampReal(bool value);
88 void setTimestampQueue(int queueId);
89
90protected:
91 void readSubscribers(MidiClient* seq);
92 void freeSubscribers();
93
98 void setClientName(QString name) { m_ClientName = name; }
99
100private:
101 snd_seq_port_info_t* m_Info;
102 QString m_ClientName;
103 SubscribersList m_ReadSubscribers;
104 SubscribersList m_WriteSubscribers;
105};
106
107
111typedef QList<PortInfo> PortInfoList;
112
118class DRUMSTICK_EXPORT MidiPort : public QObject
119{
120 Q_OBJECT
121 friend class MidiClient;
122
123public:
124 MidiPort( QObject* parent = 0 );
125 virtual ~MidiPort();
126
127 void attach( MidiClient* seq );
128 void detach();
129 void subscribe( Subscription* subs );
130 void unsubscribe( Subscription* subs );
131 void unsubscribeAll();
132 void unsubscribeTo( QString const& name );
133 void unsubscribeTo( PortInfo* port );
134 void unsubscribeTo( const snd_seq_addr_t* addr );
135 void unsubscribeFrom( QString const& name );
136 void unsubscribeFrom( PortInfo* port );
137 void unsubscribeFrom( const snd_seq_addr_t* addr );
138 void subscribeTo( PortInfo* port);
139 void subscribeTo( int client, int port );
140 void subscribeTo( QString const& name );
141 void subscribeFrom( PortInfo* port );
142 void subscribeFrom( int client, int port );
143 void subscribeFrom( QString const& name );
144 void subscribeFromAnnounce();
145 void updateSubscribers();
146 SubscriptionsList getSubscriptions() const;
147 PortInfoList getReadSubscribers();
148 PortInfoList getWriteSubscribers();
149 void updateConnectionsTo(const PortInfoList& desired);
150 void updateConnectionsFrom(const PortInfoList& desired);
151
152 static bool containsAddress(const snd_seq_addr_t* addr, const PortInfoList& lst);
153
154 void applyPortInfo();
155 QString getPortName();
156 void setPortName( QString const& newName);
157 int getPortId();
158 unsigned int getCapability();
159 void setCapability( unsigned int newValue);
160 unsigned int getPortType();
161 void setPortType( unsigned int newValue);
162 int getMidiChannels();
163 void setMidiChannels(int newValue);
164 int getMidiVoices();
165 void setMidiVoices(int newValue);
166 int getSynthVoices();
167 void setSynthVoices(int newValue);
168 bool getTimestamping();
169 bool getTimestampReal();
170 int getTimestampQueue();
171 void setTimestamping(bool value);
172 void setTimestampReal(bool value);
173 void setTimestampQueue(int queueId);
174
175signals:
181 void subscribed(MidiPort* port, Subscription* subs);
192 void attached(MidiPort* port);
197 void detached(MidiPort* port);
198
199protected:
200 PortInfo* getPortInfo();
201 void freeSubscriptions();
202 void setMidiClient( MidiClient* seq );
203
204private:
205 MidiClient* m_MidiClient;
206 PortInfo m_Info;
207 bool m_Attached;
208 SubscriptionsList m_Subscriptions;
209};
210
214typedef QList<MidiPort*> MidiPortList;
215
216}
217
220#endif //DRUMSTICK_ALSAPORT_H
QList< MidiPort * > MidiPortList
List of Ports instances.
Definition alsaport.h:214
QList< PortInfo > PortInfoList
List of port information objects.
Definition alsaport.h:111
The QObject class is the base class of all Qt objects.
Client information.
Definition alsaclient.h:50
Client management.
Definition alsaclient.h:198
Port management.
Definition alsaport.h:119
void detached(MidiPort *port)
Signal emitted when the port is detached from a MidiClient.
void attached(MidiPort *port)
Signal emitted when the port is attached to a MidiClient.
void midiClientChanged(MidiPort *port, MidiClient *seq)
Signal emitted when the MidiClient has changed.
void subscribed(MidiPort *port, Subscription *subs)
Signal emitted when an internal subscription is done.
Port information container.
Definition alsaport.h:40
QString getClientName() const
Gets the client name.
Definition alsaport.h:59
void setClientName(QString name)
Sets the client name.
Definition alsaport.h:98
Subscription management.
Classes managing ALSA sequencer subscriptions.
QList< Subscription > SubscriptionsList
List of subscriptions.
QList< Subscriber > SubscribersList
List of subscribers.