Sick-Boy
Legacy Member
Ik ben bezig een synthesizer aan het programmeren in java en ik zou graag verschillende instrumenten gebruiken.
Maar als ik loadInstrument(Instrument) gebruik krijg ik altijd hetzelfde geluid, nl piano.
Stukje code:
Maar als ik loadInstrument(Instrument) gebruik krijg ik altijd hetzelfde geluid, nl piano.
Stukje code:
Code:
class MidiSynthesizerSample
{
public static void main(String[] args) {
try {
Synthesizer synth = MidiSystem.getSynthesizer();
synth.open();
final MidiChannel[] mc = synth.getChannels();
Instrument[] instr = synth.getDefaultSoundbank().getInstruments();
//System.out.println(instr[76].toString());
synth.loadInstrument(instr[76]); // Bottle Blow
for (int i = 0; i < 50; ++i) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {}
mc[5].noteOn(i,200);
}
} catch (MidiUnavailableException e) {}
}
}