fixed nubmer of bands caused segfault after last update
master
karl 11 years ago
parent c744591eff
commit 45d0effdda
  1. 27
      cava.c

@ -213,7 +213,7 @@ int main(int argc, char **argv)
long int lpeak, hpeak; long int lpeak, hpeak;
int bands = 25; int bands = 25;
int sleep = 0; int sleep = 0;
int i, n, o, size, dir, err, bw, width, height, c, rest, virt; int i, n, o, size, dir, err, bw, width, height, c, rest, virt, fixedbands;
int autoband = 1; int autoband = 1;
//long int peakhist[bands][400]; //long int peakhist[bands][400];
float temp; float temp;
@ -262,9 +262,9 @@ int main(int argc, char **argv)
} }
break; break;
case 'b': case 'b':
bands = atoi(optarg); fixedbands = atoi(optarg);
autoband = 0; //dont automaticly add bands to fill frame autoband = 0; //dont automaticly add bands to fill frame
if (bands > 200)bands = 200; if (fixedbands > 200)fixedbands = 200;
break; break;
case 'd': case 'd':
device = optarg; device = optarg;
@ -357,11 +357,11 @@ int main(int argc, char **argv)
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
while (1) {//jumbing back to this loop means that you resized the screen while (1) {//jumbing back to this loop means that you resized the screen
//getting orignial numbers of bands incase of resize //getting orignial numbers of bands incase of resize
if (autoband == 0) { if (autoband == 1) {
bands = atoi(optarg); bands = 25;
if (bands > 200)bands = 200; }
} else bands = fixedbands;
else bands = 25;
if(bands > (int)w.ws_col / 2 - 1)bands = (int)w.ws_col / 2 - if(bands > (int)w.ws_col / 2 - 1)bands = (int)w.ws_col / 2 -
1; //handle for user setting to many bars 1; //handle for user setting to many bars
@ -417,8 +417,8 @@ int main(int argc, char **argv)
//constants to weigh signal to frequency //constants to weigh signal to frequency
for(n = 0; n < bands; for(n = 0; n < bands;
n++)k[n] = ((float)height * pow(log(lcf[n] + 1), n++)k[n] = ((float)height * pow(log(lcf[n] + 1),
2.4+((float)bands/75))) / (1024 * (M / 2+((float)bands/75))) / (1024 * (M /
10)); // the log(lcf[n]) is because higher frequencys are usally lower ine effect in music 16)); // the log(lcf[n]) is because higher frequencys are usally lower ine effect in music
@ -507,6 +507,7 @@ int main(int argc, char **argv)
if(temp > height)temp = height; //just in case if(temp > height)temp = height; //just in case
//**falloff function**// //**falloff function**//
if(temp < flast[o]) { if(temp < flast[o]) {
f[o] = fpeak[o] - (g * fall[o] * fall[o]); f[o] = fpeak[o] - (g * fall[o] * fall[o]);
fall[o]++; fall[o]++;
@ -516,11 +517,11 @@ int main(int argc, char **argv)
fall[o] = 0; fall[o] = 0;
} }
//**smoothening**// //**smoothening**//
fmem[o]+=f[o]; fmem[o]+=f[o];
fmem[o]=fmem[o]*0.55; fmem[o]=fmem[o]*0.55;
f[o]=fmem[o]; f[o]=fmem[o];

Loading…
Cancel
Save