drumstick 2.9.0
C++ MIDI libraries using Qt objects, idioms, and style.
|
Sequence player auxiliary class. More...
#include <playthread.h>
Public Slots | |
void | start (QThread::Priority priority=InheritPriority) |
Starts the playback thread. More... | |
Signals | |
void | playbackFinished () |
Signal emitted when the sequence play-back has finished. | |
void | playbackStopped () |
Signal emitted when the play-back has stopped. | |
Public Member Functions | |
SequencerOutputThread (MidiClient *seq, int portId) | |
Constructor. More... | |
virtual void | run () override |
Thread process loop. | |
virtual unsigned int | getInitialPosition () |
Gets the initial position in ticks of the sequence. More... | |
virtual unsigned int | getEchoResolution () |
Gets the echo event resolution in ticks. More... | |
virtual bool | hasNext ()=0 |
Check if there is one more event in the sequence. More... | |
virtual SequencerEvent * | nextEvent ()=0 |
Gets the next event in the sequence. More... | |
virtual void | stop () |
Stops playing the current sequence. More... | |
Protected Member Functions | |
virtual void | sendEchoEvent (int tick) |
Sends an echo event, with the same PortId as sender and destination. More... | |
virtual void | sendSongEvent (SequencerEvent *ev) |
Sends a SequencerEvent. More... | |
virtual void | drainOutput () |
Flush the ALSA output buffer. | |
virtual void | syncOutput () |
Waits until the ALSA output queue is empty (all the events have been played.) | |
virtual bool | stopRequested () |
Checks if stop has been requested. More... | |
Protected Attributes | |
MidiClient * | m_MidiClient |
MidiClient instance pointer. | |
MidiQueue * | m_Queue |
MidiQueue instance pointer. | |
int | m_PortId |
MidiPort numeric identifier. | |
bool | m_Stopped |
Stopped status. | |
int | m_QueueId |
MidiQueue numeric identifier. | |
int | m_npfds |
Number of pollfd pointers. | |
pollfd * | m_pfds |
Array of pollfd pointers. | |
QReadWriteLock | m_mutex |
Mutex object used for synchronization. | |
Sequence player auxiliary class.
This class is used to implement an asynchronous sequence player using ALSA sequencer scheduling
Examples: guiplayer.cpp and playsmf.cpp
Definition at line 58 of file playthread.h.
SequencerOutputThread | ( | MidiClient * | seq, |
int | portId | ||
) |
Constructor.
seq | Existing MidiClient object pointer |
portId | Numeric input/output port identifier |
Definition at line 67 of file playthread.cpp.
References MidiClient::getQueue(), SequencerOutputThread::m_MidiClient, SequencerOutputThread::m_Queue, and SequencerOutputThread::m_QueueId.
|
inlinevirtual |
Gets the echo event resolution in ticks.
This is the time between echo events interleaved with the MIDI sequence. The default value zero means that no echo events are sent at all.
Definition at line 77 of file playthread.h.
Referenced by SequencerOutputThread::run().
|
inlinevirtual |
Gets the initial position in ticks of the sequence.
The default value zero means starting from the beginning.
Definition at line 70 of file playthread.h.
Referenced by SequencerOutputThread::run().
|
pure virtual |
Check if there is one more event in the sequence.
This is a pure virtual method that must be overridden in the derived class.
Referenced by SequencerOutputThread::run().
|
pure virtual |
Gets the next event in the sequence.
This is a pure virtual function that must be overridden in the derived class.
Referenced by SequencerOutputThread::run().
|
protectedvirtual |
Sends an echo event, with the same PortId as sender and destination.
tick | Event schedule time in ticks. |
Definition at line 114 of file playthread.cpp.
References MidiClient::getClientId(), SequencerOutputThread::m_MidiClient, SequencerOutputThread::m_PortId, SequencerOutputThread::m_QueueId, SequencerEvent::scheduleTick(), SequencerOutputThread::sendSongEvent(), SequencerEvent::setDestination(), SequencerEvent::setSource(), and SequencerOutputThread::stopRequested().
Referenced by SequencerOutputThread::run().
|
protectedvirtual |
Sends a SequencerEvent.
ev | SequencerEvent object pointer |
Definition at line 130 of file playthread.cpp.
References MidiClient::getHandle(), SequencerEvent::getHandle(), SequencerOutputThread::m_MidiClient, SequencerOutputThread::m_npfds, SequencerOutputThread::m_pfds, and SequencerOutputThread::stopRequested().
Referenced by SequencerOutputThread::run(), and SequencerOutputThread::sendEchoEvent().
|
slot |
Starts the playback thread.
priority | Thread priority, default is InheritPriority |
Definition at line 219 of file playthread.cpp.
References SequencerOutputThread::m_mutex, and SequencerOutputThread::m_Stopped.
|
virtual |
Stops playing the current sequence.
Stops the playback task.
Definition at line 99 of file playthread.cpp.
References SequencerOutputThread::m_mutex, and SequencerOutputThread::m_Stopped.
|
protectedvirtual |
Checks if stop has been requested.
Definition at line 89 of file playthread.cpp.
References SequencerOutputThread::m_mutex, and SequencerOutputThread::m_Stopped.
Referenced by SequencerOutputThread::drainOutput(), SequencerOutputThread::run(), SequencerOutputThread::sendEchoEvent(), SequencerOutputThread::sendSongEvent(), and SequencerOutputThread::syncOutput().