Skip to content

rodrigo-dc/wavegen

Repository files navigation

wavegen Build Status

Go package for discrete wave generation

Currently, wavegen is able to generate square and sine waves.

Example

Simple example showing the generation of a sinusoid.

package main

import (
	"fmt"
	"os"

	"github.com/rodrigo-dc/wavegen"
)

func main() {
	wave, err := wavegen.Sine(440, 44100)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	// Print tab-separated values, ready to be used by GNU Plot
	for i, s := range wave {
		fmt.Println(i, "\t", s)
	}
}

The output of the example above can be used as an input to GNU Plot.

./sine | gnuplot -e "set style data lines;plot '-'" --persist

GNU Plot output

About

Go package for discrete wave generation

Resources

License

Stars

Watchers

Forks

Contributors

Languages