Planeshift
Public Member Functions

MeasureElement Class Reference

An element of a measure with a given duration. More...

#include <scoreelements.h>

List of all members.

Public Member Functions

bool AddNote (char name, int octave, psMusic::Accidental writtenAccidental)
 Copy a note into the chord.
psMusic::Duration GetDuration ()
 Get the duration of this element.
size_t GetNNotes () const
 Get the number of notes in this chord.
NoteGetNote (size_t n)
 Return the n-th note in the element.
const NoteGetNote (size_t n) const
bool IsRest () const
 Return whether this element is a rest or not.
 MeasureElement (psMusic::Duration duration)
 Constructor.
bool RemoveNote (char name, int octave)
 Delete a note with the same name and octave.
void SetDuration (psMusic::Duration duration)
 Set the duration of this element.
void SetRest ()
 Set this element to be a rest.

Detailed Description

An element of a measure with a given duration.

It can be a rest, a single note or a group of notes with same duration that must be played together (a chord).

Definition at line 209 of file scoreelements.h.


Constructor & Destructor Documentation

MeasureElement::MeasureElement ( psMusic::Duration  duration)

Constructor.

The default element is a rest of the given duration.

Parameters:
durationThe duration of this element.

Member Function Documentation

bool MeasureElement::AddNote ( char  name,
int  octave,
psMusic::Accidental  writtenAccidental 
)

Copy a note into the chord.

If a note with the same name and octave already exists this will overwrite it or, in other words, its accidental will be overwritten.

Parameters:
nameName of the note (C, D, E, F, G, A or B). Must be uppercase.
octaveOctave number. Octave number 4 is the one that contains the central C on the piano.
accidentalThe accidental with which the note is written on the score.
Returns:
True if no note was overwritten, false otherwise.
psMusic::Duration MeasureElement::GetDuration ( ) [inline]

Get the duration of this element.

Returns:
The duration of this element.

Definition at line 236 of file scoreelements.h.

size_t MeasureElement::GetNNotes ( ) const [inline]

Get the number of notes in this chord.

Returns:
the number of notes in this chord, 0 if this is a rest.

Definition at line 243 of file scoreelements.h.

Note& MeasureElement::GetNote ( size_t  n) [inline]

Return the n-th note in the element.

Parameters:
nThe number of the note in the element.
Returns:
The n-th note in the element.

Definition at line 251 of file scoreelements.h.

const Note& MeasureElement::GetNote ( size_t  n) const [inline]

Definition at line 256 of file scoreelements.h.

bool MeasureElement::IsRest ( ) const [inline]

Return whether this element is a rest or not.

Returns:
True if this is a rest.

Definition at line 263 of file scoreelements.h.

bool MeasureElement::RemoveNote ( char  name,
int  octave 
)

Delete a note with the same name and octave.

Parameters:
noteThe note that must be deleted.
Returns:
True if the note was found, false otherwise.
void MeasureElement::SetDuration ( psMusic::Duration  duration) [inline]

Set the duration of this element.

Parameters:
durationthe new duration for this element.

Definition at line 278 of file scoreelements.h.

void MeasureElement::SetRest ( ) [inline]

Set this element to be a rest.

All existing notes are deleted.

Definition at line 283 of file scoreelements.h.


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