Created
March 26, 2021 03:18
-
-
Save renanbastos93/70b13f0a999686ef4d3800dd812003d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
"github.com/gen2brain/beeep" | |
) | |
func main() { | |
guitarra := time.NewTicker(time.Second) | |
bateria := time.NewTicker(2 * time.Second) | |
compasso := time.NewTicker(4 * time.Second) | |
done := make(chan bool) | |
go func() { | |
c, g, b := "", "", "" | |
for { | |
select { | |
case <-done: | |
return | |
case <-compasso.C: | |
c = "X4" | |
g, b = "", "" | |
err := beeep.Beep(beeep.DefaultFreq, beeep.DefaultDuration) | |
if err != nil { | |
panic(err) | |
} | |
case <-bateria.C: | |
b = "RE" | |
err := beeep.Beep(440, beeep.DefaultDuration) | |
if err != nil { | |
panic(err) | |
} | |
case <-guitarra.C: | |
g = "DO" | |
err := beeep.Beep(122, beeep.DefaultDuration) | |
if err != nil { | |
panic(err) | |
} | |
} | |
fmt.Printf("%s-%s-%s\n", c, g, b) | |
} | |
}() | |
time.Sleep(40 * time.Second) | |
bateria.Stop() | |
guitarra.Stop() | |
done <- true | |
fmt.Println("Ticker stopped") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment