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;
}
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;
}
Aggregations