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. | |
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.
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");} } }
1.5.4