feat: add new warning sound

This commit is contained in:
Louis Dalibard 2024-08-25 14:12:59 +02:00
parent f892ba3f09
commit 3bb9b2350c
8 changed files with 19 additions and 9 deletions

3
go.mod
View File

@ -17,6 +17,9 @@ require (
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/hajimehoshi/oto v0.7.1 // indirect
github.com/icza/bitio v1.0.0 // indirect
github.com/mewkiz/flac v1.0.7 // indirect
github.com/mewkiz/pkg v0.0.0-20190919212034-518ade7978e2 // indirect
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect

4
go.sum
View File

@ -21,7 +21,9 @@ github.com/hajimehoshi/go-mp3 v0.3.0/go.mod h1:qMJj/CSDxx6CGHiZeCgbiq2DSUkbK0Ubt
github.com/hajimehoshi/oto v0.6.1/go.mod h1:0QXGEkbuJRohbJaxr7ZQSxnju7hEhseiPx2hrh6raOI=
github.com/hajimehoshi/oto v0.7.1 h1:I7maFPz5MBCwiutOrz++DLdbr4rTzBsbBuV2VpgU9kk=
github.com/hajimehoshi/oto v0.7.1/go.mod h1:wovJ8WWMfFKvP587mhHgot/MBr4DnNy9m6EepeVGnos=
github.com/icza/bitio v1.0.0 h1:squ/m1SHyFeCA6+6Gyol1AxV9nmPPlJFT8c2vKdj3U8=
github.com/icza/bitio v1.0.0/go.mod h1:0jGnlLAx8MKMr9VGnn/4YrvZiprkvBelsVIbA9Jjr9A=
github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6 h1:8UsGZ2rr2ksmEru6lToqnXgA8Mz1DP11X4zSJ159C3k=
github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6/go.mod h1:xQig96I1VNBDIWGCdTt54nHt6EeI639SmHycLYL7FkA=
github.com/jfreymuth/oggvorbis v1.0.1/go.mod h1:NqS+K+UXKje0FUYUPosyQ+XTVvjmVjps1aEZH1sumIk=
github.com/jfreymuth/vorbis v1.0.0/go.mod h1:8zy3lUAm9K/rJJk223RKy6vjCZTWC61NA2QD06bfOE0=
@ -31,7 +33,9 @@ github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f h1:dKccXx7xA56UNq
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f/go.mod h1:4rEELDSfUAlBSyUjPG0JnaNGjf13JySHFeRdD/3dLP0=
github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mewkiz/flac v1.0.7 h1:uIXEjnuXqdRaZttmSFM5v5Ukp4U6orrZsnYGGR3yow8=
github.com/mewkiz/flac v1.0.7/go.mod h1:yU74UH277dBUpqxPouHSQIar3G1X/QIclVbFahSd1pU=
github.com/mewkiz/pkg v0.0.0-20190919212034-518ade7978e2 h1:EyTNMdePWaoWsRSGQnXiSoQu0r6RS1eA557AwJhlzHU=
github.com/mewkiz/pkg v0.0.0-20190919212034-518ade7978e2/go.mod h1:3E2FUC/qYUfM8+r9zAwpeHJzqRVVMIYnpzD/clwWxyA=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
3,1,0,0,140,16,4,2,9,0,3,128,0,256,128,0,0,128,0,256,3,0,0,0,0,22,55,1,1,0,65,1,1,0,65,1,3,0,65,1,5,0,65,1,8,0,65,1,10,0,97,1,0,0,97,1,1,0,97,1,2,0,97,1,3,0,97,1,4,0,97,1,5,0,97,1,6,0,97,1,7,0,97,1,8,0,97,1,9,0,97,1,10,0,97,1,11,0,97,1,12,0,97,1,13,0,97,1,14,0,97,1,15,0,0,0,0,0,0,0,0,0,0,1,0,3,97,8,8,0,98,8,0,0,99,8,8,0,0,4,0,4,0,2,-1,-1,-1,-1,-1,-1,0,2,-1,-1,-1,-1,-1,-1,0,2,-1,-1,-1,-1,-1,-1,0,2,-1,-1,-1,-1,-1,-1,

Binary file not shown.

View File

@ -0,0 +1 @@
3,1,0,0,140,16,4,2,9,0,3,128,0,256,128,0,0,128,0,256,3,0,0,0,0,22,55,1,1,0,65,1,1,0,65,1,3,0,65,1,5,0,65,1,8,0,65,1,10,0,97,1,0,0,97,1,1,0,97,1,2,0,97,1,3,0,97,1,4,0,97,1,5,0,97,1,6,0,97,1,7,0,97,1,8,0,97,1,9,0,97,1,10,0,97,1,11,0,97,1,12,0,97,1,13,0,97,1,14,0,97,1,15,0,0,0,0,0,0,0,0,0,0,1,0,3,97,8,8,0,98,8,0,0,99,8,8,0,0,14,0,14,0,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,

View File

@ -14,14 +14,15 @@ import (
"embed"
"github.com/faiface/beep"
"github.com/faiface/beep/flac"
"github.com/faiface/beep/speaker"
"github.com/faiface/beep/wav"
"github.com/gen2brain/beeep"
"github.com/gorilla/websocket"
"github.com/sqweek/dialog"
)
//go:embed assets/alert-sat.wav
//go:embed assets/alertv3-sat.flac
var alertSoundFile embed.FS
type TypeMessage struct {
@ -85,10 +86,10 @@ var LastRetry time.Time
func Listen() {
// Init sound
alertSound, err := alertSoundFile.Open("assets/alert-sat.wav")
alertSound, err := alertSoundFile.Open("assets/alertv3-sat.flac")
utils.CheckError(err)
defer alertSound.Close()
streamer, format, err := wav.Decode(alertSound)
streamer, format, err := flac.Decode(alertSound)
utils.CheckError(err)
defer streamer.Close()
// Listen
@ -161,11 +162,11 @@ func Listen() {
if config.Config.IssueWarningSound {
speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/10))
streamer.Seek(0)
speaker.Play(streamer)
for i := 0; i < 10; i++ {
time.Sleep(2 * time.Second)
streamer.Seek(0)
}
donep := make(chan bool)
speaker.Play(beep.Seq(streamer, beep.Callback(func() {
donep <- true
})))
<-donep
speaker.Close()
}
}