Skip to content

Commit

Permalink
Merge pull request #7 from pablodz/dev
Browse files Browse the repository at this point in the history
fix #6
  • Loading branch information
pablodz authored Jan 13, 2023
2 parents 99e014b + a7fda32 commit d5fdd81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
21 changes: 13 additions & 8 deletions pkg/transcoder/mulaw2wav.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ import (
"golang.org/x/term"
)

func init() {
err := error(nil)
WIDTH_TERMINAL, HEIGHT_TERMINAL, err = term.GetSize(0)
if err != nil {
log.Fatal(err)
}
}

// Transcode an ulaw file to a wav file (large files supported)
// https://raw.githubusercontent.com/corkami/pics/master/binary/WAV.png
// http://www.topherlee.com/software/pcm-tut-wavformat.html
Expand Down Expand Up @@ -170,6 +162,13 @@ func graphIn(in *AudioFileIn) {
values[i] = float64(val)
}

WIDTH_TERMINAL, HEIGHT_TERMINAL, err = term.GetSize(0)
if err != nil {
WIDTH_TERMINAL = 80
HEIGHT_TERMINAL = 24
log.Println("Error getting terminal size, using default values (80x24) instead")
}

fmt.Println(asciigraph.Plot(
values,
asciigraph.Height(HEIGHT_TERMINAL/3),
Expand Down Expand Up @@ -235,6 +234,12 @@ func graphOut(in *AudioFileIn, out *AudioFileOut) {
lineOutput[0] = 0
lineOutput[len(lineOutput)-1] = math.Round(float64(math.MaxUint8) / 2)

WIDTH_TERMINAL, HEIGHT_TERMINAL, err = term.GetSize(0)
if err != nil {
WIDTH_TERMINAL = 80
HEIGHT_TERMINAL = 24
log.Println("Error getting terminal size, using default values (80x24) instead")
}
log.Println("Sample of the input file (ulaw) (first 100 samples of n)")
fmt.Println(asciigraph.PlotMany(
[][]float64{linesMiddle, lineInput},
Expand Down
10 changes: 0 additions & 10 deletions pkg/transcoder/mulaw2wavlogpcm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,13 @@ import (
"bufio"
"fmt"
"io"
"log"
"os"

"github.com/pablodz/sopro/pkg/audioconfig"
"github.com/pablodz/sopro/pkg/cpuarch"
"github.com/pablodz/sopro/pkg/encoding"
"golang.org/x/term"
)

func init() {
err := error(nil)
WIDTH_TERMINAL, HEIGHT_TERMINAL, err = term.GetSize(0)
if err != nil {
log.Fatal(err)
}
}

// Transcode an ulaw file to a wav file (large files supported)
// https://raw.githubusercontent.com/corkami/pics/master/binary/WAV.png
// http://www.topherlee.com/software/pcm-tut-wavformat.html
Expand Down

0 comments on commit d5fdd81

Please sign in to comment.