Search in sources :

Example 1 with VoiceAdd

use of com.xenoage.zong.commands.core.music.VoiceAdd in project Zong by Xenoage.

the class Context method writeVoiceElement.

/**
 * Writes the given {@link VoiceElement} to the current position
 * without moving the cursor forward. When the element could be written, true is returned,
 * otherwise (e.g. when the measure was full), false is returned.
 */
public boolean writeVoiceElement(VoiceElement element, int staffIndexInPart, int voice) {
    MP mp = this.mp.withStaff(getPartStaffIndices().getStart() + staffIndexInPart).withVoice(voice);
    try {
        // create voice if needed
        Measure measure = score.getMeasure(mp);
        if (measure.getVoices().size() < voice + 1)
            execute(new VoiceAdd(measure, voice));
        execute(new VoiceElementWrite(score.getVoice(mp), mp, element, writeVoicElementOptions));
        return true;
    } catch (MeasureFullException ex) {
        reportError(ex.getMessage());
        return false;
    }
}
Also used : VoiceElementWrite(com.xenoage.zong.commands.core.music.VoiceElementWrite) MP(com.xenoage.zong.core.position.MP) VoiceAdd(com.xenoage.zong.commands.core.music.VoiceAdd) MeasureFullException(com.xenoage.zong.utils.exceptions.MeasureFullException)

Aggregations

VoiceAdd (com.xenoage.zong.commands.core.music.VoiceAdd)1 VoiceElementWrite (com.xenoage.zong.commands.core.music.VoiceElementWrite)1 MP (com.xenoage.zong.core.position.MP)1 MeasureFullException (com.xenoage.zong.utils.exceptions.MeasureFullException)1