Last active
September 24, 2018 05:10
-
-
Save dudk/0b90e71bdd45b150515fc869b87f00f4 to your computer and use it in GitHub Desktop.
phono example 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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