Search in sources :

Example 1 with ClefType

use of com.xenoage.zong.core.music.clef.ClefType in project Zong by Xenoage.

the class Base43e method getExpectedClefs.

static List<Tuple2<MP, Clef>> getExpectedClefs() {
    List<Tuple2<MP, Clef>> clefs = alist();
    clefs.add(t(atBeat(0, 0, unknown, Companion.get_0()), new Clef(ClefType.Companion.getClefTreble())));
    clefs.add(t(atBeat(0, 2, unknown, Companion.get_0()), new Clef(new ClefType(ClefSymbol.C, 2))));
    clefs.add(t(atBeat(1, 0, unknown, Companion.get_0()), new Clef(ClefType.Companion.getClefBass())));
    clefs.add(t(atBeat(1, 1, unknown, Companion.get_0()), new Clef(ClefType.Companion.getClefTreble())));
    return clefs;
}
Also used : Tuple2(com.xenoage.utils.kernel.Tuple2) Clef(com.xenoage.zong.core.music.clef.Clef) ClefType(com.xenoage.zong.core.music.clef.ClefType)

Example 2 with ClefType

use of com.xenoage.zong.core.music.clef.ClefType in project Zong by Xenoage.

the class ElementStamper method createClefStamping.

/**
 * Creates a stamping for the given clef.
 */
public StaffSymbolStamping createClefStamping(ClefNotation clef, float xMm, StamperContext context) {
    val staff = context.getCurrentStaffStamping();
    ClefType clefType = clef.element.getType();
    return new StaffSymbolStamping(clef, staff, context.getSymbol(CommonSymbol.getClef(clefType.getSymbol())), null, sp(xMm, clefType.getLp()), clef.scaling, false);
}
Also used : lombok.val(lombok.val) ClefType(com.xenoage.zong.core.music.clef.ClefType) StaffSymbolStamping(com.xenoage.zong.musiclayout.stampings.StaffSymbolStamping)

Example 3 with ClefType

use of com.xenoage.zong.core.music.clef.ClefType in project Zong by Xenoage.

the class ScoreTest method createTestScoreClefsKeys.

/**
 * Creates a score with a single staff, two measures,
 * and a number of clefs, keys and chords.
 * The score, the list of clefs and the list of keys is returned.
 */
private Tuple3<Score, List<ClefType>, List<Key>> createTestScoreClefsKeys() {
    // create two measures:
    // clef-g, key-Gmaj, C#1/4, clef-f, Db1/4, clef-g, key-Fmaj, Cnat1/4 |
    // C#1/4, key-Cmaj, clef-f, C2/4.
    Score score = ScoreFactory.create1Staff();
    new MeasureAdd(score, 1).execute();
    List<ClefType> clefs = alist();
    List<Key> keys = alist();
    ClefType c;
    Key k;
    // measure 0
    Measure measure = score.getMeasure(atMeasure(0, 0));
    new Clef(ClefType.Companion.getClefTreble());
    clefs.add(c = ClefType.Companion.getClefTreble());
    new MeasureElementWrite(new Clef(c), measure, Companion.fr(0, 4)).execute();
    keys.add(k = new TraditionalKey(1, Mode.Major));
    new MeasureElementWrite(k, measure, Companion.fr(0, 4)).execute();
    new VoiceElementWrite(measure.getVoice(0), atElement(0, 0, 0, 0), chord(Companion.pi(0, 1, 4), Companion.fr(1, 4)), null).execute();
    clefs.add(c = ClefType.Companion.getClefBass());
    new MeasureElementWrite(new Clef(c), measure, Companion.fr(1, 4)).execute();
    new VoiceElementWrite(measure.getVoice(0), atElement(0, 0, 0, 1), chord(Companion.pi(1, -1, 4), Companion.fr(1, 4)), null).execute();
    clefs.add(c = ClefType.Companion.getClefTreble());
    new MeasureElementWrite(new Clef(c), measure, Companion.fr(2, 4)).execute();
    keys.add(k = new TraditionalKey(-1, Mode.Major));
    new MeasureElementWrite(k, measure, Companion.fr(2, 4)).execute();
    new VoiceElementWrite(measure.getVoice(0), atElement(0, 0, 0, 2), chord(Companion.pi(0, 0, 4), Companion.fr(1, 4)), null).execute();
    // measure 1
    measure = score.getMeasure(atMeasure(0, 1));
    new VoiceElementWrite(measure.getVoice(0), atElement(0, 1, 0, 0), chord(Companion.pi(0, 1, 4), Companion.fr(1, 4)), null).execute();
    keys.add(k = new TraditionalKey(0, Mode.Major));
    new MeasureElementWrite(k, measure, Companion.fr(1, 4)).execute();
    clefs.add(c = ClefType.Companion.getClefBass());
    new MeasureElementWrite(new Clef(c), measure, Companion.fr(1, 4)).execute();
    new VoiceElementWrite(measure.getVoice(0), atElement(0, 1, 0, 1), chord(Companion.pi(0, 0, 4), Companion.fr(2, 4)), null).execute();
    return t3(score, clefs, keys);
}
Also used : ClefType(com.xenoage.zong.core.music.clef.ClefType) Clef(com.xenoage.zong.core.music.clef.Clef) TraditionalKey(com.xenoage.zong.core.music.key.TraditionalKey) TraditionalKey(com.xenoage.zong.core.music.key.TraditionalKey) Key(com.xenoage.zong.core.music.key.Key)

Example 4 with ClefType

use of com.xenoage.zong.core.music.clef.ClefType in project Zong by Xenoage.

the class Test12a method checkClef.

private void checkClef(Score score, int measure, ClefSymbol expectedSymbol, int expectedClefLP, int expectedC4LP) {
    ClefType clef = score.getMeasure(atMeasure(0, measure)).getClefs().getFirst().getElement().getType();
    assertEquals("measure " + measure, expectedSymbol, clef.getSymbol());
    assertEquals("measure " + measure, expectedClefLP, clef.getLp());
    assertEquals("measure " + measure, expectedC4LP, clef.getLp(Companion.pi('C', 0, 4)));
}
Also used : ClefType(com.xenoage.zong.core.music.clef.ClefType)

Example 5 with ClefType

use of com.xenoage.zong.core.music.clef.ClefType in project Zong by Xenoage.

the class TraditionalKeyNotator method compute.

public TraditionalKeyNotation compute(TraditionalKey key, Context context) {
    // compute width
    float width = 0;
    int fifth = key.getFifths();
    if (fifth > 0)
        width = fifth * context.settings.spacings.widthSharp;
    else
        width = -fifth * context.settings.spacings.widthFlat;
    ElementWidth keyWidth = new ElementWidth(0, width, 1);
    // compute LPs
    ClefType contextClef = context.score.getClef(context.mp, Before);
    int c4Lp = contextClef.getLp(Companion.pi(0, 0, 4));
    int minLp = contextClef.getKeySignatureLowestLp(fifth);
    return new TraditionalKeyNotation(key, keyWidth, c4Lp, minLp);
}
Also used : ElementWidth(com.xenoage.zong.musiclayout.spacing.ElementWidth) TraditionalKeyNotation(com.xenoage.zong.musiclayout.notation.TraditionalKeyNotation) ClefType(com.xenoage.zong.core.music.clef.ClefType)

Aggregations

ClefType (com.xenoage.zong.core.music.clef.ClefType)8 Clef (com.xenoage.zong.core.music.clef.Clef)4 Tuple2 (com.xenoage.utils.kernel.Tuple2)2 Key (com.xenoage.zong.core.music.key.Key)1 TraditionalKey (com.xenoage.zong.core.music.key.TraditionalKey)1 TraditionalKeyNotation (com.xenoage.zong.musiclayout.notation.TraditionalKeyNotation)1 ElementWidth (com.xenoage.zong.musiclayout.spacing.ElementWidth)1 StaffSymbolStamping (com.xenoage.zong.musiclayout.stampings.StaffSymbolStamping)1 MxlClef (com.xenoage.zong.musicxml.types.MxlClef)1 lombok.val (lombok.val)1