aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2009-04-15 04:15:39 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2009-04-15 04:15:39 +0000
commitdfcdf5e7a6ef65bac688ab8a7c017a9e34ce5561 (patch)
treea9f9704cd5c83cd7cd8c6e7e472fa4a904d174fa
parentf1ab17519a1993805667994ba4b289d5870ad252 (diff)
oops, now the file loading was loading into unallocated memory, so now if the file is found, just write over the earplug_impulses struct that comes from earplug~.h (fixed bug #2763275)
svn path=/trunk/externals/earplug~/; revision=11027
-rw-r--r--earplug~.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/earplug~.c b/earplug~.c
index faa85fb..d70c786 100644
--- a/earplug~.c
+++ b/earplug~.c
@@ -187,27 +187,21 @@ static void *earplug_new(t_floatarg azimArg, t_floatarg elevArg)
filedesc = open_via_path(canvas_getdir(canvas_getcurrent())->s_name, "earplug_data.txt", "", buff, &bufptr, 1024, 0 );
- if (filedesc < 0) // If there was an error opening the text file...
+ if (filedesc >= 0) // If there was no error opening the text file...
{
- x->impulses = earplug_impulses;
- post("warning: didn't find impulse reponse file 'earplug_data.txt', using defaults.\n") ;
- } else {
- post("let's try loading");
- //x->impulses = getbytes(sizeof(t_float)*368*2*128);
+ post("[earplug~] found impulse reponse file, overriding defaults:") ;
+ post("let's try loading %s/earplug_data.txt", buff);
fp = fdopen(filedesc, "r") ;
for (i = 0; i < 368; i++)
{
- fprintf(stderr, "i%d ", i);
while(fgetc(fp) != 10) ;
for (j = 0 ; j < 128 ; j++) {
- fprintf(stderr, "j%d ", j);
-
- fscanf(fp, "%f %f ", &x->impulses[i][0][j], &x->impulses[i][1][j]);
+ fscanf(fp, "%f %f ", &earplug_impulses[i][0][j], &earplug_impulses[i][1][j]);
}
-
}
fclose(fp) ;
}
+ x->impulses = earplug_impulses;
post(" earplug~: binaural filter with measured reponses\n") ;
post(" elevation: -40 to 90 degrees. azimuth: 360") ;