Main Page | File List | Globals

robotsound.c File Reference

Contains the sound routines. More...

#include "robotsound.h"

Go to the source code of this file.

Functions

void play (u16 Hz)
 Plays a tone in Herz The tone in Herz. 0-17 for switching off.

void playt (u08 tone)
 Plays a tone described in start_sound(u08 *soundtostart, u08 override).

int playi ()
 This function is called from SIGNAL(SIG_OVERFLOW0).

int start_sound (u08 *soundtostart, u08 override)
 With this function you can enable a sound (melodie). The sound bites are in program memory and have the following structure:.


Variables

u08 __ATTR_PROGMEM__ beeps []
u08 __ATTR_PROGMEM__ start_up [] = {5,42, 3,54, 10,0, 0,0}
u08 __ATTR_PROGMEM__ go_sleep [] = {3,70, 3,60, 3,50, 3,40, 3,30, 3,20, 0,0}
u08 __ATTR_PROGMEM__ wake_up [] = {3,20, 3,30, 3,40, 3,50, 3,60, 3,70, 0,0}
u08 __ATTR_PROGMEM__ go_hungry [] = {20,36, 20,48, 20,36, 20,48, 0,0}
u08 __ATTR_PROGMEM__ go_empty [] = {10,49, 255,0, 10,49, 255,0, 10,49, 0,0}
u08 __ATTR_PROGMEM__ snore [] = {50,1, 40,0, 0,0}
u08 __ATTR_PROGMEM__ get_connected [] = {1,20, 50,85, 50,86, 10,70, 0,0}
u16 __ATTR_PROGMEM__ tones []
u08act_sound
s16 s_ticks


Detailed Description

Contains the sound routines.

This file is for using the "sound system".

The speaker is at Pin 17 and uses the Timer2. Possible frequencies are from 18Hz to about 50kHz, but the high frequencies don't have a good quantisation. The tone is always a square wave.

Definition in file robotsound.c.


Function Documentation

void play u16  Hz  ) 
 

Plays a tone in Herz The tone in Herz. 0-17 for switching off.

This function should not be invoced directly (just for testing purposes) because it overrides the normal sound and doesn't stop brawling.

Parameters:
Hz 

Definition at line 32 of file robotsound.c.

Referenced by playt().

void playi  ) 
 

This function is called from SIGNAL(SIG_OVERFLOW0).

Here the sound is playied. It is called every 16,3ms which is the fastest Tick in a sound.

Definition at line 78 of file robotsound.c.

Referenced by SIGNAL().

void start_sound u08 soundtostart,
u08  override
 

With this function you can enable a sound (melodie). The sound bites are in program memory and have the following structure:.

[ticks, tone],[ticks,tone],...[0, 0].

One tick is about 16ms and by setting tone to 0 you can make a pause. The tones start at a C [33Hz] and go up 7 octaves. tone = 60 is the standart pitch 440Hz max is 83. a value of 85 plaies rising tones. and 86 does the same downwards.

Parameters:
soundtostart A pointer to the sound which is ended by 0,0
override Set this to one if the sound should replace a playing sound.

Definition at line 95 of file robotsound.c.

Referenced by do_boredom(), do_sleep(), and main().


Variable Documentation

u08 __ATTR_PROGMEM__ beeps[]
 

Initial value:

 {5,40, 10,0, 5,40, 10,0, 5,40, 10,0, 5,40, 10,0, 5,40, 10,0,
                                5,40, 10,0, 5,40, 10,0, 5,40, 10,0, 5,40, 10,0, 5,40, 40,0, 0,0}

Definition at line 11 of file robotsound.c.

u16 __ATTR_PROGMEM__ tones[]
 

Initial value:

 { 0,
                                 33,   35,   37,   39,   41,   44,   46,   49,   52,   55,   58,   62,
                                 65,   69,   73,   78,   82,   87,   92,   98,   104,  110,  117,  123,
                                 131,  139,  147,  156,  164,  175,  185,  196,  208,  220,  233,  247,
                                 262,  277,  294,  311,  330,  349,  370,  392,  415,  440,  466,  494,
                                 523,  554,  587,  622,  659,  698,  740,  784,  831,  880,  932,  988,
                                 1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1976,
                                 2093, 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951}

Definition at line 20 of file robotsound.c.


Generated on Wed Feb 2 20:03:50 2005 for Robot by doxygen 1.3.6