HELP udp and sending llll

Discussions, advice, bug reports and much more about the "bach" environment.
Dtronlujan
Posts: 15
Joined: Sun Apr 14, 2019 1:27 am

HELP udp and sending llll

Post by Dtronlujan » Wed May 01, 2019 10:26 pm

What I'm trying to do is very simple. I'm sending "subscore nil" into a bach.score then connecting that to another bach.score, where I will adjust measure ranges and stuff. This is very simple. However, I am wanting to do this using udp. Subscore a bach.score on one computer and have it fill a bach.score on another computer. So I'm essentially sending a message like this: bach.llll 142714 over udp. However, when this message reaches the bach.score on the new computer I get the error: "bach.score bad input llll". Is it possible to send this list information over udp?
Thanks for any help
D

pedrnun
Posts: 74
Joined: Sun Jan 17, 2016 3:23 am
Contact:

Re: HELP udp and sending llll

Post by pedrnun » Thu May 02, 2019 3:05 am

Hi!

I think all you have to do is place a [bach.portal @out t] before the [udpsend].

On a side note, UDP is "fast and unreliable" whereas TCP is "slow and reliable".
I use the former in situations where low latency is more important than a message not arriving (like a 'addchord' message) and the latter when I don't mind waiting a few hundred milliseconds (if that be the case) for a message I really need to arrive intact. I don't know what's your use case, but...
If you're not familiar with it, check out [mxj net.tcp.send] and [mxj net.tcp.recv] – you'll need Java installed.

Cheers,
Pedro

Dtronlujan
Posts: 15
Joined: Sun Apr 14, 2019 1:27 am

Re: HELP udp and sending llll

Post by Dtronlujan » Thu May 02, 2019 2:14 pm

Hi Pedro,

Thank you so much you are a LIFESAVER! [bach.portal @out t] works like a charm! I didn't know about TCP though and I will definitely check it out. In my case low latency is fairly important but making sure a message DOES arrive is even more so.

Thank you again this REALLY helps me.

Best,
Daniel

danieleghisi
Site Admin
Posts: 1347
Joined: Fri Dec 03, 2010 1:25 pm

Re: HELP udp and sending llll

Post by danieleghisi » Thu May 02, 2019 5:32 pm

Glad Pedro helped! I add my two cents: to reduce the amount of things sent through the net, you might only want to dump the body of the score, you probably don't need to send all the header each time.

Dtronlujan
Posts: 15
Joined: Sun Apr 14, 2019 1:27 am

Re: HELP udp and sending llll

Post by Dtronlujan » Thu May 02, 2019 6:08 pm

Hi Daniele,

I think I just ran into that problem. On my initial test the [bach.portal @out t] worked fine... But now that I'm trying to replicate it I keep getting the error "udpsend: message too long for maximum package size". So send only the body? How do I go about doing that....is it a matter of changing the subscore message?


EDIT: Hey sorry I should really try things out before I ask more questions! I'm finicking with the subscore message rn and it's doing stuff. I see what you mean and it's working.

EDIT 2: Okay I can't catch a break. I need to be able to send key sig and clef information. I realize that it's just too much information for udp to handle. I need to send a pretty lengthy score each time. Even if I just do the body it's too much. So now I'm stuck. There has to be a way to get the information through... Will TCP be able to?

Thanks for bearing with me. These brick walls are frustrating! I'm so close!

Daniel

pedrnun
Posts: 74
Joined: Sun Jan 17, 2016 3:23 am
Contact:

Re: HELP udp and sending llll

Post by pedrnun » Fri May 03, 2019 2:47 pm

Hi,

TCP is generally used for things like sending e-mails, etc. In theory, it's good for large amounts of data.
UDP is best for online gaming (event triggering like gunshots, etc).

The only bottleneck to TCP might be Max's own data limits. I know Max's message object, for example, has a list size limit which many times doesn't allow bach scores to be dumped to such objects.

As I mentioned in the other topic, I have sent subscores (only 8 measures each - so, quite small) through TCP. The only way you're gonna be sure if it works with your score is if you try it. I would like to hear about your findings...

I hope this helps.
Pedro

Dtronlujan
Posts: 15
Joined: Sun Apr 14, 2019 1:27 am

Re: HELP udp and sending llll

Post by Dtronlujan » Fri May 03, 2019 4:17 pm

Hi Pedro,

Thanks for your response. I've tried using the tcp objects that you mentioned. They work but just as well as udp.

I have my main bach.score going into a bach.portal like you mentioned. Then that goes into the tcp.send object.When I "subscore" a small amount of data, 5 measures or so, the information comes out from the tcp.recv object just fine.However, it's when I send a large amount of data that Max crashes.

Right now I'm trying to iterate the data instead of sending it all at once but I haven't been successful yet. For instance, I subscore out of the main bach.score, send that to a [bach.iter @out t], then into [mxj net.tcp.send...]. The iterated data comes out of [mxj net.tcp.recv...], then that goes into a bach.collect. The idea is that bach.collect will piece together the iterated information into its original form, although I'm finding that it probably doesn't work this way.

This is what I've tried so far. Also, just so you know exactly what I'm trying to do, I want to be able to send a full-length score with multiple voices of at least 100 measures. In my current example I can send a piano score of 100 measures just fine. But as soon as I kick it up to 200 measures Max crashes.(the musical material is light/thin too) So I guess it'll just be a game of me figuring out how much data I can and cannot send.

The good thing is that I CAN control (from the host computer) the size of each of these scores that I'm sending. I just need to be mindful that they aren't too big to crash Max.

That's where I am right now and you've been very helpful to me. And I know I've said a lot!

On a side note, Pedro, it seems like you and I are doing similar things and that's really cool! Comprovisador looks awesome! I'm doing a similar thing with multiple musicians reading generated music but it involves video games B).

This post has gotten long oops.

Best,
Daniel

pedrnun
Posts: 74
Joined: Sun Jan 17, 2016 3:23 am
Contact:

Re: HELP udp and sending llll

Post by pedrnun » Sat May 04, 2019 1:56 am

Hi,
Multiple musicians reading generated music involving video games? How awesome is that! :)

Here's one more insight and a few random ideas for you to try out.
Right now I'm trying to iterate the data instead of sending it all at once but I haven't been successful yet. For instance, I subscore out of the main bach.score, send that to a [bach.iter @out t], then into [mxj net.tcp.send...]. The iterated data comes out of [mxj net.tcp.recv...], then that goes into a bach.collect. The idea is that bach.collect will piece together the iterated information into its original form, although I'm finding that it probably doesn't work this way.
A quick random one: try [jit.net.send] / [jit.net.recv]. I haven't been successful with these objects (which can send messages and/or matrices) for my needs, but who knows... Your's are clearly different from mine, so it might be worth a shot.

As you've probably read on my reply to the other topic, I've had some trouble with sequential (or iterated) messages through [mxj net.tcp.*]. I've discovered that sometimes unwanted reordering would happen (although one would think it wouldn't happen with the TCP protocol). If you are going to piece together messages that arrive out of order, then you got yourself a problem.

One solution that comes to mind is to assign a key to each of the iterated bits so that you can properly parse them and ensure the right order is maintained. For example, you could do it with [bach.keys] and [bach.join], adding some logic to ensure all sent parts have been received, before triggering [bach.join].

Another random idea goes a bit against what Daniele said on the other topic, but since you are having to split the contents of the dumped score anyway, it might make sense to try out the following:
- do a selective dump (message 'dump separate' or only those you really need (extras?));
- assign keys as mentioned above;
- parse with [bach.keys] directly to the corresponding inlets of your client's [bach.score];
- trigger the [bach.score] with a bang when all parts are in;
You might need an extra [bach.score] on the host side (if you aren't using one already) to use as a temporary buffer for the 'subscore' and where you can perform the selective dump.
I want to be able to send a full-length score with multiple voices of at least 100 measures. In my current example I can send a piano score of 100 measures just fine. But as soon as I kick it up to 200 measures Max crashes.(the musical material is light/thin too) So I guess it'll just be a game of me figuring out how much data I can and cannot send.
Firstly, if you ever discover what those limits are, please share! I'd be interested to know.

Secondly, because you are needing to send 100 or 200 measures at once, I wonder if you could just send the score as a file... in a pen-drive, by e-mail, using a shared folder or a server, maybe ?
Don't get me wrong: I'm not wanting to be sarcastic or anything! :mrgreen: but 100 measures seems a lot of music. If it is generated (and not precomposed, where you could indeed use a pen-drive) then I'm guessing it is not in a reactive fashion (as is the case in Comprovisador, which never generates more then a few dozen sixteenth notes at a time).
So maybe you do have the chance to save that generated score (or individual subscores) as a file (or files), send a notification to your clients and get them to read the saved file from your computer before performance begins. I know: it seems random, but it might work just fine!

Have a look at ways to configure a server in your computer. Old macs had Apache which can still be re-activated in newer macs (which is my case). I've also heard of python's "simple server" which you can use to serve the contents of a folder (like Apache, but (I'm guessing) you can choose a specific folder). Moreover, I'm sure you can do the same with node.js – and since Max 8 has Node For Max, there might be some advantages there!

If you set things up this way (server), you'll need [maxurl] on the client side to download the score file. Otherwise, if you have a shared (public) folder in your host machine, just tell your client's [bach.score] to read from it. If you opt for the shared folder, though, I'll give one advice: make sure it works across all platforms!

... I know... so many things you didn't ask for... sorry! :-)
I hope I didn't cause more confusion than help.

Cheers,
Pedro Louzeiro

Dtronlujan
Posts: 15
Joined: Sun Apr 14, 2019 1:27 am

Re: HELP udp and sending llll

Post by Dtronlujan » Sat May 04, 2019 2:22 am

Pedro,

Your suggestions and advice are INVALUABLE. I can't wait to try out the suggestions you've given me! My eventual goal is to be able to use some sort of server like you mention, likely utilizing Node. I've looked into it but the learning curve seems high and resources are few and far between. So for NOW I'm using UDP/TCP since I'm having a demonstration of my project in a week! But my project is definitely long-term.

It might take me a while to respond with my progress but I will definitely be in touch.

Thanks for pouring a lot of yourself into this! You've been a great help.

Best,
Daniel

pedrnun
Posts: 74
Joined: Sun Jan 17, 2016 3:23 am
Contact:

Re: HELP udp and sending llll

Post by pedrnun » Sun May 05, 2019 5:55 pm

You're welcome! :-)
Keep me posted!

Best,
Pedro

Post Reply