Canorus  0.0
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
CAVoice Class Reference

Class which represents a voice in the staff. More...

#include <voice.h>

Public Member Functions

 CAVoice (const QString name, CAStaff *staff, CANote::CAStemDirection stemDirection=CANote::StemNeutral)
 
 ~CAVoice ()
 
CAStaffstaff ()
 
void setStaff (CAStaff *staff)
 
void clear ()
 
CAVoiceclone (CAStaff *newStaff=0)
 
void cloneVoiceProperties (CAVoice *v)
 
void append (CAMusElement *elt, bool addToChord=false)
 
bool insert (CAMusElement *eltAfter, CAMusElement *elt, bool addToChord=false)
 
bool remove (CAMusElement *elt, bool updateSignsTimes=true)
 
CAPlayableinsertInTupletAndVoiceAt (CAPlayable *p, CAPlayable *n)
 
bool synchronizeMusElements ()
 
const QList< CAMusElement * > & musElementList ()
 
QList< CAMusElement * > getSignList ()
 
QList< CANote * > getNoteList ()
 
bool containsPitch (int noteName, int timeStart)
 
bool containsPitch (CADiatonicPitch p, int timeStart)
 
CAMusElementnext (CAMusElement *elt)
 
CAMusElementprevious (CAMusElement *elt)
 
CAMusElementnextByType (CAMusElement::CAMusElementType type, CAMusElement *elt)
 
CAMusElementpreviousByType (CAMusElement::CAMusElementType type, CAMusElement *elt)
 
CANotenextNote (int timeStart)
 
CANotepreviousNote (int timeStart)
 
CARestnextRest (int timeStart)
 
CARestpreviousRest (int timeStart)
 
CAPlayablenextPlayable (int timeStart)
 
CAPlayablepreviousPlayable (int timeStart)
 
bool binarySearch_startTime (int time, int &position)
 \A common binary search Algorithm with its pseudocode More...
 
CAMusElementgetOneEltByType (CAMusElement::CAMusElementType type, int startTime)
 
QList< CAMusElement * > getEltByType (CAMusElement::CAMusElementType type, int startTime)
 
CAMusElementgetOnePreviousByType (CAMusElement::CAMusElementType type, int startTime)
 
QList< CAMusElement * > getPreviousByType (CAMusElement::CAMusElementType type, int startTime)
 
int lastTimeEnd ()
 
int lastTimeStart ()
 
CAMusElementlastMusElement ()
 
CADiatonicPitch lastNotePitch (bool inChord=false)
 
CAPlayablelastPlayableElt ()
 
CANotelastNote ()
 
CATimeSignaturegetTimeSig (CAMusElement *elt)
 
CAKeySignaturegetKeySig (CAMusElement *elt)
 
CAClefgetClef (CAMusElement *elt)
 
QList< CAPlayable * > getChord (int time)
 
QList< CAMusElement * > getBar (int time)
 
CATempogetTempo (int time)
 
QList< CAMusElement * > getKeySignature (int startTime)
 
QList< CAMusElement * > getTimeSignature (int startTime)
 
QList< CAMusElement * > getClef (int startTime)
 
QList< CAMusElement * > getPreviousKeySignature (int startTime)
 
QList< CAMusElement * > getPreviousTimeSignature (int startTime)
 
QList< CAMusElement * > getPreviousClef (int startTime)
 
int voiceNumber ()
 
bool isFirstVoice ()
 
CANote::CAStemDirection stemDirection ()
 
void setStemDirection (CANote::CAStemDirection direction)
 
const QString name ()
 
void setName (const QString name)
 
unsigned char midiChannel ()
 
void setMidiChannel (const unsigned char ch)
 
unsigned char midiProgram ()
 
void setMidiProgram (const unsigned char program)
 
char midiPitchOffset ()
 
void setMidiPitchOffset (const char midiPitchOffset)
 
const QList< CALyricsContext * > & lyricsContextList ()
 
void addLyricsContext (CALyricsContext *lc)
 
void setLyricsContexts (QList< CALyricsContext * > list)
 
void addLyricsContexts (QList< CALyricsContext * > list)
 
bool removeLyricsContext (CALyricsContext *lc)
 

Private Member Functions

bool addNoteToChord (CANote *note, CANote *referenceNote)
 
bool insertMusElement (CAMusElement *before, CAMusElement *elt)
 
bool updateTimes (int idx, int length, bool signsToo=false)
 

Private Attributes

QList< CAMusElement * > _musElementList
 
CAStaff_staff
 
CANote::CAStemDirection _stemDirection
 
QList< CALyricsContext * > _lyricsContextList
 
QString _name
 
unsigned char _midiChannel
 
unsigned char _midiProgram
 
char _midiPitchOffset
 

Friends

class CAStaff
 

Detailed Description

Class which represents a voice in the staff.

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

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

CAVoice is a class which holds music elements in the staff. In hieararchy, staff includes multiple voices and every voice includes multiple music elements.

See also
CAStaff, CAMusElement

Constructor & Destructor Documentation

◆ CAVoice()

CAVoice::CAVoice ( const QString  name,
CAStaff staff,
CANote::CAStemDirection  stemDirection = CANote::StemNeutral 
)

Creates a new voice named name, in staff, voiceNumber and stemDirection of notes stems. Voice number starts at 1.

References _midiChannel, _midiPitchOffset, _midiProgram, _name, _staff, _stemDirection, CAMidiDevice::freeMidiChannel(), name(), CAContext::sheet(), staff(), and stemDirection().

Referenced by clone().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~CAVoice()

CAVoice::~CAVoice ( )

Clears and destroys the current voice. This also destroys all non-shared music elements held by the voice.

See also
clear()

References clear(), lyricsContextList(), CAStaff::removeVoice(), and staff().

Here is the call graph for this function:

Member Function Documentation

◆ addLyricsContext()

void CAVoice::addLyricsContext ( CALyricsContext lc)
inline

References _lyricsContextList.

Referenced by CAMusicXmlImport::readNote(), CALyricsContext::setAssociatedVoice(), and CAMainWin::sourceViewCommit().

Here is the caller graph for this function:

◆ addLyricsContexts()

void CAVoice::addLyricsContexts ( QList< CALyricsContext * >  list)
inline

References _lyricsContextList.

◆ addNoteToChord()

bool CAVoice::addNoteToChord ( CANote note,
CANote referenceNote 
)
private

Adds a note to an already existing referenceNote chord or a single note and creates a chord out of it. Notes in a chord always need to be sorted by pitch rising. Chord in Canorus isn't its own structure but simply a list of notes sharing the same start time.

The inserted note properteis timeStart, timeLength, dotted and playableLength change according to other notes in the chord.

Returns True, if a referenceNote was found and a note was added; otherwise False.

See also
CANote::chord()

References _musElementList, CANote::diatonicPitch(), CANote::getChord(), CADiatonicPitch::noteName(), CAPlayable::playableLength(), CAPlayable::setPlayableLength(), CANote::setStemDirection(), CAMusElement::setTimeLength(), CAMusElement::setTimeStart(), CANote::stemDirection(), CAMusElement::timeLength(), and CAMusElement::timeStart().

Referenced by append(), and insert().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ append()

void CAVoice::append ( CAMusElement elt,
bool  addToChord = false 
)

Appends a music element elt at the end of the voice.

If addToChord is True and the appended element is note, the note is added to the chord instead of added after the chord. If appended element is rest, addToChord is ignored.

Appended element's timeStart is changed respectively.

Note
Due to speed issues, voices are NOT synchronized for every inserted element. User should manually call CAStaff::synchronizeVoices().
See also
insert()

References addNoteToChord(), insertMusElement(), musElementList(), CAMusElement::musElementType(), CAMusElement::Note, CAMusElement::setTimeStart(), CAMusElement::timeEnd(), and CAMusElement::timeStart().

Referenced by CAMusicXmlImport::addVoiceIfNeeded(), CAMainWin::copySelection(), CACanorusMLImport::endElement(), CALilyPondImport::importVoiceImpl(), CAKeybdInput::midiInEventToScore(), CAMusicXmlImport::readForward(), CAMusicXmlImport::readNote(), CAMidiImport::writeMidiChannelEventsToVoice_New(), and CAMidiImport::writeMidiFileEventsToScore_New().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ binarySearch_startTime()

bool CAVoice::binarySearch_startTime ( int  time,
int &  position 
)

\A common binary search Algorithm with its pseudocode

References _musElementList.

◆ clear()

void CAVoice::clear ( )

Destroys all non-shared music elements held by the voice.

When clearing the whole staff, make sure the voice is deleted. It is automatically removed from the staff - in voice's destructor.

References _musElementList, and staff().

Referenced by ~CAVoice().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clone()

CAVoice * CAVoice::clone ( CAStaff newStaff = 0)

Clones the current voice including all the music elements. Sets the voice staff to newStaff. If none given, use the original staff.

References CAVoice(), cloneVoiceProperties(), name(), and setStaff().

Here is the call graph for this function:

◆ cloneVoiceProperties()

void CAVoice::cloneVoiceProperties ( CAVoice voice)

Sets the properties of the given voice to this voice.

References lyricsContextList(), midiChannel(), midiPitchOffset(), midiProgram(), name(), setLyricsContexts(), setMidiChannel(), setMidiPitchOffset(), setMidiProgram(), setName(), setStaff(), setStemDirection(), staff(), and stemDirection().

Referenced by clone(), and CALilyPondImport::importVoiceImpl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ containsPitch() [1/2]

bool CAVoice::containsPitch ( CADiatonicPitch  p,
int  timeStart 
)

Returns true, if this voice contains a note with the given diatonic pitch at the given timeStart.

This is useful when inserting a note and there needs to be determined if a user is adding a note to a chord and the note is maybe already there.

References _musElementList, and CAMusElement::Note.

◆ containsPitch() [2/2]

bool CAVoice::containsPitch ( int  noteName,
int  timeStart 
)

Returns true, if this voice contains a note with the given pitch notename at the given timeStart.

This is useful when inserting a note and there needs to be determined if a user is adding a note to a chord and the note is maybe already there. Note's accidentals are ignored.

References _musElementList, and CAMusElement::Note.

Referenced by CAMainWin::insertMusElementAt().

Here is the caller graph for this function:

◆ getBar()

QList< CAMusElement * > CAVoice::getBar ( int  time)

Returns a list of music elements inside the given bar. The return list consists of all music elements between two barlines excluding the first barline. Expression marks and other non-standalone elements are excluded as well. The parameter time is any time of music elements inside the bar.

This function is usually called when double clicking on the score.

References CAMusElement::Barline, getChord(), CAMusElement::musElementType(), next(), and previous().

Here is the call graph for this function:

◆ getChord()

QList< CAPlayable * > CAVoice::getChord ( int  time)

Returns a list of notes and rests (chord) in the given voice in the given time slice time.

This is useful for determination of the harmony at certain point in time.

See also
CAStaff:getChord(), CASheet::getChord()
Todo:
Casting QList<CANote*> to QList<CAPlayable*> doesn't work?! :( Do the conversation manually. This is slow. -Matevz

References _musElementList, and CAMusElement::Note.

Referenced by getBar(), getTempo(), insert(), CAKeybdInput::midiInEventToScore(), and synchronizeMusElements().

Here is the caller graph for this function:

◆ getClef() [1/2]

CAClef * CAVoice::getClef ( CAMusElement elt)

Returns a pointer to the clef which the given elt belongs to. Returns 0, if no clefs placed yet.

Warning! This operation is slow (linear time), but always returns the correct clef depending on the order of the musElementList. If a timeBased result suffices, use CAStaff::getClef(time).

References CAMusElement::Clef, lastMusElement(), musElementList(), CAMusElement::musElementType(), and previous().

Here is the call graph for this function:

◆ getClef() [2/2]

QList< CAMusElement * > CAVoice::getClef ( int  startTime)

Returns a list of pointers to key signatures which have the given startTime. This is useful for querying for eg. If a new key signature exists at the certain point in time.

References CAStaff::clefRefs(), and staff().

Here is the call graph for this function:

◆ getEltByType()

QList< CAMusElement * > CAVoice::getEltByType ( CAMusElement::CAMusElementType  type,
int  startTime 
)

Returns a list of pointers to actual music elements which have the given startTime and are of given type. This is useful for querying for eg. If a new key signature exists at the certain point in time.

References _musElementList.

◆ getKeySig()

CAKeySignature * CAVoice::getKeySig ( CAMusElement elt)

Returns a pointer to the key signature which the given elt belongs to. Returns 0, if no key signatures placed yet.

Warning! This operation is slow (linear time), but always returns the correct keySig depending on the order of the musElementList. If a timeBased result suffices, use CAStaff::getClef(time).

References CAMusElement::KeySignature, lastMusElement(), musElementList(), CAMusElement::musElementType(), and previous().

Referenced by CAMainWin::scoreViewKeyPress().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getKeySignature()

QList< CAMusElement * > CAVoice::getKeySignature ( int  startTime)

Returns a list of pointers to key signatures which have the given startTime. This is useful for querying for eg. If a new key signature exists at the certain point in time.

References CAStaff::keySignatureRefs(), and staff().

Here is the call graph for this function:

◆ getNoteList()

QList< CANote * > CAVoice::getNoteList ( )

Generates a list of all the notes and chords in the voice.

This is useful for harmony analysis.

References _musElementList, and CAMusElement::Note.

Referenced by CAMainWin::insertMusElementAt(), CALyricsContext::repositSyllables(), and CANote::updateTies().

Here is the caller graph for this function:

◆ getOneEltByType()

CAMusElement * CAVoice::getOneEltByType ( CAMusElement::CAMusElementType  type,
int  startTime 
)

Returns a music element which has the given startTime and type. This is useful for querying for eg. If a barline exists at the certain point in time.

References _musElementList.

◆ getOnePreviousByType()

CAMusElement * CAVoice::getOnePreviousByType ( CAMusElement::CAMusElementType  type,
int  startTime 
)

Returns a music elements which is at or left (not past) the given startTime and of given type. This is useful for querying for eg. which is the barline before a certain point in time.

References _musElementList.

Referenced by CAMidiImport::writeMidiChannelEventsToVoice_New().

Here is the caller graph for this function:

◆ getPreviousByType()

QList< CAMusElement * > CAVoice::getPreviousByType ( CAMusElement::CAMusElementType  type,
int  startTime 
)

Returns a list of pointers to actual music elements which are at or left (not past) the given startTime and are of given type. This is useful for querying for eg. which key pitch is in effect before a certain point in time.

A list from time 0 until startTime is created which is questionable regarding need and efficiency.

References _musElementList.

Referenced by CAKeybdInput::matchPitchToKey(), and CAMidiImport::matchPitchToKey().

Here is the caller graph for this function:

◆ getPreviousClef()

QList< CAMusElement * > CAVoice::getPreviousClef ( int  startTime)

Returns a list of pointers to clefs which are at or left (not past) the given startTime. This is useful for querying for eg. which clef is in effect before a certain point in time.

References CAStaff::clefRefs(), and staff().

Here is the call graph for this function:

◆ getPreviousKeySignature()

QList< CAMusElement * > CAVoice::getPreviousKeySignature ( int  startTime)

Returns a list of pointers to key signatures which are at or left (not past) the given startTime. This is useful for querying for eg. which key signature is in effect before a certain point in time.

References CAStaff::keySignatureRefs(), and staff().

Here is the call graph for this function:

◆ getPreviousTimeSignature()

QList< CAMusElement * > CAVoice::getPreviousTimeSignature ( int  startTime)

Returns a list of pointers to key signatures which are at or left (not past) the given startTime. This is useful for querying for eg. which key signature is in effect before a certain point in time.

References staff(), and CAStaff::timeSignatureRefs().

Here is the call graph for this function:

◆ getSignList()

QList< CAMusElement * > CAVoice::getSignList ( )

Generates a list of all the notes and chords in the voice.

This is useful when importing a specific voice and all the shared elements should be completely repositioned.

References _musElementList.

Referenced by CAMainWin::sourceViewCommit().

Here is the caller graph for this function:

◆ getTempo()

CATempo * CAVoice::getTempo ( int  time)

Returns the Tempo element active at the given time.

References getChord(), musElementList(), and CAMark::Tempo.

Here is the call graph for this function:

◆ getTimeSig()

CATimeSignature * CAVoice::getTimeSig ( CAMusElement elt)

Returns a pointer to the time signature which the given elt belongs to. Returns 0, if no time signatures placed yet.

Warning! This operation is slow (linear time), but always returns the correct timeSig depending on the order of the musElementList. If a timeBased result suffices, use CAStaff::getClef(time).

References lastMusElement(), musElementList(), CAMusElement::musElementType(), previous(), and CAMusElement::TimeSignature.

Here is the call graph for this function:

◆ getTimeSignature()

QList< CAMusElement * > CAVoice::getTimeSignature ( int  startTime)

Returns a list of pointers to key signatures which have the given startTime. This is useful for querying for eg. If a new key signature exists at the certain point in time.

References staff(), and CAStaff::timeSignatureRefs().

Here is the call graph for this function:

◆ insert()

bool CAVoice::insert ( CAMusElement eltAfter,
CAMusElement elt,
bool  addToChord = false 
)

Adds the given element elt to the voice before the given eltAfter. If eltAfter is null, the element is appended.

If elt is non-playable, it eventually does the same as insertMusElement().

If elt is a note and addToChord is True, the eltAfter should also be a note and the elt is then added to the chord which eltAfter is part of.

If elt is other playable element, it is appropriately added before the eltAfter. addToChord is ignored.

Inserted element's timeStart is correctly changed.

Returns True, if the insertion action was successfully made, otherwise False.

Note
Due to speed issues, voices are NOT synchronized for every inserted element. User should manually call CAStaff::synchronizeVoices().
See also
insertMusElement()

References addNoteToChord(), CAMusElement::Clef, CANote::diatonicPitch(), CANote::getChord(), getChord(), insertMusElement(), CAMusElement::isPlayable(), lastTimeEnd(), musElementList(), CAMusElement::musElementType(), CAMusElement::Note, CAMusElement::setTimeStart(), CAMusElement::timeLength(), CAMusElement::timeStart(), and updateTimes().

Referenced by CATuplet::assignTimes(), CAMusElementFactory::configureNote(), CAMusElementFactory::configureRest(), CAMainWin::deleteSelection(), insertInTupletAndVoiceAt(), CAMainWin::insertMusElementAt(), CAKeybdInput::midiInEventToScore(), CAMainWin::on_uiPlayableLength_toggled(), CAStaff::placeAutoBar(), CATuplet::resetTimes(), and CAMainWin::scoreViewKeyPress().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertInTupletAndVoiceAt()

CAPlayable * CAVoice::insertInTupletAndVoiceAt ( CAPlayable reference,
CAPlayable p 
)

Inserts a note/rest in a tuplet/voice. If the result should not be a chord the element found will be deleted and replaced. This function probably should also work for non tuplets.

Currently only adding notes, and with the basic tuplet timelength are implemented.

References CATuplet::addNote(), CATuplet::assignTimes(), insert(), next(), remove(), CATuplet::removeNote(), CAMusElement::Rest, CAMusElement::setTimeStart(), CAPlayable::setTuplet(), CAMusElement::timeStart(), CAPlayable::tuplet(), and CAPlayable::voice().

Referenced by CAKeybdInput::midiInEventToScore().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertMusElement()

bool CAVoice::insertMusElement ( CAMusElement eltAfter,
CAMusElement elt 
)
private

Inserts the elt before the given eltAfter. If eltAfter is Null, it appends the element.

Returns True, if eltAfter was found and the elt was inserted/appended; otherwise False.

References _musElementList, CAMusElement::Barline, CAStaff::barlineRefs(), CAMusElement::Clef, CAStaff::clefRefs(), CAMusElement::KeySignature, CAStaff::keySignatureRefs(), musElementList(), CAMusElement::musElementType(), next(), nextByType(), CAMusElement::Slur, staff(), CAMusElement::TimeSignature, and CAStaff::timeSignatureRefs().

Referenced by append(), and insert().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isFirstVoice()

bool CAVoice::isFirstVoice ( )
inline

References voiceNumber().

Here is the call graph for this function:

◆ lastMusElement()

CAMusElement* CAVoice::lastMusElement ( )
inline

References musElementList().

Referenced by getClef(), getKeySig(), getTimeSig(), CALilyPondImport::importVoiceImpl(), CAKeybdInput::midiInEventToScore(), and CAMidiImport::writeMidiChannelEventsToVoice_New().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lastNote()

CANote * CAVoice::lastNote ( )

Returns the note in the voice.

See also
lastNotePitch()

References _musElementList, and CAMusElement::Note.

Referenced by CAMusElementFactory::configureNote(), and CACanorusMLImport::endElement().

Here is the caller graph for this function:

◆ lastNotePitch()

CADiatonicPitch CAVoice::lastNotePitch ( bool  inChord = false)

Returns the pitch of the last note in the voice (default) or of the first note in the last chord, if inChord is true.

This method is usually used by LilyPond parser when exporting the document, where , or ' octave marks need to be determined.

See also
lastPlayableElt()

References _musElementList, CAMusElement::Clef, CANote::diatonicPitch(), and CAMusElement::Note.

Here is the call graph for this function:

◆ lastPlayableElt()

CAPlayable * CAVoice::lastPlayableElt ( )

Returns the last playable element (eg. note or rest) in the voice.

See also
lastNotePitch()

References _musElementList.

Referenced by CAKeybdInput::midiInEventToScore().

Here is the caller graph for this function:

◆ lastTimeEnd()

int CAVoice::lastTimeEnd ( )
inline

◆ lastTimeStart()

int CAVoice::lastTimeStart ( )
inline

References musElementList().

Referenced by CAKeybdInput::midiInEventToScore().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lyricsContextList()

const QList<CALyricsContext*>& CAVoice::lyricsContextList ( )
inline

◆ midiChannel()

unsigned char CAVoice::midiChannel ( )
inline

◆ midiPitchOffset()

char CAVoice::midiPitchOffset ( )
inline

◆ midiProgram()

unsigned char CAVoice::midiProgram ( )
inline

◆ musElementList()

CAVoice::musElementList ( )
inline

◆ name()

const QString CAVoice::name ( )
inline

◆ next()

CAMusElement * CAVoice::next ( CAMusElement elt)

Returns pointer to the music element after the given elt or 0, if the next music element doesn't exist.

If \elt is null, it returns the first element in the voice.

References _musElementList, and musElementList().

Referenced by CATuplet::assignTimes(), CAMainWin::deleteSelection(), getBar(), insertInTupletAndVoiceAt(), insertMusElement(), CAMainWin::insertMusElementAt(), nextByType(), CAMainWin::on_uiPlayableLength_toggled(), CATuplet::resetTimes(), CAMainWin::scoreViewKeyPress(), and CAScoreView::selectNextMusElement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nextByType()

CAMusElement * CAVoice::nextByType ( CAMusElement::CAMusElementType  type,
CAMusElement elt 
)

Returns the first element of type type after the given elt or Null if such an element doesn't exist.

If elt is Null, it returns the first element with such a type in the voice.

See also
previousByType()

References CAMusElement::musElementType(), and next().

Referenced by insertMusElement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nextNote()

CANote * CAVoice::nextNote ( int  timeStart)

Returns a pointer to the next note with the strictly higher timeStart than the given one. Returns 0, if the such a note doesn't exist.

References _musElementList, and CAMusElement::Note.

◆ nextPlayable()

CAPlayable * CAVoice::nextPlayable ( int  timeStart)

Returns a pointer to the next playable element with the strictly higher timeStart than the given one. Returns 0, if the such a note doesn't exist.

References _musElementList.

Referenced by CAMainWin::deleteSelection().

Here is the caller graph for this function:

◆ nextRest()

CARest * CAVoice::nextRest ( int  timeStart)

Returns a pointer to the next rest with the strictly higher timeStart than the given one. Returns 0, if the such a note doesn't exist.

References _musElementList, and CAMusElement::Rest.

◆ previous()

CAMusElement * CAVoice::previous ( CAMusElement elt)

Returns pointer to the music element before the given elt or 0, if the previous music element doesn't exist.

If \elt is null, it returns the last element in the voice.

References _musElementList, and musElementList().

Referenced by getBar(), getClef(), getKeySig(), getTimeSig(), previousByType(), and CAScoreView::selectPrevMusElement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ previousByType()

CAMusElement * CAVoice::previousByType ( CAMusElement::CAMusElementType  type,
CAMusElement elt 
)

Returns the first element of type type before the given elt or Null if such an element doesn't exist.

If elt is Null, it returns the last element with such a type in the voice.

See also
previousByType()

References CAMusElement::musElementType(), and previous().

Referenced by CAKeybdInput::midiInEventToScore(), CAStaff::placeAutoBar(), and CAMidiImport::writeMidiChannelEventsToVoice_New().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ previousNote()

CANote * CAVoice::previousNote ( int  timeStart)

Returns a pointer to the previous note with the strictly lower timeStart than the given one. Returns 0, if the such a note doesn't exist.

References _musElementList, and CAMusElement::Note.

Referenced by CAMusicXmlImport::readNote().

Here is the caller graph for this function:

◆ previousPlayable()

CAPlayable * CAVoice::previousPlayable ( int  timeStart)

Returns a pointer to the previous playable with the strictly lower timeStart than the given one. Returns 0, if the such a note doesn't exist.

References _musElementList.

◆ previousRest()

CARest * CAVoice::previousRest ( int  timeStart)

Returns a pointer to the previous rest with the strictly lower timeStart than the given one. Returns 0, if the such a note doesn't exist.

References _musElementList, and CAMusElement::Rest.

◆ remove()

bool CAVoice::remove ( CAMusElement elt,
bool  updateSigns = true 
)

Removes the given music element elt from this voice, if the element is playable or from all the voices in the staff, if non-playable and part of the staff.

If updateSigns is True, startTimes of elements after the removed one are decreased including the shared signs. Otherwise only timeStarts for playable elements are effected.

Warning
This function doesn't destroy the object, but only removes its reference in the voice.
Note
Due to speed issues, voices are NOT synchronized for every inserted element. User should manually call CAStaff::synchronizeVoices().

Returns true, if the element was found and removed; otherwise false.

References _musElementList, CAMusElement::addMark(), CAMusElement::Barline, CAStaff::barlineRefs(), CAMusElement::Clef, CAStaff::clefRefs(), CANote::getChord(), CANote::isFirstInChord(), CANote::isPartOfChord(), CAMusElement::isPlayable(), CAMusElement::KeySignature, CAStaff::keySignatureRefs(), CAMusElement::markList(), musElementList(), CAMusElement::musElementType(), CAMusElement::Note, CANote::phrasingSlurEnd(), CANote::phrasingSlurStart(), CAMusElement::removeMark(), CANote::setPhrasingSlurEnd(), CANote::setPhrasingSlurStart(), CANote::setSlurEnd(), CANote::setSlurStart(), CANote::slurEnd(), CANote::slurStart(), staff(), CAMusElement::timeLength(), CAMusElement::TimeSignature, CAStaff::timeSignatureRefs(), CAPlayable::tuplet(), updateTimes(), and CAStaff::voiceList().

Referenced by CATuplet::assignTimes(), CAMainWin::deleteSelection(), insertInTupletAndVoiceAt(), CAMainWin::insertMusElementAt(), CAMainWin::on_uiPlayableLength_toggled(), CATuplet::resetTimes(), CAMainWin::scoreViewKeyPress(), CAMainWin::sourceViewCommit(), and CAPlayable::~CAPlayable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeLyricsContext()

bool CAVoice::removeLyricsContext ( CALyricsContext lc)
inline

◆ setLyricsContexts()

void CAVoice::setLyricsContexts ( QList< CALyricsContext * >  list)
inline

References _lyricsContextList.

Referenced by cloneVoiceProperties().

Here is the caller graph for this function:

◆ setMidiChannel()

void CAVoice::setMidiChannel ( const unsigned char  ch)
inline

◆ setMidiPitchOffset()

void CAVoice::setMidiPitchOffset ( const char  midiPitchOffset)
inline

References _midiPitchOffset, and midiPitchOffset().

Referenced by CAPropertiesDialog::applyProperties(), cloneVoiceProperties(), and CACanorusMLImport::startElement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMidiProgram()

void CAVoice::setMidiProgram ( const unsigned char  program)
inline

◆ setName()

void CAVoice::setName ( const QString  name)
inline

References _name, and name().

Referenced by cloneVoiceProperties(), and CAMainWin::on_uiVoiceName_returnPressed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setStaff()

void CAVoice::setStaff ( CAStaff staff)
inline

References _staff, and staff().

Referenced by clone(), and cloneVoiceProperties().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setStemDirection()

void CAVoice::setStemDirection ( CANote::CAStemDirection  direction)
inline

Sets the stem direction and update slur directions in all the notes in the voice.

References _stemDirection.

Referenced by cloneVoiceProperties(), and CAMainWin::on_uiVoiceStemDirection_toggled().

Here is the caller graph for this function:

◆ staff()

CAStaff* CAVoice::staff ( )
inline

◆ stemDirection()

CANote::CAStemDirection CAVoice::stemDirection ( )
inline

◆ synchronizeMusElements()

bool CAVoice::synchronizeMusElements ( )

Fixes any inconsistencies between music elements: 1) If a common (shared) mark is present only in non-first note of the chord, it's moved and assigned to first note in the chord. The exception are non-common marks (eg. fingering), which are assigned to each note separately.

Returns True, if fixes were made or False otherwise.

References getChord(), musElementList(), and CAMusElement::Note.

Referenced by CAKeybdInput::midiInEventToScore().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateTimes()

bool CAVoice::updateTimes ( int  idx,
int  length,
bool  signsToo = false 
)
private

Updates times of playable elements and optionally signsToo after and including the given index idx for a delta length. The order of the elements stays intact.

This method is usually called when inserting, removing or changing the music elements so they affect others.

References CAMark::isCommon(), musElementList(), CAMusElement::Note, and CAMusElement::setTimeStart().

Referenced by insert(), and remove().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ voiceNumber()

CAVoice::voiceNumber ( )
inline

Voice number in the staff starting at 1.

Voice number is 1, if no staff defined.

References staff(), and CAStaff::voiceList().

Referenced by CAMusicXmlExport::exportMeasure(), isFirstVoice(), CAMainWin::scoreViewKeyPress(), and CAMainWin::sourceViewCommit().

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ CAStaff

friend class CAStaff
friend

Member Data Documentation

◆ _lyricsContextList

QList<CALyricsContext*> CAVoice::_lyricsContextList
private

◆ _midiChannel

unsigned char CAVoice::_midiChannel
private

◆ _midiPitchOffset

char CAVoice::_midiPitchOffset
private

◆ _midiProgram

unsigned char CAVoice::_midiProgram
private

◆ _musElementList

QList<CAMusElement *> CAVoice::_musElementList
private

◆ _name

QString CAVoice::_name
private

Referenced by CAVoice(), name(), and setName().

◆ _staff

CAVoice::_staff
private

Staff which this voice belongs to.

See also
staff()

Referenced by CAVoice(), setStaff(), and staff().

◆ _stemDirection

CANote::CAStemDirection CAVoice::_stemDirection
private

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