2020-08-08 07:49:25 +03:00
|
|
|
/*
|
|
|
|
AUTHORS
|
|
|
|
Trek Hopton <trek@ausocean.org>
|
|
|
|
|
|
|
|
LICENSE
|
|
|
|
Copyright (C) 2020 the Australian Ocean Lab (AusOcean)
|
|
|
|
|
|
|
|
It is free software: you can redistribute it and/or modify them
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Package soundcheck is a program for switching a transducer from playing to recording audio.
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"os/exec"
|
2020-08-11 14:47:21 +03:00
|
|
|
"time"
|
2020-08-08 07:49:25 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2020-08-11 14:47:21 +03:00
|
|
|
var pTime time.Duration
|
|
|
|
var rTime time.Duration
|
|
|
|
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")
|
2020-08-08 07:49:25 +03:00
|
|
|
flag.Parse()
|
|
|
|
|
2020-08-11 14:47:21 +03:00
|
|
|
loopCmd := exec.Command("../looper/looper", path)
|
|
|
|
rvCmd := exec.Command("../rv/rv")
|
2020-08-08 07:49:25 +03:00
|
|
|
for {
|
|
|
|
if err := loopCmd.Start(); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2020-08-11 14:47:21 +03:00
|
|
|
time.Sleep(pTime)
|
2020-08-08 07:49:25 +03:00
|
|
|
if err := loopCmd.Process.Kill(); err != nil {
|
|
|
|
fmt.Println("failed to kill process: ", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := rvCmd.Start(); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2020-08-11 14:47:21 +03:00
|
|
|
time.Sleep(rTime)
|
2020-08-08 07:49:25 +03:00
|
|
|
if err := rvCmd.Process.Kill(); err != nil {
|
|
|
|
fmt.Println("failed to kill process: ", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|