Decent cava linear visualizer
This commit is contained in:
parent
8a6ac222bb
commit
31ae919a7a
7 changed files with 178 additions and 419 deletions
|
|
@ -7,43 +7,46 @@ import Quickshell.Io
|
|||
Singleton {
|
||||
id: root
|
||||
|
||||
property var values: Array(count).fill(0)
|
||||
property int count: 44
|
||||
property int noiseReduction: 60
|
||||
property string channels: "mono"
|
||||
property string monoOption: "average"
|
||||
property var values: Array(barsCount).fill(0)
|
||||
property int barsCount: 20
|
||||
|
||||
property var config: ({
|
||||
"general": {
|
||||
"bars": count,
|
||||
"framerate": 30,
|
||||
"autosens": 1
|
||||
"bars": barsCount,
|
||||
"mode": "normal",
|
||||
"framerate": 60,
|
||||
"autosens": 0,
|
||||
"overshoot": 0,
|
||||
"sensitivity": 200,
|
||||
"lower_cutoff_freq": 50,
|
||||
"higher_cutoff_freq": 12000
|
||||
},
|
||||
"smoothing": {
|
||||
"monstercat": 1,
|
||||
"gravity": 1000000,
|
||||
"noise_reduction": noiseReduction
|
||||
"gravity": 100,
|
||||
"noise_reduction": 77
|
||||
},
|
||||
"output": {
|
||||
"method": "raw",
|
||||
"bit_format": 8,
|
||||
"channels": channels,
|
||||
"mono_option": monoOption
|
||||
"channels": "mono",
|
||||
"mono_option": "average"
|
||||
}
|
||||
})
|
||||
|
||||
Process {
|
||||
id: process
|
||||
property int index: 0
|
||||
property int fillIndex: 0
|
||||
stdinEnabled: true
|
||||
running: MediaPlayer.isPlaying
|
||||
command: ["cava", "-p", "/dev/stdin"]
|
||||
onExited: {
|
||||
stdinEnabled = true
|
||||
index = 0
|
||||
values = Array(count).fill(0)
|
||||
fillIndex = 0
|
||||
values = Array(barsCount).fill(0)
|
||||
}
|
||||
onStarted: {
|
||||
|
||||
for (const k in config) {
|
||||
if (typeof config[k] !== "object") {
|
||||
write(k + "=" + config[k] + "\n")
|
||||
|
|
@ -56,20 +59,23 @@ Singleton {
|
|||
}
|
||||
}
|
||||
stdinEnabled = false
|
||||
fillIndex = 0
|
||||
values = Array(barsCount).fill(0)
|
||||
}
|
||||
stdout: SplitParser {
|
||||
splitMarker: ""
|
||||
onRead: data => {
|
||||
const newValues = Array(count).fill(0)
|
||||
for (var i = 0; i < values.length; i++) {
|
||||
newValues[i] = values[i]
|
||||
if (process.fillIndex + data.length >= barsCount) {
|
||||
process.fillIndex = 0
|
||||
}
|
||||
if (process.index + data.length > count) {
|
||||
process.index = 0
|
||||
}
|
||||
for (var i = 0; i < data.length; i += 1) {
|
||||
newValues[process.index] = Math.min(data.charCodeAt(i), 128) / 128
|
||||
process.index = (process.index + 1) % count
|
||||
|
||||
// copy array
|
||||
var newValues = values.slice(0)
|
||||
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var amp = Math.min(data.charCodeAt(i), 128) / 128
|
||||
newValues[process.fillIndex] = amp * amp
|
||||
process.fillIndex = (process.fillIndex + 1) % barsCount
|
||||
}
|
||||
values = newValues
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue