CAPlayback Class Reference

Audio playback of the score. This class creates playback events (usually MIDI events) for the music elements and sends these events to one of the playback devices (usually CAMidiDevice). More...

#include <playback.h>

Inheritance diagram for CAPlayback:

Inheritance graph
[legend]

List of all members.

Public Slots

void stopNow ()

Signals

void playbackFinished ()

Public Member Functions

 CAPlayback (CASheet *, CAMidiDevice *)
 ~CAPlayback ()
void run ()
void stop ()
const int getInitTimeStart ()
void setInitTimeStart (int t)
CAMidiDevicemidiDevice ()
CASheetsheet ()
void setSheet (CASheet *s)
QList< CAPlayable * > & curPlaying ()

Private Member Functions

void initStreams (CASheet *sheet)
void loopUntilPlayable (int i, bool ignoreRepeats=false)
QList< CAMusElement * > streamAt (int idx)
int streamCount ()
int & streamIdx (int i)
int & curTime (int i)
int & lastRepeatOpenIdx (int i)
bool & repeating (int i)
bool stopLock ()
void setStopLock (bool lock)
void setMidiDevice (CAMidiDevice *d)
void setStop (bool stop)

Private Attributes

CASheet_sheet
CAMidiDevice_midiDevice
bool _stop
bool _stopLock
int _initTimeStart
QList< QList
< CAMusElement * > > 
_stream
QList< CAPlayable * > _curPlaying
int * _streamIdx
bool * _repeating
int * _lastRepeatOpenIdx
int * _curTime


Detailed Description

Audio playback of the score. This class creates playback events (usually MIDI events) for the music elements and sends these events to one of the playback devices (usually CAMidiDevice).

Copyright (c) 2006-2007, Matevž Jekovec, Canorus development team All Rights Reserved. See AUTHORS for a complete list of authors.

Licensed under the GNU GENERAL PUBLIC LICENSE. See COPYING for details.

To use the playback capabilities: 1) Create one of the CAMidiDevices (eg. CARtMidiDevice) and configure it (open output/input port). 2) Create CAPlayback object passing it the current score viewport (played notes will be painted red) or only the sheet (usually used in scripting environment) and the midi device. 3) Optionally configure playback (setInitTimeStart() to start playback from the specific time. Default 0). 4) Call myPlaybackObject->run(). This will start playing in a new thread. 5) Call myPlaybackObject->stop() to stop the playback. Playback also stops automatically when finished.

The playbackFinished() signal is emitted once playback has finished or stopped.

Definition at line 19 of file playback.h.


Constructor & Destructor Documentation

CAPlayback::CAPlayback ( CASheet s,
CAMidiDevice m 
)

Definition at line 44 of file playback.cpp.

References _stop, setInitTimeStart(), setMidiDevice(), setSheet(), setStopLock(), and stopNow().

Here is the call graph for this function:

CAPlayback::~CAPlayback (  ) 

Destructor deletes the created arrays.

Definition at line 56 of file playback.cpp.

References _curTime, _lastRepeatOpenIdx, _repeating, and _streamIdx.


Member Function Documentation

void CAPlayback::run (  ) 

Definition at line 67 of file playback.cpp.

References _curPlaying, _curTime, _stop, curTime(), CAMark::Dynamic, initStreams(), CAMark::InstrumentChange, loopUntilPlayable(), CAMusElement::markList(), CAMidiDevice::Midi_Ctl_Volume, CAVoice::midiChannel(), midiDevice(), CANote::midiPitch(), CAMusElement::musElementType(), CASlur::noteEnd(), CAPlayable::playableLengthToTimeLength(), CAMusElement::Rest, CAMidiDevice::send(), setStop(), sheet(), stop(), streamAt(), streamCount(), streamIdx(), CAMark::Tempo, CANote::tieEnd(), CANote::tieStart(), and CAPlayable::voice().

Referenced by CAMidiExport::exportDocumentImpl().

Here is the call graph for this function:

Here is the caller graph for this function:

void CAPlayback::stop (  ) 

The nice and the right way to stop the playback. Returns immediately.

See also:
stopNow()

Definition at line 197 of file playback.cpp.

References _stop.

Referenced by CAMainWin::on_uiPlayFromSelection_toggled(), run(), and stopNow().

Here is the caller graph for this function:

const int CAPlayback::getInitTimeStart (  )  [inline]

Definition at line 30 of file playback.h.

References _initTimeStart.

Referenced by initStreams().

Here is the caller graph for this function:

void CAPlayback::setInitTimeStart ( int  t  )  [inline]

Definition at line 31 of file playback.h.

References _initTimeStart.

Referenced by CAPlayback(), and CAMainWin::on_uiPlayFromSelection_toggled().

Here is the caller graph for this function:

CAMidiDevice* CAPlayback::midiDevice (  )  [inline]

Definition at line 32 of file playback.h.

References _midiDevice.

Referenced by initStreams(), and run().

Here is the caller graph for this function:

CASheet* CAPlayback::sheet (  )  [inline]

Definition at line 33 of file playback.h.

References _sheet.

Referenced by run().

Here is the caller graph for this function:

void CAPlayback::setSheet ( CASheet s  )  [inline]

Definition at line 34 of file playback.h.

References _sheet.

Referenced by CAPlayback().

Here is the caller graph for this function:

QList<CAPlayable*>& CAPlayback::curPlaying (  )  [inline]

Definition at line 35 of file playback.h.

References _curPlaying.

Referenced by CAMainWin::onRepaintTimerTimeout().

void CAPlayback::stopNow (  )  [slot]

Stop playback and clean up. Blocks until all cleanups are done.

See also:
stop()

Definition at line 207 of file playback.cpp.

References playbackFinished(), setStopLock(), stop(), and stopLock().

Referenced by CAPlayback(), and CAMainWin::stopPlayback().

void CAPlayback::playbackFinished (  )  [signal]

Referenced by stopNow().

void CAPlayback::initStreams ( CASheet sheet  )  [private]

Generates streams (elements lists) of playable elements (notes, rests) and stores it locally.

Definition at line 224 of file playback.cpp.

References _curTime, _lastRepeatOpenIdx, _repeating, _stream, _streamIdx, CASheet::contextAt(), CASheet::contextCount(), CAContext::contextType(), curTime(), getInitTimeStart(), lastRepeatOpenIdx(), loopUntilPlayable(), CAVoice::midiChannel(), midiDevice(), CAVoice::midiProgram(), CAVoice::musElementList(), repeating(), CAMidiDevice::send(), CAContext::Staff, streamCount(), streamIdx(), CAStaff::voiceAt(), and CAStaff::voiceCount().

Referenced by run().

Here is the call graph for this function:

Here is the caller graph for this function:

void CAPlayback::loopUntilPlayable ( int  i,
bool  ignoreRepeats = false 
) [private]

Loops from the stream with the given index i until the last element with smaller or equal start time of the current time. This function also remembers any special signs like open repeat barlines.

Definition at line 267 of file playback.cpp.

References CAMusElement::Barline, curTime(), lastRepeatOpenIdx(), CAMusElement::Note, CABarline::RepeatClose, repeating(), CABarline::RepeatOpen, streamAt(), and streamIdx().

Referenced by initStreams(), and run().

Here is the call graph for this function:

Here is the caller graph for this function:

QList<CAMusElement*> CAPlayback::streamAt ( int  idx  )  [inline, private]

Definition at line 53 of file playback.h.

References _stream.

Referenced by loopUntilPlayable(), and run().

Here is the caller graph for this function:

int CAPlayback::streamCount (  )  [inline, private]

Definition at line 54 of file playback.h.

References _stream.

Referenced by initStreams(), and run().

Here is the caller graph for this function:

int& CAPlayback::streamIdx ( int  i  )  [inline, private]

Definition at line 55 of file playback.h.

References _streamIdx.

Referenced by initStreams(), loopUntilPlayable(), and run().

Here is the caller graph for this function:

int& CAPlayback::curTime ( int  i  )  [inline, private]

Definition at line 56 of file playback.h.

References _curTime.

Referenced by initStreams(), loopUntilPlayable(), and run().

Here is the caller graph for this function:

int& CAPlayback::lastRepeatOpenIdx ( int  i  )  [inline, private]

Definition at line 57 of file playback.h.

References _lastRepeatOpenIdx.

Referenced by initStreams(), and loopUntilPlayable().

Here is the caller graph for this function:

bool& CAPlayback::repeating ( int  i  )  [inline, private]

Definition at line 58 of file playback.h.

References _repeating.

Referenced by initStreams(), and loopUntilPlayable().

Here is the caller graph for this function:

bool CAPlayback::stopLock (  )  [inline, private]

Definition at line 60 of file playback.h.

References _stopLock.

Referenced by stopNow().

void CAPlayback::setStopLock ( bool  lock  )  [inline, private]

Definition at line 61 of file playback.h.

References _stopLock.

Referenced by CAPlayback(), and stopNow().

Here is the caller graph for this function:

void CAPlayback::setMidiDevice ( CAMidiDevice d  )  [inline, private]

Definition at line 66 of file playback.h.

References _midiDevice.

Referenced by CAPlayback().

Here is the caller graph for this function:

void CAPlayback::setStop ( bool  stop  )  [inline, private]

Definition at line 68 of file playback.h.

References _stop.

Referenced by run().

Here is the caller graph for this function:


Member Data Documentation

CASheet* CAPlayback::_sheet [private]

Definition at line 63 of file playback.h.

Referenced by setSheet(), and sheet().

CAMidiDevice* CAPlayback::_midiDevice [private]

Definition at line 65 of file playback.h.

Referenced by midiDevice(), and setMidiDevice().

bool CAPlayback::_stop [private]

Definition at line 69 of file playback.h.

Referenced by CAPlayback(), run(), setStop(), and stop().

bool CAPlayback::_stopLock [private]

Definition at line 70 of file playback.h.

Referenced by setStopLock(), and stopLock().

int CAPlayback::_initTimeStart [private]

Definition at line 72 of file playback.h.

Referenced by getInitTimeStart(), and setInitTimeStart().

QList< QList<CAMusElement*> > CAPlayback::_stream [private]

Definition at line 74 of file playback.h.

Referenced by initStreams(), streamAt(), and streamCount().

QList<CAPlayable*> CAPlayback::_curPlaying [private]

Definition at line 75 of file playback.h.

Referenced by curPlaying(), and run().

int* CAPlayback::_streamIdx [private]

Definition at line 76 of file playback.h.

Referenced by initStreams(), streamIdx(), and ~CAPlayback().

bool* CAPlayback::_repeating [private]

Definition at line 77 of file playback.h.

Referenced by initStreams(), repeating(), and ~CAPlayback().

int* CAPlayback::_lastRepeatOpenIdx [private]

Definition at line 78 of file playback.h.

Referenced by initStreams(), lastRepeatOpenIdx(), and ~CAPlayback().

int* CAPlayback::_curTime [private]

Definition at line 79 of file playback.h.

Referenced by curTime(), initStreams(), run(), and ~CAPlayback().


The documentation for this class was generated from the following files:
Generated on Sat Feb 9 13:19:30 2008 for Canorus by  doxygen 1.5.3