Skip to content

Instantly share code, notes, and snippets.

@dudk
Last active September 24, 2018 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dudk/0b90e71bdd45b150515fc869b87f00f4 to your computer and use it in GitHub Desktop.
Save dudk/0b90e71bdd45b150515fc869b87f00f4 to your computer and use it in GitHub Desktop.
phono example 1
package example
import (
"github.com/dudk/phono"
"github.com/dudk/phono/pipe"
"github.com/dudk/phono/portaudio"
"github.com/dudk/phono/wav"
)
// Example:
// Read .wav file
// Play it with portaudio
func one() {
wavPath := "../_testdata/sample1.wav"
bufferSize := phono.BufferSize(512)
// wav pump
wavPump, err := wav.NewPump(
wavPath,
bufferSize,
)
check(err)
// portaudio sink
paSink := portaudio.NewSink(
bufferSize,
wavPump.WavSampleRate(),
wavPump.WavNumChannels(),
)
// build pipe
p := pipe.New(
pipe.WithPump(wavPump),
pipe.WithSinks(paSink),
)
defer p.Close()
// run pipe
err = p.Do(pipe.Run)
check(err)
}
package example
func check(err error) {
if err != nil {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment