Skip to content

Commit

Permalink
added usage message for tone-player example
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyapashuk committed Aug 31, 2021
1 parent 451b3a8 commit 1a05c2c
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions examples/tone-player/main.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
package main

import (
"os"
"fmt"
"github.com/faiface/beep"
"github.com/faiface/beep/generators"
"github.com/faiface/beep/speaker"
"github.com/faiface/beep"
"os"
"strconv"
)

func usage() {
fmt.Printf("usage: %s freq\n", os.Args[0])
fmt.Println("where freq must be an integer from 1 to 24000")
fmt.Println("24000 because samplerate of 48000 is hardcoded")
}
func main() {
f, _ := strconv.Atoi(os.Args[1])
if len(os.Args) < 2 {
usage()
return
}
f, err := strconv.Atoi(os.Args[1])
if err != nil {
usage()
return
}
speaker.Init(beep.SampleRate(48000), 4800)
s, err := generators.SinTone(beep.SampleRate(48000), f)
if err != nil {
Expand Down

0 comments on commit 1a05c2c

Please sign in to comment.