Skip to content

Commit

Permalink
#573: fix waves filter with very high bar values (raw output)
Browse files Browse the repository at this point in the history
  • Loading branch information
karlstav committed Jun 18, 2024
1 parent d59dde4 commit f04365c
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions cava.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,23 +168,28 @@ static bool directory_exists(const char *path) {

#endif

float *monstercat_filter(float *bars, int number_of_bars, int waves, double monstercat) {
float *monstercat_filter(float *bars, int number_of_bars, int waves, double monstercat,
int height) {

int z;

// process [smoothing]: monstercat-style "average"

int m_y, de;
int height_normalizer = 1;
if (height > 1000) {
height_normalizer = height / 1000;
}
if (waves > 0) {
for (z = 0; z < number_of_bars; z++) { // waves
bars[z] = bars[z] / 1.25;
// if (bars[z] < 1) bars[z] = 1;
for (m_y = z - 1; m_y >= 0; m_y--) {
de = z - m_y;
de = (z - m_y) * height_normalizer;
bars[m_y] = max(bars[z] - pow(de, 2), bars[m_y]);
}
for (m_y = z + 1; m_y < number_of_bars; m_y++) {
de = m_y - z;
de = (m_y - z) * height_normalizer;
bars[m_y] = max(bars[z] - pow(de, 2), bars[m_y]);
}
}
Expand Down Expand Up @@ -985,14 +990,15 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co
// process [filter]
if (p.monstercat) {
if (audio_channels == 2) {
bars_left = monstercat_filter(
bars_left, number_of_bars / output_channels, p.waves, p.monstercat);
bars_left =
monstercat_filter(bars_left, number_of_bars / output_channels,
p.waves, p.monstercat, *dimension_value);
bars_right =
monstercat_filter(bars_right, number_of_bars / output_channels,
p.waves, p.monstercat);
p.waves, p.monstercat, *dimension_value);
} else {
bars_raw =
monstercat_filter(bars_raw, number_of_bars, p.waves, p.monstercat);
bars_raw = monstercat_filter(bars_raw, number_of_bars, p.waves,
p.monstercat, *dimension_value);
}
}
if (audio_channels == 2) {
Expand Down

0 comments on commit f04365c

Please sign in to comment.