Last active
December 15, 2015 06:08
-
-
Save koyachi/5213730 to your computer and use it in GitHub Desktop.
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 ( | |
"github.com/koyachi/go-asynth" | |
"github.com/koyachi/go-baudio" | |
"math" | |
) | |
func main() { | |
s := asynth.New(func(note asynth.Note, t float64) float64 { | |
freq := 440.0 * math.Pow(2, float64(note.Key-49)/12) | |
x := math.Sin(1.0 * math.Pi * t * freq) | |
x1 := math.Sin(1.2*math.Pi*t*freq + math.Pi*0.1) | |
x2 := math.Sin(1.2*math.Pi*t*freq + math.Pi*0.2) | |
x3 := math.Sin(1.2*math.Pi*t*freq + math.Pi*0.3) | |
y := math.Sin(2.0 * math.Pi * t * freq / 4) | |
return x*0.2 + x1*0.1 + x2*0.1 + x3*0.1 + y*0.5 | |
}) | |
s.Play(nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment