mirror of
https://github.com/make-42/xyosc
synced 2024-11-22 17:20:09 +01:00
feat: add transparency
This commit is contained in:
parent
a777d6da08
commit
b687d1622e
@ -2,6 +2,7 @@ package audio
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"xyosc/config"
|
||||
"xyosc/utils"
|
||||
|
||||
@ -15,10 +16,8 @@ var SampleSizeInBytes uint32
|
||||
const format = malgo.FormatF32
|
||||
|
||||
func Init() {
|
||||
deviceConfig := malgo.DefaultDeviceConfig(malgo.Duplex)
|
||||
SampleRingBuffer = ringbuffer.New(int(config.Config.RingBufferSize))
|
||||
deviceConfig.Capture.Format = format
|
||||
SampleSizeInBytes = uint32(malgo.SampleSizeInBytes(deviceConfig.Capture.Format))
|
||||
SampleSizeInBytes = uint32(malgo.SampleSizeInBytes(format))
|
||||
}
|
||||
|
||||
func Start() {
|
||||
@ -31,11 +30,31 @@ func Start() {
|
||||
ctx.Free()
|
||||
}()
|
||||
|
||||
deviceConfig := malgo.DefaultDeviceConfig(malgo.Duplex)
|
||||
// Capture devices.
|
||||
infos, err := ctx.Devices(malgo.Capture)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Println("Capture Devices")
|
||||
for i, info := range infos {
|
||||
e := "ok"
|
||||
full, err := ctx.DeviceInfo(malgo.Capture, info.ID, malgo.Shared)
|
||||
if err != nil {
|
||||
e = err.Error()
|
||||
}
|
||||
fmt.Printf(" %d: %v, %s, [%s], formats: %+v\n",
|
||||
i, info.ID, info.Name(), e, full.Formats)
|
||||
}
|
||||
|
||||
deviceConfig := malgo.DefaultDeviceConfig(malgo.Capture)
|
||||
deviceConfig.Capture.Format = format
|
||||
deviceConfig.Capture.Channels = 2
|
||||
deviceConfig.Capture.DeviceID = infos[config.Config.CaptureDeviceIndex].ID.Pointer()
|
||||
deviceConfig.SampleRate = config.Config.SampleRate
|
||||
deviceConfig.Alsa.NoMMap = 1
|
||||
|
||||
onRecvFrames := func(pSample2, pSample []byte, framecount uint32) {
|
||||
SampleRingBuffer.Write(pSample)
|
||||
}
|
||||
@ -49,7 +68,6 @@ func Start() {
|
||||
err = device.Start()
|
||||
|
||||
utils.CheckError(err)
|
||||
for {
|
||||
}
|
||||
select {}
|
||||
//device.Uninit()
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ type ConfigS struct {
|
||||
TargetFPS int32
|
||||
WindowWidth int32
|
||||
WindowHeight int32
|
||||
WindowOpacity float32
|
||||
CaptureDeviceIndex int
|
||||
SampleRate uint32
|
||||
RingBufferSize uint32
|
||||
ReadBufferSize uint32
|
||||
@ -30,8 +32,10 @@ var DefaultConfig = ConfigS{
|
||||
TargetFPS: 60,
|
||||
WindowWidth: 800,
|
||||
WindowHeight: 800,
|
||||
WindowOpacity: 0.9,
|
||||
CaptureDeviceIndex: 0,
|
||||
SampleRate: 192000,
|
||||
RingBufferSize: 192000 * 4,
|
||||
RingBufferSize: 192000,
|
||||
ReadBufferSize: 192000,
|
||||
Gain: 1,
|
||||
LineOpacity: 50,
|
||||
|
2
main.go
2
main.go
@ -16,7 +16,7 @@ func main() {
|
||||
scale := min(config.Config.WindowWidth, config.Config.WindowHeight) / 2
|
||||
rl.InitWindow(config.Config.WindowWidth, config.Config.WindowHeight, "xyosc")
|
||||
defer rl.CloseWindow()
|
||||
rl.SetWindowOpacity(0.5)
|
||||
rl.SetWindowOpacity(config.Config.WindowOpacity)
|
||||
rl.SetConfigFlags(rl.FlagWindowTransparent)
|
||||
rl.SetConfigFlags(rl.FlagMsaa4xHint)
|
||||
rl.SetWindowState(rl.FlagWindowUndecorated)
|
||||
|
Loading…
Reference in New Issue
Block a user