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
32
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 );
146 void updateSubscribers();
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);
188 void midiClientChanged(MidiPort* port, MidiClient* seq);
193 void attached(MidiPort* port);
198 void detached(MidiPort* port);
199
200protected:
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
220
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 management.
Definition alsaclient.h:199
QString getPortName()
Gets the port name.
Definition alsaport.cpp:894
void freeSubscriptions()
Releases the lists of subscriptions.
Definition alsaport.cpp:590
void detached(MidiPort *port)
Signal emitted when the port is detached from a MidiClient.
void subscribeTo(PortInfo *port)
Subscribe to another port destination.
Definition alsaport.cpp:655
void updateConnectionsTo(const PortInfoList &desired)
Update the write subscriptions.
void unsubscribeAll()
Unsubscribe all subscriptions.
Definition alsaport.cpp:863
void attached(MidiPort *port)
Signal emitted when the port is attached to a MidiClient.
void unsubscribeTo(QString const &name)
Unsubscribe a destination port.
Definition alsaport.cpp:704
void subscribe(Subscription *subs)
Subscribe a Subscription object.
Definition alsaport.cpp:615
void subscribeFrom(PortInfo *port)
Subscribe a source port.
Definition alsaport.cpp:755
PortInfoList getWriteSubscribers()
Gets the list of write subscribers.
bool getTimestamping()
Gets the timestamping mode.
void updateConnectionsFrom(const PortInfoList &desired)
Update the read susbcriptions.
void setPortName(QString const &newName)
Sets the port name.
Definition alsaport.cpp:904
unsigned int getPortType()
Gets the port type.
Definition alsaport.cpp:949
int getMidiVoices()
Gets the MIDI voices.
Definition alsaport.cpp:992
void unsubscribe(Subscription *subs)
Unsubscribe a Subscription object.
Definition alsaport.cpp:627
int getTimestampQueue()
Gets the timestamp queue number.
void attach(MidiClient *seq)
Attach the port to a MidiClient instance.
void setPortType(unsigned int newValue)
Sets the port type bitmap.
Definition alsaport.cpp:960
PortInfoList getReadSubscribers()
Gets the list of read subscribers.
int getMidiChannels()
Gets the MIDI channels.
Definition alsaport.cpp:971
void setCapability(unsigned int newValue)
Sets the port capabilities.
Definition alsaport.cpp:937
void midiClientChanged(MidiPort *port, MidiClient *seq)
Signal emitted when the MidiClient has changed.
bool getTimestampReal()
Gets the timestamp real mode.
static bool containsAddress(const snd_seq_addr_t *addr, const PortInfoList &lst)
Checks if the provided address is included in the port list.
void subscribeFromAnnounce()
Subscribe from the System:announce port.
Definition alsaport.cpp:854
void setTimestamping(bool value)
Sets the timestamping mode.
void setMidiClient(MidiClient *seq)
Sets the MidiClient.
Definition alsaport.cpp:600
int getSynthVoices()
Gets the synth voices.
int getPortId()
Gets the port number.
Definition alsaport.cpp:915
void setMidiVoices(int newValue)
Sets the MIDI voices.
void setMidiChannels(int newValue)
Sets the MIDI channels.
Definition alsaport.cpp:981
void updateSubscribers()
Update the subscribers list in the PortInfo member.
void detach()
Detach the port from any MidiClient instance previously attached.
void setSynthVoices(int newValue)
Sets the synth voices.
void unsubscribeFrom(QString const &name)
Unsubscribe a source port.
Definition alsaport.cpp:804
PortInfo * getPortInfo()
Gets the PortInfo object pointer.
Definition alsaport.cpp:571
void setTimestampReal(bool value)
Sets the timestamp real mode.
unsigned int getCapability()
Gets the port capabilities.
Definition alsaport.cpp:926
void setTimestampQueue(int queueId)
Sets the timestamp queue number.
SubscriptionsList getSubscriptions() const
Gets the list of susbcriptions.
Definition alsaport.cpp:581
void applyPortInfo()
Applies all the the delayed PortInfo changes to the MIDI port object.
Definition alsaport.cpp:880
MidiPort(QObject *parent=0)
Constructor.
Definition alsaport.cpp:549
void subscribed(MidiPort *port, Subscription *subs)
Signal emitted when an internal subscription is done.
Port information container.
Definition alsaport.h:41
int getSizeOfInfo() const
Gets the size of the ALSA info object.
Definition alsaport.cpp:473
QString getClientName() const
Gets the client name.
Definition alsaport.h:60
int getClient()
Gets the client number.
Definition alsaport.cpp:145
int getPort()
Gets the port number.
Definition alsaport.cpp:156
PortInfo & operator=(const PortInfo &other)
Assignment operator.
Definition alsaport.cpp:130
PortInfo()
Default constructor.
Definition alsaport.cpp:56
PortInfo * clone()
Copy the current object.
Definition alsaport.cpp:120
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.