media controls: improve dupe entry filtering, correct cava config

This commit is contained in:
end-4
2025-06-11 22:59:16 +02:00
parent c2c7078957
commit 5a867ea061
3 changed files with 12 additions and 9 deletions
@@ -54,7 +54,7 @@ Scope {
for (let j = i + 1; j < players.length; ++j) { for (let j = i + 1; j < players.length; ++j) {
let p2 = players[j]; let p2 = players[j];
if (p1.trackTitle && p2.trackTitle && if (p1.trackTitle && p2.trackTitle &&
(p1.trackTitle.startsWith(p2.trackTitle) || p2.trackTitle.startsWith(p1.trackTitle))) { (p1.trackTitle.includes(p2.trackTitle) || p2.trackTitle.includes(p1.trackTitle))) {
group.push(j); group.push(j);
} }
} }
@@ -81,8 +81,7 @@ Scope {
stdout: SplitParser { stdout: SplitParser {
onRead: data => { onRead: data => {
// Parse `;`-separated values into the visualizerPoints array // Parse `;`-separated values into the visualizerPoints array
let allPoints = data.split(";").map(p => parseFloat(p.trim())).filter(p => !isNaN(p)); let points = data.split(";").map(p => parseFloat(p.trim())).filter(p => !isNaN(p));
let points = allPoints.slice(Math.floor(allPoints.length / 2), allPoints.length);
root.visualizerPoints = points; root.visualizerPoints = points;
} }
} }
@@ -27,6 +27,7 @@ Item { // Player instance
property bool downloaded: false property bool downloaded: false
property list<real> visualizerPoints: [] property list<real> visualizerPoints: []
property real maxVisualizerValue: 1000 // Max value in the data points property real maxVisualizerValue: 1000 // Max value in the data points
property int visualizerSmoothing: 2 // Number of points to average for smoothing
implicitWidth: widgetWidth implicitWidth: widgetWidth
implicitHeight: widgetHeight implicitHeight: widgetHeight
@@ -168,7 +169,7 @@ Item { // Player instance
// Smoothing: simple moving average (optional) // Smoothing: simple moving average (optional)
var smoothPoints = []; var smoothPoints = [];
var smoothWindow = 3; // adjust for more/less smoothing var smoothWindow = playerController.visualizerSmoothing; // adjust for more/less smoothing
for (var i = 0; i < n; ++i) { for (var i = 0; i < n; ++i) {
var sum = 0, count = 0; var sum = 0, count = 0;
for (var j = -smoothWindow; j <= smoothWindow; ++j) { for (var j = -smoothWindow; j <= smoothWindow; ++j) {
@@ -178,6 +179,7 @@ Item { // Player instance
} }
smoothPoints.push(sum / count); smoothPoints.push(sum / count);
} }
if (!playerController.player?.isPlaying) smoothedPoints.fill(0); // If not playing, show no points
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(0, h); ctx.moveTo(0, h);
@@ -193,7 +195,7 @@ Item { // Player instance
blendedColors.colPrimary.r, blendedColors.colPrimary.r,
blendedColors.colPrimary.g, blendedColors.colPrimary.g,
blendedColors.colPrimary.b, blendedColors.colPrimary.b,
0.25 0.15
); );
ctx.fill(); ctx.fill();
} }
@@ -205,16 +207,15 @@ Item { // Player instance
} }
layer.enabled: true layer.enabled: true
layer.effect: MultiEffect { // Blur a tiny bit to obscure away the points layer.effect: MultiEffect { // Blur a bit to obscure away the points
source: visualizerCanvas source: visualizerCanvas
saturation: 0.2 saturation: 0.2
blurEnabled: true blurEnabled: true
blurMax: 6 blurMax: 7
blur: 1 blur: 1
} }
} }
RowLayout { RowLayout {
anchors.fill: parent anchors.fill: parent
anchors.margins: root.contentPadding anchors.margins: root.contentPadding
@@ -2,13 +2,16 @@
mode = waves mode = waves
framerate = 60 framerate = 60
autosens = 1 autosens = 1
bars = 60 bars = 50
[output] [output]
method = raw method = raw
raw_target = /dev/stdout raw_target = /dev/stdout
data_format = ascii data_format = ascii
channels = mono
mono_option = average
[smoothing] [smoothing]
noise_reduction = 20 noise_reduction = 20