Sunday, 18 September 2011

Mic Audio Sampling

Using the Audio sound sensor to try to capture audio data.

The Code:



Setup:
startTime = millis();
Main Loop
if(!end) {    

      sensorRead = analogRead(A0);        
      file.println(sensorRead);    // write the read to the file
    }
    
    // stop the recording after 10 seconds
    if (millis() > 10000) {
      
      endTime = millis();
      duration = endTime - startTime;
      file.println(duration);
      
      file.close();            //Close the file.
      end=true;
      Serial.print("done");
      while(1);
    }


Each sensor reading is written to the text file. This loop records makes note of the start and end time to calculate the length (for future designs when length will not be set at 10 secs). The duration is added as the final value. 


Results
After running the output file through he wave convertor I ended up wit the following file. The recording is me saying "hello" into the mic over and over. The wave convertor calculates the sample rate at 3289sample/sec. I need to investigate other sensors and see if a raw write will allow faster sampling.

No comments:

Post a Comment