Search in sources :

Example 1 with CList

use of com.xenoage.utils.collections.CList in project Zong by Xenoage.

the class BeamedStems method fromBeam.

public static BeamedStems fromBeam(List<ChordSpacing> beamChords) {
    val stems = new CList<BeamedStem>(beamChords.size());
    for (val chord : beamChords) {
        // we need a stem for each beamed chord
        if (chord.notation.stem == null)
            throw new IllegalStateException("TODO! we need a stem for each beamed chord");
        SLP stemSideNoteSlp = chord.getNotation().getStemSideNoteSlp();
        SLP stemEndSlp = chord.getNotation().getStemEndSlp();
        stems.add(new BeamedStem(chord.getStemXIs(), chord.notation.stemDirection, stemSideNoteSlp, stemEndSlp));
    }
    return new BeamedStems(stems.close());
}
Also used : lombok.val(lombok.val) CList(com.xenoage.utils.collections.CList) SLP(com.xenoage.zong.musiclayout.SLP)

Example 2 with CList

use of com.xenoage.utils.collections.CList in project Zong by Xenoage.

the class Example method getStems.

public BeamedStems getStems() {
    val stems = new CList<BeamedStem>();
    int[] notesLp = getNotesLp();
    val stemDir = getStemDir();
    float distance = getStemsDistanceIs();
    for (int i : range(notesLp)) {
        float stemXIs = i * distance;
        float stemLengthIs;
        if (i == 0)
            stemLengthIs = leftStemLengthIs;
        else if (i == notesLp.length - 1)
            stemLengthIs = rightStemLengthIs;
        else
            stemLengthIs = stemDrawer.getPreferredStemLengthIs(new ChordLps(notesLp[i]), stemDir, Companion.getStaff5Lines());
        float stemEndLp = notesLp[i] + stemDir.getSign() * stemLengthIs * 2;
        stems.add(new BeamedStem(stemXIs, stemDir, slp(0, notesLp[i]), slp(0, stemEndLp)));
    }
    return new BeamedStems(stems.close());
}
Also used : lombok.val(lombok.val) BeamedStems(com.xenoage.zong.musiclayout.spacer.beam.stem.BeamedStems) CList(com.xenoage.utils.collections.CList) ChordLps(com.xenoage.zong.musiclayout.notation.chord.ChordLps) BeamedStem(com.xenoage.zong.musiclayout.spacer.beam.stem.BeamedStem)

Aggregations

CList (com.xenoage.utils.collections.CList)2 lombok.val (lombok.val)2 SLP (com.xenoage.zong.musiclayout.SLP)1 ChordLps (com.xenoage.zong.musiclayout.notation.chord.ChordLps)1 BeamedStem (com.xenoage.zong.musiclayout.spacer.beam.stem.BeamedStem)1 BeamedStems (com.xenoage.zong.musiclayout.spacer.beam.stem.BeamedStems)1