Search in sources :

Example 1 with MxlMidiInstrument

use of com.xenoage.zong.musicxml.types.MxlMidiInstrument in project Zong by Xenoage.

the class InstrumentsReader method readMidiInstruments.

private void readMidiInstruments() {
    for (MxlMidiInstrument mxlMidiInstr : mxlScorePart.getMidiInstruments()) {
        Info info = getInfo(mxlMidiInstr.id);
        // midi program
        info.midiProgram = mxlMidiInstr.getMidiProgram();
        // midi channel
        info.midiChannel = mxlMidiInstr.getMidiChannel();
        // global volume
        info.volume = mxlMidiInstr.getVolume();
        if (info.volume != null)
            // to 0..1
            info.volume /= 100;
        // global panning
        info.pan = mxlMidiInstr.getPan();
        if (info.pan != null) {
            if (info.pan > 90)
                // e.g. convert 120° to 60°
                info.pan = 90 - (info.pan - 90);
            else if (info.pan < -90)
                // e.g. convert -120° to -60°
                info.pan = -90 - (info.pan + 90);
            // to -1..1
            info.pan /= 90f;
        }
    }
}
Also used : MxlMidiInstrument(com.xenoage.zong.musicxml.types.MxlMidiInstrument)

Aggregations

MxlMidiInstrument (com.xenoage.zong.musicxml.types.MxlMidiInstrument)1