Skip to content

Instantly share code, notes, and snippets.

@peterhellberg
Last active April 4, 2017 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save peterhellberg/7f2da321abd1da239608 to your computer and use it in GitHub Desktop.
Save peterhellberg/7f2da321abd1da239608 to your computer and use it in GitHub Desktop.
Generated music inspired by https://www.youtube.com/watch?v=MqZgoNRERY8
// Generated music inspired by https://www.youtube.com/watch?v=MqZgoNRERY8
//
// First you need to install SoX: brew install sox
//
// go run music.go | play -c 1 -b 8 -e unsigned -t raw -r 22k -
package main
import "fmt"
func g(v, m, o, i int) int {
s := "BY}6YB6%"
if (3 & v >> 11) != 0 {
s = "Qj}6jQ6%"
}
n := int(int(s[o%8]+51)*v) >> uint(i)
return (3 & m & n) << 3
}
func main() {
for i := 0; ; i++ {
n := i >> 12
s := i >> 17
fmt.Printf("%c",
g(i, 1, n, 12)+
g(i, s, n^i>>13, 10)+
g(i, s/3, n+((i>>11)%3), 10)+
g(i, s/5, 8+n-((i>>10)%3), 9))
}
}
This file has been truncated, but you can view the full file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment