Search in sources :

Example 31 with Fraction

use of com.xenoage.utils.math.Fraction in project Zong by Xenoage.

the class Context method moveCurrentBeat.

/**
 * Moves the current beat within the current part and measure.
 */
public void moveCurrentBeat(Fraction beat) {
    Fraction newBeat = this.mp.getBeat().add(beat);
    // never step back behind 0
    if (newBeat.getNumerator() < 0) {
        reportError("Step back behind beat 0");
        newBeat = Companion.get_0();
    }
    this.mp = this.mp.withBeat(newBeat);
}
Also used : Fraction(com.xenoage.utils.math.Fraction)

Example 32 with Fraction

use of com.xenoage.utils.math.Fraction in project Zong by Xenoage.

the class StaffTest method testMeasureFilledBeats.

public static void testMeasureFilledBeats(Fraction[] expectedMeasureFilledBeats, Staff staff) {
    assertEquals(expectedMeasureFilledBeats.length, staff.getMeasures().size());
    for (int i : range(expectedMeasureFilledBeats)) {
        Fraction filledBeats = staff.getMeasure(i).getFilledBeats();
        assertEquals("Measure " + i, expectedMeasureFilledBeats[i], filledBeats);
    }
}
Also used : Fraction(com.xenoage.utils.math.Fraction)

Aggregations

Fraction (com.xenoage.utils.math.Fraction)32 BeatOffset (com.xenoage.zong.musiclayout.spacing.BeatOffset)6 Chord (com.xenoage.zong.core.music.chord.Chord)5 ElementSpacing (com.xenoage.zong.musiclayout.spacing.ElementSpacing)5 lombok.val (lombok.val)5 Voice (com.xenoage.zong.core.music.Voice)4 Measure (com.xenoage.zong.core.music.Measure)3 VoiceElement (com.xenoage.zong.core.music.VoiceElement)3 Clef (com.xenoage.zong.core.music.clef.Clef)3 TraditionalKey (com.xenoage.zong.core.music.key.TraditionalKey)3 TimeSignature (com.xenoage.zong.core.music.time.TimeSignature)3 VoiceSpacing (com.xenoage.zong.musiclayout.spacing.VoiceSpacing)3 ColumnElementWrite (com.xenoage.zong.commands.core.music.ColumnElementWrite)2 Score (com.xenoage.zong.core.Score)2 Part (com.xenoage.zong.core.music.Part)2 Note (com.xenoage.zong.core.music.chord.Note)2 Rest (com.xenoage.zong.core.music.rest.Rest)2 ChordNotation (com.xenoage.zong.musiclayout.notation.ChordNotation)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1