Sound


Files

file  e_sound.c
 Package to play basics sounds on the e-puck's speaker.
For more info look at this: Sound.
file  e_sound.h
 Package to play basics sounds on the e-puck's speaker.

Detailed Description

Introduction

The e-puck has got a speaker on his top. This package is made to take advantage of it, by playing little sample.

Package organization

The internals functions of this package are written in assembler, because of speed. The sound you can play is in the file codec/e_const_sound.s

The externals functions are located in the file codec/e_sound.c. There are three functions: e_init_sound(void), e_play_sound(int sound_offset, int sound_length) and void e_close_sound(void). When you want to play a sound YOU HAVE TO call e_init_sound(void) at first, but only the first time.
To play a sound call e_play_sound(int sound_offset, int sound_length). This function takes two parameters, the first set the begining of the sound, the second set the length of the sound. In fact it works like this:

If you don't want to use the sound anymore call e_close_sound.

Warning:
If you call void e_close_sound(void), you have to recall ee_init_sound(void) to play sound again.

Sounds plage

In the file codec/e_const_sound.s there are 19044 words. Five sounds are organized as following [begining, length]:

Then if you want to play the "yaouh" sound from the begining to the end just write this: e_play_sound(7294, 3732);

A little exemple which plays the five sounds one by one.

 #include <codec/e_sound.h>
 #include <motor_led/e_init_port.h>
 
 int main(void)
 {
        e_init_port();
        e_init_sound();
        while(1)
        {
                long i;
                e_play_sound(0, 2112); //sound 1
                for(i=0; i<4000000; i++) {asm("nop");}
                e_play_sound(2116, 1760); //sound 2
                for(i=0; i<4000000; i++) {asm("nop");}
                e_play_sound(3878, 3412); //sound 3
                for(i=0; i<4000000; i++) {asm("nop");}
                e_play_sound(7294, 3732); //sound 4
                for(i=0; i<4000000; i++) {asm("nop");}
                e_play_sound(11028, 8016); //sound 5
                for(i=0; i<4000000; i++) {asm("nop");}
        }
 }

Author:
Code: Michael Bonani
Doc: Jonathan Besuchet

Generated on Fri Feb 29 14:26:55 2008 for e-puck by  doxygen 1.5.4