🌈 ESP32-S3 Rainbow: ZX Spectrum Emulator Board! Get it on Crowd Supply →
View All Posts
read
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi

I got a 10‑cent MCU literally talking. With just 16K of flash and 2K of RAM, I used PWM and a tiny transistor amp to play 6+ seconds of audio at 8 kHz by compressing it with super‑simple 2‑bit ADPCM—4:1 compression and a decoder in under 2 KB. I built a handy WAV‑to‑2‑bit‑ADPCM tool to make it easy. For longer phrases, I switched to the Talkie library (TI LPC speech synthesis from the TMS5220/TMS5100 era—think Speak & Spell and classic arcades), and I even made a web tool and player for generating and previewing LPC data. It’s wild what you can squeeze out of a 10‑cent MCU. Also, PCBWay did the boards—link below.

Related Content
Transcript

Open the part bay doors.




I’m sorry, Dave. I’m afraid I can’t do
that.
Good morning. The time is 11:36 a.m. 1 2
3 4 5 6 7 8 9 10.
That’s right. We’ve got our 10 cent MCU
talking. The PCBs I’m using came from
PCB Way, and they’ve done a great job.
As always, there’s a link to PCB way in
the description. Definitely worth
checking out if you want some PCBs. Now,
in the previous video, I used one of
these very cheap SMD buzzers. We played
some tunes using beeps and even got
polyonic tunes working. For these
experiments, I’m using a small speaker.
I’m using the same simple transistor
driver circuit, and the code does work
with the buzzer as well, but it is very
quiet. The actual results are a lot
better than I was expecting. We’re
really pushing the boundaries of what
you can do with 16K of flash and 2K of
RAM. The first example I played is just
over 6 seconds of audio sampled at 8
kHz. It’s the famous sequence from 2001.
Open the bay door.
I’m sorry, Dave. I’m afraid I can’t do
that.
Now, uncompressed, 6 seconds of audio
with 16 bits per sample should take up
almost 94k. That’s definitely not going
to fit in our 16K of flash. We’ve also
got to remember that this 16K of flash
needs to be shared between our audio
data and our playback code. So, we
really are limited on what we can do.
So, what are our options? We can go down
to 8 bits per sample. We’re using PWM to
output the audio. So, we’re not going to
get really high quality output for the 6
seconds of audio data. That brings us
down to just under 48K of audio data.
That’s still three times bigger than our
flash. We need something a lot more
aggressive. I’ve got a table here with
our options. We could try 4bit ADPCM.
That does get us quite close to our
target and it’s pretty simple to decode.
So, the decoding code doesn’t take up
much flash. The quite okay audio codec
gets us even closer. It only needs 3.2
bits per sample, but it is a lot more
complicated.
Two bit ADPCM is the definite winner. It
only needs two bits per sample. That’s a
4:1 compression ratio. This gets us well
under the 16k limit, leaving us plenty
of room for our code. It’s also
incredibly simple to implement. My
playback code for 2bit ADPCM is less
than 2,000 bytes. That leaves us a
couple of K of headroom for any
additional features we might want to add
to the firmware. Now, how does 2bit
ADPCM work? It’s actually remarkably
simple. Both the encoder and decoder
share very similar logic. They both have
a table of step sizes and they keep
track of an index into this table. When
we encode the audio, we store a set of
instructions on how to change the index
into this step table. If the audio
signal is changing rapidly, we move to a
larger step size. If the signal is
changing slowly, we move to a smaller
step size. That’s the adaptive side of
things. You can see a small section of
audio data here. Our predicted value
closely follows the real signal. So I’ve
made a handy tool here that will convert
a W file into our twobit ADPCM format.
So let’s load some audio in. Let’s just
drag and drop it. So here’s the
original.
Shall we play?
And here’s the two bit ADPCM encoded.
And you can see here the compression
rate. So the original size 23k, it’s
down to 5K. So a 4:1 compression ratio.
So let’s download these and load them
onto the device and see how it sounds.
So it should sound like this.
[Music]
And that’s not bad. Pretty good. But
what about the second example I played?
That was around 10 seconds of someone
talking. Surely that can’t fit into our
flash. Well, for that I’m using the toy
library. This is a software
implementation of the LPC Texas
instrument beach symphysis architecture.
This was used in chips such as the TMS
52220 and the TMS 5100. These were used
a lot during the 80s as add-ons to home
computers like the BBC Micro and in the
very famous Speak and Spell.
Now spell the machine. M A C H I N. You
are correct.
[Applause]
It was also used in various arcade
games. The original work on the talking
library was done by Peter Knight and
then it was added to by Adafruit. This
is a really cool library. There’s a
large amount of predefined vocab and it
takes up very little space. Pretty
amazing stuff from a 10-centent MCU. I
did find some software that will create
new LPC encoded data. There is Blue
Wizard, which is a Mac application, and
Python Wizard, which is a Python
application. I had a few issues getting
these both to work nicely, but in the
end, I did get them to run. But I fed
both of these into an AI coding tool,
and it’s created me a nice online
version that you can use. This seems to
work pretty well.
I’ve also added a player so you can
paste in LPC encoded data and play it
back. This works really nicely.
Force is strong.
And of course, all of this works on our
super cheap 10- cent MCU. Not bad.
The force will be with you.
Red five standing by. This is five. I’m
going in.
I’m on the leader.
I can’t change it. I’m not bad. See what
you can do with it.
Staying in attack for me.
R2 trying to increase the power.
Use the false snoo.
I have you now.
I’ve lost R2. You’re all clear, kid.
Great job, kid.




HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
Blog Logo

Chris Greening

> Image

atomic14

A collection of slightly mad projects, instructive/educational videos, and generally interesting stuff. Building projects around the Arduino and ESP32 platforms - we'll be exploring AI, Computer Vision, Audio, 3D Printing - it may get a bit eclectic...

View All Posts