Update of /cvsroot/audacity/audacity-src/src/effects
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv30280/src/effects
Modified Files:
Equalization.cpp
Log Message:
Correct the time-shift introduced by a real-world filter.
Index: Equalization.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/Equalization.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- Equalization.cpp 13 Mar 2007 07:09:15 -0000 1.57
+++ Equalization.cpp 14 Mar 2007 00:00:32 -0000 1.58
@@ -406,6 +406,9 @@
TrackProgress(count, 0.);
+ int wcopy;
+ int offset = (mM - 1)/2;
+
while(len)
{
sampleCount block = idealBlockLen;
@@ -418,7 +421,7 @@
for(i=0; i<block; i+=L) //go through block in lumps of length L
{
- int wcopy = L;
+ wcopy = L;
if (i + wcopy > block) //if last lump would exceed block
wcopy = block - i; //shorten it
for(j=0; j<wcopy; j++)
@@ -430,15 +433,30 @@
Filter(windowSize, thisWindow);
- for(j=0; j<mM-1; j++)
- buffer[i+j] = thisWindow[j] + lastWindow[L + j];
- for(j=mM-1; j<wcopy; j++)
- buffer[i+j] = thisWindow[j];
+ //when copying samples from the output of the filter back to the
buffer,
+ //offset them by half the filter length. This makes the filter
acausal
+ //but eliminates the delay.
+ //This means we start 'offset' samples into the filter's output.
+ if(i == 0)
+ {
+ for(j=offset; j<wcopy; j++)
+ buffer[i+j-offset] = thisWindow[j];
+ }
+ else
+ {
+ for(j=0; j<mM-1; j++)
+ buffer[i+j-offset] = thisWindow[j] + lastWindow[L + j];
+ for(j=mM-1; j<wcopy; j++)
+ buffer[i+j-offset] = thisWindow[j];
+ }
float *tempP = thisWindow;
thisWindow = lastWindow;
lastWindow = tempP;
- } //next i, windowSize lump of this block
+ } //next i, lump of size L or less
+ i -= L; //put pointer back where it was
+ for(j; j<wcopy+offset; j++) //fill the last 'offset' samples from the
filter
+ buffer[i+j-offset] = lastWindow[j];
t->Set((samplePtr)buffer, floatSample, s, block);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs