cmd/audio-player/looper: use a command line flag for choosing audio file path

This commit is contained in:
Scott 2020-02-28 16:28:02 +10:30
parent 8cbc7e700c
commit c5fb58e70c
1 changed files with 5 additions and 3 deletions

View File

@ -28,6 +28,7 @@ package main
import (
"bytes"
"flag"
"io"
"os"
"os/exec"
@ -38,8 +39,9 @@ import (
)
func main() {
// Constants.
const soundFile = "/home/pi/48khz.wav"
// Command line flags.
var soundFilePtr = flag.String("path", "", "Location of sound file")
flag.Parse()
// Logging constants.
const (
@ -71,7 +73,7 @@ func main() {
numPlays++
log.Log(logger.Debug, "playing audio", "play number", numPlays)
cmd := exec.Command(audioCmd, soundFile)
cmd := exec.Command(audioCmd, *soundFilePtr)
var stdoutBuf, stderrBuf bytes.Buffer
stdoutIn, _ := cmd.StdoutPipe()