tags:

views:

390

answers:

3

I'm planning to create my own metronome (woodblock instrument) using Java that could set its bpm, volume, etc. And I have tried over 16 channels (MIDI 1.0 specification) obtained from getChannels() but there is no woodblock heard at all.

Here's the code taken from http://www.jsresources.org

  /*
   * Turn the note on on MIDI channel 1.
   * (Index zero means MIDI channel 1)
   */
  MidiChannel[] channels = synth.getChannels();
  channels[0].noteOn(nNoteNumber, nVelocity);

  /*
   * Wait for the specified amount of time
   * (the duration of the note).
   */
  try
  {
   Thread.sleep(nDuration);
  }
  catch (InterruptedException e)
  {
  }

  /*
   * Turn the note off.
   */
  channels[0].noteOff(nNoteNumber);

Anyone got anything about this? thanks.

A: 

a woodblock is a percussion instrument. you should hear it when you play the right note on a channel which has been assigned a drums or percussions patch. (in a percussions or drums patch, each note plays a different instrument: wood block, snare drum, hi-tom, clave, etc.)

Adrien Plisson
A: 

Use (eg) this General MIDI (GM) reference to look up patches. You need channel 10 for GM percussion, and note number 76 for Hi Wood Block or 77 for Low Wood Block.

Also, instrument 116 is a full keyboard (any pitch from 1 to 128) woodblock. I believe that should work on any non-percussion (ie not 10, or possibly 16) channel.

Note: GM appears to be 1-based, whereas your API seems to be 0-based, so you may have to subtract one from some of these values.

Ewan Todd
+1  A: 

Depending on your synthesizer, the percussion sounds will be on channel 10 or channel 16 (indexes 9 or 15 in your array). The woodblock sounds would be note numbers 76 and 77, and you would probably want to use a note velocity value of 128 (for maximum volume).

I haven't looked at the code you're using, but you may also need to call a method to turn on the synthesizer before you can play anything. Also, since you're playing a percussion note, you may be able to send the corresponding note off message immediately after the note on message (so you don't have to figure out the duration of the fixed percussion note). Most MIDI synths that I've used play the entire percussion sound even after receiving the note off message.

MusiGenesis