Skip to content

Instantly share code, notes, and snippets.

@nckltcha
Created August 28, 2012 08:58
Show Gist options
  • Select an option

  • Save nckltcha/3496353 to your computer and use it in GitHub Desktop.

Select an option

Save nckltcha/3496353 to your computer and use it in GitHub Desktop.
Java Synth
// SimpleGroovyMidiSynthesizer sample
import javax.sound.midi.*;
public class MidiSynthesizerSample {
static void main(args) {
def notes = [60, 62, 64, 65, 67, 69, 71, 72, 72, 71, 69, 67, 65, 64, 62, 60]
def synth = MidiSystem.getSynthesizer()
def vel = 50 // velocity from 0..127
def dur = 100 // duration in milliseconds
synth.open()
def channel = synth. getChannels()[0]
notes.each{
channel.noteOn(it, vel)
Thread.sleep(dur)
channel.noteOff(it)
}
}
}
/* See Xantorohara: Simple Java MIDI synthesizer sample (Show on Google Sidewiki)*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment