Lomse library. API documentation  0.30.0
AScore Class Reference
Inheritance diagram for AScore:
AObject ISiblings AObject

Detailed Description

AScore represents a full music score, that is, an object comprising all of the music for all of the players and their instruments, typically laid out in a specific order. In lomse, an score is, basically, a collection instruments (AInstrument objects) and some information common to all them, such as score titles.

In a full score, related instruments are usually grouped by sharing barlines and having some visual clues, such as a brace or bracket, and a group name. In lomse, a group of instruments is represented by an AInstrGroup object, and the AScore object is also responsible for managing the collection of all defined instrument groups.

See The structure of a music score.

Warning
This documentation is incomplete. The user API for the document internal model is currently being defined and, thus, for this class, only some methods have been defined.

Public Member Functions

ImoScore * internal_object () const
 
void end_of_changes ()
 
Instruments management. Access to information
AInstrument instrument_at (int iInstr) const
 
int num_instruments () const
 
Instruments management. Add/delete instruments
AInstrument append_new_instrument ()
 
void delete_instrument (ImoId instrId)
 
void delete_instrument (AInstrument &instr)
 
Instruments management. Reordering instruments
void move_up_instrument (ImoId instrId)
 
void move_up_instrument (AInstrument &instr)
 
void move_down_instrument (ImoId instrId)
 
void move_down_instrument (AInstrument &instr)
 
Groups management. Access to information
int num_instruments_groups () const
 
AInstrGroup instruments_group_at (int iGroup) const
 
Groups management. Create/remove groups
AInstrGroup group_instruments (int iFirstInstr, int iLastInstr)
 
bool delete_instruments_group_at (int iGroup)
 
bool delete_instruments_group (const AInstrGroup &group)
 
void delete_all_instruments_groups ()
 
Algorithms
MeasureLocator locator_for (TimeUnits timepos, int iInstr)
 
TimeUnits timepos_for (int iMeasure, int iBeat, int iInstr)
 
TimeUnits timepos_for (const MeasureLocator &ml)
 
- Public Member Functions inherited from AObject
 AObject ()
 
bool is_valid () const
 
ImoObj * internal_object () const
 
ImoId object_id () const
 
const std::string & object_name () const
 
ADocument owner_document () const
 
ADynamic downcast_to_dynamic () const
 
AInstrument downcast_to_instrument () const
 
AInstrGroup downcast_to_instr_group () const
 
ALink downcast_to_link () const
 
AList downcast_to_list () const
 
AParagraph downcast_to_paragraph () const
 
AScore downcast_to_score () const
 
ATextItem downcast_to_text_item () const
 
bool is_anonymous_block () const
 
bool is_button () const
 
bool is_content () const
 
bool is_control () const
 
bool is_dynamic () const
 
bool is_heading () const
 
bool is_image () const
 
bool is_inline_wrapper () const
 
bool is_instrument () const
 
bool is_instr_group () const
 
bool is_link () const
 
bool is_list () const
 
bool is_list_item () const
 
bool is_midi_info () const
 
bool is_multicolumn () const
 
bool is_music_data () const
 
bool is_paragraph () const
 
bool is_score () const
 
bool is_sound_info () const
 
bool is_table () const
 
bool is_table_cell () const
 
bool is_table_body () const
 
bool is_table_head () const
 
bool is_table_row () const
 
bool is_text_item () const
 
- Public Member Functions inherited from ISiblings
AObject previous_sibling () const
 
AObject next_sibling () const
 

Member Function Documentation

◆ append_new_instrument()

AInstrument append_new_instrument ( )

Appends a new empty instrument to the score, instantiated with default values:

  • One empty staff, staff size 7.2 mm (rastral size between 2 (7.4mm) and 3 (7.0mm)).
  • No name, no abbreviation
  • Not included in any existing instruments group.
  • Has default MIDI info (see AMidiInfo for default values)

Returns the created instrument.

◆ delete_all_instruments_groups()

void delete_all_instruments_groups ( )

Deletes all instruments groups defined in the score, if any.

◆ delete_instrument() [1/2]

void delete_instrument ( ImoId  instrId)

Removes the specified instrument form the score and deletes it.

Instrument groups in the score are not affected, as they are not tied to specific instruments but to instruments positions. That is, a group joining instruments two to five will always join the instruments occupying those positions, whatever they are there after a delete instrument operation. A remove operation will not affect existing groups unless the group contained the last instrument in the score, as that instrument position will no longer exist after deleting an instrument. In that case, the group will have one less instrument or will be deleted if only containing one instrument.

Parameters
instrIdThe ID of the instrument to delete.

◆ delete_instrument() [2/2]

void delete_instrument ( AInstrument instr)

Removes the specified instrument form the score and deletes it.

Instrument groups in the score are not affected, as they are not tied to specific instruments but to instruments positions. That is, a group joining instruments two to five will always join the instruments occupying those positions, whatever they are there after a delete instrument operation. A remove operation will not affect existing groups unless the group contained the last instrument in the score, as that instrument position will no longer exist after deleting an instrument. In that case, the group will have one less instrument or will be deleted if only containing one instrument.

Parameters
instrA reference to the instrument to delete.

◆ delete_instruments_group()

bool delete_instruments_group ( const AInstrGroup group)

Deletes the instruments group group. Returns false if any error.

Parameters
groupThe group to delete.

◆ delete_instruments_group_at()

bool delete_instruments_group_at ( int  iGroup)

Deletes the instruments group at position iGroup. Returns false if error (invalid value for param iGroup).

Parameters
iGroupPosition (0..num.groups-1) of group to delete. Please, notice that groups are ordered as they are created: first created one has index 0.

◆ end_of_changes()

void end_of_changes ( )

When you finish modifying the content of an score it is necessary to inform lomse for updating all internal structures associated to the score. For this it is mandatory to invoke this method. Alternatively, you can invoke ADocument::end_of_changes(), that will invoke this method on all scores.

◆ group_instruments()

AInstrGroup group_instruments ( int  iFirstInstr,
int  iLastInstr 
)

Creates a group whose first instrument will be instrument at position iFirstInstr and the last in the group will be instrument at position iLastInstr.

Parameters
iFirstInstrPosition (0..n-1) of first instrument to include in the group.
iLastInstrPosition (0..n-1) of last instrument to include in the group. Notice that iFirstInstr must be lower than iLastInstr. Otherwise this method will do nothing and will return an invalid AInstrGroup.

The created group will not have any symbol (k_group_symbol_none), the instruments will have their barlines joined (k_joined_barlines), and the group will have neither name nor abbreviation. After the group is created, you can change all these default settings.

◆ instrument_at()

AInstrument instrument_at ( int  iInstr) const

Returns the requested instrument.

Parameters
iInstrIs the index to the requested instrument (0 ... num_instruments - 1).

◆ instruments_group_at()

AInstrGroup instruments_group_at ( int  iGroup) const

Returns the requested instruments group.

Parameters
iGroupIs the index to the requested instruments group (0 ... num.groups - 1).

◆ internal_object()

ImoScore * internal_object ( ) const

Transitional, to facilitate migration to the new public API. Notice that this method will be removed in future so, please, if you need to use this method open an issue at https://github.com/lenmus/lomse/issues explaining the need, so that the public API could be fixed and your app. would not be affected in future when this method is removed.

◆ locator_for()

MeasureLocator locator_for ( TimeUnits  timepos,
int  iInstr 
)

Returns a measure locator for the specified instrument and timepos.

Parameters
timepos
iInstrNumber of the instrument (0..m) to which the measures refer to. Take into account that for polymetric music (music in which not all instruments have the same time signature), the measure number is not an absolute value, common to all the score instruments, but it is relative to an instrument. For normal scores, just providing measure number and location will do the job.

◆ move_down_instrument() [1/2]

void move_down_instrument ( ImoId  instrId)

Changes the order of the instruments in the score by moving the referenced instrument after the one immediately below it.

Parameters
instrIdThe ID of the instrument to move down.

Trying to move down the last instrument is a valid operation but nothing will be changed.

Instrument groups in the score are not affected, as they are not tied to specific instruments but to instruments positions. That is, a group joining instruments two to five will always join the instruments occupying those positions, whatever they are there after a move operation.

See also
move_up_instrument()

◆ move_down_instrument() [2/2]

void move_down_instrument ( AInstrument instr)

Changes the order of the instruments in the score by moving the referenced instrument after the one immediately below it.

Parameters
instrA reference to the instrument to move down.

Trying to move down the last instrument is a valid operation but nothing will be changed.

Instrument groups in the score are not affected, as they are not tied to specific instruments but to instruments positions. That is, a group joining instruments two to five will always join the instruments occupying those positions, whatever they are there after a move operation.

See also
move_up_instrument()

◆ move_up_instrument() [1/2]

void move_up_instrument ( ImoId  instrId)

Changes the order of the instruments in the score by moving the referenced instrument before the one immediately above it.

Parameters
instrIdThe ID of the instrument to move up.

Trying to move up the first instrument is a valid operation but nothing will be changed.

Instrument groups in the score are not affected, as they are not tied to specific instruments but to instruments positions. That is, a group joining instruments two to five will always join the instruments occupying those positions, whatever they are there after a move operation.

See also
move_down_instrument()

◆ move_up_instrument() [2/2]

void move_up_instrument ( AInstrument instr)

Changes the order of the instruments in the score by moving the referenced instrument before the one immediately above it.

Parameters
instrA reference to the instrument to move up.

Trying to move up the first instrument is a valid operation but nothing will be changed.

Instrument groups in the score are not affected, as they are not tied to specific instruments but to instruments positions. That is, a group joining instruments two to five will always join the instruments occupying those positions, whatever they are there after a move operation.

See also
move_down_instrument()

◆ num_instruments()

int num_instruments ( ) const

Returns the number of instruments that this score contains.

◆ num_instruments_groups()

int num_instruments_groups ( ) const

Returns the number of instrument groups that this score contains.

◆ timepos_for() [1/2]

TimeUnits timepos_for ( int  iMeasure,
int  iBeat,
int  iInstr 
)

Returns the time position for the specified measure and beat.

Parameters
iMeasureMeasure number (0..n) in instrument iInstr.
iBeatBeat number (0..m) relative to the measure.
iInstrNumber of the instrument (0..m) to which the measures refer to. Take into account that for polymetric music (music in which not all instruments have the same time signature), the measure number is not an absolute value, common to all the score instruments, but it is relative to an instrument. For normal scores, just providing measure number and location will do the job.
Warning
For scores without time signature this method is useless as there are no measures, and beats are not defined. Therefore, if this method is invoked in an score without time signature, this method will always return time position 0.

◆ timepos_for() [2/2]

TimeUnits timepos_for ( const MeasureLocator &  ml)

Returns the time position for the specified measure locator.

Parameters
mlThe measure locator to convert.