#include <playback.h>

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) |
| CAMidiDevice * | midiDevice () |
| CASheet * | sheet () |
| 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 |
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.
| CAPlayback::CAPlayback | ( | CASheet * | s, | |
| CAMidiDevice * | m | |||
| ) |
Definition at line 44 of file playback.cpp.
References _stop, setInitTimeStart(), setMidiDevice(), setSheet(), setStopLock(), and stopNow().

| CAPlayback::~CAPlayback | ( | ) |
Destructor deletes the created arrays.
Definition at line 56 of file playback.cpp.
References _curTime, _lastRepeatOpenIdx, _repeating, and _streamIdx.
| 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().


| void CAPlayback::stop | ( | ) |
The nice and the right way to stop the playback. Returns immediately.
Definition at line 197 of file playback.cpp.
References _stop.
Referenced by CAMainWin::on_uiPlayFromSelection_toggled(), run(), and stopNow().

| const int CAPlayback::getInitTimeStart | ( | ) | [inline] |
Definition at line 30 of file playback.h.
References _initTimeStart.
Referenced by initStreams().

| void CAPlayback::setInitTimeStart | ( | int | t | ) | [inline] |
Definition at line 31 of file playback.h.
References _initTimeStart.
Referenced by CAPlayback(), and CAMainWin::on_uiPlayFromSelection_toggled().

| CAMidiDevice* CAPlayback::midiDevice | ( | ) | [inline] |
Definition at line 32 of file playback.h.
References _midiDevice.
Referenced by initStreams(), and run().

| CASheet* CAPlayback::sheet | ( | ) | [inline] |
Definition at line 33 of file playback.h.
References _sheet.
Referenced by run().

| void CAPlayback::setSheet | ( | CASheet * | s | ) | [inline] |
Definition at line 34 of file playback.h.
References _sheet.
Referenced by CAPlayback().

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


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


| QList<CAMusElement*> CAPlayback::streamAt | ( | int | idx | ) | [inline, private] |
Definition at line 53 of file playback.h.
References _stream.
Referenced by loopUntilPlayable(), and run().

| int CAPlayback::streamCount | ( | ) | [inline, private] |
Definition at line 54 of file playback.h.
References _stream.
Referenced by initStreams(), and run().

| int& CAPlayback::streamIdx | ( | int | i | ) | [inline, private] |
Definition at line 55 of file playback.h.
References _streamIdx.
Referenced by initStreams(), loopUntilPlayable(), and run().

| int& CAPlayback::curTime | ( | int | i | ) | [inline, private] |
Definition at line 56 of file playback.h.
References _curTime.
Referenced by initStreams(), loopUntilPlayable(), and run().

| int& CAPlayback::lastRepeatOpenIdx | ( | int | i | ) | [inline, private] |
Definition at line 57 of file playback.h.
References _lastRepeatOpenIdx.
Referenced by initStreams(), and loopUntilPlayable().

| bool& CAPlayback::repeating | ( | int | i | ) | [inline, private] |
Definition at line 58 of file playback.h.
References _repeating.
Referenced by initStreams(), and loopUntilPlayable().

| bool CAPlayback::stopLock | ( | ) | [inline, private] |
| void CAPlayback::setStopLock | ( | bool | lock | ) | [inline, private] |
Definition at line 61 of file playback.h.
References _stopLock.
Referenced by CAPlayback(), and stopNow().

| void CAPlayback::setMidiDevice | ( | CAMidiDevice * | d | ) | [inline, private] |
Definition at line 66 of file playback.h.
References _midiDevice.
Referenced by CAPlayback().

| void CAPlayback::setStop | ( | bool | stop | ) | [inline, private] |
Definition at line 68 of file playback.h.
References _stop.
Referenced by run().

CASheet* CAPlayback::_sheet [private] |
CAMidiDevice* CAPlayback::_midiDevice [private] |
bool CAPlayback::_stop [private] |
bool CAPlayback::_stopLock [private] |
int CAPlayback::_initTimeStart [private] |
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] |
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().
1.5.3