soundcheck: builds

This commit is contained in:
Trek H 2020-08-11 21:17:21 +09:30
parent 73e1007edd
commit 3265f7c195
1 changed files with 11 additions and 12 deletions

View File

@ -26,27 +26,26 @@ import (
"flag" "flag"
"fmt" "fmt"
"log" "log"
"os"
"os/exec" "os/exec"
"time"
) )
func main() { func main() {
pTime := flag.Duration("ptime", 60, "duration to play audio") var pTime time.Duration
rTime := flag.Duration("rtime", 20, "duration to record audio") var rTime time.Duration
path := flag.String("path", "", "path to sound file we wish to play") var path string
flag.DurationVar(&pTime, "ptime", 60, "duration to play audio")
flag.DurationVar(&rTime, "rtime", 20, "duration to record audio")
flag.StringVar(&path, "path", "", "path to sound file we wish to play")
flag.Parse() flag.Parse()
if _, err := os.Stat(path); os.IsNotExist(err) { loopCmd := exec.Command("../looper/looper", path)
log.Fatal(err) rvCmd := exec.Command("../rv/rv")
}
loopCmd := exec.Command("./looper", path)
rvCmd := exec.Command("./rv")
for { for {
if err := loopCmd.Start(); err != nil { if err := loopCmd.Start(); err != nil {
log.Fatal(err) log.Fatal(err)
} }
time.sleep(pTime) time.Sleep(pTime)
if err := loopCmd.Process.Kill(); err != nil { if err := loopCmd.Process.Kill(); err != nil {
fmt.Println("failed to kill process: ", err) fmt.Println("failed to kill process: ", err)
} }
@ -54,7 +53,7 @@ func main() {
if err := rvCmd.Start(); err != nil { if err := rvCmd.Start(); err != nil {
log.Fatal(err) log.Fatal(err)
} }
time.sleep(rTime) time.Sleep(rTime)
if err := rvCmd.Process.Kill(); err != nil { if err := rvCmd.Process.Kill(); err != nil {
fmt.Println("failed to kill process: ", err) fmt.Println("failed to kill process: ", err)
} }