[xiph-cvs] cvs commit: vorbis/lib envelope.c

Monty xiphmont at xiph.org
Wed Jan 31 15:58:50 PST 2001



xiphmont    01/01/31 15:58:50

  Modified:    lib      envelope.c
  Log:
  Lower the highpass cutoff frequency a bit; midrange has preecho too.
  Also, look for preecho in the sides of the stereo image, so that the
  center does not dominate detection (eg, ringing hihat in the center).
  
  Monty

Revision  Changes    Path
1.30      +49 -7     vorbis/lib/envelope.c

Index: envelope.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/envelope.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- envelope.c	2001/01/22 01:38:24	1.29
+++ envelope.c	2001/01/31 23:58:49	1.30
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: PCM data envelope analysis and manipulation
- last mod: $Id: envelope.c,v 1.29 2001/01/22 01:38:24 xiphmont Exp $
+ last mod: $Id: envelope.c,v 1.30 2001/01/31 23:58:49 xiphmont Exp $
 
  Preecho calculation.
 
@@ -31,10 +31,6 @@
 #include "envelope.h"
 #include "misc.h"
 
-/* We use a Chebyshev bandbass for the preecho trigger bandpass; it's
-   close enough for sample rates 32000-48000 Hz (corner frequencies at
-   6k/14k assuming sample rate of 44.1kHz) */
-
 /* Digital filter designed by mkfilter/mkshape/gencode A.J. Fisher
    Command line: /www/usr/fisher/helpers/mkfilter -Ch \
    -6.0000000000e+00 -Bp -o 5 -a 1.3605442177e-01 3.1746031746e-01 -l */
@@ -57,7 +53,27 @@
   0.0303413711f};
 #endif 
 
+/* 4kHz Chebyshev highpass */
 static int    cheb_highpass_stages=10;
+static float cheb_highpass_gain= 1.314337427e+01f;
+/* z^-stage, z^-stage+1... */
+static float cheb_highpass_B[]={1.f,-10.f,45.f,-120.f,210.f,
+				-252.f,210.f,-120.f,45.f,-10.f,1.f};
+static float cheb_highpass_A[]={
+  -0.1013448254f,
+  0.4524819695f,
+  -1.3268091670f,
+  3.2875726855f,
+  -7.2782468961f,
+  13.0298867474f,
+  -17.6698599469f,
+  17.2757670409f,
+  -11.6207967046f,
+  4.8672119675f};
+
+#if 0
+/* 6kHz Chebyshev highpass */
+static int    cheb_highpass_stages=10;
 static float cheb_highpass_gain= 5.291963434e+01f;
 /* z^-stage, z^-stage+1... */
 static float cheb_highpass_B[]={1.f,-10.f,45.f,-120.f,210.f,
@@ -73,6 +89,7 @@
   4.1950871291f,
   -4.2771757867f,
   2.3920318913f};
+#endif
 
 void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi){
   codec_setup_info *ci=vi->codec_setup;
@@ -164,7 +181,8 @@
   vorbis_info *vi=v->vi;
   codec_setup_info *ci=vi->codec_setup;
   envelope_lookup *ve=((backend_lookup_state *)(v->backend_state))->ve;
-  long i,j;
+  long i,j,k;
+  float *work=alloca(sizeof(float)*ve->winlength*2);
 
   /* make sure we have enough storage to match the PCM */
   if(v->pcm_storage>ve->storage){
@@ -211,7 +229,31 @@
       }
       /*granulepos++;*/
     }
-    
+
+    /* look also for preecho in coupled channel pairs with the center
+       subtracted out (A-B) */
+    for(i=1;i<ve->ch;i+=2){
+      float *filteredA=ve->filtered[i-1]+j-ve->winlength;
+      float *filteredB=ve->filtered[i]+j-ve->winlength;
+      float m;
+
+      for(k=0;k<ve->winlength*2;k++)
+	work[k]=filteredA[k]-filteredB[k];
+
+      m=_ve_deltai(ve,work,work+ve->winlength);
+      
+      if(m>ci->preecho_thresh){
+	/*granulepos++;*/
+	return(0);
+      }
+      if(m<ci->postecho_thresh){
+	/*granulepos++;*/
+	return(0);
+      }
+      /*granulepos++;*/
+    }
+
+
     j+=min(ci->blocksizes[0],ve->winlength)/2;
 
     if(j>=searchpoint){

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list