I2S signal generation (ESP32)?

192 views
Skip to first unread message

David Madden

unread,
Mar 3, 2022, 1:43:37 PM3/3/22
to dorkbotpd...@googlegroups.com
I've started playing with I2S audio generation on an ESP32. It appears
that any kind of discontinuity in a waveform will make clicks & pops --
it's a lot more significant than you'd expect for a 1/16000 sec blip!

I'm sure this is Old News for people who've been doing MIDI and audio
stuff for years, but to help me get up to speed:

What are some good techniques for generating "pretty good" audio samples
quickly enough to feed a voracious I2S DMA? My current goals are
"analog-phone" noises -- dial tone, ring tone, busy, DMTF, tri-tone
SIPs, etc. I'd like to have smooth, pop-free start and stop of tones
with configurable duration.

Some ideas:

* Prepare a clean set of 16-bit samples of an integral number of cycles
of (mixed) tones, and use a simple envelope algorithm to ramp up and
down. (This can be a fairly large number of samples when mixed
frequencies have a large LCM.)

* Prepare clean sets of 16-bit samples of individual frequencies, then
just add them prior to DMA

* Prepare a single cycle of 16-bit samples of a sine wave, and use
different indexes stepping through it to get different frequencies.
(Maybe using fixed-point delta increments to get finer frequency control.)

The ESP32 doesn't seem to have enough horsepower to just make samples on
the fly using floating point.
--
Mersenne Law · www.mersenne.com · +1-503-679-1671
Small Business, Startup and Intellectual Property Law
420 N.W. 11th Ave., Suite 814; Portland, Oregon 97209
OpenPGP_signature

space...@gmail.com

unread,
Mar 4, 2022, 5:02:04 PM3/4/22
to dorkbotpdx-blabber
Prepare a single cycle of 16-bit samples of a sine wave, and use
different indexes stepping through it to get different frequencies.
(Maybe using fixed-point delta increments to get finer frequency control.)


This way was easy to implement and without any optimizing, I can do 2 voices in 0.85uS/sample, out of my budget of 62.5uS/sample.  So...problem solved (unless/until I discover that ESP32 WiFi or Bluetooth uses unreasonably big chunks of CPU time!)

David Oster

unread,
Mar 6, 2022, 2:24:20 PM3/6/22
to dorkbotpdx-blabber
https://www.youtube.com/watch?v=a936wNgtcRA ESP32 Audio Tutorial with lots of examples [14 min] was published today.

On Thursday, March 3, 2022 at 10:43:37 AM UTC-8 David Madden wrote:

Justin R. Miller

unread,
Mar 6, 2022, 5:18:55 PM3/6/22
to dorkbotpd...@googlegroups.com
You may also find the sound & music projects here of use:

http://www.technoblogy.com

All of the projects are cool, the photography is cute, and most use the much less powerful ATtiny 25 or 85 chips. There are some clever optimizations here and there that may be of use.

JM
> --
> You received this message because you are subscribed to the Google Groups "dorkbotpdx-blabber" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to dorkbotpdx-blab...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/dorkbotpdx-blabber/c06fd021-2e76-4ec3-8add-24bdb8f6ddf8n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages