]> git.sesse.net Git - vlc/blobdiff - modules/visualization/galaktos/beat_detect.c
Removes trailing spaces. Removes tabs.
[vlc] / modules / visualization / galaktos / beat_detect.c
index 5d8306858f850ce3aa225344dbe0a240a6042645..f351cf0a24143b6c832ee2c0f9b66736d2e15246 100644 (file)
@@ -19,7 +19,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 //
@@ -30,8 +30,6 @@
 //
 //Some stuff was taken from Frederic Patin's beat-detection article, you'll find it online
 
-#include <stdlib.h>
-#include <stdio.h>
 #include "engine_vars.h"
 
 double beat_buffer[32][80],beat_instant[32],beat_history[32];
@@ -43,7 +41,7 @@ double vol_buffer[80],vol_instant,vol_history;
 void initBeatDetect()
 {
 
-  int x,y; 
+  int x,y;
 
   vol_instant=0;
   vol_history=0;
@@ -67,12 +65,12 @@ void initBeatDetect()
       beat_att[x]=1.0;
       beat_variance[x]=0;
       for (y=0;y<80;y++)
-       {
-         beat_buffer[x][y]=0;
-       }
+    {
+      beat_buffer[x][y]=0;
+    }
     }
 
-} 
+}
 
 void getBeatVals(double *vdataL,double *vdataR, double *vol)
 {
@@ -82,29 +80,29 @@ void getBeatVals(double *vdataL,double *vdataR, double *vol)
   vol_instant=0;
 
       for ( x=0;x<16;x++)
-       {
-         
-         beat_instant[x]=0;
-         for ( y=linear*2;y<(linear+8+x)*2;y++)
-           {
-             beat_instant[x]+=((vdataL[y]*vdataL[y])+(vdataR[y]*vdataR[y]))*(1.0/(8+x)); 
-             vol_instant+=((vdataL[y]*vdataL[y])+(vdataR[y]*vdataR[y]))*(1.0/512.0);
-
-           }
-         
-         linear=y/2;
-         beat_history[x]-=(beat_buffer[x][beat_buffer_pos])*.0125;
-         beat_buffer[x][beat_buffer_pos]=beat_instant[x];
-         beat_history[x]+=(beat_instant[x])*.0125;
-         
-         beat_val[x]=(beat_instant[x])/(beat_history[x]);
-         
-         beat_att[x]+=(beat_instant[x])/(beat_history[x]);
-
-
-         
-       }
-      
+    {
+    
+      beat_instant[x]=0;
+      for ( y=linear*2;y<(linear+8+x)*2;y++)
+        {
+          beat_instant[x]+=((vdataL[y]*vdataL[y])+(vdataR[y]*vdataR[y]))*(1.0/(8+x));
+          vol_instant+=((vdataL[y]*vdataL[y])+(vdataR[y]*vdataR[y]))*(1.0/512.0);
+
+        }
+    
+      linear=y/2;
+      beat_history[x]-=(beat_buffer[x][beat_buffer_pos])*.0125;
+      beat_buffer[x][beat_buffer_pos]=beat_instant[x];
+      beat_history[x]+=(beat_instant[x])*.0125;
+    
+      beat_val[x]=(beat_instant[x])/(beat_history[x]);
+    
+      beat_att[x]+=(beat_instant[x])/(beat_history[x]);
+
+
+     
+    }
       vol_history-=(vol_buffer[beat_buffer_pos])*.0125;
       vol_buffer[beat_buffer_pos]=vol_instant;
       vol_history+=(vol_instant)*.0125;
@@ -112,33 +110,33 @@ void getBeatVals(double *vdataL,double *vdataR, double *vol)
       double temp2=0;
       mid=0;
       for(x=1;x<10;x++)
-       {
-        mid+=(beat_instant[x]);
-         temp2+=(beat_history[x]);
-        
-       }
-       
-        mid=mid/(1.5*temp2);
-        temp2=0;
-        treb=0;
-         for(x=10;x<16;x++)
-           { 
-             treb+=(beat_instant[x]);
-             temp2+=(beat_history[x]);
-           }
-         treb=treb/(1.5*temp2);
-         *vol=vol_instant/(1.5*vol_history);
-  
-         bass=(beat_instant[0])/(1.5*beat_history[0]);
-
-         treb_att=.6 * treb_att + .4 * treb;
-         mid_att=.6 * mid_att + .4 * mid;
-         bass_att=.6 * bass_att + .4 * bass;
-         //printf("%f %f %f %f\n",bass,mid,treb,*vol);
-          // *vol=(beat_instant[3])/(beat_history[3]);
-         beat_buffer_pos++;
-         if( beat_buffer_pos>79)beat_buffer_pos=0;
-       
+    {
+     mid+=(beat_instant[x]);
+      temp2+=(beat_history[x]);
+    
+    }
+    
+     mid=mid/(1.5*temp2);
+     temp2=0;
+     treb=0;
+       for(x=10;x<16;x++)
+        {
+          treb+=(beat_instant[x]);
+          temp2+=(beat_history[x]);
+        }
+      treb=treb/(1.5*temp2);
+      *vol=vol_instant/(1.5*vol_history);
+      bass=(beat_instant[0])/(1.5*beat_history[0]);
+
+      treb_att=.6 * treb_att + .4 * treb;
+      mid_att=.6 * mid_att + .4 * mid;
+      bass_att=.6 * bass_att + .4 * bass;
+      //printf("%f %f %f %f\n",bass,mid,treb,*vol);
+       // *vol=(beat_instant[3])/(beat_history[3]);
+      beat_buffer_pos++;
+      if( beat_buffer_pos>79)beat_buffer_pos=0;
+    
 }
 void freeBeatDetect()
 {