Search in sources :

Example 6 with ChordLps

use of com.xenoage.zong.musiclayout.notation.chord.ChordLps in project Zong by Xenoage.

the class SingleStemDirector method compute.

public StemDirection compute(Chord chord, MusicContext context) {
    // stem specified in chord?
    Stem stem = chord.getStem();
    if (stem.getDirection() != StemDirection.Default)
        return stem.getDirection();
    // stem needed?
    if (!isStemNeeded(chord))
        return StemDirection.None;
    // compute default stem
    ChordLps chordLp = new ChordLps(chord, context);
    int linesCount = context.getLinesCount();
    return compute(chordLp, linesCount);
}
Also used : ChordLps(com.xenoage.zong.musiclayout.notation.chord.ChordLps) Stem(com.xenoage.zong.core.music.chord.Stem)

Example 7 with ChordLps

use of com.xenoage.zong.musiclayout.notation.chord.ChordLps 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)

Example 8 with ChordLps

use of com.xenoage.zong.musiclayout.notation.chord.ChordLps in project Zong by Xenoage.

the class StemNotatorTest method testPitch.

private void testPitch(Pitch[] pitches, float start, float end) {
    MusicContext context = MusicContext.Companion.getSimpleInstance();
    Chord chord;
    NotesNotation chordNotesAlignment;
    StemNotation chordStemAlignment;
    Fraction fraction = Companion.fr(1, 1);
    chord = ChordFactory.chord(pitches, fraction);
    ChordLps linepositions = new ChordLps(chord, context);
    StemDirection stemDirection = singleStemDirector.compute(linepositions, 5);
    chordNotesAlignment = notesNotator.compute(chord, stemDirection, defaultChordWidthsNormal, context);
    chordStemAlignment = testee.compute(Stem.Companion.getDefaultStem(), chordNotesAlignment.getLps(), stemDirection, 0, Companion.getStaff5Lines(), 1);
    assertEquals(start, chordStemAlignment.startSlp.lp, Delta.DELTA_FLOAT);
    assertEquals(end, chordStemAlignment.endSlp.lp, Delta.DELTA_FLOAT);
}
Also used : ChordLps(com.xenoage.zong.musiclayout.notation.chord.ChordLps) NotesNotation(com.xenoage.zong.musiclayout.notation.chord.NotesNotation) Fraction(com.xenoage.utils.math.Fraction) MusicContext(com.xenoage.zong.core.music.MusicContext) Chord(com.xenoage.zong.core.music.chord.Chord) StemDirection(com.xenoage.zong.core.music.chord.StemDirection) StemNotation(com.xenoage.zong.musiclayout.notation.chord.StemNotation)

Aggregations

ChordLps (com.xenoage.zong.musiclayout.notation.chord.ChordLps)8 MusicContext (com.xenoage.zong.core.music.MusicContext)2 Chord (com.xenoage.zong.core.music.chord.Chord)2 StemDirection (com.xenoage.zong.core.music.chord.StemDirection)2 NotesNotation (com.xenoage.zong.musiclayout.notation.chord.NotesNotation)2 Test (org.junit.Test)2 CList (com.xenoage.utils.collections.CList)1 Fraction (com.xenoage.utils.math.Fraction)1 Stem (com.xenoage.zong.core.music.chord.Stem)1 MP (com.xenoage.zong.core.position.MP)1 NoteDisplacement (com.xenoage.zong.musiclayout.notation.chord.NoteDisplacement)1 StemNotation (com.xenoage.zong.musiclayout.notation.chord.StemNotation)1 BeamedStem (com.xenoage.zong.musiclayout.spacer.beam.stem.BeamedStem)1 BeamedStems (com.xenoage.zong.musiclayout.spacer.beam.stem.BeamedStems)1 lombok.val (lombok.val)1