|
Canorus
0.7
|
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>

Public Slots | |
| void | stopNow () |
Signals | |
| void | playbackFinished () |
Public Member Functions | |
| CAPlayback (CASheet *, CAMidiDevice *) | |
| CAPlayback (CAMidiDevice *, int port) | |
| ~CAPlayback () | |
| void | run () |
| void | stop () |
| void | playImmediately (QList< CAMusElement * > elts, int port) |
| 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) |
| void | playSelectionImpl () |
| 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 |
| bool | _playSelectionOnly |
| QList< CAMusElement * > | _selection |
| int | _initTimeStart |
| QList< QList< CAMusElement * > > | _stream |
| QList< CAPlayable * > | _curPlaying |
| int * | _streamIdx |
| bool * | _repeating |
| int * | _lastRepeatOpenIdx |
| int * | _curTime |
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.
If you want to immediately play only given elements (eg. when inserting notes), call playImmediately().
| CAPlayback::CAPlayback | ( | CASheet * | s, |
| CAMidiDevice * | m | ||
| ) |
References _curTime, _lastRepeatOpenIdx, _playSelectionOnly, _repeating, _stop, _streamIdx, setInitTimeStart(), setMidiDevice(), setSheet(), setStopLock(), and stopNow().

| CAPlayback::CAPlayback | ( | CAMidiDevice * | m, |
| int | port | ||
| ) |
Plays the list of music elements simultaniously. It only takes notes into account.
References _curTime, _lastRepeatOpenIdx, _playSelectionOnly, _repeating, _stop, _streamIdx, setMidiDevice(), setStopLock(), and stopNow().

| CAPlayback::~CAPlayback | ( | ) |
Destructor deletes the created arrays.
References _curTime, _lastRepeatOpenIdx, _repeating, and _streamIdx.
|
inline |
References _curPlaying.
Referenced by CAMainWin::deleteSelection(), and CAMainWin::onRepaintTimerTimeout().

|
inlineprivate |
References _curTime.
Referenced by initStreams(), loopUntilPlayable(), playSelectionImpl(), and run().

|
inline |
|
private |
Generates streams (elements lists) of playable elements (notes, rests) from the given sheet.
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().


|
inlineprivate |
References _lastRepeatOpenIdx.
Referenced by initStreams(), and loopUntilPlayable().

|
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.
References CAMusElement::Barline, curTime(), lastRepeatOpenIdx(), CAMusElement::Note, CABarline::RepeatClose, repeating(), CABarline::RepeatOpen, streamAt(), and streamIdx().
Referenced by initStreams(), and run().


|
inline |
References _midiDevice.
Referenced by initStreams(), playImmediately(), playSelectionImpl(), and run().

|
signal |
| void CAPlayback::playImmediately | ( | QList< CAMusElement * > | elts, |
| int | port | ||
| ) |
Immediately plays the given elts.
References _selection, midiDevice(), and CAMidiDevice::openOutputPort().
Referenced by CAMainWin::playImmediately().


|
private |
Private function for immediately playing the music elements in _selection. This function ends when all the notes in _selection queue are played. _selection queue might be refilled during the playback by calling playImmediately().
This function is usually called when inserting new notes. If the first note is still playing, the second note is played simultaniously - thus having two notes in _selection for eg.
References _curPlaying, _selection, _stop, curTime(), CANote::diatonicPitch(), CAMidiDevice::diatonicPitchToMidiPitch(), CAVoice::midiChannel(), midiDevice(), CAVoice::midiProgram(), CAMusElement::Note, CAMidiDevice::send(), stop(), CAMusElement::timeLength(), and CAPlayable::voice().
Referenced by run().


|
inlineprivate |
References _repeating.
Referenced by initStreams(), and loopUntilPlayable().

| void CAPlayback::run | ( | ) |
References _curPlaying, _curTime, _playSelectionOnly, _stop, curTime(), CANote::diatonicPitch(), CAMidiDevice::diatonicPitchToMidiPitch(), CAMark::Dynamic, initStreams(), CAMark::InstrumentChange, loopUntilPlayable(), CAMusElement::markList(), CAMidiDevice::Midi_Ctl_Volume, CAVoice::midiChannel(), midiDevice(), CAMusElement::musElementType(), CASlur::noteEnd(), CAPlayableLength::playableLengthToTimeLength(), playSelectionImpl(), CAMusElement::Rest, CAMidiDevice::send(), setStop(), sheet(), stop(), streamAt(), streamCount(), streamIdx(), CAMark::Tempo, CANote::tieEnd(), CANote::tieStart(), and CAPlayable::voice().
Referenced by CAMidiExport::exportDocumentImpl().


|
inline |
References _initTimeStart.
Referenced by CAPlayback(), and CAMainWin::on_uiPlayFromSelection_toggled().

|
inlineprivate |
|
inline |
|
inlineprivate |
|
inlineprivate |
References _stopLock.
Referenced by CAPlayback(), and stopNow().

|
inline |
| void CAPlayback::stop | ( | ) |
The nice and the right way to stop the playback. Returns immediately.
References _stop.
Referenced by CAMainWin::on_uiPlayFromSelection_toggled(), playSelectionImpl(), run(), setStop(), and stopNow().

|
inlineprivate |
|
slot |
Stop playback and clean up. Blocks until all cleanups are done.
References playbackFinished(), setStopLock(), stop(), and stopLock().
Referenced by CAPlayback(), CAMainWin::deleteSelection(), and CAMainWin::stopPlayback().


|
inlineprivate |
References _stream.
Referenced by loopUntilPlayable(), and run().

|
inlineprivate |
References _stream.
Referenced by initStreams(), and run().

|
inlineprivate |
References _streamIdx.
Referenced by initStreams(), loopUntilPlayable(), and run().

|
private |
Referenced by curPlaying(), playSelectionImpl(), and run().
|
private |
Referenced by CAPlayback(), curTime(), initStreams(), run(), and ~CAPlayback().
|
private |
Referenced by getInitTimeStart(), and setInitTimeStart().
|
private |
Referenced by CAPlayback(), initStreams(), lastRepeatOpenIdx(), and ~CAPlayback().
|
private |
Referenced by midiDevice(), and setMidiDevice().
|
private |
Referenced by CAPlayback(), and run().
|
private |
Referenced by CAPlayback(), initStreams(), repeating(), and ~CAPlayback().
|
private |
Referenced by playImmediately(), and playSelectionImpl().
|
private |
Referenced by setSheet(), and sheet().
|
private |
Referenced by CAPlayback(), playSelectionImpl(), run(), setStop(), and stop().
|
private |
Referenced by setStopLock(), and stopLock().
|
private |
Referenced by initStreams(), streamAt(), and streamCount().
|
private |
Referenced by CAPlayback(), initStreams(), streamIdx(), and ~CAPlayback().
1.8.3