19 #include <QMetaMethod> 61 snd_seq_port_info_malloc(&m_Info);
70 snd_seq_port_info_malloc(&m_Info);
71 snd_seq_port_info_copy(m_Info, other.m_Info);
72 m_ReadSubscribers = other.m_ReadSubscribers;
73 m_WriteSubscribers = other.m_WriteSubscribers;
74 m_ClientName = other.m_ClientName;
83 snd_seq_port_info_malloc(&m_Info);
84 snd_seq_port_info_copy(m_Info, other);
95 snd_seq_port_info_malloc(&m_Info);
106 snd_seq_port_info_malloc(&m_Info);
115 snd_seq_port_info_free(m_Info);
137 snd_seq_port_info_copy(m_Info, other.m_Info);
138 m_ReadSubscribers = other.m_ReadSubscribers;
139 m_WriteSubscribers = other.m_WriteSubscribers;
140 m_ClientName = other.m_ClientName;
152 return snd_seq_port_info_get_client(m_Info);
163 return snd_seq_port_info_get_port(m_Info);
181 const snd_seq_addr_t*
184 return snd_seq_port_info_get_addr(m_Info);
195 return QString(snd_seq_port_info_get_name(m_Info));
206 return snd_seq_port_info_get_capability(m_Info);
217 return snd_seq_port_info_get_type(m_Info);
228 return snd_seq_port_info_get_midi_channels(m_Info);
239 return snd_seq_port_info_get_midi_voices(m_Info);
250 return snd_seq_port_info_get_synth_voices(m_Info);
260 return snd_seq_port_info_get_read_use(m_Info);
270 return snd_seq_port_info_get_write_use(m_Info);
281 return snd_seq_port_info_get_port_specified(m_Info);
292 snd_seq_port_info_set_client(m_Info, client);
303 snd_seq_port_info_set_port(m_Info, port);
314 snd_seq_port_info_set_addr(m_Info, addr);
325 snd_seq_port_info_set_name(m_Info, name.toLocal8Bit().data());
347 snd_seq_port_info_set_capability(m_Info, capability);
374 snd_seq_port_info_set_type(m_Info, type);
385 snd_seq_port_info_set_midi_channels(m_Info, channels);
396 snd_seq_port_info_set_midi_voices(m_Info, voices);
407 snd_seq_port_info_set_synth_voices(m_Info, voices);
418 snd_seq_port_info_set_port_specified(m_Info, val);
428 return m_ReadSubscribers;
438 return m_WriteSubscribers;
454 subs.
setType(SND_SEQ_QUERY_SUBS_READ);
457 while (snd_seq_query_port_subscribers(seq->
getHandle(), subs.m_Info) >= 0)
459 m_ReadSubscribers.append(subs);
463 subs.
setType(SND_SEQ_QUERY_SUBS_WRITE);
466 while (snd_seq_query_port_subscribers(seq->
getHandle(), subs.m_Info) >= 0)
468 m_WriteSubscribers.append(subs);
479 m_ReadSubscribers.clear();
480 m_WriteSubscribers.clear();
500 return snd_seq_port_info_sizeof();
511 return (snd_seq_port_info_get_timestamping(m_Info) == 1);
522 return (snd_seq_port_info_get_timestamp_real(m_Info) == 1);
533 return snd_seq_port_info_get_timestamp_queue(m_Info);
544 snd_seq_port_info_set_timestamping(m_Info, value?1:0);
555 snd_seq_port_info_set_timestamp_real(m_Info, value?1:0);
566 snd_seq_port_info_set_timestamp_queue(m_Info, queueId);
576 m_MidiClient( nullptr ),
609 return m_Subscriptions;
618 m_Subscriptions.clear();
628 if (m_MidiClient != seq)
645 m_Subscriptions.append(*subs);
646 if (isSignalConnected(subscribedSignal)) {
659 if (m_MidiClient ==
nullptr)
664 SubscriptionsList::iterator it;
665 for(it = m_Subscriptions.begin(); it != m_Subscriptions.end(); ++it)
673 m_Subscriptions.erase(it);
702 addr.client = client;
718 if ((m_MidiClient !=
nullptr) && (m_MidiClient->
getHandle() !=
nullptr))
737 if ((m_MidiClient !=
nullptr) && (m_MidiClient->
getHandle() !=
nullptr))
755 if ((m_MidiClient !=
nullptr) && (m_MidiClient->
getHandle() !=
nullptr))
771 if ((m_MidiClient !=
nullptr) && (m_MidiClient->
getHandle() !=
nullptr))
802 addr.client = client;
818 if ((m_MidiClient !=
nullptr) && (m_MidiClient->
getHandle() !=
nullptr))
837 if ((m_MidiClient !=
nullptr) && (m_MidiClient->
getHandle() !=
nullptr))
855 if ((m_MidiClient !=
nullptr) && (m_MidiClient->
getHandle() !=
nullptr))
871 if ((m_MidiClient !=
nullptr) && (m_MidiClient->
getHandle() !=
nullptr))
885 subscribeFrom(SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_ANNOUNCE);
894 if (m_MidiClient ==
nullptr) {
897 SubscriptionsList::Iterator it;
898 for( it = m_Subscriptions.begin(); it != m_Subscriptions.end(); ++it) {
902 m_Subscriptions.clear();
911 if (m_Attached && (m_MidiClient !=
nullptr) && (m_MidiClient->
isOpened()))
914 m_Info.
getPort(), m_Info.m_Info ));
1128 if (!m_Attached && (seq !=
nullptr)) {
1142 if (m_Attached && (m_MidiClient !=
nullptr)) {
1167 SubscribersList::ConstIterator it;
1168 for(it = subs.constBegin(); it != subs.constEnd(); ++it) {
1170 int client = s.
getAddr()->client;
1171 if ((client != SND_SEQ_CLIENT_SYSTEM) && (client != m_Info.
getClient())) {
1173 PortInfo p(m_MidiClient, client, port);
1174 if ((p.
getCapability() & SND_SEQ_PORT_CAP_NO_EXPORT) == 0) {
1192 SubscribersList::ConstIterator it;
1193 for(it = subs.constBegin(); it != subs.constEnd(); ++it) {
1195 int client = s.
getAddr()->client;
1196 if ((client != SND_SEQ_CLIENT_SYSTEM) && (client != m_Info.
getClient())) {
1198 PortInfo p(m_MidiClient, client, port);
1199 if ((p.
getCapability() & SND_SEQ_PORT_CAP_NO_EXPORT) == 0) {
1217 PortInfoList::ConstIterator i;
1218 for( i = lst.begin(); i != lst.end(); ++i) {
1220 if ((p.
getAddr()->client == addr->client) &&
1221 (p.
getAddr()->port == addr->port)) {
1236 PortInfoList::ConstIterator i;
1237 for (i = subs.constBegin(); i != subs.constEnd(); ++i) {
1243 for (i = ports.constBegin(); i != ports.constEnd(); ++i) {
1259 PortInfoList::ConstIterator i;
1260 for (i = subs.constBegin(); i != subs.constEnd(); ++i) {
1266 for (i = ports.constBegin(); i != ports.constEnd(); ++i) {
void setTimestampReal(bool value)
Sets the timestamp real mode.
bool getTimestampReal()
Gets the timestamp real mode.
void portDetach(MidiPort *port)
Detach a MidiPort instance from this client.
void subscribed(drumstick::ALSA::MidiPort *port, drumstick::ALSA::Subscription *subs)
Signal emitted when an internal subscription is done.
Error checking functions and macros.
SubscribersList getReadSubscribers() const
Gets the list of read subscribers.
void freeSubscribers()
Releases the subscribers lists.
MidiPort(QObject *parent=nullptr)
Constructor.
void subscribeTo(PortInfo *port)
Subscribe to another port destination.
void subscribeFromAnnounce()
Subscribe from the System:announce port.
static bool containsAddress(const snd_seq_addr_t *addr, const PortInfoList &lst)
Checks if the provided address is included in the port list.
void setDest(unsigned char client, unsigned char port)
Sets the Subscription's destination (MIDI IN) port.
void setClient(int client)
Sets the client number.
Classes managing ALSA Sequencer clients.
int getTimestampQueue()
Gets the timestamping queue number.
QString getClientName() const
Gets the client name.
void setPort(int port)
Set the port number.
void setPortSpecified(int val)
Sets the port-specified mode.
void updateConnectionsFrom(const PortInfoList &desired)
Update the read susbcriptions.
void setPortType(unsigned int newValue)
Sets the port type bitmap.
unsigned int getPortType()
Gets the port type.
void freeSubscriptions()
Releases the lists of subscriptions.
unsigned int getCapability()
Gets the port capabilities.
snd_seq_t * getHandle()
Returns the sequencer handler managed by ALSA.
void setName(QString const &name)
Sets the port name.
void setTimestampReal(bool value)
Sets the timestamping real mode.
#define DRUMSTICK_ALSA_CHECK_WARNING(x)
This macro calls the check warning function.
int getReadUse()
Get the number of read subscriptions.
int getPort()
Gets the port number.
Subscriber container class.
void setType(snd_seq_query_subs_type_t type)
Sets the subscription type.
The QObject class is the base class of all Qt objects.
void setMidiChannels(int newValue)
Sets the MIDI channels.
QString getName()
Gets the port name.
unsigned int getType()
Gets the port type.
void setTimestamping(bool value)
Sets the timestamping mode.
void setTimestamping(bool value)
Sets the timestamping mode.
PortInfo * clone()
Copy the current object.
int getSizeOfInfo() const
Gets the size of the ALSA info object.
QString getPortName()
Gets the port name.
void setTimestampQueue(int queueId)
Sets the timestamp queue number.
void setTimestampQueue(int queueId)
Sets the timestamp queue number.
int getWriteUse()
Gets the number of write subscriptions.
void unsubscribe(MidiClient *seq)
Breaks the subscription in the ALSA sequencer subsystem.
const snd_seq_addr_t * getAddr()
Gets the subscriber's address.
void setPortName(QString const &newName)
Sets the port name.
void updateSubscribers()
Update the subscribers list in the PortInfo member.
void unsubscribeTo(QString const &name)
Unsubscribe a destination port.
QList< PortInfo > PortInfoList
List of port information objects.
int getIndex()
Gets the index of the subscriber container.
int getMidiVoices()
Gets the MIDI voices.
void unsubscribeAll()
Unsubscribe all subscriptions.
PortInfoList getWriteSubscribers()
Gets the list of write subscribers.
Port information container.
const snd_seq_addr_t * getAddr()
Gets the address record for this port.
int getPortId()
Gets the port number.
void setCapability(unsigned int capability)
Sets the capability bitmap.
bool getTimestamping()
Gets the timestamping mode.
void setMidiVoices(int newValue)
Sets the MIDI voices.
QList< Subscription > SubscriptionsList
List of subscriptions.
void subscribeFrom(PortInfo *port)
Subscribe a source port.
void setSender(unsigned char client, unsigned char port)
Sets the Subscription's sender (MIDI OUT) port.
void portAttach(MidiPort *port)
Attach a MidiPort instance to this client.
void detach()
Detach the port from any MidiClient instance previously attached.
void setCapability(unsigned int newValue)
Sets the port capabilities.
bool parseAddress(const QString &straddr, snd_seq_addr &result)
Parse a text address representation, returning an ALSA address record.
SubscriptionsList getSubscriptions() const
Gets the list of susbcriptions.
void applyPortInfo()
Applies all the the delayed PortInfo changes to the MIDI port object.
void setAddr(const snd_seq_addr_t *addr)
Sets the address record.
bool getTimestamping()
Gets the timestamping mode.
PortInfo & operator=(const PortInfo &other)
Assignment operator.
virtual ~PortInfo()
Destructor.
bool getTimestampReal()
Gets the timestamping real mode.
int getPortSpecified()
Gets the port-specified mode.
void setSynthVoices(int newValue)
Sets the synth voices.
int getTimestampQueue()
Gets the timestamp queue number.
void setMidiVoices(int voices)
Sets the MIDI voices.
void subscribe(MidiClient *seq)
Performs the subscription in the ALSA sequencer subsystem.
PortInfo()
Default constructor.
void midiClientChanged(drumstick::ALSA::MidiPort *port, drumstick::ALSA::MidiClient *seq)
Signal emitted when the MidiClient has changed.
void setSynthVoices(int voices)
Sets the synth voices.
int getSynthVoices()
Gets the synth voices.
void updateConnectionsTo(const PortInfoList &desired)
Update the write subscriptions.
bool isOpened()
Returns true if the sequencer is opened.
int getMidiVoices()
Gets the MIDI voices.
void readSubscribers(MidiClient *seq)
Obtains the port subscribers lists.
void setClientName(QString name)
Sets the client name.
SubscribersList getWriteSubscribers() const
Gets the list of write subscribers.
void setIndex(int index)
Sets the index of the subscriber.
Subscription * clone()
Copy the current object.
PortInfo * getPortInfo()
Gets the PortInfo object pointer.
const snd_seq_addr_t * getDest()
Gets the destination address of the subscription (MIDI IN port)
QList< Subscriber > SubscribersList
List of subscribers.
void subscribe(Subscription *subs)
Subscribe a Subscription object.
int getClient()
Gets the client number.
int getMidiChannels()
Gets the MIDI channels.
unsigned int getCapability()
Gets the capabilities bitmap.
virtual ~MidiPort()
Destructor.
Classes managing ALSA Sequencer queues.
void unsubscribeFrom(QString const &name)
Unsubscribe a source port.
void detached(drumstick::ALSA::MidiPort *port)
Signal emitted when the port is detached from a MidiClient.
void setType(unsigned int type)
Sets the port type.
void setMidiChannels(int channels)
Set the MIDI channels.
int getMidiChannels()
Gets the MIDI channels.
void attached(drumstick::ALSA::MidiPort *port)
Signal emitted when the port is attached to a MidiClient.
void attach(MidiClient *seq)
Attach the port to a MidiClient instance.
PortInfoList getReadSubscribers()
Gets the list of read subscribers.
const snd_seq_addr_t * getSender()
Gets the sender address of the subscription (MIDI OUT port)
void unsubscribe(Subscription *subs)
Unsubscribe a Subscription object.
QString getClientName()
Gets the client's public name.
void setRoot(snd_seq_addr_t *addr)
Sets the subscriber's root address.
int getSynthVoices()
Gets the synth voices.
void setMidiClient(MidiClient *seq)
Sets the MidiClient.