drumstick
0.5.0
|
00001 /* 00002 MIDI Sequencer C++ library 00003 Copyright (C) 2006-2010, Pedro Lopez-Cabanillas <plcl@users.sf.net> 00004 00005 This library is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License along 00016 with this program; if not, write to the Free Software Foundation, Inc., 00017 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 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(); 00094 00099 void setClientName(QString name) { m_ClientName = name; } 00100 00101 private: 00102 snd_seq_port_info_t* m_Info; 00103 QString m_ClientName; 00104 SubscribersList m_ReadSubscribers; 00105 SubscribersList m_WriteSubscribers; 00106 }; 00107 00108 00112 typedef QList<PortInfo> PortInfoList; 00113 00119 class DRUMSTICK_EXPORT MidiPort : public QObject 00120 { 00121 Q_OBJECT 00122 friend class MidiClient; 00123 00124 public: 00125 MidiPort( QObject* parent = 0 ); 00126 virtual ~MidiPort(); 00127 00128 void attach( MidiClient* seq ); 00129 void detach(); 00130 void subscribe( Subscription* subs ); 00131 void unsubscribe( Subscription* subs ); 00132 void unsubscribeAll(); 00133 void unsubscribeTo( QString const& name ); 00134 void unsubscribeTo( PortInfo* port ); 00135 void unsubscribeTo( const snd_seq_addr_t* addr ); 00136 void unsubscribeFrom( QString const& name ); 00137 void unsubscribeFrom( PortInfo* port ); 00138 void unsubscribeFrom( const snd_seq_addr_t* addr ); 00139 void subscribeTo( PortInfo* port); 00140 void subscribeTo( int client, int port ); 00141 void subscribeTo( QString const& name ); 00142 void subscribeFrom( PortInfo* port ); 00143 void subscribeFrom( int client, int port ); 00144 void subscribeFrom( QString const& name ); 00145 void subscribeFromAnnounce(); 00146 void updateSubscribers(); 00147 SubscriptionsList getSubscriptions() const; 00148 PortInfoList getReadSubscribers(); 00149 PortInfoList getWriteSubscribers(); 00150 void updateConnectionsTo(const PortInfoList& desired); 00151 void updateConnectionsFrom(const PortInfoList& desired); 00152 00153 static bool containsAddress(const snd_seq_addr_t* addr, const PortInfoList& lst); 00154 00155 void applyPortInfo(); 00156 QString getPortName(); 00157 void setPortName( QString const& newName); 00158 int getPortId(); 00159 unsigned int getCapability(); 00160 void setCapability( unsigned int newValue); 00161 unsigned int getPortType(); 00162 void setPortType( unsigned int newValue); 00163 int getMidiChannels(); 00164 void setMidiChannels(int newValue); 00165 int getMidiVoices(); 00166 void setMidiVoices(int newValue); 00167 int getSynthVoices(); 00168 void setSynthVoices(int newValue); 00169 bool getTimestamping(); 00170 bool getTimestampReal(); 00171 int getTimestampQueue(); 00172 void setTimestamping(bool value); 00173 void setTimestampReal(bool value); 00174 void setTimestampQueue(int queueId); 00175 00176 signals: 00182 void subscribed(MidiPort* port, Subscription* subs); 00188 void midiClientChanged(MidiPort* port, MidiClient* seq); 00193 void attached(MidiPort* port); 00198 void detached(MidiPort* port); 00199 00200 protected: 00201 PortInfo* getPortInfo(); 00202 void freeSubscriptions(); 00203 void setMidiClient( MidiClient* seq ); 00204 00205 private: 00206 MidiClient* m_MidiClient; 00207 PortInfo m_Info; 00208 bool m_Attached; 00209 SubscriptionsList m_Subscriptions; 00210 }; 00211 00215 typedef QList<MidiPort*> MidiPortList; 00216 00217 } 00218 00221 #endif //DRUMSTICK_ALSAPORT_H