Created
February 21, 2017 21:07
-
-
Save moul/fd8ca0e917b1b16bda6f0fca987b3081 to your computer and use it in GitHub Desktop.
synth roulette
This file contains 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 main | |
import ( | |
"fmt" | |
"log" | |
"time" | |
"github.com/rakyll/portmidi" | |
) | |
func main() { | |
portmidi.Initialize() | |
defer portmidi.Terminate() | |
fmt.Println(portmidi.CountDevices()) | |
out, err := portmidi.NewOutputStream(portmidi.DefaultOutputDeviceID(), 1024, 0) | |
if err != nil { | |
log.Fatal(err) | |
} | |
// note on events to play C major chord | |
out.WriteShort(0x90, 60, 100) | |
out.WriteShort(0x90, 64, 100) | |
out.WriteShort(0x90, 67, 100) | |
// notes will be sustained for 2 seconds | |
time.Sleep(2 * time.Second) | |
// note off events | |
out.WriteShort(0x80, 60, 100) | |
out.WriteShort(0x80, 64, 100) | |
out.WriteShort(0x80, 67, 100) | |
out.Close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment