Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions CavaProcess.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ QtObject {
property int refCount: 0
property bool cavaAvailable: false
property bool isIdle: true
property int lowerCutoffFreq: 50
property int higherCutoffFreq: 12000
readonly property int effectiveLowCutoffFreq: Math.max(1, Math.min(lowerCutoffFreq, higherCutoffFreq - 1))
readonly property int effectiveHighCutoffFreq: Math.min(20000, Math.max(higherCutoffFreq, effectiveLowCutoffFreq + 1))

// Idle detection: consider idle when all values near zero for idleTimeout ms
property int idleTimeout: 2000
Expand All @@ -19,6 +23,15 @@ QtObject {
onTriggered: root.isIdle = true
}

property var _restartTimer: Timer {
interval: 30
repeat: false
onTriggered: {
if (root.cavaAvailable && root.refCount > 0)
root._cavaProcess.running = true;
}
}

property var _cavaCheck: Process {
command: ["which", "cava"]
running: false
Expand All @@ -36,8 +49,9 @@ framerate=60
bars=32
autosens=0
sensitivity=80
lower_cutoff_freq=50
higher_cutoff_freq=12000
# previous values: lower_cutoff_freq=50, higher_cutoff_freq=12000
lower_cutoff_freq=${root.effectiveLowCutoffFreq}
higher_cutoff_freq=${root.effectiveHighCutoffFreq}

[output]
method=raw
Expand Down Expand Up @@ -92,4 +106,18 @@ CAVACONF`]
Component.onCompleted: {
_cavaCheck.running = true;
}

onLowerCutoffFreqChanged: {
if (_cavaProcess.running) {
_cavaProcess.running = false;
_restartTimer.restart();
}
}

onHigherCutoffFreqChanged: {
if (_cavaProcess.running) {
_cavaProcess.running = false;
_restartTimer.restart();
}
}
}
10 changes: 10 additions & 0 deletions DankAudioVisualizer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ DesktopPluginComponent {
readonly property string visualizationMode: pluginData.visualizationMode ?? "barsRings"
readonly property real waveThickness: 0.3 + (pluginData.waveThickness ?? 41) / 100.0 * 1.7 // 0% → 0.3, 100% → 2.0
readonly property real innerDiameter: (pluginData.innerDiameter ?? 70) / 100.0 // 0% → 0.0, 100% → 1.0
readonly property int lowerCutoffFreq: {
const n = Number(pluginData.lowerCutoffFreq ?? 50)
return Number.isFinite(n) ? Math.round(n) : 50
}
readonly property int higherCutoffFreq: {
const n = Number(pluginData.higherCutoffFreq ?? 12000)
return Number.isFinite(n) ? Math.round(n) : 12000
}
readonly property bool fadeWhenIdle: pluginData.fadeWhenIdle ?? false
readonly property bool useCustomColors: pluginData.useCustomColors ?? false
readonly property color customPrimaryColor: pluginData.customPrimaryColor ?? "#6750A4"
Expand All @@ -39,6 +47,8 @@ DesktopPluginComponent {
// Self-contained cava audio source (32 bars, 60 FPS)
CavaProcess {
id: cavaProcess
lowerCutoffFreq: root.lowerCutoffFreq
higherCutoffFreq: root.higherCutoffFreq
}

// Manage cava lifecycle via reference counting
Expand Down
16 changes: 16 additions & 0 deletions DankAudioVisualizerSettings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ PluginSettings {
unit: "%"
}

StringSetting {
settingKey: "lowerCutoffFreq"
label: "Low Cutoff Frequency"
description: "Lower bound of the frequency range analyzed by cava (1-19999 Hz)"
placeholder: "50"
defaultValue: "50"
}

StringSetting {
settingKey: "higherCutoffFreq"
label: "High Cutoff Frequency"
description: "Upper bound of the frequency range analyzed by cava (2-20000 Hz)"
placeholder: "12000"
defaultValue: "12000"
}

ToggleSetting {
settingKey: "fadeWhenIdle"
label: "Fade When Idle"
Expand Down