C:/Users/Michael/Desktop/trunk/program/demo/runfftlistener.c File Reference

The frequency recognizer using FFT. More...

#include <p30Fxxxx.h>
#include <dsp.h>
#include "math.h"
#include "motor_led/e_epuck_ports.h"
#include "motor_led/e_init_port.h"
#include "a_d/advance_ad_scan/e_ad_conv.h"
#include "fft/e_fft.h"
#include "fft/e_fft_utilities.h"
#include "motor_led/advance_one_timer/e_motors.h"
#include "motor_led/advance_one_timer/e_agenda.h"
#include "motor_led/advance_one_timer/e_led.h"

Functions

int localise_pic_max (fractcomplex *spectre, int spectre_length)
 Localize the bigger pic of the array.
int get_volume (fractcomplex *spectre, int pic_pos)
 Get the max volume of the sound detected.
void display_volume_on_led (int volume)
 Display the volume of the soud detected on the LEDs.
int calcul_frequence (int pic_pos)
 Calcul the corresponding frequency of the bigger pic detected.
void set_speed (int frequency)
 Set the speed of the e-puck.
void run_fft_listener (void)
 The "main" function of the demo.


Detailed Description

The frequency recognizer using FFT.

Introduction

The runfftlistener programm is made to illustrate how you can use the FFT package of the library. The goal is to determine the frequency of the sound comming from the microphone number 0. If the frequency is under 900Hz the e-puck will turn left. If the frequency is between 900Hz and 1800Hz the e-puck will go forward. If the frequency is over 1800Hz the e-puck will turn right.

Playing the demo

First of all, move the selector to the position 9 to 15 and reset the e-puck. To play the demo, you have two allternatives:

Video of the demo

Author:
Code: Michael Bonani, Jonathan Besuchet
Doc: Jonathan Besuchet

Function Documentation

int calcul_frequence ( int  pic_pos  ) 

Calcul the corresponding frequency of the bigger pic detected.

Parameters:
pic_pos The index of the bigger pic detected
Returns:
The corresponding frequency

void display_volume_on_led ( int  volume  ) 

Display the volume of the soud detected on the LEDs.

Parameters:
volume The max volume of the sound detected

int get_volume ( fractcomplex *  spectre,
int  pic_pos 
)

Get the max volume of the sound detected.

Parameters:
spectre The array in which the FFT was made
pic_pos The index of the louder frequency
Returns:
The amplitude of the louder frequency

int localise_pic_max ( fractcomplex *  spectre,
int  spectre_length 
)

Localize the bigger pic of the array.

Parameters:
spectre The array in which the FFT was made
spectre_length The length of the scan in the array
Returns:
The index of the bigger pic detected

void set_speed ( int  frequency  ) 

Set the speed of the e-puck.

Set the speed of the e-puck relatively of the frequency of the sound detected.

Parameters:
frequency The frequence of the sound


Generated on Fri Feb 29 14:27:42 2008 for Demo by  doxygen 1.5.4