Skip to content

Instantly share code, notes, and snippets.

@koyachi
Last active December 15, 2015 06:08
Show Gist options
  • Save koyachi/5213730 to your computer and use it in GitHub Desktop.
Save koyachi/5213730 to your computer and use it in GitHub Desktop.
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