use of com.xenoage.zong.musiclayout.notation.chord.NotesNotation in project Zong by Xenoage.
the class LegerLinesStamper method stamp.
public LegerLineStamping[] stamp(ChordNotation chordNotation, float chordXMm, StaffStamping staffStamping) {
NotesNotation notes = chordNotation.notes;
int bottomCount = getBottomCount(notes.getBottomNote().lp);
int topCount = getTopCount(notes.getTopNote().lp, staffStamping.linesCount);
if (bottomCount > 0 || topCount > 0) {
// horizontal position and width (may differ above and below staff, dependent on suspended notes)
NoteSuspension bottomSuspension = getBottomSuspension(notes.notes);
float xTopMm = getXMm(chordXMm, notes.noteheadWidthIs, bottomSuspension, staffStamping.is);
float widthBottomIs = getWidthIs(bottomSuspension != None);
NoteSuspension topSuspension = getTopSuspension(notes.notes, staffStamping.linesCount);
float xBottomMm = getXMm(chordXMm, notes.noteheadWidthIs, topSuspension, staffStamping.is);
float widthTopIs = getWidthIs(bottomSuspension != None);
// vertical positions
int[] bottomLps = getBottomLps(bottomCount);
int[] topLps = getTopLps(topCount, staffStamping.linesCount);
// create stampings
LegerLineStamping[] ret = new LegerLineStamping[bottomCount + topCount];
for (int i : range(bottomCount)) ret[i] = new LegerLineStamping(sp(xBottomMm, bottomLps[i]), widthBottomIs, staffStamping);
for (int i : range(topCount)) ret[bottomCount + i] = new LegerLineStamping(sp(xTopMm, topLps[i]), widthTopIs, staffStamping);
return ret;
} else {
return empty;
}
}
use of com.xenoage.zong.musiclayout.notation.chord.NotesNotation in project Zong by Xenoage.
the class StemNotatorTest method testPitch.
private void testPitch(Pitch[] pitches, float start, float end) {
MusicContext context = MusicContext.simpleInstance;
Chord chord;
NotesNotation chordNotesAlignment;
StemNotation chordStemAlignment;
Fraction fraction = 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.defaultStem, chordNotesAlignment.getLps(), stemDirection, 0, staff5Lines, 1);
assertEquals(start, chordStemAlignment.startSlp.lp, Delta.DELTA_FLOAT);
assertEquals(end, chordStemAlignment.endSlp.lp, Delta.DELTA_FLOAT);
}
use of com.xenoage.zong.musiclayout.notation.chord.NotesNotation in project Zong by Xenoage.
the class NotesNotatorTest method testChordC5C5.
/**
* Tests a C5/C5 (unison) chord, 1/4. Stem: left, down. Width: 2x quarter.
*/
@Test
public void testChordC5C5() {
Chord chord = chord(new Pitch[] { pi(0, 0, 5), pi(0, 0, 5) }, fr(1, 4));
NotesNotation notes = testee.compute(chord, StemDirection.Down, cw, context);
assertEquals(n, notes.stemOffsetIs, Df);
assertEquals(2 * n, notes.widthIs, Df);
NoteDisplacement note = notes.getNote(0);
assertEquals(5, note.lp);
assertEquals(0, note.xIs, Df);
assertEquals(NoteSuspension.Left, note.suspension);
note = notes.getNote(1);
assertEquals(5, note.lp);
assertEquals(n, note.xIs, Df);
assertEquals(NoteSuspension.None, note.suspension);
}
use of com.xenoage.zong.musiclayout.notation.chord.NotesNotation in project Zong by Xenoage.
the class NotesNotatorTest method testSingleNoteC5.
/**
* Tests a C5, 1/4. Stem: left, down. Width: 1x quarter.
*/
@Test
public void testSingleNoteC5() {
Chord chord = chord(pi(0, 0, 5), fr(1, 4));
NotesNotation notes = testee.compute(chord, StemDirection.Down, cw, context);
assertEquals(0, notes.stemOffsetIs, Df);
assertEquals(n, notes.widthIs, Df);
NoteDisplacement note = notes.getNote(0);
assertEquals(5, note.lp);
assertEquals(0, note.xIs, Df);
assertEquals(NoteSuspension.None, note.suspension);
}
use of com.xenoage.zong.musiclayout.notation.chord.NotesNotation in project Zong by Xenoage.
the class NotesNotatorTest method testDotPositions.
/**
* Tests the dot positions for some chords.
*/
@Test
public void testDotPositions() {
// C5: position 6
Chord chord = chord(pi(0, 0, 5), fr(3, 4));
NotesNotation notes = testee.compute(chord, StemDirection.Down, cw, context);
assertEquals(1, notes.getDotsPerNoteCount());
assertEquals(1, notes.dotsLp.length);
assertEquals(5, notes.dotsLp[0]);
// B4: position 6
chord = chord(pi(6, 0, 4), fr(7, 8));
notes = testee.compute(chord, StemDirection.Down, cw, context);
assertEquals(2, notes.getDotsPerNoteCount());
assertEquals(1, notes.dotsLp.length);
assertEquals(5, notes.dotsLp[0]);
// D4: position -1
chord = chord(pi(1, 0, 4), fr(3, 4));
notes = testee.compute(chord, StemDirection.Up, cw, context);
assertEquals(1, notes.getDotsPerNoteCount());
assertEquals(1, notes.dotsLp.length);
assertEquals(-1, notes.dotsLp[0]);
// C4: position -1
chord = chord(pi(0, 0, 4), fr(3, 4));
notes = testee.compute(chord, StemDirection.Up, cw, context);
assertEquals(1, notes.getDotsPerNoteCount());
assertEquals(1, notes.dotsLp.length);
assertEquals(-1, notes.dotsLp[0]);
// B3: position -3
chord = chord(pi(6, 0, 3), fr(3, 4));
notes = testee.compute(chord, StemDirection.Up, cw, context);
assertEquals(1, notes.getDotsPerNoteCount());
assertEquals(1, notes.dotsLp.length);
assertEquals(-3, notes.dotsLp[0]);
// F4, F4: position 1
chord = chord(new Pitch[] { pi(3, 0, 4), pi(3, 0, 4) }, fr(7, 16));
notes = testee.compute(chord, StemDirection.Down, cw, context);
assertEquals(2, notes.getDotsPerNoteCount());
assertEquals(1, notes.dotsLp.length);
assertEquals(1, notes.dotsLp[0]);
// F5, A5, B5: positions 7, 9, 11
chord = chord(new Pitch[] { pi(3, 0, 5), pi(5, 0, 5), pi(6, 0, 5) }, fr(3, 2));
notes = testee.compute(chord, StemDirection.Down, cw, context);
assertEquals(1, notes.getDotsPerNoteCount());
assertEquals(3, notes.dotsLp.length);
assertEquals(7, notes.dotsLp[0]);
assertEquals(9, notes.dotsLp[1]);
assertEquals(11, notes.dotsLp[2]);
}
Aggregations