如何在Midi中更换乐器?
在显示“ Channel out of range”(通道超出范围)后,我可以将channel的值最多更改为9,这全是钢琴。例如,如何将其更改为吉他

  public noteplay()
  throws InvalidMidiDataException,MidiUnavailableException
  {
    bpm =80;
    beatLength = 1;
    theTimeMelody = 0;
    theTimeBass =0;
    seq = new Sequence(Sequence.PPQ,3);
    trkBass = seq.createTrack();
    trkMelody = seq.createTrack();
  }
  public void melody(int volume)
    throws InvalidMidiDataException,MidiUnavailableException

  {

   int list1[] = { 56,59,60,63,56,59,60,63, 61,64,65,68,61,64,65,68,    56,59,60,63,56,59,60,63,    63,66,67,70,73,66,67,70,};

    for (int pitch : list1)
      {
    ShortMessage onMsg = new ShortMessage();
    onMsg.setMessage(ShortMessage.NOTE_ON, 0, pitch, 80);

    ShortMessage offMsg = new ShortMessage();
    offMsg.setMessage(ShortMessage.NOTE_OFF, 0, pitch, 90);

    trkBass.add(new MidiEvent(onMsg,theTimeBass));
    trkBass.add(new MidiEvent(offMsg,theTimeBass+beatLength));
    theTimeBass += beatLength;

      }
  }
}

最佳答案

通用MIDI标准为鼓保留了第十个通道。

您可以将其他十五个通道用于旋律乐器。

关于java - 如何在Java MIDI程序中更改乐器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55690935/

10-11 03:34