A simple Go library for reading PCM WAV audio files.
import "github.com/djfritz/wav"
w, err := wav.LoadFromFile("audio.wav")
if err != nil {
// handle error
}
fmt.Println(w.Channels) // number of channels
fmt.Println(w.Frequency) // sample rate (e.g., 44100)
fmt.Println(w.BitsPerSample) // e.g., 16
fmt.Println(w.Length()) // durationw, err := wav.Load(data)The PCM data is arranged as N many channels in the wav.Data field. Each channel
has the same number of samples, and is stored as an int regardless of the
bits per sample. You will have to scale the data using the BitsPerSample
field.
BSD 2-Clause