fix: misc music fixes + add visualizer options

This commit is contained in:
ferreo
2025-07-14 23:38:31 +01:00
parent c169e7702a
commit ab29e3a084
7 changed files with 129 additions and 19 deletions
+2 -4
View File
@@ -20,6 +20,7 @@ Scope {
mono_option: monoOption,
}
})
property var values: Array(count).fill(0) // 0 <= value <= 1
Process {
@@ -28,7 +29,7 @@ Scope {
stdinEnabled: true
running: MusicManager.isPlaying
command: ["cava", "-p", "/dev/stdin"]
onExited: { stdinEnabled = true; index = 0 }
onExited: { stdinEnabled = true; index = 0; values = []; }
onStarted: {
const iniParts = []
for (const k in config) {
@@ -55,9 +56,6 @@ Scope {
newValues[i + process.index] = Math.min(data.charCodeAt(i), 128) / 128
}
process.index += data.length
if (newValues.length !== values.length) {
console.log("length!", values.length, newValues.length)
}
values = newValues
}
}
+28 -12
View File
@@ -1,5 +1,6 @@
import QtQuick
import qs.Components
import qs.Settings
Item {
id: root
@@ -9,9 +10,14 @@ Item {
property color strokeColor: "#fff"
property int strokeWidth: 0
property var values: []
property int usableOuter: 48
width: outerRadius * 2
height: outerRadius * 2
width: usableOuter * 2
height: usableOuter * 2
onOuterRadiusChanged: () => {
usableOuter = Settings.visualizerType === "fire" ? outerRadius * 0.85 : outerRadius;
}
Repeater {
model: root.values.length
@@ -19,23 +25,33 @@ Item {
property real value: root.values[index]
property real angle: (index / root.values.length) * 360
width: Math.max(2, (root.innerRadius * 2 * Math.PI) / root.values.length - 4)
height: value * (root.outerRadius - root.innerRadius)
height: Settings.visualizerType === "diamond" ? value * 2 * (usableOuter - root.innerRadius) : value * (usableOuter - root.innerRadius)
radius: width / 2
color: root.fillColor
border.color: root.strokeColor
border.width: root.strokeWidth
antialiasing: true
x: root.width / 2 + (root.innerRadius) * Math.cos(Math.PI/2 + 2 * Math.PI * index / root.values.length) - width / 2
y: root.height / 2 - (root.innerRadius) * Math.sin(Math.PI/2 + 2 * Math.PI * index / root.values.length) - height
x: Settings.visualizerType === "radial" ? root.width / 2 - width / 2 : root.width / 2 + root.innerRadius * Math.cos(Math.PI / 2 + 2 * Math.PI * index / root.values.length) - width / 2
transform: Rotation {
origin.x: width / 2
origin.y: height
angle: -angle
y: Settings.visualizerType === "radial" ? root.height / 2 - height : Settings.visualizerType === "diamond" ? root.height / 2 - root.innerRadius * Math.sin(Math.PI / 2 + 2 * Math.PI * index / root.values.length) - height / 2 : root.height / 2 - root.innerRadius * Math.sin(Math.PI / 2 + 2 * Math.PI * index / root.values.length) - height
transform: [
Rotation {
origin.x: width / 2
origin.y: Settings.visualizerType === "diamond" ? height / 2 : height
angle: Settings.visualizerType === "radial" ? (index / root.values.length) * 360 : Settings.visualizerType === "fire" ? 0 : (index / root.values.length) * 360 - 90
},
Translate {
x: Settings.visualizerType === "radial" ? root.innerRadius * Math.cos(2 * Math.PI * index / root.values.length) : 0
y: Settings.visualizerType === "radial" ? root.innerRadius * Math.sin(2 * Math.PI * index / root.values.length) : 0
}
]
Behavior on height {
SmoothedAnimation {
duration: 120
}
}
Behavior on height { SmoothedAnimation { duration: 120 } }
}
}
}
}