Search in sources :

Example 6 with StemDirection

use of com.xenoage.zong.core.music.chord.StemDirection in project Zong by Xenoage.

the class StemDirector method compute.

/**
 * Computes the {@link StemDirection} of the given chord (and maybe connected
 * ones) and returns them. The chord must be part of a score.
 */
public Map<Chord, StemDirection> compute(Chord chord) {
    Map<Chord, StemDirection> ret = map();
    Beam beam = chord.getBeam();
    Score score = chord.getScore();
    if (beam != null) {
        // compute stem directions for all chords of the beam
        StemDirection[] beamedStems = beamedStemDirector.compute(beam, score);
        for (int iChord : range(beam.size())) ret.put(beam.getChord(iChord), beamedStems[iChord]);
    } else {
        // compute stem direction for single chord
        MP mp = MP.getMP(chord);
        StemDirection stem = singleStemDirector.compute(chord, score.getMusicContext(mp, BeforeOrAt, Before));
        ret.put(chord, stem);
    }
    // but it was bad and outdated, so we removed it.
    return ret;
}
Also used : Beam(com.xenoage.zong.core.music.beam.Beam) Score(com.xenoage.zong.core.Score) MP(com.xenoage.zong.core.position.MP) Chord(com.xenoage.zong.core.music.chord.Chord) StemDirection(com.xenoage.zong.core.music.chord.StemDirection)

Example 7 with StemDirection

use of com.xenoage.zong.core.music.chord.StemDirection 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

StemDirection (com.xenoage.zong.core.music.chord.StemDirection)7 Chord (com.xenoage.zong.core.music.chord.Chord)4 Score (com.xenoage.zong.core.Score)2 MusicContext (com.xenoage.zong.core.music.MusicContext)2 Beam (com.xenoage.zong.core.music.beam.Beam)2 ChordLps (com.xenoage.zong.musiclayout.notation.chord.ChordLps)2 NotesNotation (com.xenoage.zong.musiclayout.notation.chord.NotesNotation)2 StemNotation (com.xenoage.zong.musiclayout.notation.chord.StemNotation)2 ChordWidths (com.xenoage.zong.musiclayout.settings.ChordWidths)2 FontInfo (com.xenoage.utils.font.FontInfo)1 TextMeasurer (com.xenoage.utils.font.TextMeasurer)1 Fraction (com.xenoage.utils.math.Fraction)1 VSide (com.xenoage.utils.math.VSide)1 Stem (com.xenoage.zong.core.music.chord.Stem)1 Stem.defaultStem (com.xenoage.zong.core.music.chord.Stem.defaultStem)1 Lyric (com.xenoage.zong.core.music.lyric.Lyric)1 SyllableType (com.xenoage.zong.core.music.lyric.SyllableType)1 SlurWaypoint (com.xenoage.zong.core.music.slur.SlurWaypoint)1 Duration (com.xenoage.zong.core.music.util.Duration)1 MP (com.xenoage.zong.core.position.MP)1