00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef DRUMSTICK_ALSAPORT_H
00021 #define DRUMSTICK_ALSAPORT_H
00022
00023 #include "subscription.h"
00024 #include <QObject>
00025
00033 namespace drumstick {
00034
00035 class MidiClient;
00036
00040 class DRUMSTICK_EXPORT PortInfo
00041 {
00042 friend class MidiPort;
00043 friend class ClientInfo;
00044 friend class MidiClient;
00045
00046 public:
00047 PortInfo();
00048 PortInfo(const PortInfo& other);
00049 PortInfo(snd_seq_port_info_t* other);
00050 PortInfo(MidiClient* seq, const int client, const int port);
00051 PortInfo(MidiClient* seq, const int port);
00052 virtual ~PortInfo();
00053 PortInfo* clone();
00054 PortInfo& operator=(const PortInfo& other);
00055 int getSizeOfInfo() const;
00056
00057 int getClient();
00058 int getPort();
00060 QString getClientName() const { return m_ClientName; }
00061 const snd_seq_addr_t* getAddr();
00062 QString getName();
00063 unsigned int getCapability();
00064 unsigned int getType();
00065 int getMidiChannels();
00066 int getMidiVoices();
00067 int getSynthVoices();
00068 int getReadUse();
00069 int getWriteUse();
00070 int getPortSpecified();
00071 void setClient(int client);
00072 void setPort(int port);
00073 void setAddr(const snd_seq_addr_t* addr);
00074 void setName( QString const& name );
00075 void setCapability(unsigned int capability);
00076 void setType(unsigned int type);
00077 void setMidiChannels(int channels);
00078 void setMidiVoices(int voices);
00079 void setSynthVoices(int voices);
00080 void setPortSpecified(int val);
00081 SubscribersList getReadSubscribers() const;
00082 SubscribersList getWriteSubscribers() const;
00083
00084 bool getTimestamping();
00085 bool getTimestampReal();
00086 int getTimestampQueue();
00087 void setTimestamping(bool value);
00088 void setTimestampReal(bool value);
00089 void setTimestampQueue(int queueId);
00090
00091 protected:
00092 void readSubscribers(MidiClient* seq);
00093 void freeSubscribers();
00095 void setClientName(QString name) { m_ClientName = name; }
00096
00097 private:
00098 snd_seq_port_info_t* m_Info;
00099 QString m_ClientName;
00100 SubscribersList m_ReadSubscribers;
00101 SubscribersList m_WriteSubscribers;
00102 };
00103
00104
00108 typedef QList<PortInfo> PortInfoList;
00109
00115 class DRUMSTICK_EXPORT MidiPort : public QObject
00116 {
00117 Q_OBJECT
00118 friend class MidiClient;
00119
00120 public:
00121 MidiPort( QObject* parent = 0 );
00122 virtual ~MidiPort();
00123
00124 void attach( MidiClient* seq );
00125 void detach();
00126 void subscribe( Subscription* subs );
00127 void unsubscribe( Subscription* subs );
00128 void unsubscribeAll();
00129 void unsubscribeTo( QString const& name );
00130 void unsubscribeTo( PortInfo* port );
00131 void unsubscribeTo( const snd_seq_addr_t* addr );
00132 void unsubscribeFrom( QString const& name );
00133 void unsubscribeFrom( PortInfo* port );
00134 void unsubscribeFrom( const snd_seq_addr_t* addr );
00135 void subscribeTo( PortInfo* port);
00136 void subscribeTo( int client, int port );
00137 void subscribeTo( QString const& name );
00138 void subscribeFrom( PortInfo* port );
00139 void subscribeFrom( int client, int port );
00140 void subscribeFrom( QString const& name );
00141 void subscribeFromAnnounce();
00142 void updateSubscribers();
00143 SubscriptionsList getSubscriptions() const;
00144 PortInfoList getReadSubscribers();
00145 PortInfoList getWriteSubscribers();
00146 void updateConnectionsTo(const PortInfoList& desired);
00147 void updateConnectionsFrom(const PortInfoList& desired);
00148
00149 static bool containsAddress(const snd_seq_addr_t* addr, const PortInfoList& lst);
00150
00151 void applyPortInfo();
00152 QString getPortName();
00153 void setPortName( QString const& newName);
00154 int getPortId();
00155 unsigned int getCapability();
00156 void setCapability( unsigned int newValue);
00157 unsigned int getPortType();
00158 void setPortType( unsigned int newValue);
00159 int getMidiChannels();
00160 void setMidiChannels(int newValue);
00161 int getMidiVoices();
00162 void setMidiVoices(int newValue);
00163 int getSynthVoices();
00164 void setSynthVoices(int newValue);
00165 bool getTimestamping();
00166 bool getTimestampReal();
00167 int getTimestampQueue();
00168 void setTimestamping(bool value);
00169 void setTimestampReal(bool value);
00170 void setTimestampQueue(int queueId);
00171
00172 signals:
00178 void subscribed(MidiPort* port, Subscription* subs);
00184 void midiClientChanged(MidiPort* port, MidiClient* seq);
00189 void attached(MidiPort* port);
00194 void detached(MidiPort* port);
00195
00196 protected:
00197 PortInfo* getPortInfo();
00198 void freeSubscriptions();
00199 void setMidiClient( MidiClient* seq );
00200
00201 private:
00202 MidiClient* m_MidiClient;
00203 PortInfo m_Info;
00204 bool m_Attached;
00205 SubscriptionsList m_Subscriptions;
00206 };
00207
00211 typedef QList<MidiPort*> MidiPortList;
00212
00213 }
00214
00217 #endif //DRUMSTICK_ALSAPORT_H