Search in sources :

Example 6 with NotesNotation

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;
    }
}
Also used : NotesNotation(com.xenoage.zong.musiclayout.notation.chord.NotesNotation) LegerLineStamping(com.xenoage.zong.musiclayout.stampings.LegerLineStamping) NoteSuspension(com.xenoage.zong.musiclayout.notation.chord.NoteSuspension)

Example 7 with NotesNotation

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);
}
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 8 with NotesNotation

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);
}
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 9 with NotesNotation

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);
}
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 10 with NotesNotation

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

Aggregations

NotesNotation (com.xenoage.zong.musiclayout.notation.chord.NotesNotation)12 Chord (com.xenoage.zong.core.music.chord.Chord)10 Test (org.junit.Test)8 NoteDisplacement (com.xenoage.zong.musiclayout.notation.chord.NoteDisplacement)5 MusicContext (com.xenoage.zong.core.music.MusicContext)2 StemDirection (com.xenoage.zong.core.music.chord.StemDirection)2 ChordLps (com.xenoage.zong.musiclayout.notation.chord.ChordLps)2 StemNotation (com.xenoage.zong.musiclayout.notation.chord.StemNotation)2 FontInfo (com.xenoage.utils.font.FontInfo)1 TextMeasurer (com.xenoage.utils.font.TextMeasurer)1 Fraction (com.xenoage.utils.math.Fraction)1 Score (com.xenoage.zong.core.Score)1 Pitch (com.xenoage.zong.core.music.Pitch)1 Lyric (com.xenoage.zong.core.music.lyric.Lyric)1 SyllableType (com.xenoage.zong.core.music.lyric.SyllableType)1 FormattedText (com.xenoage.zong.core.text.FormattedText)1 FormattedTextStyle (com.xenoage.zong.core.text.FormattedTextStyle)1 ChordNotation (com.xenoage.zong.musiclayout.notation.ChordNotation)1 AccidentalsNotation (com.xenoage.zong.musiclayout.notation.chord.AccidentalsNotation)1 ArticulationsNotation (com.xenoage.zong.musiclayout.notation.chord.ArticulationsNotation)1