2024-10-20 22:58:09 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/binary"
|
|
|
|
"xyosc/audio"
|
|
|
|
"xyosc/config"
|
2024-10-21 01:30:26 +02:00
|
|
|
"xyosc/fonts"
|
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
|
2024-10-21 01:30:26 +02:00
|
|
|
|
|
|
|
fonts.Init()
|
2024-10-20 22:58:09 +02:00
|
|
|
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
|
|
|
|
}
|
2024-10-21 12:18:55 +02:00
|
|
|
//audio.SampleRingBuffer.Reset()
|
2024-10-20 22:58:09 +02:00
|
|
|
if config.Config.FPSCounter {
|
2024-10-21 13:56:50 +02:00
|
|
|
rl.DrawFPS(16, config.Config.WindowHeight-32)
|
2024-10-20 22:58:09 +02:00
|
|
|
}
|
2024-10-21 01:30:26 +02:00
|
|
|
rl.DrawTextEx(fonts.FontIosevka32, media.PlayingMediaInfo.Artist+" - "+media.PlayingMediaInfo.Title, rl.NewVector2(16, 16), 32, 2, config.AccentColor)
|
|
|
|
rl.DrawTextEx(fonts.FontIosevka16, media.PlayingMediaInfo.Album, rl.NewVector2(16, 48), 16, 1, config.ThirdColor)
|
|
|
|
rl.DrawTextEx(fonts.FontIosevka32, media.FmtDuration(media.PlayingMediaInfo.Position)+" / "+media.FmtDuration(media.PlayingMediaInfo.Duration), rl.NewVector2(16, 64), 32, 2, config.AccentColor)
|
2024-10-20 22:58:09 +02:00
|
|
|
rl.EndDrawing()
|
|
|
|
}
|
|
|
|
|
|
|
|
rl.CloseWindow()
|
|
|
|
}
|