go-wav
go-wav copied to clipboard
return wav header data
hope to get wav header data from format
attr.
so i can detect wheater a 44 or 46-byte header.
You can get the chunk size of fmt chunk with the following code If the chunk size <= 18, the header size will be 46
package main
import (
"flag"
"log"
"os"
riff "github.com/youpy/go-riff"
)
func main() {
var path = flag.String("path", "", "WAV file path")
flag.Parse()
file, err := os.Open(*path)
if err != nil {
panic(err)
}
reader := riff.NewReader(file)
r, err := reader.Read()
if err != nil {
panic(err)
}
for _, chunk := range r.Chunks {
chunkID := string(chunk.ChunkID[:])
log.Printf("Chunk ID: %s", chunkID)
log.Printf("Chunk size: %d", chunk.ChunkSize)
}
}