fix bug where left channel was replaced by right channel, this resolves #335

master
karlstav 6 years ago
parent 6407af045b
commit 47ab43b279
  1. 27
      cava.c

@ -58,6 +58,9 @@
#define GCC_UNUSED /* nothing */ #define GCC_UNUSED /* nothing */
#endif #endif
#define LEFT_CHANNEL 1
#define RIGHT_CHANNEL 2
// struct termios oldtio, newtio; // struct termios oldtio, newtio;
// int M = 8 * 1024; // int M = 8 * 1024;
@ -170,13 +173,13 @@ int *separate_freq_bands(int FFTbassbufferSize, fftw_complex out_bass[FFTbassbuf
// printf("%d peak o: %f * sens: %f * k: %f = f: %f\n", o, peak[o], sens, k[o], temp); // printf("%d peak o: %f * sens: %f * k: %f = f: %f\n", o, peak[o], sens, k[o], temp);
if (temp <= ignore) if (temp <= ignore)
temp = 0; temp = 0;
if (channel == 1) if (channel == LEFT_CHANNEL)
fl[o] = temp; fl[o] = temp;
else else
fr[o] = temp; fr[o] = temp;
} }
if (channel == 1) if (channel == LEFT_CHANNEL)
return fl; return fl;
else else
return fr; return fr;
@ -843,15 +846,17 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co
fftw_execute(p_treble_l); fftw_execute(p_treble_l);
fftw_execute(p_treble_r); fftw_execute(p_treble_r);
fl = separate_freq_bands( fl = separate_freq_bands(audio.FFTbassbufferSize, out_bass_l,
audio.FFTbassbufferSize, out_bass_l, audio.FFTmidbufferSize, out_mid_l, audio.FFTmidbufferSize, out_mid_l,
audio.FFTtreblebufferSize, out_treble_l, bass_cut_off_bar, audio.FFTtreblebufferSize, out_treble_l,
treble_cut_off_bar, bars / 2, lcf, hcf, k, 1, p.sens, p.ignore); bass_cut_off_bar, treble_cut_off_bar, bars / 2,
lcf, hcf, k, LEFT_CHANNEL, p.sens, p.ignore);
fr = separate_freq_bands( fr = separate_freq_bands(audio.FFTbassbufferSize, out_bass_r,
audio.FFTbassbufferSize, out_bass_r, audio.FFTmidbufferSize, out_mid_r, audio.FFTmidbufferSize, out_mid_r,
audio.FFTtreblebufferSize, out_treble_r, bass_cut_off_bar, audio.FFTtreblebufferSize, out_treble_r,
treble_cut_off_bar, bars / 2, lcf, hcf, k, 1, p.sens, p.ignore); bass_cut_off_bar, treble_cut_off_bar, bars / 2,
lcf, hcf, k, RIGHT_CHANNEL, p.sens, p.ignore);
} else { } else {
fftw_execute(p_bass_l); fftw_execute(p_bass_l);
@ -860,7 +865,7 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co
fl = separate_freq_bands( fl = separate_freq_bands(
audio.FFTbassbufferSize, out_bass_l, audio.FFTmidbufferSize, out_mid_l, audio.FFTbassbufferSize, out_bass_l, audio.FFTmidbufferSize, out_mid_l,
audio.FFTtreblebufferSize, out_treble_l, bass_cut_off_bar, audio.FFTtreblebufferSize, out_treble_l, bass_cut_off_bar,
treble_cut_off_bar, bars, lcf, hcf, k, 1, p.sens, p.ignore); treble_cut_off_bar, bars, lcf, hcf, k, LEFT_CHANNEL, p.sens, p.ignore);
} }
} else { //**if in sleep mode wait and continue**// } else { //**if in sleep mode wait and continue**//

Loading…
Cancel
Save