Search in sources :

Example 16 with Pitch

use of com.xenoage.zong.core.music.Pitch in project Zong by Xenoage.

the class Base01a method getExpectedPitches.

default Pitch[] getExpectedPitches() {
    Pitch[] expectedPitches = new Pitch[24 * 4 + 6];
    int iPitch = 0;
    for (int alter : new int[] { 0, 1, -1 }) {
        Pitch nextPitch = Companion.pi('G', alter, 2);
        for (int i = 0; i < 8 * 4; i++) {
            expectedPitches[iPitch++] = nextPitch;
            int newStep = nextPitch.getStep() + 1;
            int newOctave = nextPitch.getOctave();
            if (newStep > 6) {
                newStep = 0;
                newOctave += 1;
            }
            nextPitch = Companion.pi(newStep, alter, newOctave);
        }
    }
    expectedPitches[iPitch++] = Companion.pi(0, 2, 5);
    expectedPitches[iPitch++] = Companion.pi(0, -2, 5);
    expectedPitches[iPitch++] = Companion.pi(0, 1, 5);
    expectedPitches[iPitch++] = Companion.pi(0, 1, 5);
    expectedPitches[iPitch++] = Companion.pi(0, 1, 5);
    expectedPitches[iPitch++] = Companion.pi(0, 1, 5);
    return expectedPitches;
}
Also used : Pitch(com.xenoage.zong.core.music.Pitch)

Example 17 with Pitch

use of com.xenoage.zong.core.music.Pitch in project Zong by Xenoage.

the class Base01b method getExpectedPitches.

default Pitch[] getExpectedPitches() {
    Pitch[] expectedPitches = new Pitch[41 * 2];
    Pitch pi1 = Companion.pi(0, 0, 5);
    Pitch pi2 = Companion.pi(0, 0, 5);
    for (int i = 0; i < expectedPitches.length / 2; i++) {
        expectedPitches[i * 2 + 0] = pi1;
        expectedPitches[i * 2 + 1] = pi2;
        pi1 = incHalftoneWithEnharmonicChange(pi1);
        pi2 = decHalftoneWithEnharmonicChange(pi2);
    }
    return expectedPitches;
}
Also used : Pitch(com.xenoage.zong.core.music.Pitch)

Example 18 with Pitch

use of com.xenoage.zong.core.music.Pitch 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 19 with Pitch

use of com.xenoage.zong.core.music.Pitch in project Zong by Xenoage.

the class StemNotatorTest method computeStemAlignmentTest.

@Test
public void computeStemAlignmentTest() {
    Pitch pitch;
    pitch = Companion.pi('B', 0, 3);
    testPitch(pitch, -3, 4);
    pitch = Companion.pi('C', 0, 4);
    testPitch(pitch, -2, 5);
    pitch = Companion.pi('D', 0, 4);
    testPitch(pitch, -1, 6);
    pitch = Companion.pi('E', 0, 4);
    testPitch(pitch, 0, 7);
    pitch = Companion.pi('F', 0, 4);
    testPitch(pitch, 1, 8);
    pitch = Companion.pi('G', 0, 4);
    testPitch(pitch, 2, 9);
    pitch = Companion.pi('A', 0, 4);
    testPitch(pitch, 3, 10);
    // Stem down
    pitch = Companion.pi('B', 0, 5);
    testPitch(pitch, 11, 4);
    pitch = Companion.pi('A', 0, 5);
    testPitch(pitch, 10, 3);
    pitch = Companion.pi('G', 0, 5);
    testPitch(pitch, 9, 2);
    pitch = Companion.pi('F', 0, 5);
    testPitch(pitch, 8, 1);
    pitch = Companion.pi('E', 0, 5);
    testPitch(pitch, 7, 0);
    pitch = Companion.pi('D', 0, 5);
    testPitch(pitch, 6, -1);
    pitch = Companion.pi('C', 0, 5);
    testPitch(pitch, 5, -2);
    pitch = Companion.pi('B', 0, 4);
    testPitch(pitch, 4, -3);
    // longer stems
    pitch = Companion.pi('C', 0, 6);
    testPitch(pitch, 12, 4);
    pitch = Companion.pi('E', 0, 6);
    testPitch(pitch, 14, 4);
    pitch = Companion.pi('F', 0, 6);
    testPitch(pitch, 15, 4);
    pitch = Companion.pi('A', 0, 6);
    testPitch(pitch, 17, 4);
    pitch = Companion.pi('A', 0, 3);
    testPitch(pitch, -4, 4);
    pitch = Companion.pi('F', 0, 3);
    testPitch(pitch, -6, 4);
    pitch = Companion.pi('E', 0, 3);
    testPitch(pitch, -7, 4);
    pitch = Companion.pi('C', 0, 3);
    testPitch(pitch, -9, 4);
    // some chords
    Pitch[] pitches = new Pitch[2];
    pitches[0] = Companion.pi('C', 0, 3);
    pitches[1] = Companion.pi('F', 0, 3);
    testPitch(pitches, -9, 4);
    pitches = new Pitch[2];
    pitches[0] = Companion.pi('C', 0, 3);
    pitches[1] = Companion.pi('F', 0, 4);
    testPitch(pitches, -9, 8);
}
Also used : Pitch(com.xenoage.zong.core.music.Pitch) Test(org.junit.Test)

Example 20 with Pitch

use of com.xenoage.zong.core.music.Pitch in project Zong by Xenoage.

the class ClefTypeTest method getLpTest.

@Test
public void getLpTest() {
    // test center pitches
    assertEquals(2, ClefType.Companion.getClefTreble().getLp(Companion.pi('G', 0, 4)));
    assertEquals(2, ClefType.Companion.getClefTreble15vb().getLp(Companion.pi('G', 0, 2)));
    assertEquals(2, ClefType.Companion.getClefTreble8vb().getLp(Companion.pi('G', 0, 3)));
    assertEquals(2, ClefType.Companion.getClefTreble8va().getLp(Companion.pi('G', 0, 5)));
    assertEquals(2, ClefType.Companion.getClefTreble15va().getLp(Companion.pi('G', 0, 6)));
    assertEquals(6, ClefType.Companion.getClefBass().getLp(Companion.pi('F', 0, 3)));
    assertEquals(6, ClefType.Companion.getClefBass15vb().getLp(Companion.pi('F', 0, 1)));
    assertEquals(6, ClefType.Companion.getClefBass8vb().getLp(Companion.pi('F', 0, 2)));
    assertEquals(6, ClefType.Companion.getClefBass8va().getLp(Companion.pi('F', 0, 4)));
    assertEquals(6, ClefType.Companion.getClefBass15va().getLp(Companion.pi('F', 0, 5)));
    assertEquals(4, ClefType.Companion.getClefAlto().getLp(Companion.pi('C', 0, 4)));
    assertEquals(6, ClefType.Companion.getClefTenor().getLp(Companion.pi('C', 0, 4)));
    assertEquals(4, ClefType.Companion.getClefTab().getLp(Companion.pi('B', 0, 4)));
    assertEquals(4, ClefType.Companion.getClefTabSmall().getLp(Companion.pi('B', 0, 4)));
    assertEquals(4, ClefType.Companion.getClefPercTwoRects().getLp(Companion.pi('B', 0, 4)));
    assertEquals(4, ClefType.Companion.getClefPercEmptyRect().getLp(Companion.pi('B', 0, 4)));
    // test e5
    Pitch e5 = Companion.pi('E', 0, 5);
    assertEquals(7, ClefType.Companion.getClefTreble().getLp(e5));
    assertEquals(21, ClefType.Companion.getClefTreble15vb().getLp(e5));
    assertEquals(14, ClefType.Companion.getClefTreble8vb().getLp(e5));
    assertEquals(0, ClefType.Companion.getClefTreble8va().getLp(e5));
    assertEquals(-7, ClefType.Companion.getClefTreble15va().getLp(e5));
    assertEquals(19, ClefType.Companion.getClefBass().getLp(e5));
    assertEquals(33, ClefType.Companion.getClefBass15vb().getLp(e5));
    assertEquals(26, ClefType.Companion.getClefBass8vb().getLp(e5));
    assertEquals(12, ClefType.Companion.getClefBass8va().getLp(e5));
    assertEquals(5, ClefType.Companion.getClefBass15va().getLp(e5));
    assertEquals(13, ClefType.Companion.getClefAlto().getLp(e5));
    assertEquals(15, ClefType.Companion.getClefTenor().getLp(e5));
    assertEquals(7, ClefType.Companion.getClefTab().getLp(e5));
    assertEquals(7, ClefType.Companion.getClefTabSmall().getLp(e5));
    assertEquals(7, ClefType.Companion.getClefPercTwoRects().getLp(e5));
    assertEquals(7, ClefType.Companion.getClefPercEmptyRect().getLp(e5));
}
Also used : Pitch(com.xenoage.zong.core.music.Pitch) Test(org.junit.Test)

Aggregations

Pitch (com.xenoage.zong.core.music.Pitch)24 Chord (com.xenoage.zong.core.music.chord.Chord)12 Test (org.junit.Test)11 MP (com.xenoage.zong.core.position.MP)4 MxlPitch (com.xenoage.zong.musicxml.types.MxlPitch)4 MxlFullNote (com.xenoage.zong.musicxml.types.groups.MxlFullNote)4 Staff (com.xenoage.zong.core.music.Staff)3 Note (com.xenoage.zong.core.music.chord.Note)3 Rest (com.xenoage.zong.core.music.rest.Rest)3 Score (com.xenoage.zong.core.Score)2 Measure (com.xenoage.zong.core.music.Measure)2 Voice (com.xenoage.zong.core.music.Voice)2 VoiceElement (com.xenoage.zong.core.music.VoiceElement)2 Grace (com.xenoage.zong.core.music.chord.Grace)2 TimeSignature (com.xenoage.zong.core.music.time.TimeSignature)2 Cursor (com.xenoage.zong.io.selection.Cursor)2 MxlNote (com.xenoage.zong.musicxml.types.MxlNote)2 MxlCueNote (com.xenoage.zong.musicxml.types.choice.MxlCueNote)2 MxlGraceNote (com.xenoage.zong.musicxml.types.choice.MxlGraceNote)2 MxlMusicDataContent (com.xenoage.zong.musicxml.types.choice.MxlMusicDataContent)2