Spark Logic

DeltaSigma PWM audio Output

I was looking at his thread on ESP forums, a MP3 WebRadio outputted on plain GPIO pin :

http://www.esp8266.com/viewtopic.php?f= … =40#p21048

Victor ? are you the same Victor “pvvx” author of this work on ESP ?

If Yes, do you plan to port some of this work to the STM2duino ?

Ciao ! ;)

Replies13

Mon Jun 22, 2015 1:51 am

I’m not the same, but is funny I was reading about using PWM for audio output, guessing that we have a bunch of timers with DMA capabilities that could be easily used for that, even for an stereo output… without much CPU usage for the output part.
But I have done nothing about it except download an MP3 decoder project for the STM32F4STM32F4Microcontrollers and processors…uild.board' preference. Auto-set to: STM32F3_DISCOVERY_F3 Board Arduino_STM32-master: STM32F4 :discovery_f407 doesn't define a 'build.board' preference. Auto-set to: STM32F4_DISCO…View in hardware catalog that I intended to try to port at some point…

EDIT: I had a quick look, this looks really cool. I have a few ESP laying around that I need to put to some use…

EDIT2: had a bit better look, I don’t think this should be difficult to port at all. We could use 2 channels of a single timer to do PWM output. We have freeRTOS and CoOS working already.

Mon Jun 22, 2015 2:11 am

Ah ! Ok ! (I came to this possible coincidence because “victor_pv” ~= “Victor pvvx” :? )

@matthias, our audio expert, what do you think about that ? do you think is is worth to have it ported ?

Mon Jun 22, 2015 7:50 am

I’ve done only a quick look at https://github.com/espressif/esp8266_mp3_decoder
This is the most interesting part for me: How to implement a mp3 software decoder. As I know the sw codex is much RAM intensive, so I read:
The MP3 example is a very memory-sensitive piece of code: the MP3 decoder uses almost all the RAM and the needed buffers for input and output buffering take up the rest: when using no external SPI RAM, only a few bytes of memory are left. The SDK libs that come with this example are libraries that have been optimized for memory usage and are known to work.
and further:
Support all ESP2866 modules (512 Kbytes flash)
Free Flash (512 Kbytes): 200 Kbytes. Free Heap: 20 Kbytes.
MP3-decodec-out uses IRAM Buffer > 20 Kbytes (IRAM: 48k + 16k cache Flash):

The specs for the ESP8266ESP8266Microcontrollers and processors…working, on the Arduino.cc forum The ESP thing looks similar, but at the moment, www. esp8266 .com is not responding, so I’ll take a look later to see if it seems to be the same b…View in hardware catalog are:
[*]64KBytes of instruction RAM
[*]96KBytes of data RAM

So I doubt getting mp3-sw-decoding, pwm-out plus frontend (incl. hardware like display…) working on a medium-density device. It’s more a job for the high-density ones – and they have I2S on board, so no fooling around with PWM-delta-sigma audio would be necessary (I2S DAC’s costs about a few cent up to 2-3 USD).

So maybe using the PWM-delta-sigma code for something else than mp3 (or any other compressed audio format) like speaking alarm clocks,…? This should be possible!

Off topic:
A really impressing demo of what can be done with pwm-audio (using 2 pins) even on AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog ’s is the outstanding mozzi library:
http://sensorium.github.io/Mozzi/

Mon Jun 22, 2015 8:22 am

I really don’t think its worth the effort, even if it was just about possible

VS1053VS1053Analog, logic and power components…inly ok, but i do occasionally get a glitch when trying to play MP3 files from SD to VS1053 . But i have not had time to find the cause, because sometimes it can run for many hour…View in hardware catalog boards are less than $10, and we have a lib for them (thanks to vasillis)
$10 http://www.ebay.com/itm/VS1053-MP3-Modu … 4853e421c4

Offloading MP3 (or WAV etc) playback to external hardware is most likely the best option as it leaves the main processor free to do some other things

Mon Jun 22, 2015 10:37 am

I really don’t think its worth the effort, even if it was just about possible
I agree if the goal is to build up a whole audio player. If you wanna use only some audio files for your project (acoustic feedback), because you are annoyed of the beeping of microwave oven, than a smart 2-pin-pwm resolution isn’t a bad idea (you only need two girls resistors and a cap):
http://sensorium.github.io/Mozzi/learn/output/

Mon Jun 22, 2015 11:31 am

Matthias

Thanks for the link to the Mozzi wiring diagram. I wondered why it needed 2 pins.

i agree. Mozzi sounds excellent, so perhaps we should port it t STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog .

i have looked at audio playback on AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog before, which used multiple pins, but it was not as clever as Mozzi. I cant remember the name of the library, but it just played beeps on multiple pins, so that you could have very basic polyphonic music e.g. like cheap musical christmas cards.

But Mozzi sounds amazing. I presume that the 2 bits, give output levels. I wonder if its scalable to more pins ?

Mon Jun 22, 2015 12:40 pm

Yes, indeed, there is *really* much brain behind that technology. It’s well explained at http://www.openmusiclabs.com/learning/d … -circuits/
Porting mozzi to stm32duino is a huge project, the author is a maniac (positive meaning!) Read the “Caveats and Workarounds” on front page. I’ve done a closer look at the code and there is much low level content. There was a plan for porting the lib to DUE, but I think the author stopped that, because of TeensyTeensyDevelopment and computing boards…true ide.contributions.boards.support.urls.wiki= ide.create_platforms_from_boardsTXT. teensy =build.core vm.debug=true software=ARDUINO ssh.user.name=root ssh.user.default.passwor…View in hardware catalog support. So a port to STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog is possible, but you need to look into many *.h and *.c files, because there is sadly no common hardware setup file, as you can see on the many #ifdefs for TeensyTeensyDevelopment and computing boards…true ide.contributions.boards.support.urls.wiki= ide.create_platforms_from_boardsTXT. teensy =build.core vm.debug=true software=ARDUINO ssh.user.name=root ssh.user.default.passwor…View in hardware catalog . No problem should be to rewrite the timer libraries (maybe a good idea to rewrite/wrap the prjc timerX libraries at all, they are nearly “standard” ).
I don’t think there is much benefit in scaling more pins, because even for 14 bit dualPWM you need a resisior accuracy of 0.78% (see the table in the openmusic document) and for triplePWM you’ll get in serious troubles matching the resistors at all! So mozzis 14bit for hi-res audio is honestly and trustworthy, everything else (above 14bit) would be a sham and waste of resources.

Mon Jun 22, 2015 12:47 pm

madias wrote:
<…>
the author is a maniac (positive meaning!)

Mon Jun 22, 2015 4:14 pm

The mp3 decoder running in the ESP seems to have been ported from an NXP port of the decoder.

According to NXP application note:

1.7 Memory requirements
The EFSL and the libmad libraries consume memory to work. The amount of the memory
is about:
Table 1. Memory requirements for the MP3 player demo
RAM [kB] Code [kB]
Libmad + EFSL 33 109 

Sat Jul 04, 2015 5:18 am

I found an mp3 decoder completely ported to the F103 MCU. It’s the Helix decoder, different than the one used in the 8266 at the top of this thread.
I found it in the link to one of the taobao boards. It was a board with 64KB, not sure how much of that it comsumes:
http://pan.baidu.com/share/link?shareid … =506725102

I haven’t look at the details yet, so no idea if it uses the DACs in that chip, or the i2s (may be the case…).

Any way, whenever I have a chance I’ll test this out in one of my RCT6 boards, as those actually have 64KB of ram, so should be enough.
This may be a good option for many, as those boards can be had for the same price as a VS1003VS1003Analog, logic and power components…global instantiation RogerClark Fri Jun 05, 2015 11:39 am Guys, I was looking at the VS1003 lib and thought it would be good to try to playback and MP3 from the SD card, but rathe…View in hardware catalog or less, and instead of 2 boards you use only one and a little amplifier.

Mon Aug 14, 2017 1:07 am

Hi. I know this topic is old but has anyone ported the Mozzi library to work on STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog ? Would love to play around with it if it has.

Mon Apr 09, 2018 4:22 pm

juliusbangert, that would be awesome wouldn’t it! I support that idea and read with interest the earlier posts in this thread about that possibility.

Post a reply

Optional · up to 10 MiB