Sie sind auf Seite 1von 4

CORE PROGRAM FOR BEAT DETECTION USING ONBOARD LEDs

#include<stdio.h> #include<conio.h> #define average_length 4000 Const int chunks = 20; Const int instant_length = 200; const float c = 1.3; double ae = 0, ie = 0; short buffer[average_length]; void main() { comm_poll(); while(average_counter < average_length) { buffer[average_counter] = input_sample(); average_counter++; } while(1) { instant_counter = 0; while(instant_counter<instant_length) { instant_counter++; }
for (average_counter=0;average_counter<average_length;average_counter++) {

//length of buffer //number of frames in buffer //length of 1 buffer //confidence multiplier //Buffer

//init DSK, codec, McBSP


//sample entire buffer

//infinite loop

//sample one frame and //move it to circular buffer

buffer[chunk_counter*instant_length+instant_counter]=input_sample();

ae=ae+buffer[average_counter]*buffer[average_counter];//av energy } ae = ae / average_length;


for (instant_counter=0;instant_counter<instant_length;instant_counter++)

//in entire buffer

{ ie=ie+buffer[chunk_counter*instant_length+instant_counter] *buffer[chunk_counter*instant_length+instant_counter]; } ie = ie / instant_length;

//average energy in last few msec

if (ie > ae*c) { .. Else { .... } chunk_counter++; if(chunk_counter>=chunks) chunk_counter=0; //if not, turn off LEDs //if energy in short buffer>whole buffer,turn on LEDs

//incr position in chunk counter //right point in buffer

} }

//end of while(1) infinite loop //end of main

SUBMITTED BYSOUMYA RANJAN ME/EEE/1032/2011

THEORY
Music visualization is a continuously progressing area in audio processing, not only for analysis of music but also for entertainment visualization purposes. The scheme is based on the idea that the drum is the most energy-rich component of the music. In this project, the beat of the music is the drum pattern or bass line of the piece of music.The beat pattern is visible in the spectrogram of the music, and the energy plot shows that the beat of the drum can be the most energy-rich portion of the music.Furthermore, it is advantageous to filter out any higher-frequency portions of the music that may also have high energy. This has the added advantage that the parts of the music containing no bass line will not confuse the algorithm. The incoming music signal is continuously sampled at 8 kHz (with a 4-kHz antialiasing filter on the codec) and stored in a buffer. The buffer has 4000 points and is decomposed into 20 chunks, each chunk consisting of 200 points. The signal energy of a smaller portion of the buffera chunk of the larger bufferconsisting of the most recently collected samples is compared to the signal energy of the entire buffer.When this portion of the signal has a significantly higher energy than the rest of the signal, it is considered to be a beat. The average algorithm is described by the following equations:
N

<E> = 1/N
io+n

B[K]2
K=0

<e>=1/n B[K]2
K=io

Beat =

true <e> False

> <E>.C
otherwise

Das könnte Ihnen auch gefallen