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