fix: tweak cava settings + improve the cava code to be more reliable
This commit is contained in:
parent
d6d206ea12
commit
4dacc2143d
1 changed files with 70 additions and 56 deletions
|
|
@ -1,63 +1,77 @@
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import qs.Components
|
|
||||||
import qs.Services
|
import qs.Services
|
||||||
|
|
||||||
Scope {
|
Scope {
|
||||||
id: root
|
id: root
|
||||||
property int count: 32
|
property int count: 32
|
||||||
property int noiseReduction: 60
|
property int noiseReduction: 60
|
||||||
property string channels: "mono" // or stereo
|
property string channels: "mono"
|
||||||
property string monoOption: "average" // or left or right
|
property string monoOption: "average"
|
||||||
property var config: ({
|
|
||||||
general: { bars: count },
|
|
||||||
smoothing: { noise_reduction: noiseReduction },
|
|
||||||
output: {
|
|
||||||
method: "raw",
|
|
||||||
bit_format: 8,
|
|
||||||
channels: channels,
|
|
||||||
mono_option: monoOption,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
property var values: Array(count).fill(0) // 0 <= value <= 1
|
|
||||||
|
|
||||||
Process {
|
property var config: ({
|
||||||
property int index: 0
|
general: {
|
||||||
id: process
|
bars: count,
|
||||||
stdinEnabled: true
|
framerate: 30,
|
||||||
running: MusicManager.isPlaying
|
autosens: 1
|
||||||
command: ["cava", "-p", "/dev/stdin"]
|
},
|
||||||
onExited: { stdinEnabled = true; index = 0; values = []; }
|
smoothing: {
|
||||||
onStarted: {
|
monstercat: 1,
|
||||||
const iniParts = []
|
gravity: 1000000,
|
||||||
for (const k in config) {
|
noise_reduction: noiseReduction
|
||||||
if (typeof config[k] !== "object") {
|
},
|
||||||
write(k + "=" + config[k] + "\n")
|
output: {
|
||||||
continue
|
method: "raw",
|
||||||
}
|
bit_format: 8,
|
||||||
write("[" + k + "]\n")
|
channels: channels,
|
||||||
const obj = config[k]
|
mono_option: monoOption
|
||||||
for (const k2 in obj) {
|
}
|
||||||
write(k2 + "=" + obj[k2] + "\n")
|
})
|
||||||
}
|
|
||||||
}
|
property var values: Array(count).fill(0)
|
||||||
stdinEnabled = false
|
|
||||||
}
|
Process {
|
||||||
stdout: SplitParser {
|
id: process
|
||||||
property var newValues: Array(count).fill(0)
|
property int index: 0
|
||||||
splitMarker: ""
|
stdinEnabled: true
|
||||||
onRead: data => {
|
running: MusicManager.isPlaying
|
||||||
if (process.index + data.length > config.general.bars) {
|
command: ["cava", "-p", "/dev/stdin"]
|
||||||
process.index = 0
|
onExited: {
|
||||||
}
|
stdinEnabled = true;
|
||||||
for (let i = 0; i < data.length; i += 1) {
|
index = 0;
|
||||||
newValues[i + process.index] = Math.min(data.charCodeAt(i), 128) / 128
|
values = Array(count).fill(0);
|
||||||
}
|
}
|
||||||
process.index += data.length
|
onStarted: {
|
||||||
values = newValues
|
for (const k in config) {
|
||||||
}
|
if (typeof config[k] !== "object") {
|
||||||
}
|
write(k + "=" + config[k] + "\n");
|
||||||
}
|
continue;
|
||||||
}
|
}
|
||||||
|
write("[" + k + "]\n");
|
||||||
|
const obj = config[k];
|
||||||
|
for (const k2 in obj) {
|
||||||
|
write(k2 + "=" + obj[k2] + "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stdinEnabled = false;
|
||||||
|
}
|
||||||
|
stdout: SplitParser {
|
||||||
|
splitMarker: ""
|
||||||
|
onRead: data => {
|
||||||
|
const newValues = Array(count).fill(0);
|
||||||
|
for (let i = 0; i < values.length; i++) {
|
||||||
|
newValues[i] = values[i];
|
||||||
|
}
|
||||||
|
if (process.index + data.length > count) {
|
||||||
|
process.index = 0;
|
||||||
|
}
|
||||||
|
for (let i = 0; i < data.length; i += 1) {
|
||||||
|
newValues[i + process.index] = Math.min(data.charCodeAt(i), 128) / 128;
|
||||||
|
}
|
||||||
|
process.index += data.length;
|
||||||
|
values = newValues;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue