From 9939de26ac840d90e71a5498b3e8b1592f188bf7 Mon Sep 17 00:00:00 2001 From: Trek H Date: Mon, 11 Feb 2019 15:47:45 +1030 Subject: [PATCH] ADPCM: removed unneeded test programs --- cmd/adpcm/cmd/decode-pcm/decode-pcm.go | 45 -------------------- cmd/adpcm/cmd/decode/decode.go | 59 -------------------------- cmd/adpcm/cmd/encode-pcm/encode-pcm.go | 43 ------------------- cmd/adpcm/cmd/encode/encode.go | 53 ----------------------- 4 files changed, 200 deletions(-) delete mode 100644 cmd/adpcm/cmd/decode-pcm/decode-pcm.go delete mode 100644 cmd/adpcm/cmd/decode/decode.go delete mode 100644 cmd/adpcm/cmd/encode-pcm/encode-pcm.go delete mode 100644 cmd/adpcm/cmd/encode/encode.go diff --git a/cmd/adpcm/cmd/decode-pcm/decode-pcm.go b/cmd/adpcm/cmd/decode-pcm/decode-pcm.go deleted file mode 100644 index 3c375de1..00000000 --- a/cmd/adpcm/cmd/decode-pcm/decode-pcm.go +++ /dev/null @@ -1,45 +0,0 @@ -package main - -import ( - "flag" - "io/ioutil" - - "bitbucket.org/ausocean/av/cmd/adpcm" -) - -// This program accepts an input file encoded in adpcm and outputs a decoded pcm file. -// Input and output file names can be specified as arguments. -func main() { - var inPath string - var outPath string - - flag.StringVar(&inPath, "in", "encoded.adpcm", "file path of input") - flag.StringVar(&outPath, "out", "decoded.pcm", "file path of output data") - flag.Parse() - //read adpcm - comp, err := ioutil.ReadFile(inPath) - if err != nil { - panic(err) - } - //decode adpcm - var decoded []byte - start := 0 - for i := 0; i < len(comp); i++ { - if i%256 == 255 { - block := comp[start : i+1] - decBlock, err := adpcm.DecodeBlock(block) - if err != nil { - //todo: use correct logging of error - panic(err) - } - decoded = append(decoded, decBlock...) - start = i + 1 - } - } - // save pcm to file - err = ioutil.WriteFile(outPath, decoded, 0644) - if err != nil { - panic(err) - } - -} diff --git a/cmd/adpcm/cmd/decode/decode.go b/cmd/adpcm/cmd/decode/decode.go deleted file mode 100644 index 69f55231..00000000 --- a/cmd/adpcm/cmd/decode/decode.go +++ /dev/null @@ -1,59 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "io/ioutil" - - "bitbucket.org/ausocean/av/cmd/adpcm" -) - -func main() { - var inPath string - var outPath string - var nChannels int - var rate int - var bps int - flag.StringVar(&inPath, "in", "encoded.adpcm", "file path of input") - flag.StringVar(&outPath, "out", "decoded.pcm", "file path of output data") - flag.IntVar(&nChannels, "channels", 1, "number of channels in adpcm data") - flag.IntVar(&rate, "rate", 8000, "number of channels in adpcm data") - flag.IntVar(&bps, "bps", 16, "number of channels in adpcm data") - flag.Parse() - //read adpcm - comp, err := ioutil.ReadFile(inPath) - if err != nil { - panic(err) - } - fmt.Println("Read ADPCM from " + inPath + ". First 8 bytes: ") - for i := 0; i < len(comp) && i < 16; i++ { - fmt.Print(comp[i], ", ") - } - fmt.Println() - //decode adpcm - var decoded []byte - start := 0 - for i := 0; i < len(comp); i++ { - if i%256 == 255 { - block := comp[start : i+1] - decBlock, err := adpcm.DecodeBlock(block) - if err != nil { - //todo: use correct logging of error - panic(err) - } - decoded = append(decoded, decBlock...) - start = i + 1 - } - } - // save pcm to file - err = ioutil.WriteFile(outPath, decoded, 0644) - if err != nil { - panic(err) - } - fmt.Println("Saved PCM to " + outPath + ". First 16 bytes: ") - for i := 0; i < len(decoded) && i < 16; i++ { - fmt.Print(decoded[i], " ") - } - fmt.Println() - -} diff --git a/cmd/adpcm/cmd/encode-pcm/encode-pcm.go b/cmd/adpcm/cmd/encode-pcm/encode-pcm.go deleted file mode 100644 index 57c9fd22..00000000 --- a/cmd/adpcm/cmd/encode-pcm/encode-pcm.go +++ /dev/null @@ -1,43 +0,0 @@ -package main - -import ( - "flag" - "io/ioutil" - - "bitbucket.org/ausocean/av/cmd/adpcm" -) - -func main() { - var inPath string - var adpcmPath string - flag.StringVar(&inPath, "in", "data.pcm", "file path of input data") - flag.StringVar(&adpcmPath, "out", "encoded.adpcm", "file path of output") - flag.Parse() - //read pcm - pcm, err := ioutil.ReadFile(inPath) - if err != nil { - panic(err) - } - - //encode adpcm - var comp []byte - start := 0 - for i := 0; i < len(pcm); i++ { - if i%1010 == 1009 { - block := pcm[start : i+1] - - encBlock, err := adpcm.EncodeBlock(block) - if err != nil { - //todo: use correct logging of error - panic(err) - } - comp = append(comp, encBlock...) - start = i + 1 - } - } - // save adpcm to file - err = ioutil.WriteFile(adpcmPath, comp, 0644) - if err != nil { - panic(err) - } -} diff --git a/cmd/adpcm/cmd/encode/encode.go b/cmd/adpcm/cmd/encode/encode.go deleted file mode 100644 index 84da6a39..00000000 --- a/cmd/adpcm/cmd/encode/encode.go +++ /dev/null @@ -1,53 +0,0 @@ -package main - -import ( - "flag" - "io/ioutil" - - "bitbucket.org/ausocean/av/cmd/adpcm" -) - -func main() { - var inPath string - var adpcmPath string - flag.StringVar(&inPath, "in", "data.pcm", "file path of input data") - flag.StringVar(&adpcmPath, "out", "encoded.adpcm", "file path of output") - flag.Parse() - //read pcm - pcm, err := ioutil.ReadFile(inPath) - if err != nil { - panic(err) - } - - //encode adpcm - var comp []byte - start := 0 - // tCount := 0 - // tNum := 1 - for i := 0; i < len(pcm); i++ { - if i%1010 == 1009 { - block := pcm[start : i+1] - // if tCount < tNum { - // fmt.Println(block[0:16]) - // tCount++ - // } - encBlock, err := adpcm.EncodeBlock(block) - if err != nil { - //todo: use correct logging of error - panic(err) - } - comp = append(comp, encBlock...) - start = i + 1 - } - } - // save adpcm to file - err = ioutil.WriteFile(adpcmPath, comp, 0644) - if err != nil { - panic(err) - } - // fmt.Println("Saved ADPCM to " + adpcmPath + ". First 16 bytes: ") - // for i := 0; i < len(comp) && i < 16; i++ { - // fmt.Println(comp[i]) - // } - // fmt.Println() -}