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.

Revisions

  1. koyachi revised this gist Mar 21, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion organ2.go
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    package main

    import (
    "github.com/koyachi/go-asynth"
    "github.com/koyachi/go-asynth"
    "github.com/koyachi/go-baudio"
    "math"
    )
  2. koyachi created this gist Mar 21, 2013.
    20 changes: 20 additions & 0 deletions organ2.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    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)
    }