mirror of
https://github.com/BlackLight/Voxifera.git
synced 2024-11-30 22:55:10 +01:00
Little corrections to dsp command line parsing and small optimization on main.c
This commit is contained in:
parent
4a52ddf55c
commit
51687876a7
3 changed files with 7 additions and 11 deletions
2
Makefile
2
Makefile
|
@ -1,5 +1,5 @@
|
||||||
all:
|
all:
|
||||||
gcc -Wall -ansi -pedantic -o vocal main.c dsp.c utils.c -lm -w -O3 -funroll-loops -fno-rtti -ffast-math -fno-stack-protector -ffunction-sections
|
gcc -Wall -ansi -pedantic -o vocal main.c dsp.c utils.c -lm -w -O3 -funroll-loops -fno-rtti -ffast-math -fno-stack-protector -ffunction-sections -funsafe-math-optimizations -fno-trapping-math
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm vocal
|
rm vocal
|
||||||
|
|
3
dsp.c
3
dsp.c
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
int init_dsp( char *device ) {
|
int init_dsp( char *device ) {
|
||||||
int dsp, arg;
|
int dsp, arg;
|
||||||
|
char *dev = (device == NULL ? "/dev/dsp" : device);
|
||||||
|
|
||||||
if ((dsp=open( (device == NULL ? "/dev/dsp" : device), O_RDONLY)) < 0) {
|
if ((dsp=open( dev, O_RDONLY)) < 0) {
|
||||||
perror("open of sound device failed");
|
perror("open of sound device failed");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
11
main.c
11
main.c
|
@ -18,7 +18,7 @@ int main (int argc, char **argv) {
|
||||||
int i, j, dsp, fd, ch, size, recognized;
|
int i, j, dsp, fd, ch, size, recognized;
|
||||||
int TOTSIZE = BUF_SIZE*SAMPLE_SIZE;
|
int TOTSIZE = BUF_SIZE*SAMPLE_SIZE;
|
||||||
|
|
||||||
char *line, *tmp, *cmd = NULL, *fname = NULL, device = NULL;
|
char *line, *tmp, *cmd = NULL, *fname = NULL, *device = NULL;
|
||||||
char **match = NULL;
|
char **match = NULL;
|
||||||
|
|
||||||
double deviance;
|
double deviance;
|
||||||
|
@ -46,7 +46,7 @@ int main (int argc, char **argv) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printf( "DEVICE : %s\n", device );
|
||||||
buf = (u8*) malloc(TOTSIZE);
|
buf = (u8*) malloc(TOTSIZE);
|
||||||
neutral = (double*) malloc(TOTSIZE*sizeof(double));
|
neutral = (double*) malloc(TOTSIZE*sizeof(double));
|
||||||
trans = (double*) malloc(TOTSIZE*sizeof(double));
|
trans = (double*) malloc(TOTSIZE*sizeof(double));
|
||||||
|
@ -78,8 +78,7 @@ int main (int argc, char **argv) {
|
||||||
|
|
||||||
close(dsp);
|
close(dsp);
|
||||||
|
|
||||||
printf ("capture done, computing DCT...\n");
|
printf ("capture done, computing DCT...\n" );
|
||||||
int count = 0;
|
|
||||||
t1 = time((unsigned) NULL);
|
t1 = time((unsigned) NULL);
|
||||||
|
|
||||||
for (i=0; i<TOTSIZE; ++i) {
|
for (i=0; i<TOTSIZE; ++i) {
|
||||||
|
@ -91,9 +90,6 @@ int main (int argc, char **argv) {
|
||||||
v += buf[j] * cos(t*j);
|
v += buf[j] * cos(t*j);
|
||||||
else
|
else
|
||||||
v += buf[j];
|
v += buf[j];
|
||||||
|
|
||||||
if (t*j < D_M_PI)
|
|
||||||
count++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
v *= coeff;
|
v *= coeff;
|
||||||
|
@ -107,7 +103,6 @@ int main (int argc, char **argv) {
|
||||||
|
|
||||||
t2 = time((unsigned) NULL);
|
t2 = time((unsigned) NULL);
|
||||||
printf ("DCT computing: done in %u seconds\n", (unsigned int) (t2-t1));
|
printf ("DCT computing: done in %u seconds\n", (unsigned int) (t2-t1));
|
||||||
printf ("%d arg < 2*pi\n", count);
|
|
||||||
|
|
||||||
for (i=0; i<TOTSIZE; i++)
|
for (i=0; i<TOTSIZE; i++)
|
||||||
sum += trans[i];
|
sum += trans[i];
|
||||||
|
|
Loading…
Reference in a new issue