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;
}
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);
}
Aggregations