Created
December 4, 2021 15:40
-
-
Save alanwhite/11b5a4f18738bf262c1d11f39fe968a8 to your computer and use it in GitHub Desktop.
Example tests for the simplest autobeam algo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AutoBeamSimpleTestAlgo1 { | |
// for divisions = 840 | |
private static Map<Integer, Integer> durations = Map.of( | |
BaseNoteModel.semiBreve, 3360, | |
BaseNoteModel.minim, 1680, | |
BaseNoteModel.crotchet, 840, | |
BaseNoteModel.quaver, 420, | |
BaseNoteModel.semiQuaver, 210, | |
BaseNoteModel.demiSemiQuaver, 105, | |
BaseNoteModel.hemiDemiSemiQuaver, 53 | |
); | |
@Test | |
void testAutoBeamSimpleTime1() { | |
// establish context | |
var mcx = new MusicalContext(); | |
var timeSig = new TimeSigModel(); | |
timeSig.setTop(2); | |
timeSig.setBottom(4); | |
mcx.setTimeSig(timeSig); | |
mcx.setDivisions(840); | |
// establish measure | |
var measure = new MeasureModel(); | |
var part = new PartModel(); | |
var parts = new ArrayList<PartModel>(); | |
parts.add(part); | |
measure.setParts(parts); | |
// add notes | |
var note1 = new DrumNoteModel(); | |
note1.setNoteValue(BaseNoteModel.semiQuaver); | |
note1.setNoteDotted(true); | |
note1.setDuration(durations.get(note1.getNoteValue()) * 15 / 10); // keeping it integer arithmetic | |
part.getStaffElements().add(note1); | |
// snip | |
// run the algo | |
var ab = new AutoBeamStraight(); | |
ab.forPart(mcx, part); | |
// check it did it's job right | |
assertTrue(note1.getBeams().isPresent()); | |
assertEquals(note1.getBeams().get().size(),2); | |
assertEquals(note1.getBeams().get().get(0),BeamEnum.BEGIN); | |
assertEquals(note1.getBeams().get().get(1),BeamEnum.BEGIN); | |
// and the rest | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment