Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add network support by omersiar #747

Open
wants to merge 61 commits into
base: main
Choose a base branch
from
Open

Add network support by omersiar #747

wants to merge 61 commits into from

Conversation

probonopd
Copy link
Owner

@probonopd probonopd commented Nov 9, 2024

image

Continuation from #744

This adds wired and wireless network for supported models:

  • rtpMIDI a.k.a. "AppleMIDI" over WLAN
  • UDP MIDI
  • FTP over WLAN (e.g., to update without takin the microSD card out of the Pi)
  • DNS-SD service discovery (a.k.a. "Bonjour", "Zeroconf")

Closes #43
Thanks @omersiar

This allows us to send MIDI e.g., from DAWs, Dexed on the PC, or even sysex for voices from sites like patches.fm

Documentation:
https://github.com/probonopd/MiniDexed/wiki/Networking#ethernet-and-wlan-support

@probonopd probonopd mentioned this pull request Nov 9, 2024
Repository owner deleted a comment from github-actions bot Nov 9, 2024
Copy link

github-actions bot commented Nov 9, 2024

Build for testing:
MiniDexed_2024-11-09-6d76e38
Use at your own risk.

@probonopd
Copy link
Owner Author

probonopd commented Nov 9, 2024

https://github.com/dwhinham/mt32-pi/wiki/Networking%3A-RTP-MIDI-%28AppleMIDI%29 says

mDNS/"Bonjour" for zero-configuration is not implemented, so mt32-pi will not be auto-discovered by your RTP-MIDI host software. You must add mt32-pi as a peer manually.

In the meantime, the awesome @rsta2 has implemented this. Do you think you could incorporate it?

An updated class CmDNSResponder is on the develop branch now with a test in test/mdns-publisher. The class now supports multiple services in one instance of the class and multiple TXT entries.

This means that we could advertise both RTP-MIDI and FTP (if enabled) on the network, making it much simpler to connect (without having to remember the IP address).

Copy link

github-actions bot commented Nov 9, 2024

Build for testing:
MiniDexed_2024-11-09-21db866
Use at your own risk.

@omersiar
Copy link

omersiar commented Nov 9, 2024

One can already connect to minidexed by its hostname (defaults to "minidexed") if the router supports home network domain.
I am aware of the mdns publisher but I don't know if minidexed checkouts to point where it is implemented

@probonopd
Copy link
Owner Author

probonopd commented Nov 9, 2024

Yes, but that won't cause it to show up in music or FTP applications on the PC/Mac automagically.

So far we are not using the mdns publisher in MiniDexed yet at all, so it would be a matter of porting it over from https://github.com/rsta2/circle/tree/master/test/mdns-publisher.

Probably something for a later/separate pull request?

@omersiar
Copy link

omersiar commented Nov 9, 2024

Oh sorry I meant the circle as a submodule. Currently minidexed do not checkout to required point for <circle/net/mdnspublisher.h>

@probonopd
Copy link
Owner Author

probonopd commented Nov 9, 2024

Probably have to adjust

https://github.com/probonopd/MiniDexed/blob/main/submod.sh

so that the needed branch/commit is checked out?

We are using this script since editing git submodules on the GitHub web interface is less than user friendly.

@omersiar
Copy link

omersiar commented Nov 9, 2024

Yeah this ⬆️, but changing this can break things. Let me check if latest circle release does break anything.

@probonopd
Copy link
Owner Author

probonopd commented Nov 9, 2024

Testing on a Windows 11 PC:

After the usual

MiniDexed
Loading...

it says

Network      IP
192.168.0.122     >

(Minor nitpick: The > suggests there is a submenu while there isn't; I think we should leave the > away here)

Trying to connect via FTP from the FTP client built into Windows, I cannot get a connection using ftp://minidexed (which could well be my router's fault). When using ftp://192.168.0.122 it asks for username and password, I used admin for both.

I do see a SD directory which contains the whole SD card contents. Cool! 👍

Now I'll move on to testing the MIDI aspects...

@omersiar
Copy link

omersiar commented Nov 9, 2024

It compiles with Step48 with these warnings:

net/ftpworker.cpp: In member function 'bool CFTPWorker::_ZN10CFTPWorker4PortEPKc.part.0(const char*)':
net/ftpworker.cpp:464:9: warning: 'char* strncpy(char*, const char*, size_t)' specified bound 512 equals destination size [-Wstringop-truncation]
  464 |  strncpy(Buffer, pArgs, sizeof(Buffer));
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net/ftpworker.cpp: In member function 'const TDirectoryListEntry* CFTPWorker::BuildDirectoryList(size_t&) const':
net/ftpworker.cpp:363:11: warning: 'char* strncpy(char*, const char*, size_t)' specified bound 6 equals destination size [-Wstringop-truncation]
  363 |    strncpy(VolumeName, VolumeNames[i], sizeof(VolumeName));
      |    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
minidexed.cpp: In member function 'void CMiniDexed::SetVoiceName(std::string, unsigned int)':
minidexed.cpp:1656:9: warning: 'char* strncpy(char*, const char*, size_t)' specified bound 10 equals destination size [-Wstringop-truncation]
 1656 |  strncpy(Name, VoiceName.c_str(),10);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../Synth_Dexed/src/dexed.cpp: In member function 'void Dexed::setName(char*)':
../Synth_Dexed/src/dexed.cpp:1699:10: warning: 'char* strncpy(char*, const char*, size_t)' output may be truncated copying 10 bytes from a string of length 155 [-Wstringop-truncation]
 1699 |   strncpy(name, (char*)&data[DEXED_VOICE_OFFSET + DEXED_NAME], 10);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@omersiar
Copy link

omersiar commented Nov 9, 2024

(Minor nitpick: The > suggests there is a submenu while there isn't; I think we should leave the > away here)

I wanted to give impression that this is not stuck and move the encoder one step to see actual menu. Dirty hack.
I am thinking to add a menu item for it.

@probonopd
Copy link
Owner Author

probonopd commented Nov 17, 2024

Yes, I understand your concerns @diyelectromusic. I view this whole networking code as an opt-in feature that should, if switched off, have no impact. So that whenever an issue comes up, we can compare with networking switched off. I've tested this quite a bit over the last days. And no, I don't advise on uploading files over FTP during a live performance ;-)

Repository owner deleted a comment from github-actions bot Nov 17, 2024
Repository owner deleted a comment from github-actions bot Nov 17, 2024
Repository owner deleted a comment from github-actions bot Nov 17, 2024
Copy link

Build for testing:
MiniDexed_2024-11-17-f881791
Use at your own risk.

@diyelectromusic
Copy link
Collaborator

diyelectromusic commented Nov 17, 2024

Ok, so it would appear (according to the Scheduler documentation in Circle) that the non-pre-emptive, cooperative multitasking scheduler will only ever work on core 0 in a multi-core system...

So in that case, these networking tasks cannot interfere with the audio DSP side of things which all happen on cores 1,2 and 3.

Any potential issues will be in things like UI handling and handling of non-networked MIDI, so it would be good to know if the USB and serial MIDI handling are affected by the networking; and then how the UI functions whilst the networking is running.

Aside: I think this call to ->Yield() probably shouldn't be there - this is in the non-multicore (so Pi V1) area of code:

void CMiniDexed::Process (bool bPlugAndPlayUpdated)
{
	CScheduler* const pScheduler = CScheduler::Get();
#ifndef ARM_ALLOW_MULTI_CORE
	ProcessSound ();
	pScheduler->Yield();
#endif

I'm also not clear why there are so many calls to Yield in the CMiniDexed::Process() - e.g. in every part of the performance file handling. Was this to fix some issues that have been found with the scheduling?

I really think this needs some developer documentation adding to the wiki to explain how the CTask and CScheduler facilities of circle are being used to support the networking.

I'd also like to see more checks/comments in the networking code to make it clear what is called when and to make sure things will drop out if things aren't properly initialised. There seems to be a few assumptions about order and call sequences to ensure that the networking isn't enabled when not configured. Should any of this sequencing change in the future (I don't know why it would, but things do shuffle around with time) then those assumptions would break.

Another Aside: I think printf() was used in mididevice.cpp as LOGNOTE doesn't always work in all contexts - e.g. if called from a serial port interrupt or something like that - I forget exactly... (although I'm not sure those printfs are particularly useful in there anymore anyway...)

I'm not sure I quite follow the logic in CMiniDexed::UpdateNetwork() - is that just performing the network startup? If so, why is it called for every scan of Process()? I'm not following the interplay between bNetIsRunning, m_bNetworkInit, and m_bNetworkReady - can we make this a proper state machine if these are states the system passes through - and are these states appearing on separate calls to UpdateNetwork() or are they all expected to happen within the same call?

Are those LOGPANIC calls really the most appropriate response to a networking issue? Also, response to various other bits of the networking failing seem inconsistent (there is no checking at all for m_UDPMIDI.Initialize() for example).

btw - should we be saying "applemidi" - wouldn't it be better to say rtpmidi... (and we'd not be building someone else's company name into the source of an open project...)?

There seem to be some build updates as part of these changes that don't seem specific to this change?

I've mentioned before that I'm really not a fan of on-the-fly patching of major source files. If you really want to build the git hash into the firmware, can we put it in its own include file or something so we're not trying to patch userinterface.cpp? Wouldn't need a s// then either - just echo it out to the file. (isn't "." a wildcard anyway? So wouldn't this actually patch every occurrence of the string "Loading" and any following three characters no matter what they are? Which could even include a newline and the start of the next line iirc...)

As I say, I've not been able to follow the networking code itself, I've just tried to think through any ramifications for the core MiniDexed functionality...

Kevin

@soyersoyer
Copy link
Contributor

If we already have wifi, ftpd, syslog, I think we should also have sshd :P Has anyone tried to use 8x synth_dexed on Linux? I think it could be interesting with PREEMPT_RT.

@probonopd
Copy link
Owner Author

probonopd commented Nov 18, 2024

I don't think synth_dexed has been ported to Linux. Might be a fun experiment for someone, though. If it is done in a way that keeps dependencies minimal (e.g., only ALSA, no jackd) it might run on a very stripped down "embedded Linux" type system containing not much more than the kernel, but allow for easier implementation of things like USB gadget mode as a sound device, MIDI device, and at the same time USB host for MIDI controllers, mass storage, etc. (I think) and networking, including ssh. Let me know if you ever start experiments in that direction. But that'd be a completely new development unrelated to today's MiniDexed. When I started MiniDexed I wanted something small and efficient, and not gigabytes of software with thousands of files.

Copy link

Build for testing:
MiniDexed_2024-11-19-5aad2ef
Use at your own risk.

@probonopd
Copy link
Owner Author

probonopd commented Dec 6, 2024

So far I have tested this successfully on RPi Zero 2 W.

We should also test it on the other models:

  • Zero (probably pointless since it has neither Ethernet nor WLAN)
  • Zero W (WLAN only)
  • Zero 2 W (WLAN only)
  • 1 (Ethernet only)
  • 2 (Ethernet and WLAN)
  • 3 (Ethernet)
  • 3 (WLAN)
  • 4 (Ethernet)
  • 4 (WLAN)
  • 5 (Ethernet and WLAN) - fan spins up loud but no activity on Ethernet port; does MiniDexed support 5 at all?

@soyersoyer which models do you have access to? At least we should ensure that it won't crash on any model.

@soyersoyer
Copy link
Contributor

I've a 3b+ and 4 for MiniDexed. I'll check out this PR on those.

@omersiar
Copy link

If we already have wifi, ftpd, syslog, I think we should also have sshd :P Has anyone tried to use 8x synth_dexed on Linux? I think it could be interesting with PREEMPT_RT.

Not synth_dexed but 3x VDX7 is achievable on RPi 3A+, this is due to VDX7 being bit accurate emulation, also author made possible to run it in headless setup.

@Minigoer
Copy link

Hello, thanks a lot for this update.
I tried several time to install MiniDexed_2024-11-19-5aad2ef on RPI 3 model b, but it freeze on the splash screen on the lcd.
I have no hdmi display to read debug message, and may miss something while doing the installation.

Copy link

Build for testing:
MiniDexed_2024-12-19-ccec4b6
Use at your own risk.

@Banana71
Copy link

Hello, thanks a lot for this update.
I tried several time to install MiniDexed_2024-12-19-ccec4b6 on RPI 4 model b, but it freeze on the splash screen on the lcd.
I have no hdmi display to read debug message.

@blixabloxa
Copy link

blixabloxa commented Dec 21, 2024

Hi All,

Thanks for working on this enhancement.

However, I too am stuck on the splash screen with Minidexed_2024-12-19-ccec4b6 on a Raspberry Pi 3 A+ wifi. I will try the previous version to see if that works.

Update: Previous version MiniDexed_2024-11-19-5aad2ef also stuck at the splash screen. Not sure if it is me or the build?

@Banana71
Copy link

Does anyone have a version after MiniDexed_2024-11-16-bfca612 working? #747 (comment)

@Minigoer
Copy link

Hello, thanks for the MiniDexed_2024-11-16-bfca612 build, but unfortunately, it stuck also as MiniDexed_2024-11-19-5aad2ef on the splash screen (showing build number). I plugged an hdmi display (and edited the .ini for debug) but nothing is displayed.

@probonopd
Copy link
Owner Author

probonopd commented Dec 21, 2024

Does anyone have a version after MiniDexed_2024-11-16-bfca612 working?

Yes, I have the latest one running, albeit with some issues:

  • MiniDexed_2024-12-19-ccec4b6 on a Raspberry Pi Zero 2 W with NetworkEnabled=1 configured to use WLAN and DHCP stalls at showing MiniDexed 20241219-ccec4b6 for a long-ish time (around 10 seconds), but then eventually proceeds to showing the IP address and seems to be working for me.
  • When the configured WLAN is not available (e.g., because the router is shut off or the configuration in wpa_supplicant.conf is wrong), then it seems to stay on the MiniDexed 20241219-ccec4b6 screen forever.
  • If networking is enabled but the wpa_supplicant.conf file is missing, the system seems to just hang or reboot.
  • With NetworkEnabled=0 it boots into the MiniDexed main screen without delay.
  • MiniDexed_2024-12-19-ccec4b6 on a Raspberry Pi 2 with NetworkEnabled=1 configured to use wired Ethernet seems to just hang or reboot. This worked in earlier builds, e.g. 20241116-973008d.

So what needs to be changed? (Better ideas welcome!)

  • Can it be changed so that it searches for the WLAN in the background without being stuck on the boot screen? In other words, boot to the MiniDexed main and only then try to (optionally) configure the network and just continue without the network if for any reason it cannot be reached.
  • It should imho boots into the MiniDexed main screen first , without network. Imagine you have configured WLAN but then you are in a different location (traveling) in which your configured WLAN is not available. MiniDexed should still be usable (without WLAN) in that case. After some timeout, it should imho just give up searching for the WLAN so that it doesn't continue to search all the time.
  • When WLAN is enabled but wpa_supplicant.conf is missing, it should imho still boot into the MiniDexed main screen, albeit without WLAN, or show a message on the screen.
  • Wired Ethernet needs to be fixed. Of course there is no wpa_supplicant.conf in this case. This worked in earlier builds, e.g. 20241116-973008d.

Copy link

Build for testing:
MiniDexed_2024-12-21-c88257d
Use at your own risk.

@omersiar
Copy link

omersiar commented Jan 3, 2025

Please see and test #783

@Mopsteri
Copy link

Mopsteri commented Jan 4, 2025

Does anyone have a version after MiniDexed_2024-11-16-bfca612 working? #747 (comment)

Hello!,
Tested with Raspberry 3B v1.2 / Zero2W

  1. Download this version MiniDexed_2025-01-03-6800987 "Latest".
  2. Install it to SDCard and make necessary modifications to files, eg. wpa_supplicant.conf, minidexed.ini and so on...
  3. Now download this version MiniDexed_2025-01-03-0ec4b55.
  4. Extract kernel8.img to the SDCard and overwrite existing file.
  5. Boot MiniDexed.
    It takes about 15 seconds to show IP-Address.

I know this is somekind "workaround" but hey! everything works just fine.

Tested with (rtpMIDI+Hatari+Twenty-Four 3.0 by Steinberg).

Br.
Marko

@blixabloxa
Copy link

Hi All,

Just confirming that I followed Marko's procedure and that I got it working too with a RPi 3A+ wifi. Loaded Filezilla on Linux and FTP works to the SD card.

Enzo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supporting RTP-MIDI
8 participants