Created
August 28, 2012 08:58
-
-
Save nckltcha/3496353 to your computer and use it in GitHub Desktop.
Java Synth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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