【问题标题】:MIDI instrument listing?MIDI 乐器列表?
【发布时间】:2011-12-10 05:01:11
【问题描述】:

我最近使用 Head First Java 中的代码实现了一个 MIDI Beatbox,我真的很想利用 Java 的 MIDI 功能做更多事情。我想我可以先在现有代码中添加更多的非打击乐器,但我似乎找不到可用乐器及其int 键的简单列表。

JDK 附带的Soundbank 是否存在这样的列表?

【问题讨论】:

    标签: java midi javasound midi-instrument


    【解决方案1】:

    这样的DYM?

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

    输出

    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)
    ...
    

    【讨论】:

      【解决方案2】:

      不过,这里是完整的列表。 http://www.midi.org/techspecs/gm1sound.php

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-08-16
        • 2015-06-30
        • 1970-01-01
        • 1970-01-01
        • 2014-05-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多