Listado de instrumentos MIDI?
-
26-10-2019 - |
Pregunta
Recientemente implementé un MIDI Beatbox del código en PRIMER Java de la cabeza Y realmente me gustaría hacer más con las capacidades MIDI de Java. Pensé que podría comenzar agregando más instrumentos no perseguidos al código existente, pero parece que no puedo encontrar una lista directa de los instrumentos disponibles y sus int
llaves.
¿Existe tal listado de este tipo para elSoundbank
que se envía con el JDK?
Solución
¿Dym como este?
import javax.sound.midi.*;
import javax.swing.*;
class Instruments {
public static void main(String[] args) throws MidiUnavailableException {
Synthesizer synthesizer = MidiSystem.getSynthesizer();
synthesizer.open();
Instrument[] orchestra = synthesizer.getAvailableInstruments();
final StringBuilder sb = new StringBuilder();
String eol = System.getProperty("line.separator");
sb.append("The orchestra has ");
sb.append(orchestra.length);
sb.append(" instruments.");
sb.append(eol);
for (Instrument instrument : orchestra) {
sb.append(instrument.toString());
sb.append(eol);
}
synthesizer.close();
Runnable r = new Runnable() {
@Override
public void run() {
JOptionPane.showMessageDialog(null,
new JScrollPane(new JTextArea(sb.toString(), 20, 30)));
}
};
SwingUtilities.invokeLater(r);
}
}
Producción
The orchestra has 411 instruments.
Instrument Piano (bank 0 program 0)
Instrument Bright Piano (bank 0 program 1)
Instrument Electric Grand (bank 0 program 2)
Instrument Honky Tonk Piano (bank 0 program 3)
Instrument Electric Piano 1 (bank 0 program 4)
Instrument Electric Piano 2 (bank 0 program 5)
Instrument Harpsichord (bank 0 program 6)
Instrument Clavinet (bank 0 program 7)
Instrument Celesta (bank 0 program 8)
Instrument Glockenspiel (bank 0 program 9)
...
Otros consejos
Aquí está la lista completa, sin embargo.http://www.midi.org/techspecs/gm1sound.php
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow