use of com.xenoage.zong.core.music.chord.Chord 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(Companion.pi(0, 0, 5), Companion.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.core.music.chord.Chord in project Zong by Xenoage.
the class NotesNotatorTest method testChordA4C5D5.
/**
* Tests a A4-C5-D5, 1/4. Stem: left, down. Width: 2x quarter.
*/
@Test
public void testChordA4C5D5() {
Chord chord = chord(new Pitch[] { Companion.pi(5, 0, 4), Companion.pi(0, 0, 5), Companion.pi(1, 0, 5) }, Companion.fr(1, 4));
NotesNotation notes = testee.compute(chord, StemDirection.Down, cw, context);
;
assertEquals(n, notes.stemOffsetIs, Df);
assertEquals(2 * n, notes.widthIs, Df);
assertEquals(n, notes.getNote(0).xIs, Df);
assertEquals(NoteSuspension.None, notes.getNote(0).suspension);
assertEquals(0, notes.getNote(1).xIs, Df);
assertEquals(NoteSuspension.Left, notes.getNote(1).suspension);
assertEquals(n, notes.getNote(2).xIs, Df);
assertEquals(NoteSuspension.None, notes.getNote(2).suspension);
}
use of com.xenoage.zong.core.music.chord.Chord 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(Companion.pi(0, 0, 5), Companion.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(Companion.pi(6, 0, 4), Companion.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(Companion.pi(1, 0, 4), Companion.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(Companion.pi(0, 0, 4), Companion.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(Companion.pi(6, 0, 3), Companion.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[] { Companion.pi(3, 0, 4), Companion.pi(3, 0, 4) }, Companion.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[] { Companion.pi(3, 0, 5), Companion.pi(5, 0, 5), Companion.pi(6, 0, 5) }, Companion.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]);
}
use of com.xenoage.zong.core.music.chord.Chord 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);
}
use of com.xenoage.zong.core.music.chord.Chord in project Zong by Xenoage.
the class VoiceElementWriteTest method grace.
private Chord grace(int step) {
Chord chord = new Chord(new Note(Companion.pi(step, 0)), Companion.fr(0, 4));
chord.setGrace(new Grace(true, Companion.fr(1, 16)));
return chord;
}
Aggregations