19#ifndef DRUMSTICK_ALSAEVENT_H
20#define DRUMSTICK_ALSAEVENT_H
23 #include <alsa/asoundlib.h>
40#if defined(DRUMSTICK_STATIC)
41#define DRUMSTICK_ALSA_EXPORT
43#if defined(drumstick_alsa_EXPORTS)
44#define DRUMSTICK_ALSA_EXPORT Q_DECL_EXPORT
46#define DRUMSTICK_ALSA_EXPORT Q_DECL_IMPORT
75 void setSequencerType(
const snd_seq_event_type_t eventType);
82 void setDestination(
const unsigned char client,
const unsigned char port);
83 void setSource(
const unsigned char port);
101 snd_seq_tick_time_t
getTick()
const {
return m_event.time.tick; }
114 void setSubscribers();
117 void scheduleTick(
const int queue,
const int tick,
const bool relative);
118 void scheduleReal(
const int queue,
const ulong secs,
const ulong nanos,
const bool relative);
119 void setPriority(
const bool high);
125 unsigned char getTag()
const {
return m_event.tag; }
126 void setTag(
const unsigned char aTag);
127 unsigned int getRaw32(
const unsigned int n)
const;
128 void setRaw32(
const unsigned int n,
const unsigned int value);
129 unsigned char getRaw8(
const unsigned int n)
const;
130 void setRaw8(
const unsigned int n,
const unsigned char value);
136 int getEncodedLength();
146 Q_DECL_DEPRECATED
void free();
202 int getKey()
const {
return m_event.data.note.note; }
222 virtual KeyEvent* clone()
const override;
244 NoteEvent(
const int ch,
const int key,
const int vel,
const int dur);
256 void setDuration(
const ulong d) { m_event.data.note.duration = d; }
258 virtual NoteEvent* clone()
const override;
277 NoteOnEvent(
const int ch,
const int key,
const int vel);
297 NoteOffEvent(
const int ch,
const int key,
const int vel);
343 uint
getParam()
const {
return m_event.data.control.param; }
349 void setParam(
const uint p ) { m_event.data.control.param = p; }
355 int getValue()
const {
return m_event.data.control.value; }
361 void setValue(
const int v ) { m_event.data.control.value = v; }
386 int getValue()
const {
return m_event.data.control.value; }
391 void setValue(
const int v ) { m_event.data.control.value = v; }
416 int getValue()
const {
return m_event.data.control.value; }
421 void setValue(
const int v ) { m_event.data.control.value = v; }
446 int getValue()
const {
return m_event.data.control.value; }
451 void setValue(
const int v ) { m_event.data.control.value = v; }
471 unsigned int getLength()
const {
return m_event.data.ext.len; }
476 const char*
getData()
const {
return static_cast<const char*
>(m_event.data.ext.ptr); }
489 explicit SysExEvent(
const snd_seq_event_t* event);
492 SysExEvent(
const unsigned int datalen,
char* dataptr);
507 explicit TextEvent(
const snd_seq_event_t* event);
508 explicit TextEvent(
const QString& text,
const int textType = 1);
510 TextEvent(
const unsigned int datalen,
char* dataptr);
512 QString getText()
const;
513 int getTextType()
const;
514 virtual TextEvent* clone()
const override;
532 explicit SystemEvent(
const snd_seq_event_type_t type);
551 QueueControlEvent(
const snd_seq_event_type_t type,
const int queue,
const int value);
556 int getQueue()
const {
return m_event.data.queue.queue; }
561 void setQueue(
const uchar q) { m_event.data.queue.queue = q; }
566 int getValue()
const {
return m_event.data.queue.param.value; }
571 void setValue(
const int val) { m_event.data.queue.param.value = val; }
576 uint
getPosition()
const {
return m_event.data.queue.param.position; }
581 void setPosition(
const uint pos) { m_event.data.queue.param.position = pos; }
586 snd_seq_tick_time_t
getTickTime()
const {
return m_event.data.queue.param.time.tick; }
591 void setTickTime(
const snd_seq_tick_time_t t) { m_event.data.queue.param.time.tick = t; }
596 uint
getSkewBase()
const {
return m_event.data.queue.param.skew.base; }
601 void setSkewBase(
const uint base) { m_event.data.queue.param.skew.base = base; }
606 uint
getSkewValue()
const {
return m_event.data.queue.param.skew.value; }
611 void setSkewValue(
const uint val) {m_event.data.queue.param.skew.value = val; }
628 ValueEvent(
const snd_seq_event_type_t type,
const int val);
633 int getValue()
const {
return m_event.data.control.value; }
638 void setValue(
const int v ) { m_event.data.control.value = v; }
676 bool subscribed()
const {
return (m_event.type == SND_SEQ_EVENT_PORT_SUBSCRIBED); }
681 bool unsubscribed()
const {
return (m_event.type == SND_SEQ_EVENT_PORT_UNSUBSCRIBED); }
701 int getDestPort()
const {
return m_event.data.connect.dest.port; }
722 int getClient()
const {
return m_event.data.addr.client; }
743 int getPort()
const {
return m_event.data.addr.port; }
744 virtual PortEvent* clone()
const override;
763 int getSizeOfInfo()
const;
766 unsigned int getCondition();
767 const snd_seq_addr_t* getDest();
771 const snd_seq_timestamp_t* getTime();
772 void setChannel(
int chan);
773 void setCondition(
unsigned int cond);
774 void setDest(
const snd_seq_addr_t* dest);
775 void setEventType(
int type);
776 void setQueue(
int queue);
777 void setTag(
int tag);
778 void setTime(
const snd_seq_timestamp_t* time);
781 snd_seq_remove_events_t* m_Info;
795 long decode(
unsigned char *buf,
797 const snd_seq_event_t *ev);
798 long encode(
const unsigned char *buf,
800 snd_seq_event_t *ev);
802 snd_seq_event_t *ev);
803 void enableRunningStatus(
bool enable);
806 void resizeBuffer(
int bufsize);
808 snd_midi_event_t* m_Info;
The QEvent class is the base class of all event classes.
The QObject class is the base class of all Qt objects.
Event representing a MIDI channel pressure or after-touch event.
ChanPressEvent(const snd_seq_event_t *event)
Constructor from an ALSA event record.
void setValue(const int v)
Sets the channel aftertouch value.
int getValue() const
Gets the channel aftertouch value.
ChanPressEvent()
Default constructor.
Base class for the events having a Channel property.
void setChannel(const MidiByte c)
Sets the channel of the event.
ChannelEvent()
Default constructor.
ChannelEvent(const snd_seq_event_t *event)
Constructor from an ALSA event record.
int getChannel() const
Gets the event's channel.
ALSA Event representing a change on some ALSA sequencer client on the system.
ClientEvent()
Default constructor.
int getClient() const
Gets the client number.
ClientEvent(const snd_seq_event_t *event)
Constructor from an ALSA event record.
Event representing a MIDI control change event.
uint getParam() const
Gets the controller event's parameter.
ControllerEvent(const snd_seq_event_t *event)
Constructor from an ALSA event record.
void setParam(const uint p)
Sets the controller event's parameter.
void setValue(const int v)
Sets the controller event's value.
ControllerEvent()
Default constructor.
int getValue() const
Gets the controller event's value.
Base class for the events having Key and Velocity properties.
int getKey() const
Gets the MIDI note of this event.
KeyEvent(const snd_seq_event_t *event)
Constructor from an ALSA event record.
void setKey(const MidiByte b)
Sets the MIDI note of this event.
KeyEvent()
Default constructor.
void setVelocity(const MidiByte b)
Sets the note velocity of this event.
int getVelocity() const
Gets the note velocity of this event.
Event representing a MIDI key pressure, or polyphonic after-touch event.
KeyPressEvent(const snd_seq_event_t *event)
Constructor from an ALSA event record.
KeyPressEvent()
Default constructor.
Auxiliary class to translate between raw MIDI streams and ALSA events.
Class representing a note event with duration.
NoteEvent()
Default constructor.
void setDuration(const ulong d)
Sets the note's duration.
ulong getDuration() const
Gets the note's duration.
NoteEvent(const snd_seq_event_t *event)
Constructor from an ALSA event record.
Event representing a note-off MIDI event.
NoteOffEvent(const snd_seq_event_t *event)
Constructor from an ALSA event record.
NoteOffEvent()
Default constructor.
Event representing a note-on MIDI event.
NoteOnEvent(const snd_seq_event_t *event)
Constructor from an ALSA event record.
NoteOnEvent()
Default constructor.
Event representing a MIDI bender, or pitch wheel event.
PitchBendEvent(const snd_seq_event_t *event)
Constructor from an ALSA event record.
void setValue(const int v)
Sets the MIDI pitch bend value, zero centered from -8192 to 8191.
int getValue() const
Gets the MIDI pitch bend value, zero centered from -8192 to 8191.
PitchBendEvent()
Default constructor.
ALSA Event representing a change on some ALSA sequencer port on the system.
PortEvent()
Default constructor.
PortEvent(const snd_seq_event_t *event)
Constructor from an ALSA event record.
int getPort() const
Gets the port number.
Event representing a MIDI program change event.
void setValue(const int v)
Sets the MIDI program number.
ProgramChangeEvent(const snd_seq_event_t *event)
Constructor from an ALSA event record.
ProgramChangeEvent()
Default constructor.
int getValue() const
Gets the MIDI program number.
ALSA Event representing a queue control command.
QueueControlEvent(const snd_seq_event_t *event)
Constructor from an ALSA event record.
void setSkewValue(const uint val)
Sets the skew value.
void setTickTime(const snd_seq_tick_time_t t)
Sets the musical time in ticks.
uint getPosition() const
Gets the queue position.
uint getSkewBase() const
Gets the skew base.
void setSkewBase(const uint base)
Sets the skew base, should be 65536.
snd_seq_tick_time_t getTickTime() const
Gets the musical time in ticks.
int getQueue() const
Gets the queue number.
void setQueue(const uchar q)
Sets the queue number.
uint getSkewValue() const
Gets the skew value.
int getValue() const
Gets the event's value.
void setPosition(const uint pos)
Sets the queue position.
QueueControlEvent()
Default constructor.
void setValue(const int val)
Sets the event's value.
Auxiliary class to remove events from an ALSA queue.
Base class for the event's hierarchy.
snd_seq_event_t m_event
ALSA sequencer event record.
snd_seq_event_t * getHandle()
Gets the handle of the event.
unsigned char getSourceClient() const
Gets the source client id.
unsigned int getRealTimeSecs() const
Gets the seconds of the event's real time.
unsigned char getTag() const
Gets the tag of the event.
snd_seq_tick_time_t getTick() const
Gets the tick time of the event.
unsigned char getSourcePort() const
Gets the source port id.
snd_seq_event_type_t getSequencerType() const
Gets the sequencer event type.
unsigned int getRealTimeNanos() const
Gets the nanoseconds of the event's real time.
ALSA Event representing a subscription between two ALSA clients and ports.
bool subscribed() const
Returns true if the event was a subscribed port.
SubscriptionEvent(const snd_seq_event_t *event)
Constructor from an ALSA event record.
int getDestClient() const
Gets the destination client number.
int getDestPort() const
Gets the destination port number.
SubscriptionEvent()
Default constructor.
int getSenderClient() const
Gets the sender client number.
int getSenderPort() const
Gets the sender port number.
bool unsubscribed() const
Returns true if the event was an unsubscribed port.
Event representing a MIDI system exclusive event.
SystemEvent()
Default constructor.
SystemEvent(const snd_seq_event_t *event)
Constructor from an ALSA event record.
ALSA Event representing a tempo change for an ALSA queue.
TempoEvent()
Default constructor.
TempoEvent(const snd_seq_event_t *event)
Constructor from an ALSA event record.
Event representing a SMF text event.
Generic event having a value property.
ValueEvent(const snd_seq_event_t *event)
Constructor from an ALSA event record.
void setValue(const int v)
Sets the event's value.
ValueEvent()
Default constructor.
int getValue() const
Gets the event's value.
Base class for variable length events.
unsigned int getLength() const
Gets the data length.
const char * getData() const
Gets the data pointer.
quint8 MidiByte
8-bit unsigned number to be used as a MIDI message parameter
const QEvent::Type SequencerEventType
Constant SequencerEventType is the QEvent::type() of any SequencerEvent object to be used to check th...