Janus message size limit?

Hi

I discovered a limit on the length of sysex messages for the SWI-Prolog-janus-mido interface. My prolog program can receive messages with a length up to 1024 bytes, but not larger. I read in the manual that SWI Prolog running on 64-bit machines supports ‘virtually unlimited’ atom sizes.

Since I don’t know of a limit on the size of sysex messages imposed by the MIDI association or the mido package, I suppose it’s imposed by janus.

Since system exclusive messages are mostly used for receiving and sending patch dumps that can be several kB long, this is very unfortunate.

If necessary I can publish some data and/or a program script to verify this.

Thanks in advance for any help.

Remifa.

AFAIK, Janus imposes no limits except for memory. If it does, it should be fairly easy to construct a counter example, preferably without the whole mido stuff :slight_smile: If you find such an example, I’m happy to stand corrected and fix it.

Since I’m using Janus exclusively for accessing the mido package, I have no other examples. I’m sorry.

Here is a minimal script to receive MIDI messages using mido (written in Python):

open_in_port(InPortName, InPort) :-
	py_call(mido:open_input(InPortName), InPort),
	format('InPort opened: ~w~n', [InPortName]),
	thread_create(input_from(InPort), _).

input_from(Port) :-
	call_cleanup(
		forall(repeat, receive_one(Port)),
		py_call(Port:close())
	).
	
receive_one(Port) :-
	py_call(Port:receive(), Msg),	
	py_call(Msg:type, Type),
	writeln(Type), %we are looking for sysex type messages
	%handle_midi_message(Type, Msg),
	py_free(Msg).

:- open_in_port('loopMIDI Port 1', _). %please replace the port name by your own port name

I included two .syx files containing sysex messages. The length of the messages is specified in the file names. Remove the .log extension as .syx files are not allowed on this forum.

You can load (View → System Exclusive Messages + File → Insert) them into MIDITools ( MIDI Tools | Mountain Utilities ) and play (select the proper Output device and click on Play) them using an output port (Options → MIDI devices → Output tab) that corresponds to the input port you specified in the prolog script.

When you send the ‘length1024.syx’ file it prints ‘sysex’.
When you send the ‘length1025.syx’ file nothing is printed, not even an error message.

I hope someone can verify this and find the cause…

I thank you in advance.

Included files:

length1024.syx.log (1 KB)
length1025.syx.log (1.0 KB)

I’m sorry, but I changed compute infrastructure in the meanwhile, so I’d have to setup MIDI again and re-familiarize with it. If there is a length limit in the interface, it should be quite trivial to call a Python function that returns something too big to illustrate that. I very much doubt such a limit exists.

Possibly some print statements can make clear there is (or not) an interface issue? What is the actual error message and/or what does the wrong reply look like?

I can understand it takes time to set up a MIDI test environment again.

I don’t get any error messages when sending a larger than 1kB message. Nothing happens. The writeln/1 statement doesn’t print anything.

It isn’t a Windows issue for sure, as I’m sending around sysex dumps around since Windows 95 and all the other tools I use handle large sysex messages. There might be a problem with my installation of Python or mido.

I plan to test the following :-

  1. send large, long sysex messages from Prolog to mido using the janus interface.
  2. send & receive large non-MIDI messages between Python and Prolog without mido
  3. send & receive large, long sysex messages using mido in Python.

I’ll report back asap.

1 Like

Here are my test results for the Prolog-janus-mido-Python message size limits :-

  1. Messages up to 200kB sent from Prolog are instantly received using the Janus-mido-Python interface. A message with a length of 300kB was seemingly sent properly (I mean, no error was produced) but wasn’t received.

  2. ‘Messages’ from Prolog to Python using the janus interface of 10MB are received without any problem. A message of 100MB results in an ERROR: Stack limit (1.0Gb) exceeded. Since 10MB is more than enough, I’m not going to increase the stack’s size.
    Though, I’ve a problem sending messages from Python to Prolog using janus. See further.

  3. Messages sent from Python’s mido up to 200kB are received without a problem. A message of 300kB is problematic as nothing is received and no error is reported. When a message of 250kB is sent, seemingly 5 separate messages are received…strange.
    Mido can’t receive sysex messages larger than 1024 bytes.

Conclusion: The problem is very probably caused by mido. I’ve transferred this problem to the mido forum.

A temporary, slow solution is to use .syx files as they can be opened by mido, regardless of their size (size limit not tested yet).

Here is my problem with sending messages from Python to Prolog using janus.

I’ve installed janus again:

C:\..>py -3.11 -m pip  install --no-build-isolation "H:\...\Python packages\janus-1.0.0-py3-none-any.whl"
Processing h:\...\python packages\janus-1.0.0-py3-none-any.whl
Requirement already satisfied: typing-extensions>=3.7.4.3 in c:\...\appdata\local\programs\python\python311\lib\site-packages (from janus==1.0.0) (4.8.0)
Installing collected packages: janus
Successfully installed janus-1.0.0
C:\..>

but I get an error when trying to import janus:

import janus_swi as janus
Traceback (most recent call last):
File “”, line 1, in
File “C:\Program Files\swipl\library\python\janus_swi.py”, line 4, in
from janus import *
File “C:\Program Files\swipl\library\python\janus.py”, line 66, in
import janus_swi._swipl as _swipl
ModuleNotFoundError: No module named ‘janus_swi._swipl’; ‘janus_swi’ is not a package

Can anyone please tell me how to resolve this problem?

Thanks for any help.

The current version at PyPi is 1.4.0. See janus-swi · PyPI

Assuming you run a recent version of Prolog, you may have some version mixup.

4 posts were split to a new topic: Installing janus_swi on Windows