Skip to content

Latest commit

 

History

History
52 lines (36 loc) · 1.09 KB

README.md

File metadata and controls

52 lines (36 loc) · 1.09 KB

sounds

Go language generation and manipulation of sounds, built on github.com/splace/signals package.

Status: (Beta :- stabilising API)

Overview/docs: GoDoc uses Signals: GoDoc

Installation:

 go get github.com/splace/sounds   

Example: play a note.(uses linux "aplay" command.)

package main

import (
	"os/exec"
	"time"
)

import . "github.com/splace/sounds"

func play(s Sound) {
	cmd := exec.Command("aplay","--rate=44100","--format=S16_LE")
	in,err:=cmd.StdinPipe()
	if err != nil {
		panic(err)
	}
	err = cmd.Start()
	if err != nil {
		panic(err)
	}
	Encode(in, 2, 44100, s)
	in.Close()
	err = cmd.Wait()
	if err != nil {
		panic(err)
	}
}

func main(){
	play(NewSound(NewTone(time.Second/440, 1),time.Second/3))
}

Example: A tune with sampled notes.

twinkle twinkle little star