Vocoder on stm32

Cesco
Mon Jul 11, 2016 4:06 am
I have tried to compile a vocoder (melp) for the stm32, the blue board, the 32f103. I did use the Melp vovcoder source, old stuff, should be out of copyright by now. And its good. It can encode voice into a 2400bps bit stream.

But i did fail. Melp seems to need 30kb ram, while the f103 provodes only 8kb. Is there ans cheapo board with 32kb ram like the blue board?


Pito
Mon Jul 11, 2016 6:08 am
Blue board and MMini offer 20kB of RAM..

Cesco
Mon Jul 11, 2016 7:49 am
Oh, you right. Ram overflowed by 8kb it states. If i enable both coder and decoder it´s 11kb.

Doesent really help me, i still need more ram, or someone to crunch the codes ram usage.
It does store coeffs in 32bit int or float, even the voice samples, but changing this will be hard.

————
Arduino: 1.6.3 (Windows 7), Board: “Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash), STM32duino bootloader”

c:/users/i7-4790/appdata/roaming/arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/bin/ld.exe: C:\Users\I7-4790\AppData\Local\Temp\build1072652885461977077.tmp/melp.cpp.elf section `.data’ will not fit in region `ram’

c:/users/i7-4790/appdata/roaming/arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/../lib/gcc/arm-none-eabi/4.8.3/../../../../arm-none-eabi/bin/ld.exe: region `ram’ overflowed by 8216 bytes

collect2.exe: error: ld returned 1 exit status

Error compiling.
————


ahull
Mon Jul 11, 2016 9:59 am
Do you have any source code we can look at?

Given the relatively low bandwidth required, you might be able to use an external flash chip for buffering

Using 8 bit rather than 32 bit samples might also work, as might decreasing the size of the buffer, but without any code to look at, I can’t really say.

You could also try running the code on an ESP8266, as they should have more RAM.


Cesco
Mon Jul 11, 2016 12:16 pm
This (with minor tweaks to compile with arduino):
https://github.com/arash-ostadzadeh/QUA … ks/melp1.2

I have used the codec before. Its from 1993-1995, TI, development paid by the US. Excellent code. Way better than what i am able to do and understand. Dont underestimate melp just because its old.

I did reduce the size to 17kb of ram by changing 2 tables from float to int16. One table is no problem, but the other one needs to be scaled. I will try to test it on my arduino due (more ram), but i need the 8khz DA and AD code first, and i need the mic and speaker hardware, plus some way to store the encoded speech.


mrburnette
Mon Jul 11, 2016 1:13 pm
A list of STM32 boards and SRAM http://wiki.stm32duino.com/index.php?ti … 103_boards

Sounds like it may be possible to use an ESP8266 (sans WiFi) at 160MHz. Plenty of SRAM
Short write-up here

Ray


Rick Kimball
Mon Jul 11, 2016 1:18 pm
Funny, that code must be old. I was looking at the makefile and I see a purify target. That is something I used to use on an a daily basis in the mid 90’s. If they were using purify and responding to its warnings, then the code will be pretty clean and leak free.

http://web.stanford.edu/class/cs343/res … purify.pdf
https://en.wikipedia.org/wiki/Rational_Purify

-rick


mrburnette
Mon Jul 11, 2016 1:21 pm
Rick Kimball wrote:
-rick

Rick Kimball
Mon Jul 11, 2016 1:50 pm
So how does that work? I tried

$ ./melp -i input/sample.pcm -o sample.bitfile

the sample.bitfile wasn’t very small. I was expecting it to shrink.

What is the sample rate of the input/sample.pcm ? Did I miss that someplace in the docs? Seems like 8k works OK.

-rick


Rick Kimball
Mon Jul 11, 2016 2:00 pm
It seems like that code makes extensive use of dynamic memory. Even if you could get the amount of static RAM lowered, I wonder how much memory is actually being allocated.

[Edit: i’ve attached the output of valgrind -tool=massif] Seems like it used +5k more with the sample.pcm file

massif.txt
(22.98 KiB) Downloaded 47 times

Rick Kimball
Mon Jul 11, 2016 2:38 pm
BTW: This might be the perfect thing to do with a Raspberry PI Zero. The code would just compile as is.

Cesco
Mon Jul 11, 2016 2:46 pm
The encoder input is a float buffer of 180 samples at 8 khz.

#define audbuffsize 180
float rfbuf[audbuffsize];


Cesco
Thu Jul 14, 2016 8:19 am
Rick Kimball wrote:The code would just compile as is.

Leave a Reply

Your email address will not be published. Required fields are marked *