Search in sources :

Example 46 with Chord

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);
}
Also used : NoteDisplacement(com.xenoage.zong.musiclayout.notation.chord.NoteDisplacement) NotesNotation(com.xenoage.zong.musiclayout.notation.chord.NotesNotation) Chord(com.xenoage.zong.core.music.chord.Chord) Test(org.junit.Test)

Example 47 with Chord

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);
}
Also used : NotesNotation(com.xenoage.zong.musiclayout.notation.chord.NotesNotation) Chord(com.xenoage.zong.core.music.chord.Chord) Test(org.junit.Test)

Example 48 with Chord

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]);
}
Also used : Pitch(com.xenoage.zong.core.music.Pitch) NotesNotation(com.xenoage.zong.musiclayout.notation.chord.NotesNotation) Chord(com.xenoage.zong.core.music.chord.Chord) Test(org.junit.Test)

Example 49 with Chord

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

Example 50 with Chord

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;
}
Also used : Grace(com.xenoage.zong.core.music.chord.Grace) Note(com.xenoage.zong.core.music.chord.Note) Chord(com.xenoage.zong.core.music.chord.Chord)

Aggregations

Chord (com.xenoage.zong.core.music.chord.Chord)63 Test (org.junit.Test)34 MP (com.xenoage.zong.core.position.MP)16 Pitch (com.xenoage.zong.core.music.Pitch)12 Score (com.xenoage.zong.core.Score)11 Voice (com.xenoage.zong.core.music.Voice)10 NotesNotation (com.xenoage.zong.musiclayout.notation.chord.NotesNotation)10 VoiceElement (com.xenoage.zong.core.music.VoiceElement)8 Note (com.xenoage.zong.core.music.chord.Note)6 Rest (com.xenoage.zong.core.music.rest.Rest)6 ChordTest (musicxmltestsuite.tests.utils.ChordTest)6 Fraction (com.xenoage.utils.math.Fraction)5 Staff (com.xenoage.zong.core.music.Staff)4 Beam (com.xenoage.zong.core.music.beam.Beam)4 Grace (com.xenoage.zong.core.music.chord.Grace)4 StemDirection (com.xenoage.zong.core.music.chord.StemDirection)4 Dynamic (com.xenoage.zong.core.music.direction.Dynamic)4 SlurWaypoint (com.xenoage.zong.core.music.slur.SlurWaypoint)4 ChordNotation (com.xenoage.zong.musiclayout.notation.ChordNotation)4 NoteDisplacement (com.xenoage.zong.musiclayout.notation.chord.NoteDisplacement)4