Canorus 0.0
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
CAStaff Class Reference

Represents a staff in the sheet. More...

#include <staff.h>

Inheritance diagram for CAStaff:
Inheritance graph
[legend]

Public Member Functions

 CAStaff (const QString name, CASheet *s, int numberOfLines=5)
 
 ~CAStaff ()
 
int numberOfLines ()
 
void setNumberOfLines (int val)
 
void clear ()
 
CAStaffclone (CASheet *s)
 
const QList< CAVoice * > & voiceList ()
 
void addVoice (CAVoice *voice)
 
void insertVoice (int idx, CAVoice *voice)
 
CAVoiceaddVoice ()
 
void removeVoice (CAVoice *voice)
 
CAVoicefindVoice (const QString name)
 
CAMusElementnext (CAMusElement *elt)
 
CAMusElementprevious (CAMusElement *elt)
 
bool remove (CAMusElement *elt, bool updateSignTimes)
 
bool remove (CAMusElement *elt)
 
int lastTimeEnd ()
 
QList< CAMusElement * > getEltByType (CAMusElement::CAMusElementType type, int startTime)
 
CAMusElementgetOneEltByType (CAMusElement::CAMusElementType type, int startTime)
 
QList< CAPlayable * > getChord (int time)
 
CATempogetTempo (int time)
 
bool synchronizeVoices ()
 
QList< CAMusElement * > & clefRefs ()
 
QList< CAMusElement * > & keySignatureRefs ()
 
QList< CAMusElement * > & timeSignatureRefs ()
 
QList< CAMusElement * > & barlineRefs ()
 
- Public Member Functions inherited from CAContext
 CAContext (const QString name, CASheet *s)
 
virtual ~CAContext ()
 
virtual CAContextclone (CASheet *)=0
 
const QString name ()
 
void setName (const QString name)
 
CAContextType contextType ()
 
CASheetsheet ()
 
void setSheet (CASheet *sheet)
 
virtual void clear ()=0
 
virtual CAMusElementnext (CAMusElement *elt)=0
 
virtual CAMusElementprevious (CAMusElement *elt)=0
 
virtual bool remove (CAMusElement *elt)=0
 

Static Public Member Functions

static bool placeAutoBar (CAPlayable *elt)
 

Private Attributes

QList< CAVoice * > _voiceList
 
int _numberOfLines
 
QList< CAMusElement * > _clefList
 
QList< CAMusElement * > _keySignatureList
 
QList< CAMusElement * > _timeSignatureList
 
QList< CAMusElement * > _barlineList
 

Additional Inherited Members

- Public Types inherited from CAContext
enum  CAContextType { Staff , LyricsContext , FunctionMarkContext , FiguredBassContext }
 
- Protected Member Functions inherited from CAContext
void setContextType (CAContextType t)
 
- Protected Attributes inherited from CAContext
CASheet_sheet
 
QString _name
 
CAContextType _contextType
 

Detailed Description

Represents a staff in the sheet.

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.

This class represents usually an infinite long n-line staff where notes, rests, barlines, clefs and other music elements are placed.

CAStaff is by hierarchy part of CASheet and can include various number of CAVoice objects.

See also
CADrawableStaff, CASheet, CAVoice

Constructor & Destructor Documentation

◆ CAStaff()

CAStaff::CAStaff ( const QString  name,
CASheet s,
int  numberOfLines = 5 
)

Creates a new empty staff with parent sheet s, named name and numberOfLines.

Warning
By default, no voices are created where music elements can be put. Use addVoice() to append a new voice.

References CAContext::_contextType, CAContext::_name, _numberOfLines, CAContext::name(), numberOfLines(), and CAContext::Staff.

Referenced by clone().

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

◆ ~CAStaff()

CAStaff::~CAStaff ( )

References clear().

Here is the call graph for this function:

Member Function Documentation

◆ addVoice() [1/2]

CAVoice * CAStaff::addVoice ( )

Adds an empty voice to the staff. Call synchronizeVoices() manually to synchronize a new voice with other voices.

References addVoice(), CAContext::name(), and voiceList().

Referenced by addVoice().

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

◆ addVoice() [2/2]

void CAStaff::addVoice ( CAVoice voice)
inline

◆ barlineRefs()

QList< CAMusElement * > & CAStaff::barlineRefs ( )
inline

References _barlineList.

Referenced by CAVoice::insertMusElement(), CAVoice::remove(), and CALilyPondExport::scanForRepeats().

Here is the caller graph for this function:

◆ clear()

void CAStaff::clear ( )
virtual

Implements CAContext.

References _voiceList.

Referenced by ~CAStaff().

Here is the caller graph for this function:

◆ clefRefs()

QList< CAMusElement * > & CAStaff::clefRefs ( )
inline

References _clefList.

Referenced by CAVoice::getClef(), CAVoice::getPreviousClef(), CAVoice::insertMusElement(), CANote::notePosition(), and CAVoice::remove().

Here is the caller graph for this function:

◆ clone()

CAStaff * CAStaff::clone ( CASheet s)
virtual

◆ findVoice()

CAVoice * CAStaff::findVoice ( const QString  name)

Returns the first voice with the given name or Null, if such a voice doesn't exist.

References _voiceList, and CAContext::name().

Here is the call graph for this function:

◆ getChord()

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

Returns a list of notes and rests (chord) for all the voices in the staff in the given time slice time.

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

See also
CASheet:getChord(), CAVoice::getChord()

References voiceList().

Referenced by CAMainWin::deleteSelection().

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

◆ getEltByType()

QList< CAMusElement * > CAStaff::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 searches the entire staff through all the voices.

See also
CASheet::getChord()

References _voiceList.

Referenced by CALilyPondImport::findSharedElement().

Here is the caller graph for this function:

◆ getOneEltByType()

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

Returns one music element which has the given startTime and type. This searches through all the voices of the staff.

See also
CASheet::getChord()

References _voiceList.

Referenced by CAMidiImport::writeMidiChannelEventsToVoice_New().

Here is the caller graph for this function:

◆ getTempo()

CATempo * CAStaff::getTempo ( int  time)

Returns the Tempo element active at the given time.

References CAMusElement::timeStart(), and voiceList().

Here is the call graph for this function:

◆ insertVoice()

void CAStaff::insertVoice ( int  idx,
CAVoice voice 
)
inline

References _voiceList.

Referenced by CAMainWin::sourceViewCommit().

Here is the caller graph for this function:

◆ keySignatureRefs()

QList< CAMusElement * > & CAStaff::keySignatureRefs ( )
inline

◆ lastTimeEnd()

int CAStaff::lastTimeEnd ( )

Returns the end of the last music element in the staff.

See also
CAVoice::lastTimeEnd()

References _voiceList, and lastTimeEnd().

Referenced by lastTimeEnd().

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

◆ next()

CAMusElement * CAStaff::next ( CAMusElement elt)
virtual

Returns the pointer to the element right next to the given elt in any of the voice.

See also
next()

Implements CAContext.

References voiceList().

Referenced by CAMainWin::scoreViewKeyPress().

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

◆ numberOfLines()

int CAStaff::numberOfLines ( )
inline

◆ placeAutoBar()

bool CAStaff::placeAutoBar ( CAPlayable elt)
static

Places a barline in front of the element, if needed and the element is the last element in the staff.

The function finds the last barline and places a new one, if the last bar is full. It searches for the time signature in effect for the last bar, not to get fooled by time signature(s) already present at a time signature change.

Returns
True, if a new barline was placed; otherwise False.

References CATimeSignature::barDuration(), CAMusElement::Barline, CAVoice::insert(), CAVoice::previousByType(), CABarline::Single, CAPlayable::staff(), CAVoice::staff(), synchronizeVoices(), CAMusElement::timeEnd(), CAMusElement::TimeSignature, CAMusElement::timeStart(), CAPlayable::voice(), and voiceList().

Referenced by CAMainWin::insertMusElementAt(), CAKeybdInput::midiInEventToScore(), and CAMidiImport::writeMidiChannelEventsToVoice_New().

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

◆ previous()

CAMusElement * CAStaff::previous ( CAMusElement elt)
virtual

Returns the pointer to the element right before the given elt in any of the voice.

See also
previous()

Implements CAContext.

References voiceList().

Here is the call graph for this function:

◆ remove() [1/2]

bool CAStaff::remove ( CAMusElement elt)
inlinevirtual

Implements CAContext.

References remove().

Referenced by remove().

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

◆ remove() [2/2]

bool CAStaff::remove ( CAMusElement elt,
bool  updateSignTimes 
)

Removes the element elt. Updates timeStarts for elements after the given element.

Also updates non-playable shared signs after the element, if updateSignTimes is True.

Eventually does the same as CAVoice::remove(), but checks for any voices present in the staff.

References voiceList().

Here is the call graph for this function:

◆ removeVoice()

void CAStaff::removeVoice ( CAVoice voice)
inline

◆ setNumberOfLines()

void CAStaff::setNumberOfLines ( int  val)
inline

References _numberOfLines.

Referenced by CAPropertiesDialog::applyProperties().

Here is the caller graph for this function:

◆ synchronizeVoices()

bool CAStaff::synchronizeVoices ( )

Fixes voices inconsistency: 1) If any of the voices include signs (key sigs, clefs etc.) which aren't present in all voices, add that sign to all the voices. 2) If a voice includes a sign which overlaps a playable element in other voice, insert rests until the sign is moved at the end of the overlapped chord in all voices. 3) If a voice elements are not linear (every N-th element's timeEnd should be N+1-th element's timeStart) inserts rests to achieve linearity.

Synchronizing voices is relatively slow (O(n*m) where n is number of voices and m number of elements in voice n). This was the main reason to not automate the synchronization: import filters use lots of insertions and synchronization of the voices every time a new element is inserted would considerably slow down the import filter.

Returns True, if everything was ok. False, if fixes were needed.

References _barlineList, _clefList, _keySignatureList, _timeSignatureList, CAMusElement::Barline, CAMusElement::Clef, CARest::composeRests(), CAMusElement::KeySignature, CAMusElement::timeEnd(), CAMusElement::TimeSignature, CAMusElement::timeStart(), and voiceList().

Referenced by CAMusicXmlImport::addVoiceIfNeeded(), CAMainWin::insertMusElementAt(), CAMainWin::newDocument(), CAMainWin::on_uiNewVoice_triggered(), CAMainWin::on_uiPlayableLength_toggled(), CAMainWin::pasteAt(), placeAutoBar(), CAMusicXmlImport::readMeasure(), CAMainWin::scoreViewKeyPress(), CAMainWin::sourceViewCommit(), and CAMidiImport::writeMidiFileEventsToScore_New().

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

◆ timeSignatureRefs()

QList< CAMusElement * > & CAStaff::timeSignatureRefs ( )
inline

◆ voiceList()

const QList< CAVoice * > & CAStaff::voiceList ( )
inline

Member Data Documentation

◆ _barlineList

QList<CAMusElement *> CAStaff::_barlineList
private

Referenced by barlineRefs(), and synchronizeVoices().

◆ _clefList

QList<CAMusElement *> CAStaff::_clefList
private

Referenced by clefRefs(), and synchronizeVoices().

◆ _keySignatureList

QList<CAMusElement *> CAStaff::_keySignatureList
private

◆ _numberOfLines

int CAStaff::_numberOfLines
private

◆ _timeSignatureList

QList<CAMusElement *> CAStaff::_timeSignatureList
private

◆ _voiceList

QList<CAVoice *> CAStaff::_voiceList
private

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