Home

Data Structures | Defines | Functions

dwengoSound.h File Reference

Sound library for Dwengo. More...

#include "dwengoInterrupt.h"
#include <math.h>

Data Structures

struct  note
 datastructure to store a note. More...

Defines

#define SPEAKERPORT   LATCbits.LATC2

Functions

void initSound (void)
 Initialize sound functionality. This routine initializes sound functionality of the Dwengo board. It configures the C pins as digital outputs. C2 is used as the speaker output. It also configures timer0 and timer1 and dispatches the sound interrupt service routine, using the dwengo interrupt library. Timer0 is the low interrupt timer. Its interrupts determine the rythm. Timer1 is the high interrupt timer. This one regulates the frequency of the notes.
void startSong (note *song, unsigned int bpm)
 Plays a song.
void stopSound (void)
 stops the timers, effectively stopping the sound.
void playFrequency (unsigned int frequency)
 keeps generating a tone on the C2 pin untill stopSound() is called
void frequencyHighISR ()
 ISR that handles the frequency.
void beatLowISR ()
 ISR that handles the tempo.
unsigned int noteFrequency (note Note)
 help function that returns the frequency of a note.

Detailed Description

Sound library for Dwengo.


Function Documentation

unsigned int noteFrequency ( note  Note)

help function that returns the frequency of a note.

Parameters:
Noteinput note of which the frequency must be determined.
void playFrequency ( unsigned int  frequency)

keeps generating a tone on the C2 pin untill stopSound() is called

Parameters:
frequencydesired frequency. This function generates a square wave on the C2 pin. Attaching a speaker to this pin will result in a audible tone.
void startSong ( note song,
unsigned int  bpm 
)

Plays a song.

Parameters:
songpointer to an array of notes.
bpmthe tempo of the song, expressed in beats per minute. Runs through an array of notes at a specified tempo. Each note encoutered will be played trough playFrequency for the specified amount of time.
 All Data Structures Files Functions Variables Defines

Generated on Wed Dec 25 2013 23:03:08 for Dwengo library by doxygen 1.7.3