drumstick 2.10.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.
 

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.
 
virtual void run () override
 Thread process loop.
 
virtual unsigned int getInitialPosition ()
 Gets the initial position in ticks of the sequence.
 
virtual unsigned int getEchoResolution ()
 Gets the echo event resolution in ticks.
 
virtual bool hasNext ()=0
 Check if there is one more event in the sequence.
 
virtual SequencerEventnextEvent ()=0
 Gets the next event in the sequence.
 
virtual void stop ()
 Stops playing the current sequence.
 

Protected Member Functions

virtual void sendEchoEvent (int tick)
 Sends an echo event, with the same PortId as sender and destination.
 
virtual void sendSongEvent (SequencerEvent *ev)
 Sends a SequencerEvent.
 
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.
 

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 m_MidiClient, m_npfds, m_pfds, m_PortId, m_Queue, m_QueueId, and m_Stopped.

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 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 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 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.

References stop().

Referenced by run().

◆ sendEchoEvent()

void sendEchoEvent ( int tick)
protectedvirtual

Sends an echo event, with the same PortId as sender and destination.

Parameters
tickEvent schedule time in ticks.

Definition at line 114 of file playthread.cpp.

References m_MidiClient, m_PortId, m_QueueId, SequencerEvent::scheduleTick(), sendSongEvent(), SequencerEvent::setDestination(), SequencerEvent::setSource(), and stopRequested().

Referenced by playbackStopped(), and run().

◆ sendSongEvent()

void sendSongEvent ( SequencerEvent * ev)
protectedvirtual

Sends a SequencerEvent.

Parameters
evSequencerEvent object pointer

Definition at line 130 of file playthread.cpp.

References SequencerEvent::getHandle(), m_MidiClient, m_npfds, m_pfds, and stopRequested().

Referenced by playbackStopped(), run(), and sendEchoEvent().

◆ 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 m_mutex, and m_Stopped.

Referenced by playbackStopped().

◆ stop()

void stop ( )
virtual

Stops playing the current sequence.

Stops the playback task.

Definition at line 99 of file playthread.cpp.

References m_mutex, and m_Stopped.

Referenced by nextEvent().

◆ stopRequested()

bool stopRequested ( )
protectedvirtual

Checks if stop has been requested.

Returns
True if stop has been requested
Since
0.2.0

Definition at line 89 of file playthread.cpp.

References m_mutex, and m_Stopped.

Referenced by drainOutput(), playbackStopped(), run(), sendEchoEvent(), sendSongEvent(), and syncOutput().


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