2024-10-20 22:58:09 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/binary"
|
|
|
|
"xyosc/audio"
|
|
|
|
"xyosc/config"
|
2024-10-21 00:44:44 +02:00
|
|
|
"xyosc/media"
|
2024-10-20 22:58:09 +02:00
|
|
|
|
|
|
|
rl "github.com/gen2brain/raylib-go/raylib"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
config.Init()
|
|
|
|
audio.Init()
|
|
|
|
go audio.Start()
|
2024-10-21 00:44:44 +02:00
|
|
|
go media.Start()
|
2024-10-20 22:58:09 +02:00
|
|
|
|
|
|
|
scale := min(config.Config.WindowWidth, config.Config.WindowHeight) / 2
|
|
|
|
rl.InitWindow(config.Config.WindowWidth, config.Config.WindowHeight, "xyosc")
|
|
|
|
defer rl.CloseWindow()
|
2024-10-21 00:07:12 +02:00
|
|
|
rl.SetWindowOpacity(config.Config.WindowOpacity)
|
2024-10-20 22:58:09 +02:00
|
|
|
rl.SetConfigFlags(rl.FlagWindowTransparent)
|
2024-10-20 23:45:40 +02:00
|
|
|
rl.SetConfigFlags(rl.FlagMsaa4xHint)
|
2024-10-20 22:58:09 +02:00
|
|
|
rl.SetWindowState(rl.FlagWindowUndecorated)
|
|
|
|
rl.SetTargetFPS(config.Config.TargetFPS)
|
|
|
|
rl.SetWindowPosition(rl.GetMonitorWidth(rl.GetCurrentMonitor())/2, rl.GetMonitorHeight(rl.GetCurrentMonitor())/2)
|
|
|
|
var AX float32
|
|
|
|
var AY float32
|
|
|
|
var BX float32
|
|
|
|
var BY float32
|
|
|
|
for !rl.WindowShouldClose() {
|
|
|
|
rl.BeginDrawing()
|
|
|
|
rl.ClearBackground(rl.Blank)
|
|
|
|
|
|
|
|
binary.Read(audio.SampleRingBuffer, binary.NativeEndian, &AX)
|
|
|
|
binary.Read(audio.SampleRingBuffer, binary.NativeEndian, &AY)
|
|
|
|
for i := uint32(0); i < config.Config.ReadBufferSize/audio.SampleSizeInBytes/2; i++ {
|
|
|
|
binary.Read(audio.SampleRingBuffer, binary.NativeEndian, &BX)
|
|
|
|
binary.Read(audio.SampleRingBuffer, binary.NativeEndian, &BY)
|
|
|
|
fAX := float32(AX) * config.Config.Gain * float32(scale)
|
|
|
|
fAY := -float32(AY) * config.Config.Gain * float32(scale)
|
|
|
|
fBX := float32(BX) * config.Config.Gain * float32(scale)
|
|
|
|
fBY := -float32(BY) * config.Config.Gain * float32(scale)
|
|
|
|
rl.DrawLineEx(rl.NewVector2(float32(config.Config.WindowWidth/2)+fAX, float32(config.Config.WindowWidth/2)+fAY), rl.NewVector2(float32(config.Config.WindowWidth/2)+fBX, float32(config.Config.WindowWidth/2)+fBY), config.Config.LineThickness, config.AccentColor)
|
|
|
|
AX = BX
|
|
|
|
AY = BY
|
|
|
|
}
|
|
|
|
if config.Config.FPSCounter {
|
2024-10-21 00:44:44 +02:00
|
|
|
rl.DrawFPS(16, config.Config.WindowHeight)
|
2024-10-20 22:58:09 +02:00
|
|
|
}
|
2024-10-21 00:44:44 +02:00
|
|
|
rl.DrawText(media.PlayingMediaInfo.Artist+" - "+media.PlayingMediaInfo.Title, 16, 16, 32, config.AccentColor)
|
|
|
|
rl.DrawText(media.PlayingMediaInfo.Album, 16, 48, 16, config.ThirdColor)
|
|
|
|
rl.DrawText(media.FmtDuration(media.PlayingMediaInfo.Position)+" / "+media.FmtDuration(media.PlayingMediaInfo.Duration), 16, 64, 32, config.AccentColor)
|
2024-10-20 22:58:09 +02:00
|
|
|
rl.EndDrawing()
|
|
|
|
}
|
|
|
|
|
|
|
|
rl.CloseWindow()
|
|
|
|
}
|