Cava: Switched to ascii mode - buttery smooth
Fixes a nasty glitch where band would jump abruptly due to wrong data parsing.
This commit is contained in:
parent
ca528695a1
commit
93b60e9002
2 changed files with 4 additions and 32 deletions
|
|
@ -24,12 +24,6 @@ Item {
|
||||||
height: root.height * amp
|
height: root.height * amp
|
||||||
x: index * xScale
|
x: index * xScale
|
||||||
y: root.height - height
|
y: root.height - height
|
||||||
|
|
||||||
Behavior on height {
|
|
||||||
SmoothedAnimation {
|
|
||||||
duration: 33
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,12 +41,6 @@ Item {
|
||||||
height: root.height * amp
|
height: root.height * amp
|
||||||
x: (values.length + index) * xScale
|
x: (values.length + index) * xScale
|
||||||
y: root.height - height
|
y: root.height - height
|
||||||
|
|
||||||
Behavior on height {
|
|
||||||
SmoothedAnimation {
|
|
||||||
duration: 33
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ Singleton {
|
||||||
property var config: ({
|
property var config: ({
|
||||||
"general": {
|
"general": {
|
||||||
"bars": barsCount,
|
"bars": barsCount,
|
||||||
"framerate": 40,
|
"framerate": 60,
|
||||||
"autosens": 0,
|
"autosens": 0,
|
||||||
"overshoot": 0,
|
"overshoot": 0,
|
||||||
"sensitivity": 200,
|
"sensitivity": 200,
|
||||||
|
|
@ -26,7 +26,8 @@ Singleton {
|
||||||
},
|
},
|
||||||
"output": {
|
"output": {
|
||||||
"method": "raw",
|
"method": "raw",
|
||||||
"data_format": "binary",
|
"data_format": "ascii",
|
||||||
|
"ascii_max_range": 100,
|
||||||
"bit_format": "8bit",
|
"bit_format": "8bit",
|
||||||
"channels": "mono",
|
"channels": "mono",
|
||||||
"mono_option": "average"
|
"mono_option": "average"
|
||||||
|
|
@ -35,17 +36,14 @@ Singleton {
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: process
|
id: process
|
||||||
property int fillIndex: 0
|
|
||||||
stdinEnabled: true
|
stdinEnabled: true
|
||||||
running: MediaPlayer.isPlaying
|
running: MediaPlayer.isPlaying
|
||||||
command: ["cava", "-p", "/dev/stdin"]
|
command: ["cava", "-p", "/dev/stdin"]
|
||||||
onExited: {
|
onExited: {
|
||||||
stdinEnabled = true
|
stdinEnabled = true
|
||||||
fillIndex = 0
|
|
||||||
values = Array(barsCount).fill(0)
|
values = Array(barsCount).fill(0)
|
||||||
}
|
}
|
||||||
onStarted: {
|
onStarted: {
|
||||||
|
|
||||||
for (const k in config) {
|
for (const k in config) {
|
||||||
if (typeof config[k] !== "object") {
|
if (typeof config[k] !== "object") {
|
||||||
write(k + "=" + config[k] + "\n")
|
write(k + "=" + config[k] + "\n")
|
||||||
|
|
@ -58,25 +56,11 @@ Singleton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stdinEnabled = false
|
stdinEnabled = false
|
||||||
fillIndex = 0
|
|
||||||
values = Array(barsCount).fill(0)
|
values = Array(barsCount).fill(0)
|
||||||
}
|
}
|
||||||
stdout: SplitParser {
|
stdout: SplitParser {
|
||||||
splitMarker: ""
|
|
||||||
onRead: data => {
|
onRead: data => {
|
||||||
if (process.fillIndex + data.length >= barsCount) {
|
root.values = data.slice(0, -1).split(";").map(v => parseInt(v, 10) / 100)
|
||||||
process.fillIndex = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
|
||||||
process.fillIndex = (process.fillIndex + 1) % barsCount
|
|
||||||
}
|
|
||||||
values = newValues
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue