SoundRecorder:

Author/Contact: miklos.maroti@vanderbilt.edu (Miklos Maroti, ISIS, Vanderbilt)

DESCRIPTION:

This component continuously samples the microphone (at 14 KHz or 16 KHZ depending
on the ADC implementation used). When a loud enough noise is detected, then we 
start recording as many (8-bit) samples as we can. Then we transmit the collected 
data back to the base station (using SendBigMsg). The collected data can be stored 
in a file using the PrintBigMsgs java program, thentransformed into a WAV file 
using the Txt2Wav java program. These programs can be found in the 
tools/java/isis/nest/* directory.

OPERATION:

1. Program one mote with the SoundRecorder component. 
2. Program another one with the GenericBase component with nodeid 1973.
3. Start them, and run the following java program on the PC connected to the
 base station:

	java isis.nest.printmsgs.PrintBigMsgs -comm COM1 -noid > recordings.txt

4. Once you have enough recordings, then terminate the java program and
 turn off the motes.
5. Run the following program to turn the recordings.txt file into a recordings.wav file:

	java isis.nest.util.Txt2Wav -type unsigned1 -rate 2.35 recordings.txt

6. Listen what you have recorded, analize the data and enjoy!

TUNABLE PARAMETERS:

The SoundRecorderM.nc file contains an enum with the following parameters:

BUFFER_LENGTH: The number of zerocrossing records we want to record and send
to the base station.

SILENCE_LENGTH: The number of zerocrossing records we want to keep and send
before we detected the loud noise.

ENERGY_THRESHOLD: This is the minimum energy level for detecting the loud noise. 
This value should be in the range 20-128

MIC_GAIN: The microphone gain to be used. For normal voice recordings the value
128 seems to work, for gun shots we use 20 or 30.

BASE_STATION: The nodeid of the base station

