Search in sources :

Example 1 with Staff

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) };
}
Also used : Score(com.xenoage.zong.core.Score) Rest(com.xenoage.zong.core.music.rest.Rest) Staff(com.xenoage.zong.core.music.Staff) Pitch(com.xenoage.zong.core.music.Pitch) Cursor(com.xenoage.zong.io.selection.Cursor) TimeSignature(com.xenoage.zong.core.music.time.TimeSignature)

Example 2 with Staff

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;
}
Also used : StavesRange(com.xenoage.zong.core.music.group.StavesRange) MxlPart(com.xenoage.zong.musicxml.types.partwise.MxlPart) Part(com.xenoage.zong.core.music.Part) StavesList(com.xenoage.zong.core.music.StavesList) Staff(com.xenoage.zong.core.music.Staff)

Example 3 with Staff

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;
}
Also used : ContinuedWedge(com.xenoage.zong.musiclayout.continued.ContinuedWedge) Staff(com.xenoage.zong.core.music.Staff) Measure(com.xenoage.zong.core.music.Measure) WedgeStamping(com.xenoage.zong.musiclayout.stampings.WedgeStamping) Direction(com.xenoage.zong.core.music.direction.Direction) Wedge(com.xenoage.zong.core.music.direction.Wedge) ContinuedWedge(com.xenoage.zong.musiclayout.continued.ContinuedWedge)

Example 4 with Staff

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);
}
Also used : Beam(com.xenoage.zong.core.music.beam.Beam) VoiceElement(com.xenoage.zong.core.music.VoiceElement) Staff(com.xenoage.zong.core.music.Staff) Voice(com.xenoage.zong.core.music.Voice) Chord(com.xenoage.zong.core.music.chord.Chord) Test(org.junit.Test)

Example 5 with Staff

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);
}
Also used : VoiceElement(com.xenoage.zong.core.music.VoiceElement) Staff(com.xenoage.zong.core.music.Staff) Pitch(com.xenoage.zong.core.music.Pitch) Measure(com.xenoage.zong.core.music.Measure) Voice(com.xenoage.zong.core.music.Voice) Chord(com.xenoage.zong.core.music.chord.Chord) ToDo(musicxmltestsuite.tests.utils.ToDo) Test(org.junit.Test)

Aggregations

Staff (com.xenoage.zong.core.music.Staff)13 Test (org.junit.Test)7 Voice (com.xenoage.zong.core.music.Voice)6 Measure (com.xenoage.zong.core.music.Measure)5 VoiceElement (com.xenoage.zong.core.music.VoiceElement)4 Chord (com.xenoage.zong.core.music.chord.Chord)4 Pitch (com.xenoage.zong.core.music.Pitch)3 Part (com.xenoage.zong.core.music.Part)2 StavesRange (com.xenoage.zong.core.music.group.StavesRange)2 Rest (com.xenoage.zong.core.music.rest.Rest)2 TimeSignature (com.xenoage.zong.core.music.time.TimeSignature)2 MP (com.xenoage.zong.core.position.MP)2 MxlPart (com.xenoage.zong.musicxml.types.partwise.MxlPart)2 ToDo (musicxmltestsuite.tests.utils.ToDo)2 Fraction (com.xenoage.utils.math.Fraction)1 ColumnElementWrite (com.xenoage.zong.commands.core.music.ColumnElementWrite)1 MeasureAddUpTo (com.xenoage.zong.commands.core.music.MeasureAddUpTo)1 MeasureElementWrite (com.xenoage.zong.commands.core.music.MeasureElementWrite)1 VoiceElementWrite (com.xenoage.zong.commands.core.music.VoiceElementWrite)1 Score (com.xenoage.zong.core.Score)1