Jump to content

MIDI over Bluetooth with ESP32


TK.

Recommended Posts

Winter time is DIY time - and this year I decided to explore the capabilities of the ESP32 platform.

There might be synergies with MIOS32, but I'm very sure that I won't fully integrate this Microcontroller into the MIOS32 ecosystem --- this hasn't been considered 10 years ago when I started with the 32bit platform, and it would take too much time to make everything compatible (with many compromises - e.g. no native USB support, and we know that this is important for best performance!)

However, I think that ESP32 is a pretty good companion device to a STM32F4, hence potential candidate for future MIDIbox enhancements.

E.g. the NodeMCU ESP32 available at Reichelt for 10 EUR supports Dual-Core (!) @240 MHz with WiFi and Bluetooth, 512k RAM, 4MB external Flash, incl. USB programmer on PCB - compare this with a PIC18F*! ;-)

I started with Bluetooth, and the result can be found here: https://github.com/midibox/esp32-idf-blemidi

This so called "BLE MIDI" service should work with any OS which supports this protocol. So far only tested on MacOS and iOS... but it should also work with Linux and Win10.

This will be the basis for further experiments at my side - I'm able to communicate with the device via MIOS Studio. :-)

(however, application download has to be done with the ESP32 ecosystem - means: the appr. esptool.py based bootloader)

In future also a WiFi connections as demonstrated in Pedalino might be possible, but I'm not there yet - focus is on the application itself, knowing that the MIDI interface options won't be so fast like known from the STM32F4 based platform.

E.g. how accurate can we control a Motorfader with the PWM LED outputs of a ESP32? :doubt:
If it works, it could be connected like a MBHP_MF_NG module via traditional UART based MIDI to a MIDIbox NG.

And will it be possible to control a SRIO chain?
Might be interesting for a future BLM16x16+X with (only) optional WiFi and Bluetooth connects.

Best Regards, Thorsten.

Link to comment
Share on other sites

Very cool development, well done! :cheers:
While the girls in the house insist on automatically shutting down the WiFi network at bedtime "so they can sleep better" :), i can see why wireless connections would be cool, maybe also in a ProgrammA context :).
Many greets,
Peter

Link to comment
Share on other sites

Capabilities and inside features are awesome!.. 512k RAM :-) hummm

Do you think you will be able to find the time, during this harsh winter, to migrate the mios32 bootloader to the HAL( F4 ;), so that this magnificent OS that we love so much will become almost eternal? Hihi

In any case thank you and have good time with DIY and experimentation... So good to read that! :)


 

Edited by Antichambre
Link to comment
Share on other sites

No, I won't have the time for a fully adaption to MIOS32, especially considering incompatibilities, missing resources and last but not least, potential additional user support which I can't give thereafter.

And concerning bootloader: the native solution of the ESP32 ecosystem is working well, no real need for an adaption.

Therefore I provide the projects "as is" and independent from MIOS32 - but you will find some things known from MIOS32 later, and the projects will be somehow integrated into the MIDIbox platform - but please don't expect so much "flawless compatibility" that we know from MBHP_CORE_STM32/MBHP_CORE_LPC17/MBHP_CORE_STM32F4...

Times have changed, today powerful DIY platforms are already available, so that it makes sense to adapt to the workflow of the corresponding users - I'm flexible and see the possibility to reduce efforts at my side ;-)

Best Regards, Thorsten.

Link to comment
Share on other sites

Should be possible -> https://github.com/lathoub/Arduino-AppleMIDI-Library

Good progress at my side: I'm now able to control motorfaders, and the accuracy is much better than ever before, because dedicated PWM outputs are used (which are normally intended to fade LEDs), clocked at non-audible 20kHz range.

Some work is still required to get it compatible with MBHP_MF_NG, but maybe I can show the difference in 1..2 days via video.

My test setup: a NodeMCU hooked on the MBHP_MF_NG board with a quick&dirty adapter board, communicating via Bluetooth (the MIDI sockets are currently not used - unfortunately ESP32 pins are not 5V tolerant)

mbhp_mf_ng_with_esp32.thumb.jpeg.0a87382

Best Regards, Thorsten.

Link to comment
Share on other sites

On 14/12/2019 at 8:23 PM, TK. said:

I'm now able to control motorfaders, and the accuracy is much better than ever before, because dedicated PWM outputs are used (which are normally intended to fade LEDs), clocked at non-audible 20kHz range

Hello Thorsten

That's interesting, what is the max possible clock speed ?

Best

Zam

Link to comment
Share on other sites

Hi Thorsten,
Is it possible to do not pair the two devices and create a network with it? If a device can broadcast to several others devices and also receive(merge) from them too?
Is there a kind of receiving state or meter, to be able to manage the distance between the devices?

Best
Bruno

Edited by Antichambre
Link to comment
Share on other sites

3 hours ago, Zam said:

That's interesting, what is the max possible clock speed ?

Depends on the desired resolution for the duty cycle. The timers are clocked at 80 MHz
Means: with 20 kHz we could have 4000 different "speed levels" (but actually I'm currently only using 64 speed levels, which is sufficient)

3 hours ago, Antichambre said:

Is it possible to do not pair the two devices and create a network with it? If a device can broadcast to several others devices and also receive(merge) from them too?
Is there a kind of receiving state or meter, to be able to manage the distance between the devices?

At least I know that MacOS and iOS don't allow this. If I take the device with one computer, it appears as "offline" on the other (and vice versa). Seems to be intended, that only a point-to-point connection is allowed.

Yes, there should be some kind of meter available, here a link to the driver documentation: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/bluetooth/

Best Regards, Thorsten.

Link to comment
Share on other sites

8 hours ago, TK. said:

Depends on the desired resolution for the duty cycle. The timers are clocked at 80 MHz
Means: with 20 kHz we could have 4000 different "speed levels" (but actually I'm currently only using 64 speed levels, which is sufficient)

Ok ! don't know what is the agenda or if any major MFNG update is on the road (which I can help on by the way...)

I suggest to factor at least 10 the clock in case of hybrid system (analog close to or in the fader...)

let say 312.5kHz , which correspond to 256 speed level (you have room over 64...) also a value over 192kHz (HD audio)

I mean If it's easy don't hesitate to change this...

Best

Zam

Link to comment
Share on other sites

19 hours ago, Zam said:

Ok ! don't know what is the agenda or if any major MFNG update is on the road (which I can help on by the way...)

Good question! Currently it's mainly a learning vehicle for me to explore a new microcontroller and corresponding software.

And now I'm also learning KiCad to enter the schematic (and maybe also the Adapter PCB) - currently only for my own interest.

If you would like to play with the project as well, you are welcome of course! :)
I will bring it at least to a state that others can use an adapter board on their existing MBHP_MF_NG, can connect via traditional MIDI but also Bluetooth and maybe also (later) rtp MIDI, but I can't promisse anything else.

And at this point in time it especially needs "real life testing" before it's build by others.

19 hours ago, Zam said:

I suggest to factor at least 10 the clock in case of hybrid system (analog close to or in the fader...)

let say 312.5kHz , which correspond to 256 speed level (you have room over 64...) also a value over 192kHz (HD audio)

I mean If it's easy don't hesitate to change this...

Was worth a try: I used 200kHz and it works like 20kHz - don't see a big difference on the motor handling itself - but probably in an analog system:

20 kHz:

fadermove_pwm_20khz.png.0d11e8299774454c

200kHz:

fadermove_pwm_200khz.png.2ce7255970bfffe

The "noise" that we see here comes from the higher ADC resolution (faders are scanned at 12bit instead of 10bit) and messy ground on my vero board - this should become better with a PCB.

But it doesn't impact the smooth movements.

Of course, most interesting would be if it works so smooth like your 89MotionN: 

 

At least I see a potential cost benefit ;-)

Best Regards, Thorsten.

Link to comment
Share on other sites

Hello Thorsten

I have something like "MF_HD" in head since time but don't start because of no more real need for me (I have my motor driver)

It's hybrid, between MF_NG and My 89MotioN, in all aspect probably (cost, quality and performance)

 

Your two AD scan from fader servo seem to show improved noise at 200kHz.

 

Best

Zam

 

Link to comment
Share on other sites

I can't recommend this solution; it only transfers via a serial protocol, which then has to be converted by a computer into MIDI messages - this is error prone.

Today we would prefer the BLE MIDI protocol, which is natively supported by many operating systems, and considers special MIDI features such as continuous SysEx streams.
And this is possible with a simple ESP32 controller, which is available for the same (or less) price - and on top of this WiFi should be possible as well.

Best Regards, Thorsten.

Link to comment
Share on other sites

My first KiCAD project - I don't miss xcircuit and Eagle & I'm happy that other people can now edit the files with state-of-the-art open source SW as well :-)

mbhp_mf_ng_esp32_adaptor_v1.thumb.png.19mbhp_mf_ng_esp32_adaptor_pcb_v1.png.5050

Best Regards, Thorsten.

P.S.: ordered at OSHpark - let's see if the circuit works like intended next year :)

Link to comment
Share on other sites

  • 2 weeks later...

While waiting for the PCB I worked on the "Apple MIDI" protocol which allows to transfer MIDI messages over WIFI (and Ethernet - known from this project: 

As a second project I consider to create a universal "MIDI bridge" device for MIDIbox projects which supports UART, Bluetooth, WIFI and SPI, maybe also CAN.

So, it can be connected via SPI port J28 to a MBHP_CORE_STM32/F4/LPC17 instead of the MBHP_ETH module, or alternatively via UART (e.g. also to PIC based projects) giving us wireless connections :)

The latency is not so nice - expect ca. 5 mS + some jitter - it won't be really suitable for sending MIDI Notes, but it will be very nice for MIDI controllers.

Another topic which needs to be explored: if the antenna is strong enough to send/receive in a metal case, like MIDIphy MBSEQ V4+

Best Regards, Thorsten. 

Link to comment
Share on other sites

Short update: the ESP32 based MBHP_MF_NG can now communicate with BLEMIDI over Bluetooth, Apple MIDI over WIFI, and traditional MIDI via UART

-> https://github.com/midibox/esp32-idf-mfdrv

Still some work to do, but I think that this is a pretty good basis for other MIDIbox projects - special focus was on reliable SysEx transfers and routing between different MIDI interfaces.
This major challenge is solved! :-)

Best Regards, Thorsten.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...