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