Search in sources :

Example 6 with Key

use of com.xenoage.zong.core.music.key.Key in project Zong by Xenoage.

the class AttributesReader method readToContext.

/**
 * Reads the given attributes element.
 */
public void readToContext(Context context) {
    // divisions
    Integer divisions = mxlAttributes.getDivisions();
    if (divisions != null)
        context.setDivisions(divisions);
    // key signature
    Key key = readKey(mxlAttributes.getKey());
    if (key != null)
        context.writeColumnElement(key);
    // time signature
    TimeSignature time = readTime(mxlAttributes.getTime());
    if (// TODO: attribute "number" for single staves
    time != null)
        context.writeColumnElement(time);
    // clefs
    if (mxlAttributes.getClefs() != null) {
        for (MxlClef mxlClef : mxlAttributes.getClefs()) {
            ClefReader clefReader = new ClefReader(mxlClef);
            Clef clef = clefReader.read();
            int staff = clefReader.readStaff();
            if (clef != null)
                context.writeMeasureElement(clef, staff);
        }
    }
    // transposition changes - TODO: clean solution for instrument changes
    PitchedInstrument instrument = readTransposedInstrument(mxlAttributes.getTranspose());
    if (instrument != null) {
        // write to all staves of this part
        for (int staff = 0; staff < context.getPartStaffIndices().getCount(); staff++) context.writeMeasureElement(new InstrumentChange(instrument), staff);
    }
}
Also used : InstrumentChange(com.xenoage.zong.core.music.InstrumentChange) PitchedInstrument(com.xenoage.zong.core.instrument.PitchedInstrument) Clef(com.xenoage.zong.core.music.clef.Clef) TraditionalKey(com.xenoage.zong.core.music.key.TraditionalKey) Key(com.xenoage.zong.core.music.key.Key) TimeSignature(com.xenoage.zong.core.music.time.TimeSignature)

Aggregations

Key (com.xenoage.zong.core.music.key.Key)6 TraditionalKey (com.xenoage.zong.core.music.key.TraditionalKey)6 Clef (com.xenoage.zong.core.music.clef.Clef)5 InstrumentChange (com.xenoage.zong.core.music.InstrumentChange)2 ElementSpacing (com.xenoage.zong.musiclayout.spacing.ElementSpacing)2 SimpleSpacing (com.xenoage.zong.musiclayout.spacing.SimpleSpacing)2 Fraction (com.xenoage.utils.math.Fraction)1 Score (com.xenoage.zong.core.Score)1 PitchedInstrument (com.xenoage.zong.core.instrument.PitchedInstrument)1 MeasureElement (com.xenoage.zong.core.music.MeasureElement)1 MusicContext (com.xenoage.zong.core.music.MusicContext)1 ClefType (com.xenoage.zong.core.music.clef.ClefType)1 Coda (com.xenoage.zong.core.music.direction.Coda)1 Direction (com.xenoage.zong.core.music.direction.Direction)1 Dynamic (com.xenoage.zong.core.music.direction.Dynamic)1 Mode (com.xenoage.zong.core.music.key.TraditionalKey.Mode)1 Rest (com.xenoage.zong.core.music.rest.Rest)1 TimeSignature (com.xenoage.zong.core.music.time.TimeSignature)1 ClefNotation (com.xenoage.zong.musiclayout.notation.ClefNotation)1 Notation (com.xenoage.zong.musiclayout.notation.Notation)1