Monday, October 29, 2018

ARDUINO VOICE CHANGER PROJECT PAGE

Waveshield Schematic:


Things to know about Waveshield:
  • The audio playback library uses 10K of flash - so if you want to use an NG arduino, you'll need to upgrade to an Atmega168 chip.
  • About 600 bytes of SRAM are used to buffer the audio and keep track of file data, so RAM-heavy projects may not work well.
  • The shield can't play MP3, WMA, Ogg or other compressed audio files. It can only play uncompressed PCM/WAV files. Converting audio to WAV format is very easy, and is often the default format for many audio programs.
  • Files are stored as 8.3 name format, and can only be placed in the root directory. That means you can only have ~512 files (but they can be any size).

Pins Used by wave shield alone:
  • 13, 12, 11 always used by the SD card (final voice changer won't need SD card)
  • The library included uses pin 10 for SD card and 2, 3, 4, 5 to talk to the DAC.

3.3V Voltage regulator

  • This takes the 5V supply from the Arduino and converts it to a nice 3.3V supply. This is necessary because SD/MMC cards only work on 3.3V. If you give them 5V they'll burn out & die! 
  • The voltage regulator used is the MCP1700-330, which can provide up to 250 mA of current. There are 4 capacitors associated with the regulator. C1 and C2 are the input capacitors; they stabilize the 5V input. C3 and C4 are the output capacitors, they stabilize the 3.3V output 
  • There is a jumper that allows you to skip the regulator and use the 'built in' 3.3V supply from the Arduino. However, it is not suggested as that supply is not guaranteed to provide the current necessary.

The microcontroller/Arduino

  • The library contains a bunch of specialized code. 
  • The first part is a 'FAT16' library, this is a set of functions that allow the chip to read the SD card, locate files and read their contents. 
adafruit_products_fncc02.gif
  • Once it opens a file and is ready to read it, it looks through the first section of the file. If it's a Wave file, there will be all sorts of information stored in this header that will indicate the channels (mono/stereo/etc), bits-per-sample (8 to 32), sample rate (ie 16KHz) etc. 
  • Basically, the firmware verifies that it is mono channel, 16 or less bits-per-sample and 22KHz or less sample rate. 
  • Then it sets up the audio interrupt that will go off sample-rate times a second. For example, if it's a 22KHz audio sample, the interrupt will go off 22,000 times a second!
adafruit_products_250px-Pcmsvg.png

  • The audio is encoded in PCM format. This means "pulse Code Modulation". 
  • Lets say it's a 16bit, 22khz wave. The audio waveform is sliced up 22,000 times a second and a corresponding value (up to 16 bits - from 0 to 65,635) is read from the waveform, then that value is stored in the file. Each sample is a unique value. The file is not compressed. This means the files are very large but the quality is very very good.
  • The SD card can provide 512 bytes at a time. This is buffered inside the Arduino's RAM so that we have smooth playback. (Techinally, its a double-buffer which means we read 256 bytes and play 256 bytes, then swap.) The audio interrupt picks one sample at a time and sends the data to the DAC (digital/analog converter). 

VOICE CHANGER
  • Human vocal range is typically 300-3,500Hz, Nyquist sampling theorem says we need 2x minimum sampling rate to reconstruct a signal, so were going to use at least a 7KHz sampling rate.
  • Arduino's standard analogRead() function in a loop is way too slow for this.
  • A capability in Arduino's analog-to-digital converter called free-run mode collects analog samples at a fast, fixed interval without repeated polling in our code. An interrupt handler is automatically called each time a new sample is ready.
  • The audio samples are stored in a circular buffer --->“when you reach the end of the buffer, roll back around to the beginning and write over it.”
Reference image for circular buffer from adafruit tutorial^^








No comments:

Post a Comment