drumstick 2.9.0
C++ MIDI libraries using Qt objects, idioms, and style.
SequencerOutputThread Class Referenceabstract

Sequence player auxiliary class. More...

#include <playthread.h>

Inheritance diagram for SequencerOutputThread:

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 SequencerEventnextEvent ()=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

MidiClientm_MidiClient
 MidiClient instance pointer.
 
MidiQueuem_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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SequencerOutputThread()

SequencerOutputThread ( MidiClient seq,
int  portId 
)

Constructor.

Parameters
seqExisting MidiClient object pointer
portIdNumeric 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.

Member Function Documentation

◆ getEchoResolution()

virtual unsigned int getEchoResolution ( )
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.

Returns
Echo resolution (ticks)

Definition at line 77 of file playthread.h.

Referenced by SequencerOutputThread::run().

◆ getInitialPosition()

virtual unsigned int getInitialPosition ( )
inlinevirtual

Gets the initial position in ticks of the sequence.

The default value zero means starting from the beginning.

Returns
Initial position (ticks)

Definition at line 70 of file playthread.h.

Referenced by SequencerOutputThread::run().

◆ hasNext()

virtual bool hasNext ( )
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.

Returns
True if the sequence has another event.

Referenced by SequencerOutputThread::run().

◆ nextEvent()

virtual SequencerEvent * nextEvent ( )
pure virtual

Gets the next event in the sequence.

This is a pure virtual function that must be overridden in the derived class.

Returns
Pointer to the next SequencerEvent to be played.

Referenced by SequencerOutputThread::run().

◆ sendEchoEvent()

void sendEchoEvent ( int  tick)
protectedvirtual

◆ sendSongEvent()

◆ start

void start ( QThread::Priority  priority = InheritPriority)
slot

Starts the playback thread.

Parameters
priorityThread priority, default is InheritPriority

Definition at line 219 of file playthread.cpp.

References SequencerOutputThread::m_mutex, and SequencerOutputThread::m_Stopped.

◆ stop()

void stop ( )
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.

◆ stopRequested()

bool stopRequested ( )
protectedvirtual

The documentation for this class was generated from the following files: