Nucleo-L476RG Audio Library support

pareidolialjebus
Mon Oct 01, 2018 8:40 pm
Hi all

I came to STM32 arduino after making a midi controller that combines multiple LFO’s to confuse the heck out of various software synths and works well, but I found when running 96 individual LFO’s it makes the arduino mega chug a little to say the least. I plan to move my project to the STM32 and it feels fairly straight forward, albeit with some minor changes to account for the 3.3v limits to the system as well as some changes to the physical interface, using touch control instead of buttons. Anyway, I wondered how much fun it would be to intergrate some hardware voices, and have ended up flying down another rabbit hole, playing with the Mozzi library on an Uno as well as buying a few blue pills (and then realising they were coming from china, so have about 6 more weeks till they arrive) with plans to try mozzi on those..and then I discovered the teensy and it’s excellent audio library.

Anyway, I’m rambling – I just wanted to give you a bit of background – what I need to ask is, while I wait for those blue pills I’ve got time to waste and wondered, is there any way to add support for either Mozzi or the Teensy audio library, or is there some other capable audio library out there that will run on the nucleo board with the stm core that also utilises the DAC?

Of course if there’s another core that will give me what need, happy to use that instead.


madias
Mon Oct 01, 2018 10:22 pm
Audio (I2s, Mozzi, …) isn’t really implemented in the official core out of the box (but this might be changed in the future – I hope so).

  • ChrisMicro played a lot with audio and the “genericCore” on F4, use the search function.
  • I did a I2S DMA circular buffer (adaption code) on the F4 which *should* running on the official core, please see here viewtopic.php?f=18&t=4095 and read this: viewtopic.php?f=48&t=4109
  • For serial MIDI take this: https://github.com/FortySevenEffects/ar … di_library (this awesome library runs on nearly every *duino platform I tried out). But for “MIDI only” I wont use a F4 but a blue pill (even this device will fads itself with MIDI and counting IDLE circles)
  • USB-Midi: Not implemented in any way (both: generic or official) – maybe arpuss will convert his USB-HID library from the F1 Roger core to *HAL.
  • Mozzi: There was an attempt by tfred some months ago (but also F1 Roger core): viewtopic.php?f=15&t=2936 – As I remember, the Mozzi library is a masterpiece, but needs timer (and low level code?) and so on, so I’m pretty sure it won’t compile out of the box.

Please keep in mind, that for the generic core there no real support or updates anymore (At least not in the last six months).


madias
Mon Oct 01, 2018 10:27 pm
But to be honest: At the moment(!) for Audio/MIDI any F103 and Rogers Core is the best choice for playing around. There are many examples in this forum and you can use USB-MIDI (so the board is recognized as a standard MIDI USB device). Keep in mind, that with the “better” F1 MCU’s (STM32F103RET and up) you have also build in DAC’s (12bit) and two independent I2S interfaces (I2S Audio DAC’s are available much under 1 Euro, so for 10PCS about 2-5 EURO) But for further projects I’ll move to the F4 (+++MHZ + floating point!) and the official core. For USB MIDI I’ll use a simple bluepill “daughter board” until there is no USB MIDI available (and I believe it won’t be in near future – USB MIDI is only for interest for a few “freaks” ;) )

ChrisMicro
Tue Oct 02, 2018 4:23 am
ChrisMicro played a lot with audio and the “genericCore” on F4, use the search function.

Hi Mathias,
thanx for mentioning that.
I also played with Rogers Core:
https://github.com/ChrisMicro/BluePillSound
In my opinion it is better to directly move to a stronger MCU than the STM32F103 because with a more complex sound generation this MCU reaches its limits soon.
I would also not recommend to use the L476 because this MCU is made for low power applications and can only run up to 80MHz. A better choice is the F407 and the the F407 discovery board has a build in audio DAC.
Here I tried the Nucleo F401 because it was laying around. But the F407 is better.
Now I ordered a F411 discovery because it is cheaper than the F407 discovery. We’ll see how it works.

The best thing would be to port the Audio-Lib from Early Hill Power ( ESP ) to the STM32. Probably it would not be too difficult and it has a build in MP3 decoder.


pareidolialjebus
Tue Oct 02, 2018 8:40 pm
Thanks both for your replies. I’m stunned. I came home today, resolved to come on here and answer you both, then settle down to start porting my existing midi software over to the nucleo board. But guess what? My chinese boards arrived. I ordered them on the 20th, the dispatch note said they would arrive in November, but both my programmer and board were waiting for me after only 12 days. I don’t think that’s bad at all.

I’ve got blink up and running, just about to start fiddling around with mozzi.

The weird thing is I tried to work out what to do with bootloaders and things, went round in circles for a while but wasnt able to upload a bootloader using my ST link clone. Decided to get roger’s core installed and try the command line option using the instructions here: https://github.com/rogerclarkmelbourne/ … ill-Boards

But for the sheer devilment I selected ST link as the upload method and just tried to upload a sketch… worked first time and is now blinking away..
..time to try mozzi.

Shame to hear USB midi is for “freaks”. Seems I’m a freak too! :)


madias
Tue Oct 02, 2018 9:15 pm
To be honest and a *very* private opinion: I always use the ST-Link clone for uploading (only exception: Maple mini clone). I got so many troubles in the past (especially on my Macbook Pro 13′ 2009). ST-Link always works for me ,no matter which board (F1 to F4) or OS. I have too many things for debugging, so I do not want also “debug” the upload method. (Lazy? Yes!)
About freaks: Yes, we *are* freaks doing synth stuff with STM32F*** ;) But neither on Energia (TI variant of Cortex Mx cores) or Chipkit (PIC32) [I leave aside official “Arduino” products, because they are unreliable and too slow for “real” synth things] there aren’t so many freaks as here – and (I speak for Rogers Core) no “Arduino” implementation has so cool “out of the box” things (MIDI USB) and examples as on stm32duino.

madias
Tue Oct 02, 2018 9:20 pm
BTW: A real cool “candidate” for synth stuff is this: https://www.aliexpress.com/item/1PCS-ST … 03267.html

pareidolialjebus
Tue Oct 02, 2018 9:30 pm
[madias – Tue Oct 02, 2018 9:20 pm] –
BTW: A real cool “candidate” for synth stuff is this: https://www.aliexpress.com/item/1PCS-ST … 03267.html

Looks nice – I like the form factor and the extra hardware built in. Have you tried Teensy out? The library seems to have all kinds of fun things. It is a relatively expensive board at £28ish in the UK, but the support looks great.


madias
Tue Oct 02, 2018 9:52 pm
Shame on my, I do not own a Teensy board. Nearly everything synth/audio related in “Arduino land” was touched by the hand of Paul J. Stoffregen in the past. I adapted many of his codes. Teensy boards are (in relationship with STM32 aliexpress) expensive, but with a superb&outstanding support. If you can afford it, buy one. You wont pay for the hardware (ok, the board layouts are also really good!), but you’ll pay Paul and his company (hopefully).
And the Teensy 3.6 is MCU hardware as it should be: https://www.pjrc.com/store/teensy36.html

ChrisMicro
Wed Oct 03, 2018 3:43 am
Yes, the software for the Teensy of Pauls Stoffregen is really good.
I was thinking about to port some of his things but then I decided: NO
Why? Because he put so much effort in his things and he is earning a little bit of money by selling his Teensies so I think it is better to not destroy his market by porting the software to cheap STM-Nucleos.
Probably not as advanced as Pauls synthesizers there are some other things.
Pauls made the graphical synth tool here.
Here I adapted another synthesizer with GUI some STM32 boards.
It is not as advanced as Pauls version but nevertheless quite good I think.
Not all sound algorithms of the original equation composer are implemented but if you don’t need to used the graphical part they probably could easily be copied.
Then the equation composer library should be as advanced as the MOZZI library.

BTW: I saw that the L476 has a SAI interface instead of an I2S interface. I assume that the I2S drivers for the other boards can not be easily ported to the SAI. right?


ChrisMicro
Wed Oct 03, 2018 4:14 am
[madias – Tue Oct 02, 2018 9:20 pm] –
BTW: A real cool “candidate” for synth stuff is this: https://www.aliexpress.com/item/1PCS-ST … 03267.html

Yes a good board. Somehow I forgot that I made a simple equation composer example for it.


madias
Wed Oct 03, 2018 5:49 am
[ChrisMicro – Wed Oct 03, 2018 3:43 am] –
BTW: I saw that the L476 has a SAI interface instead of an I2S interface. I assume that the I2S drivers for the other boards can not be easily ported to the SAI. right?

I think SAI is compatible to I2S, but you are right, there might be some other register entries needed getting the “I2S compatibility mode”. Beside that, SAI is very interesting, there are cheap Audio DAC’s supporting SAI. Advantage: You can handle multiple I/O streams with SAI.


GrumpyOldPizza
Wed Oct 03, 2018 2:15 pm
[madias – Wed Oct 03, 2018 5:49 am] –

[ChrisMicro – Wed Oct 03, 2018 3:43 am] –
BTW: I saw that the L476 has a SAI interface instead of an I2S interface. I assume that the I2S drivers for the other boards can not be easily ported to the SAI. right?

I think SAI is compatible to I2S, but you are right, there might be some other register entries needed getting the “I2S compatibility mode”. Beside that, SAI is very interesting, there are cheap Audio DAC’s supporting SAI. Advantage: You can handle multiple I/O streams with SAI.

https://github.com/GrumpyOldPizza/ardui … raries/I2S

Works like a charm with a I2S microphone …

The SAI peripheral is more complex than the I2S off SPI. It allows more than 2 channels, and different slot encodings …


ChrisMicro
Sat Oct 06, 2018 6:11 am
[GrumpyOldPizza – Wed Oct 03, 2018 2:15 pm] –
https://github.com/GrumpyOldPizza/ardui … raries/I2S

Works like a charm with a I2S microphone …

Because I got a L432Nucleo I thougth I can give it a try on my Ubuntu. But it seems openocd has a problem:
.arduino15/packages/grumpyoldpizza/hardware/stm32l4/0.0.28/tools/linux/openocd/bin/openocd.bin: error while loading shared libraries: libudev.so.1: cannot open shared object file: No such file or directory


GrumpyOldPizza
Mon Oct 08, 2018 2:59 pm
[ChrisMicro – Sat Oct 06, 2018 6:11 am] –

[GrumpyOldPizza – Wed Oct 03, 2018 2:15 pm] –
https://github.com/GrumpyOldPizza/ardui … raries/I2S

Works like a charm with a I2S microphone …

Because I got a L432Nucleo I thougth I can give it a try on my Ubuntu. But it seems openocd has a problem:
.arduino15/packages/grumpyoldpizza/hardware/stm32l4/0.0.28/tools/linux/openocd/bin/openocd.bin: error while loading shared libraries: libudev.so.1: cannot open shared object file: No such file or directory

You got to install the 32bit compatibilty libraries. Thought it said so in the instructions.


Leave a Reply

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