use of com.xenoage.zong.core.music.Staff in project Zong by Xenoage.
the class Base42b method getExpectedStaves.
/**
* Gets the expected musical data, but without the dynamics, articulations and slurs
* and also without the clef changes.
*/
static Staff[] getExpectedStaves() {
Score score = ScoreFactory.create1Staff();
Cursor cursor = new Cursor(score, mp0, true);
cursor.write(new TimeSignature(TimeType.Companion.getTime_6_8()));
// staff 1, measure 0
cursor.write(chord(Companion.pi('F', 0, 4), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('D', 0, 4), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('B', 0, 3), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('G', 0, 3), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('F', 0, 3), Companion.fr(1, 4)));
// staff 1, measure 1
cursor.write(chord(Companion.pi('E', 0, 5), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('C', 0, 5), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('G', 0, 4), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('G', 0, 4), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('F', 0, 4), Companion.fr(1, 4)));
// staff 1, measure 0
cursor.setMp(atElement(1, 0, 0, 0));
cursor.write(new Rest(Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('G', 0, 2), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('G', 0, 2), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('G', 0, 2), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('A', 0, 2), Companion.fr(1, 16)));
cursor.write(chord(Companion.pi('G', 0, 2), Companion.fr(1, 16)));
cursor.write(chord(Companion.pi('F', 1, 2), Companion.fr(1, 16)));
cursor.write(chord(Companion.pi('G', 0, 2), Companion.fr(1, 16)));
// staff 1, measure 1
cursor.write(chord(new Pitch[] { Companion.pi('C', 0, 3), Companion.pi('E', 0, 3), Companion.pi('G', 0, 3), Companion.pi('C', 0, 4) }, Companion.fr(1, 4)));
cursor.write(new Rest(Companion.fr(1, 8)));
cursor.write(new Rest(Companion.fr(1, 4)));
cursor.write(chord(Companion.pi('G', 0, 3), Companion.fr(1, 8)));
return new Staff[] { score.getStaff(0), score.getStaff(1) };
}
use of com.xenoage.zong.core.music.Staff in project Zong by Xenoage.
the class StavesListReader method createStavesList.
/**
* Creates the (still empty) {@link StavesList} for this document.
*/
private StavesList createStavesList(List<Part> parts, List<PartsBarlineGroup> barlineGroups, List<PartsBracketGroup> bracketGroups) {
StavesList ret = new StavesList();
// add parts
for (Part part : parts) {
ret.getParts().add(part);
for (int i = 0; i < part.getStavesCount(); i++) {
Staff staff = Staff.Companion.staffMinimal();
staff.setParent(ret);
ret.getStaves().add(staff);
}
}
// add groups
for (PartsBarlineGroup barlineGroup : barlineGroups) {
int startIndex = getFirstStaffIndex(barlineGroup.startPartIndex, parts);
int endIndex = getLastStaffIndex(barlineGroup.stopPartIndex, parts);
ret.addBarlineGroup(new StavesRange(startIndex, endIndex), barlineGroup.style);
}
for (PartsBracketGroup bracketGroup : bracketGroups) {
int startIndex = getFirstStaffIndex(bracketGroup.startPartIndex, parts);
int endIndex = getLastStaffIndex(bracketGroup.stopPartIndex, parts);
ret.addBracketGroup(new StavesRange(startIndex, endIndex), bracketGroup.style);
}
// parts with more than one staff
for (int i : range(parts)) {
if (parts.get(i).getStavesCount() > 1 && !isPartInGroup(i, barlineGroups, bracketGroups)) {
int startIndex = getFirstStaffIndex(i, parts);
int endIndex = getLastStaffIndex(i, parts);
ret.addBarlineGroup(new StavesRange(startIndex, endIndex), BarlineGroup.Style.Common);
ret.addBracketGroup(new StavesRange(startIndex, endIndex), BracketGroup.Style.Brace);
}
}
return ret;
}
use of com.xenoage.zong.core.music.Staff in project Zong by Xenoage.
the class WedgeStamper method stampSystem.
/**
* Creates all wedge stampings in the given system.
* @param openWedges input and output parameter: voltas, which are still open from the
* last system. After the method returns, it contains the voltas which
* are still open after this system
*/
public List<WedgeStamping> stampSystem(SystemSpacing system, Score score, StaffStampings staffStampings, OpenWedges openWedges) {
List<WedgeStamping> ret = alist();
// find new wedges beginning in this staff
for (int iStaff : range(score.getStavesCount())) {
Staff staff = score.getStaff(iStaff);
for (int iMeasure : system.getMeasures()) {
Measure measure = staff.getMeasure(iMeasure);
for (BeatE<Direction> dir : measure.getDirections()) {
if (dir.getElement() instanceof Wedge) {
Wedge wedge = (Wedge) dir.getElement();
// if the position of the end element is known
if (wedge.getWedgeEnd().getMP() != null)
openWedges.wedges.add(new ContinuedWedge((Wedge) dir.getElement()));
}
}
}
}
// draw wedges in the cache, and remove them if closed in this system
for (Iterator<ContinuedWedge> itW = openWedges.wedges.iterator(); itW.hasNext(); ) {
ContinuedWedge wedge = itW.next();
ret.add(stamp(wedge.element, staffStampings.get(system.getSystemIndexInFrame(), wedge.element.getMP().staff)));
if (MP.getMP(wedge.element.getWedgeEnd()).measure <= system.getEndMeasure()) {
// wedge is closed
itW.remove();
}
}
return ret;
}
use of com.xenoage.zong.core.music.Staff in project Zong by Xenoage.
the class Test24a method testBeams.
@Test
public void testBeams() {
Staff staff = getFirstStaff();
int iChord = 0;
Beam currentBeam = null;
for (int iM = 0; iM < staff.getMeasures().size(); iM++) {
Voice voice = staff.getMeasure(iM).getVoice(0);
for (VoiceElement e : voice.getElements()) {
Chord expectedChord = expectedChords[iChord];
// beams between chord 2 and 3 and between 11 and 12
if (iChord == 2 || iChord == 11) {
assertNotNull("chord " + iChord + " unbeamed", expectedChord.getBeam());
assertEquals("chord " + iChord, WaypointPosition.Start, expectedChord.getBeam().getWaypointPosition(expectedChord));
currentBeam = expectedChord.getBeam();
} else if (iChord == 3 || iChord == 12) {
assertNotNull("chord " + iChord + " unbeamed", expectedChord.getBeam());
assertEquals("wrong beam", currentBeam, expectedChord.getBeam());
assertEquals("chord " + iChord, WaypointPosition.Stop, expectedChord.getBeam().getWaypointPosition(expectedChord));
currentBeam = null;
} else {
assertNull("chord " + iChord + " beamed", expectedChord.getBeam());
}
iChord++;
}
}
assertEquals("not all chords found", expectedChords.length, iChord);
}
use of com.xenoage.zong.core.music.Staff in project Zong by Xenoage.
the class Test01a method test.
@ToDo("the editiorial sharp (sharp in parenthesis) in the last measure is not supported yet")
@Test
public void test() {
Pitch[] expectedPitches = getExpectedPitches();
Staff staff = getFirstStaff();
assertEquals(26, staff.getMeasures().size());
int iPitch = 0;
for (int iM = 0; iM < staff.getMeasures().size(); iM++) {
Measure measure = staff.getMeasures().get(iM);
Voice voice = measure.getVoice(0);
for (VoiceElement e : voice.getElements()) {
if (e instanceof Chord) {
// check note and pitch
Chord chord = (Chord) e;
assertEquals(expectedPitches[iPitch++], chord.getNotes().get(0).getPitch());
}
}
}
assertEquals("not all notes found", expectedPitches.length, iPitch);
}
Aggregations