Package go-wav
reads and writes WAV file.
The following example concatinates input1.wav
and input2.wav
into output.wav
.
package main
import (
"io"
"io/ioutil"
"github.com/moutend/go-wav"
)
func main() {
// Read input1.wav and input2.wav
i1, _ := ioutil.ReadFile("input1.wav")
i2, _ := ioutil.ReadFile("input2.wav")
// Create wav.File.
a := &wav.File{}
b := &wav.File{}
// Unmarshal input1.wav and input2.wav.
wav.Unmarshal(i1, a)
wav.Unmarshal(i2, b)
// Add input2.wav to input1.wav.
c, _ := wav.New(a.SamplesPerSec(), a.BitsPerSample(), a.Channels())
io.Copy(c, a)
io.Copy(c, b)
// Marshal input1.wav and save result.
file, _ := wav.Marshal(c)
ioutil.WriteFile("output.wav", file, 0644)
}
Note that the example assumes that the two input files have same sample rate, bit depth and channels.
- Fork (https://github.com/moutend/go-wca/fork)
- Create a feature branch
- Add changes
- Run
go fmt
andgo test
- Commit your changes
- Open a new Pull Request