-
-
Save djui/4a648b238086e8605257bead8f9ce763 to your computer and use it in GitHub Desktop.
Generated music inspired by https://www.youtube.com/watch?v=MqZgoNRERY8
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
// 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)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment