Go Down

Topic: Uploading Audio files to EEPROM (Read 189 times) previous topic - next topic

SagarDev

Hey Guys,

I am working on a project which needs to provide a clicking sound when a process is running.
I have the clicking sound in WAV which has a duration of 0.01s and consumes 4kB of memory.

As 4kB is a very small capacity for a memory card, I chose the 24C32 CMOS EEPROM.

Now, how do I get the clicking sound file onto the EEPROM and how can I access it using Code?
Shakespeare's pen is an Electronics Engineer's Soldering Iron...

Grumpy_Mike

#1
Apr 13, 2018, 03:00 pm Last Edit: Apr 13, 2018, 03:02 pm by Grumpy_Mike
Quote
Now, how do I get the clicking sound file onto the EEPROM
You write an Arduino sketch that puts it into the EEPROM byte by byte.

Store the waveform in program memory, and read it back one byte at a time.

This will involve you in writing the array deceleration for program memory in the IDE. A much better way is to use a Processing program to read the wav file and print it out byte by byte in a format that can be copped and pasted into this Arduino sketch.

I would arrange this Processing sketch to also normalise the samples and then convert them into bytes, I would also omit the wav header.

To play it back you need to fish the bytes one at a time out of this EEPROM and send them to a D/A converter or a PWM program.

However while I have done this I have never done it with an external I2C EEPROM so I an not sure you can read the samples out of it fast enough for playback. What sample rate are you aiming at? Remember the I2C clock normally only runs at 100KHz.

The sort of quality you can get can be see here:-
https://youtu.be/WShVFcrFpwU

DVDdoug

Depending on the nature of your click sound you might be able to generate it with a pulse (then you wouldn't need any memory).

For example, have you ever connected a battery to a speaker?    You get a click when you connect it and another click when you disconnect it.   And if you can connect/disconnect it fast enough you'll hear a single click.

SagarDev

Hey,

Thank you for those suggestions

You write an Arduino sketch that puts it into the EEPROM byte by byte.

Store the waveform in program memory, and read it back one byte at a time.

This will involve you in writing the array deceleration for program memory in the IDE. A much better way is to use a Processing program to read the wav file and print it out byte by byte in a format that can be copped and pasted into this Arduino sketch.

I would arrange this Processing sketch to also normalise the samples and then convert them into bytes, I would also omit the wav header.

To play it back you need to fish the bytes one at a time out of this EEPROM and send them to a D/A converter or a PWM program.

However while I have done this I have never done it with an external I2C EEPROM so I an not sure you can read the samples out of it fast enough for playback. What sample rate are you aiming at? Remember the I2C clock normally only runs at 100KHz.
So do you mean that I provide a +ve offset voltage to the wave and then store the PWM values at equidistant points of the wave in an array? and then playback is nothing but the values read at equal intervals of time?

Now, does 100kHz mean 100,000 Samples every second?

Depending on the nature of your click sound you might be able to generate it with a pulse (then you wouldn't need any memory).

For example, have you ever connected a battery to a speaker?    You get a click when you connect it and another click when you disconnect it.   And if you can connect/disconnect it fast enough you'll hear a single click.
I have attached the waveform as an image. Could you help me with a circuit which can generate this waveform?
Shakespeare's pen is an Electronics Engineer's Soldering Iron...

Grumpy_Mike

#4
Today at 09:52 am Last Edit: Today at 09:55 am by Grumpy_Mike
Quote
So do you mean that I provide a +ve offset voltage to the wave and then store the PWM values at equidistant points of the wave in an array? and then playback is nothing but the values read at equal intervals of time?
Yes that is how recording and playing sound works. Once you read the samples you have to send them to a A/D converter of some sort

Quote
Now, does 100kHz mean 100,000 Samples every second?
No you get 100,000 bytes per second transfer. Then you have the overhead of having to ask for the data and receiving it. If the sample data is more than one byte this could take a long time but it also depends on your sample rate.

Quote
I have attached the waveform as an image.
Sorry but useless, you need the numbers. Also it looks like most of the click is just the start and the end discontinuity and nothing to do with the sin wave inbetween.

Go Up