Search in sources :

Example 11 with Dynamic

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

the class NotationsReader method readToNote.

public void readToNote(Chord chord, int noteIndex, int staffIndexInPart, Context context) {
    StaffDetails staffDetails = StaffDetails.fromContext(context, staffIndexInPart);
    ArrayList<Annotation> annotations = alist(0);
    for (MxlNotations mxlNotationsElement : mxlNotations) {
        for (MxlNotationsContent mxlNC : mxlNotationsElement.getElements()) {
            MxlNotationsContentType mxlNCType = mxlNC.getNotationsContentType();
            switch(mxlNCType) {
                case SlurOrTied:
                    {
                        SlurReader.readToContext(chord, noteIndex, staffIndexInPart, context, (MxlSlurOrTied) mxlNC);
                        break;
                    }
                case Dynamics:
                    {
                        Dynamic dynamics = DynamicsReader.read((MxlDynamics) mxlNC, staffDetails);
                        new DirectionAdd(dynamics, chord).execute();
                        break;
                    }
                case Articulations:
                    {
                        MxlArticulations mxlArticulations = (MxlArticulations) mxlNC;
                        annotations.addAll(ArticulationReader.read(mxlArticulations));
                        break;
                    }
                case Fermata:
                    {
                        Fermata fermata = FermataReader.read((MxlFermata) mxlNC, staffDetails);
                        annotations.add(fermata);
                        break;
                    }
                case Ornaments:
                    {
                        MxlOrnaments mxlOrnaments = (MxlOrnaments) mxlNC;
                        annotations.addAll(OrnamentReader.read(mxlOrnaments));
                        break;
                    }
                default:
            }
        }
    }
    if (annotations.size() > 0)
        chord.setAnnotations(annotations);
}
Also used : Dynamic(com.xenoage.zong.core.music.direction.Dynamic) MxlFermata(com.xenoage.zong.musicxml.types.MxlFermata) MxlDynamics(com.xenoage.zong.musicxml.types.MxlDynamics) MxlSlurOrTied(com.xenoage.zong.musicxml.types.MxlSlurOrTied) Annotation(com.xenoage.zong.core.music.annotation.Annotation) MxlNotationsContent(com.xenoage.zong.musicxml.types.choice.MxlNotationsContent) Fermata(com.xenoage.zong.core.music.annotation.Fermata) MxlFermata(com.xenoage.zong.musicxml.types.MxlFermata) DirectionAdd(com.xenoage.zong.commands.core.music.direction.DirectionAdd) MxlNotations(com.xenoage.zong.musicxml.types.MxlNotations) MxlArticulations(com.xenoage.zong.musicxml.types.MxlArticulations) StaffDetails(com.xenoage.zong.io.musicxml.in.util.StaffDetails) MxlOrnaments(com.xenoage.zong.musicxml.types.MxlOrnaments) MxlNotationsContentType(com.xenoage.zong.musicxml.types.choice.MxlNotationsContent.MxlNotationsContentType)

Example 12 with Dynamic

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

the class Test21d method testMeasure1.

@Test
public void testMeasure1() {
    MP m2 = mp0.withMeasure(1);
    // chords
    Chord chord = (Chord) score.getVoice(m2).getElementAt(Companion.get_0());
    assertEquals(2, chord.getNotes().size());
    assertEquals(Companion.pi('F', 0, 4), chord.getNotes().get(0).getPitch());
    assertEquals(Companion.pi('A', -1, 4), chord.getNotes().get(1).getPitch());
    assertEquals(Companion.fr(3, 8), chord.getDuration());
    chord = (Chord) score.getVoice(m2).getElementAt(Companion.fr(3, 8));
    assertEquals(2, chord.getNotes().size());
    assertEquals(Companion.pi('F', 0, 4), chord.getNotes().get(0).getPitch());
    assertEquals(Companion.pi('A', -1, 4), chord.getNotes().get(1).getPitch());
    assertEquals(Companion.fr(1, 8), chord.getDuration());
    chord = (Chord) score.getVoice(m2).getElementAt(Companion.fr(2, 4));
    assertEquals(2, chord.getNotes().size());
    assertEquals(Companion.pi('G', 0, 4), chord.getNotes().get(0).getPitch());
    assertEquals(Companion.pi('B', -1, 4), chord.getNotes().get(1).getPitch());
    assertEquals(Companion.fr(1, 4), chord.getDuration());
    chord = (Chord) score.getVoice(m2).getElementAt(Companion.fr(3, 4));
    assertEquals(2, chord.getNotes().size());
    assertEquals(Companion.pi('G', 0, 4), chord.getNotes().get(0).getPitch());
    assertEquals(Companion.pi('B', -1, 4), chord.getNotes().get(1).getPitch());
    assertEquals(Companion.fr(1, 4), chord.getDuration());
    // dynamics "p"
    Dynamic dynamics = (Dynamic) score.getMeasure(m2).getMeasureElements().get(Companion.get_0());
    assertEquals(DynamicValue.p, dynamics.getValue());
    assertEquals(Placement.Below, dynamics.getPositioning());
}
Also used : Dynamic(com.xenoage.zong.core.music.direction.Dynamic) MP(com.xenoage.zong.core.position.MP) Chord(com.xenoage.zong.core.music.chord.Chord) Test(org.junit.Test)

Example 13 with Dynamic

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

the class Test21f method test.

@Test
public void test() {
    Score score = getScore();
    // 1/4 with 3 notes at beat 0
    List<VoiceElement> e = score.getVoice(mp0).getElements();
    Chord chord = (Chord) e.get(0);
    assertEquals(3, chord.getNotes().size());
    assertEquals(Companion.fr(1, 4), chord.getDuration());
    // followed by 2 rests, 1/4 and 2/4
    assertEquals(Companion.fr(1, 4), ((Rest) e.get(1)).getDuration());
    assertEquals(Companion.fr(2, 4), ((Rest) e.get(2)).getDuration());
    // segno at beat 1/4 in column (moved to the end of the measure, since we accept no mid-measure segnos)
    Direction segno = (Segno) score.getColumnHeader(0).getNavigationOrigin();
    assertNotNull(segno);
    // dynamics p at beat 1/4 in measure
    Dynamic dynamics = (Dynamic) score.getMeasure(mp0).getDirections().get(Companion.fr(1, 4));
    assertNotNull(dynamics);
    assertEquals(DynamicValue.p, dynamics.getValue());
}
Also used : Score(com.xenoage.zong.core.Score) Dynamic(com.xenoage.zong.core.music.direction.Dynamic) VoiceElement(com.xenoage.zong.core.music.VoiceElement) Segno(com.xenoage.zong.core.music.direction.Segno) Chord(com.xenoage.zong.core.music.chord.Chord) Direction(com.xenoage.zong.core.music.direction.Direction) Test(org.junit.Test)

Aggregations

Dynamic (com.xenoage.zong.core.music.direction.Dynamic)13 Score (com.xenoage.zong.core.Score)5 Chord (com.xenoage.zong.core.music.chord.Chord)4 lombok.val (lombok.val)4 Test (org.junit.Test)4 PartAdd (com.xenoage.zong.commands.core.music.PartAdd)3 Part (com.xenoage.zong.core.music.Part)3 Direction (com.xenoage.zong.core.music.direction.Direction)3 Wedge (com.xenoage.zong.core.music.direction.Wedge)3 TimeSignature (com.xenoage.zong.core.music.time.TimeSignature)3 Cursor (com.xenoage.zong.io.selection.Cursor)3 MaybeNull (com.xenoage.utils.annotations.MaybeNull)2 Tuple2 (com.xenoage.utils.kernel.Tuple2)2 MeasureAdd (com.xenoage.zong.commands.core.music.MeasureAdd)2 MeasureElementWrite (com.xenoage.zong.commands.core.music.MeasureElementWrite)2 MeasureElement (com.xenoage.zong.core.music.MeasureElement)2 Clef (com.xenoage.zong.core.music.clef.Clef)2 WedgeEnd (com.xenoage.zong.core.music.direction.WedgeEnd)2 Words (com.xenoage.zong.core.music.direction.Words)2 TraditionalKey (com.xenoage.zong.core.music.key.TraditionalKey)2