diff --git a/audio_unix.go b/audio_unix.go new file mode 100644 index 0000000..17a108e --- /dev/null +++ b/audio_unix.go @@ -0,0 +1,77 @@ +//go:build linux || darwin +// +build linux darwin + +package main + +import ( + "fmt" + "io" + "os" + + "github.com/gen2brain/malgo" + "github.com/youpy/go-wav" +) + +func PlayWAVFile(filename string, stopPlaying *bool) error { + file, err := os.Open(filename) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + defer file.Close() + + w := wav.NewReader(file) + f, err := w.Format() + if err != nil { + return err + } + + reader := w + channels := uint32(f.NumChannels) + sampleRate := f.SampleRate + + ctx, err := malgo.InitContext(nil, malgo.ContextConfig{}, func(message string) { + fmt.Printf("LOG <%v>\n", message) + }) + if err != nil { + return err + } + defer func() { + _ = ctx.Uninit() + ctx.Free() + }() + + deviceConfig := malgo.DefaultDeviceConfig(malgo.Playback) + deviceConfig.Playback.Format = malgo.FormatS16 + deviceConfig.Playback.Channels = channels + deviceConfig.SampleRate = sampleRate + deviceConfig.Alsa.NoMMap = 1 + + // This is the function that's used for sending more data to the device for playback. + onSamples := func(pOutputSample, pInputSamples []byte, framecount uint32) { + io.ReadFull(reader, pOutputSample) + } + + deviceCallbacks := malgo.DeviceCallbacks{ + Data: onSamples, + } + + device, err := malgo.InitDevice(ctx.Context, deviceConfig, deviceCallbacks) + if err != nil { + return err + } + defer device.Uninit() + + err = device.Start() + if err != nil { + return err + } + + for device.IsStarted() { + if *stopPlaying { + break + } + } + + return nil +} diff --git a/audio_windows.go b/audio_windows.go new file mode 100644 index 0000000..ae61599 --- /dev/null +++ b/audio_windows.go @@ -0,0 +1,45 @@ +//go:build windows +// +build windows + +package main + +import ( + "os" + "time" + + "github.com/gopxl/beep" + "github.com/gopxl/beep/speaker" + "github.com/gopxl/beep/wav" +) + +func PlayWAVFile(filename string, stopPlaying *bool) error { + f, err := os.Open(filename) + if err != nil { + return err + } + + streamer, format, err := wav.Decode(f) + if err != nil { + return err + } + defer streamer.Close() + + speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/10)) + + done := false + callbackFunc := beep.Callback(func() { + done = true + }) + + speaker.Play( + beep.Seq(streamer, callbackFunc), + ) + + for done == false { + if *stopPlaying { + break + } + } + + return nil +} diff --git a/go.mod b/go.mod index e51e88d..c423461 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,8 @@ require ( ) require ( + github.com/ebitengine/oto/v3 v3.1.0 // indirect + github.com/ebitengine/purego v0.5.0 // indirect github.com/getlantern/context v0.0.0-20220418194847-3d5e7a086201 // indirect github.com/getlantern/errors v1.0.3 // indirect github.com/getlantern/golog v0.0.0-20230503153817-8e72de7e0a65 // indirect @@ -23,8 +25,11 @@ require ( github.com/go-stack/stack v1.8.1 // indirect github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect + github.com/gopxl/beep v1.1.0 // indirect + github.com/hajimehoshi/oto v0.7.1 // indirect github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect + github.com/pkg/errors v0.9.1 // indirect github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect github.com/youpy/go-riff v0.1.0 // indirect github.com/zaf/g711 v0.0.0-20190814101024-76a4a538f52b // indirect @@ -34,5 +39,8 @@ require ( go.uber.org/goleak v1.2.1 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.26.0 // indirect + golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8 // indirect + golang.org/x/image v0.0.0-20190227222117-0694c2d4d067 // indirect + golang.org/x/mobile v0.0.0-20190415191353-3e0bab5405d6 // indirect golang.org/x/sys v0.13.0 // indirect ) diff --git a/go.sum b/go.sum index 26dab23..a9e4c69 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,15 @@ +github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/d4l3k/messagediff v1.2.2-0.20190829033028-7e0a312ae40b/go.mod h1:Oozbb1TVXFac9FtSIxHBMnBCq2qeH/2KkEQxENCrlLo= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/ebitengine/oto/v3 v3.1.0 h1:9tChG6rizyeR2w3vsygTTTVVJ9QMMyu00m2yBOCch6U= +github.com/ebitengine/oto/v3 v3.1.0/go.mod h1:IK1QTnlfZK2GIB6ziyECm433hAdTaPpOsGMLhEyEGTg= +github.com/ebitengine/purego v0.5.0 h1:JrMGKfRIAM4/QVKaesIIT7m/UVjTj5GYhRSQYwfVdpo= +github.com/ebitengine/purego v0.5.0/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ= +github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= +github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM= github.com/gen2brain/beeep v0.0.0-20230907135156-1a38885a97fc h1:NNgdMgPX3j33uEAoVVxNxillDPnxT0xbGv8uh4CKIAo= github.com/gen2brain/beeep v0.0.0-20230907135156-1a38885a97fc/go.mod h1:0W7dI87PvXJ1Sjs0QPvWXKcQmNERY77e8l7GFhZB/s4= github.com/gen2brain/malgo v0.11.10 h1:u41QchDBS7Z2rwEVPu7uycK6HA8IyzKoUOhLU7IvYW4= @@ -28,6 +36,9 @@ github.com/getlantern/ops v0.0.0-20230519221840-1283e026181c h1:qcPAzA1ZDnwx618j github.com/getlantern/ops v0.0.0-20230519221840-1283e026181c/go.mod h1:g2ueCncOwWenlAr56Fh90FwsACkelqqtFUDLAHg1mng= github.com/getlantern/systray v1.2.2 h1:dCEHtfmvkJG7HZ8lS/sLklTH4RKUcIsKrAD9sThoEBE= github.com/getlantern/systray v1.2.2/go.mod h1:pXFOI1wwqwYXEhLPm9ZGjS2u/vVELeIgNMY5HvhHhcE= +github.com/go-audio/audio v1.0.0/go.mod h1:6uAu0+H2lHkwdGsAY+j2wHPNPpPoeg5AaEFh9FlA+Zs= +github.com/go-audio/riff v1.0.0/go.mod h1:l3cQwc85y79NQFCRB7TiPoNiaijp6q8Z0Uv38rVG498= +github.com/go-audio/wav v1.0.0/go.mod h1:3yoReyQOsiARkvPl3ERCi8JFjihzG6WhjYpZCf5zAWE= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= @@ -45,14 +56,28 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/gopxl/beep v1.1.0 h1:YBfaDhZh4bC6IJfDsEi/8wmtUanir0dMIxpRu3F6Yeo= +github.com/gopxl/beep v1.1.0/go.mod h1:N5ClU2N8ESeO6ibbz5UThPRFpdEgbU9G60CLZ6u3v9s= +github.com/hajimehoshi/go-mp3 v0.3.0/go.mod h1:qMJj/CSDxx6CGHiZeCgbiq2DSUkbK0UbtXShQcnfyMM= +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/go.mod h1:0jGnlLAx8MKMr9VGnn/4YrvZiprkvBelsVIbA9Jjr9A= +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= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s= github.com/lxn/walk v0.0.0-20210112085537-c389da54e794/go.mod h1:E23UucZGqpuUANJooIbHWCufXvOcT6E7Stq81gU+CSQ= github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk= +github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mewkiz/flac v1.0.7/go.mod h1:yU74UH277dBUpqxPouHSQIar3G1X/QIclVbFahSd1pU= +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= github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw= @@ -103,8 +128,16 @@ go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8 h1:idBdZTd9UioThJp8KpM/rTSinK/ChZFBE43/WtIy8zg= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/image v0.0.0-20190220214146-31aff87c08e9/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067 h1:KYGJGHOQy8oSi1fDlSpcZF0+juKwk/hEMv5SiwHogR0= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mobile v0.0.0-20190415191353-3e0bab5405d6 h1:vyLBGJPIl9ZYbcQFM2USFmJBK6KI+t+z6jL0lbwjrnc= +golang.org/x/mobile v0.0.0-20190415191353-3e0bab5405d6/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -112,7 +145,10 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190429190828-d89cdac9e872/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/icons/darkmusicicon/darkmusicicon.ico b/icons/darkmusicicon/darkmusicicon.ico new file mode 100644 index 0000000..8f44f88 Binary files /dev/null and b/icons/darkmusicicon/darkmusicicon.ico differ diff --git a/icons/darkmusicicon/darkmusicicon_windows.go b/icons/darkmusicicon/darkmusicicon_windows.go new file mode 100644 index 0000000..75e0a12 --- /dev/null +++ b/icons/darkmusicicon/darkmusicicon_windows.go @@ -0,0 +1,37 @@ +//go:build windows +// +build windows + +// File generated by 2goarray v0.1.0 (http://github.com/cratonica/2goarray) + +package darkmusicicon + +var Data []byte = []byte{ + 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x20, 0x20, 0x02, 0x00, 0x01, 0x00, + 0x01, 0x00, 0x30, 0x01, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x87, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03, + 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x83, + 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xf3, + 0xff, 0xff, 0xff, 0xf3, 0xef, 0xff, 0xff, 0xf3, 0xcf, 0xff, 0xff, 0xf3, + 0xcf, 0xff, 0xff, 0xf3, 0x8f, 0xff, 0xff, 0xf3, 0x9f, 0xff, 0xff, 0xf0, + 0x3f, 0xff, 0xff, 0xf0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, +} diff --git a/icons/lightmusicicon/lightmusicicon.ico b/icons/lightmusicicon/lightmusicicon.ico new file mode 100644 index 0000000..4b7a40a Binary files /dev/null and b/icons/lightmusicicon/lightmusicicon.ico differ diff --git a/icons/lightmusicicon/lightmusicicon_windows.go b/icons/lightmusicicon/lightmusicicon_windows.go new file mode 100644 index 0000000..8144d82 --- /dev/null +++ b/icons/lightmusicicon/lightmusicicon_windows.go @@ -0,0 +1,37 @@ +//go:build windows +// +build windows + +// File generated by 2goarray v0.1.0 (http://github.com/cratonica/2goarray) + +package lightmusicicon + +var Data []byte = []byte{ + 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x20, 0x20, 0x02, 0x00, 0x01, 0x00, + 0x01, 0x00, 0x30, 0x01, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x87, 0xff, 0xff, 0xff, 0x03, + 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03, + 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xf3, + 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xf3, 0xef, 0xff, 0xff, 0xf3, + 0xcf, 0xff, 0xff, 0xf3, 0xcf, 0xff, 0xff, 0xf3, 0x8f, 0xff, 0xff, 0xf3, + 0x9f, 0xff, 0xff, 0xf0, 0x3f, 0xff, 0xff, 0xf0, 0x7f, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x87, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03, + 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x83, + 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xf3, + 0xff, 0xff, 0xff, 0xf3, 0xef, 0xff, 0xff, 0xf3, 0xcf, 0xff, 0xff, 0xf3, + 0xcf, 0xff, 0xff, 0xf3, 0x8f, 0xff, 0xff, 0xf3, 0x9f, 0xff, 0xff, 0xf0, + 0x3f, 0xff, 0xff, 0xf0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, +} diff --git a/main.go b/main.go index df1250a..b6e93f8 100644 --- a/main.go +++ b/main.go @@ -17,10 +17,8 @@ import ( lightmusicicon "gitea.ronald1985.uk/ronald1985/Eye-Reminder/icons/lightmusicicon" "github.com/gen2brain/beeep" - "github.com/gen2brain/malgo" "github.com/getlantern/systray" ge "github.com/ronaldr1985/graceful-exit" - "github.com/youpy/go-wav" "gopkg.in/yaml.v3" ) @@ -113,69 +111,6 @@ func SendNotification(title string, message string) bool { return true } -func PlayWAVFile(filename string, stopPlaying *bool) error { - file, err := os.Open(filename) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - defer file.Close() - - w := wav.NewReader(file) - f, err := w.Format() - if err != nil { - return err - } - - reader := w - channels := uint32(f.NumChannels) - sampleRate := f.SampleRate - - ctx, err := malgo.InitContext(nil, malgo.ContextConfig{}, func(message string) { - fmt.Printf("LOG <%v>\n", message) - }) - if err != nil { - return err - } - defer func() { - _ = ctx.Uninit() - ctx.Free() - }() - - deviceConfig := malgo.DefaultDeviceConfig(malgo.Playback) - deviceConfig.Playback.Format = malgo.FormatS16 - deviceConfig.Playback.Channels = channels - deviceConfig.SampleRate = sampleRate - deviceConfig.Alsa.NoMMap = 1 - - // This is the function that's used for sending more data to the device for playback. - onSamples := func(pOutputSample, pInputSamples []byte, framecount uint32) { - io.ReadFull(reader, pOutputSample) - } - - deviceCallbacks := malgo.DeviceCallbacks{ - Data: onSamples, - } - device, err := malgo.InitDevice(ctx.Context, deviceConfig, deviceCallbacks) - if err != nil { - return err - } - defer device.Uninit() - - err = device.Start() - if err != nil { - return err - } - - for device.IsStarted() { - if *stopPlaying { - break - } - } - - return nil -} - func systrayOnReady() { var enabled bool = true var notificationsEnabled bool = true