Search in sources :

Example 1 with UnpitchedInstrument

use of com.xenoage.zong.core.instrument.UnpitchedInstrument in project Zong by Xenoage.

the class ChannelMapperTest method createScore.

private Score createScore(int[] midiPrograms, int... partStavesCount) {
    val score = new Score();
    for (int iPart : range(partStavesCount)) {
        Instrument instrument;
        if (midiPrograms[iPart] == drums)
            instrument = new UnpitchedInstrument("part " + iPart);
        else
            instrument = new PitchedInstrument("part " + iPart, midiPrograms[iPart]);
        new PartAdd(score, new Part("", null, partStavesCount[iPart], alist(instrument)), iPart, null).execute();
    }
    return score;
}
Also used : lombok.val(lombok.val) UnpitchedInstrument(com.xenoage.zong.core.instrument.UnpitchedInstrument) Score(com.xenoage.zong.core.Score) PitchedInstrument(com.xenoage.zong.core.instrument.PitchedInstrument) Part(com.xenoage.zong.core.music.Part) UnpitchedInstrument(com.xenoage.zong.core.instrument.UnpitchedInstrument) PitchedInstrument(com.xenoage.zong.core.instrument.PitchedInstrument) Instrument(com.xenoage.zong.core.instrument.Instrument) PartAdd(com.xenoage.zong.commands.core.music.PartAdd)

Example 2 with UnpitchedInstrument

use of com.xenoage.zong.core.instrument.UnpitchedInstrument in project Zong by Xenoage.

the class InstrumentsReader method readInstrument.

private Instrument readInstrument(Info info) {
    Instrument instrument = null;
    if (info.midiChannel != null && info.midiChannel == 10) {
        // unpitched instrument
        instrument = new UnpitchedInstrument(info.id);
    } else {
        // pitched instrument
        // midi-program is 1-based in MusicXML but 0-based in MIDI
        // TODO: find value that matches instrument name
        int midiProgram = notNull(info.midiProgram, 1) - 1;
        midiProgram = MathUtils.INSTANCE.clamp(midiProgram, 0, 127);
        PitchedInstrument pitchedInstrument;
        instrument = pitchedInstrument = new PitchedInstrument(info.id, midiProgram);
        pitchedInstrument.setTranspose(info.transpose);
    }
    instrument.setName(info.name);
    instrument.setAbbreviation(info.abbreviation);
    if (info.volume != null)
        instrument.setVolume(info.volume);
    if (info.pan != null)
        instrument.setPan(info.pan);
    return instrument;
}
Also used : UnpitchedInstrument(com.xenoage.zong.core.instrument.UnpitchedInstrument) PitchedInstrument(com.xenoage.zong.core.instrument.PitchedInstrument) UnpitchedInstrument(com.xenoage.zong.core.instrument.UnpitchedInstrument) MxlMidiInstrument(com.xenoage.zong.musicxml.types.MxlMidiInstrument) PitchedInstrument(com.xenoage.zong.core.instrument.PitchedInstrument) Instrument(com.xenoage.zong.core.instrument.Instrument) MxlScoreInstrument(com.xenoage.zong.musicxml.types.MxlScoreInstrument)

Aggregations

Instrument (com.xenoage.zong.core.instrument.Instrument)2 PitchedInstrument (com.xenoage.zong.core.instrument.PitchedInstrument)2 UnpitchedInstrument (com.xenoage.zong.core.instrument.UnpitchedInstrument)2 PartAdd (com.xenoage.zong.commands.core.music.PartAdd)1 Score (com.xenoage.zong.core.Score)1 Part (com.xenoage.zong.core.music.Part)1 MxlMidiInstrument (com.xenoage.zong.musicxml.types.MxlMidiInstrument)1 MxlScoreInstrument (com.xenoage.zong.musicxml.types.MxlScoreInstrument)1 lombok.val (lombok.val)1