adpcm: updated decode and encode pcm commands

This commit is contained in:
Trek H 2019-05-22 15:04:21 +09:30
parent 5e4a2fb866
commit 537d5bab73
2 changed files with 2 additions and 4 deletions

View File

@ -52,8 +52,7 @@ func main() {
fmt.Println("Read", len(comp), "bytes from file", inPath) fmt.Println("Read", len(comp), "bytes from file", inPath)
// Decode adpcm. // Decode adpcm.
numBlocks := len(comp) / adpcm.AdpcmBS decoded := bytes.NewBuffer(make([]byte, 0, len(comp)*4))
decoded := bytes.NewBuffer(make([]byte, 0, adpcm.PcmBS*numBlocks))
dec := adpcm.NewDecoder(decoded) dec := adpcm.NewDecoder(decoded)
_, err = dec.Write(comp) _, err = dec.Write(comp)
if err != nil { if err != nil {

View File

@ -52,8 +52,7 @@ func main() {
fmt.Println("Read", len(pcm), "bytes from file", inPath) fmt.Println("Read", len(pcm), "bytes from file", inPath)
// Encode adpcm. // Encode adpcm.
numBlocks := len(pcm) / adpcm.PcmBS comp := bytes.NewBuffer(make([]byte, 0, adpcm.EncBytes(len(pcm))))
comp := bytes.NewBuffer(make([]byte, 0, adpcm.AdpcmBS*numBlocks))
enc := adpcm.NewEncoder(comp) enc := adpcm.NewEncoder(comp)
_, err = enc.Write(pcm) _, err = enc.Write(pcm)
if err != nil { if err != nil {