jejt / jmons

Engineering Tommorrow

Arduino as Digital Filter… Hopes downed, and then Revived


I had hoped in my previous post to sample the audio through the use of an analogue input pin on the Arduino, then do some bit manipulation in the form of a Digital filter before playing back. However, my hopes have been crushed with this system:

To test the feasability of this, the code was simple – define an int to store a sample in, call analogRead() to read a byte in, convert this value into a value suitable for the number of output pins, then pass it out.

AnalogRead reads in a value between 0 and 1024, which is a 10 bit number. Because I’ve only got a 6bit DAC, I decided to just take the top 6 bits (I should really try this again with scaling as opposed to just taking MSB).

Now, since starting to write this and battling with lots of media upload tools AND wordpress.com etc, I’ve realised two things. 1) I’m not actually taking the top 6 bits, I’m using the top 2 bits because of a stupidity. and 2) I should use Scaling instead of just using the top 6 bits. I have just tried it again using 6 bits and there is a large improvement, as for scaling, that will have to wait.

My code (which is BAD and WRONG):
void loop() {
  buffer = analogRead(analogPin);
  PORTD = (byte) buffer >> 4 ; // only use MSB 6 bits
}

The following is an MP3 hosted on SplashCast Here. The first sample is the sample I’m inputting into the arduino, the second and third is the output.

[splashcast UQVA8175RX]

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 222 other followers

%d bloggers like this: