audio DSP on the ESP32 chip

steph_tsf
Posts: 1
Joined: Mon Jan 08, 2018 4:07 pm

audio DSP on the ESP32 chip

Postby steph_tsf » Mon Jan 08, 2018 5:46 pm

I am a hobbyist doing wireless audio DSP. I may select the ESP32 chip instead one or another ARM Cortex-M4 or M7 chip. Being a hobbyist, wanting to join the ESP32 bandwagon, I am forced to cope with what's inside the ESP32 chip. The various Tensilica HiFi DSP engines remain thus out of my reach.
Anyway, I see a nice audio DSP potential in the ESP32 chip featuring the WiFi Radio, Bluetooth radio, twin I2S (digital audio interfaces), I2C and SPI (DAC control), MUL16, MAC16, 40-bit accumulator, data load with pointer increment/decrement, zero loop overhead, and windowed register set. Not to forget the 40 nanometer design rule, the 240 MHz clock, and the dualcore feature.
Question 1 : how to reserve one of the two Tensilica LX6 cores to audio DSP, in such a way it never gets disturbed by housekeeping tasks like infrared remote control, I2C or SPI (DAC control), WiFi or Bluetooth?
Question 2 : how to persuade the GCC C compiler to intensively rely on the MAC16 engine when coding a FIR filter (convolver) say 256-tap long ? This is thus for a 16-bit audio input, 16-bit coefficients, delivering 24-bit (or 32-bit) audio output.
Question 3 : are there two MAC16 engines in the dualcore ESP32 chip? Can they work at the same time without hitting bus congestion?
Question 4 : for IIR Biquad filtering like correcting the deep bass end (Linkwitz Transform), the 32-bit IEEE754 FPU and the MUL16 engine don't provide enough precision. I therefore need to code a enhanced resolution IIR Biquad filter aiming at processing 24-bit audio as input, 16-bit coefficients, delivering 24-bit (or 32-bit) audio output. The application note entitled "Extended Precision IIR Filter Design on the TMS320C54x DSP (June 1998)" tells how to code such IIR filter, basing on the TMS320C54 featuring MUL16 and MAC16 capabilities, quite similar to the ESP32 MUL16 and MAC16 capabilities. For the ESP32, I would like to code a) the Direct form 1 IIR Biquad filter showing on page 5, and b) the Optimized Cascaded IIR Biquad filter variant showing on page 17. Can somebody provide guidance? Is the GCC C compiler, the best tool? Can I hook a straightforward ESP32 Assembly compiler on the GNU Compiler Collection, concentrating on the assembly instructions that are required for doing audio DSP?

User avatar
Vader_Mester
Posts: 300
Joined: Tue Dec 05, 2017 8:28 pm
Location: Hungary
Contact:

Re: audio DSP on the ESP32 chip

Postby Vader_Mester » Tue Jan 16, 2018 7:28 pm

Rading through your post I decided to answer.

Answer for question 1:
You can use the FreeRTOS to create the tasks of the DSP application to run dedicatedly one core (preferably APP_CPU), and using the same method of allocating every other task on PRO_CPU.
You should look into how FreeRTOS works, there are nice stuff there here: FREE RTOS API REFERENCE
Also learn what a semaphore and a mutex is and how to be used in the ESP32 FreeRTOS API. This is inevitable to lear at least in general how they work, to be able to use the 2 cores, specially where you have memory like input and output buffers for I2S, Wifi, BT, etc which can/will be accessed by either cores.
(the aboves will keep the cores doing that in the same time, which if does happen you have a crash).

Answer to Question 2:
I have to say, but sadly you will have to ASSEMBLY code. Tensilica actually has a document listing all asembly instructions. There is a section in there detailing the MAC16 instructions.
You can put your assembly code as "Inline" code in the midst of your C code.
if you are not familiar with it, here's a link for some info: Click me
If you really want crazy fast and efficient processing, assembly is the way to go.
There are some threads on the forum with some tips for coding in assembly.

Code: Select all

task_t coffeeTask()
{
	while(atWork){
		if(!xStreamBufferIsEmpty(mug)){
			coffeeDrink(mug);
		} else {
			xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
			xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
		}
	}
	vTaskDelete(NULL);
}

User avatar
Jakobsen
Posts: 89
Joined: Mon Jan 16, 2017 8:12 am

Re: audio DSP on the ESP32 chip

Postby Jakobsen » Thu Jan 18, 2018 8:51 am

Did some DSP stuff on the ESP using BuddyCasino's web radio and the I2S input multilevel Audio amplifier from Merus Audio.

I have stated a laying out a DSP audio library to do filtering, delay, audio flow frame work, etc - what ever is needed to do Audio system design with the ESP32.

In doing so I had to tinkering with inline assembler to make sure to get the processing / precision needed in my bi quads exp. deep bass calculations. I found the floating unit cal engine to work very well and hard to beat using my own fixed point assembler multiplication stuff.

I am long way from done but will be very happy to share and event cooperate and increase the ambition level.
Analog Digital IC designer / DevOps @ Merus Audio, Copenhagen, Denmark.
We do novel and best in class Audio amplifiers for consumer products.
Programmed assembler for C-64 back in 1980's, learned some electronics - hacking since then

Who is online

Users browsing this forum: No registered users and 21 guests