Created
August 16, 2013 08:57
-
-
Save kafecho/6248352 to your computer and use it in GitHub Desktop.
Random MIDI tune with Scala and the Java MIDI API.
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
package org.kafecho.learning.midi | |
import javax.sound.midi.MidiSystem | |
import javax.sound.midi.ShortMessage | |
import scala.util.Random | |
object MidiTest extends App { | |
val rcvr = MidiSystem.getReceiver | |
while (true) { | |
val myMsg = new ShortMessage | |
myMsg.setMessage(ShortMessage.NOTE_ON, 8, Random.nextInt.abs % 127, 93) | |
rcvr.send(myMsg, -1) | |
Thread.sleep(100) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I did quite a lot of MIDI work but that was ages ago, however I can't remember from the top of my head. Have a look at: http://docs.oracle.com/javase/tutorial/sound/ for inspiration