Adding a custom dynamic variable to abstraction name, is this possible?
Ah, that makes sense with the mother patch (and the fact the variables need to be created at load time). I am maybe approaching my problem from the wrong angle in that case. I have a simple abstraction that will receive an OSC message from Open Stage Control, and I want to reuse this over and over, so currently adding the OSC address as a static variable in the abstraction name and that works really well.
As I am trying to create a sort of modular in pure data, I wondered if I have two identical for example 'envelope' abstractions (with controls pre-mapped to OSC), then it would be fantastic to make the OSC addresses dynamic (so /EnvAtt_1 could be /EnvAtt_$3), and I could have a floatbox define the $3 on each copy of the envelope abstraction.
So inside my OSC control I have declared the OSC address in its title and then use this in a receive, but the issue is declaring a dynamic variable in a receive path (that is not from the abstraction name), so 'r EnvAtt_$3' for example. Can you declare a variable for a receive any other way?
Sorry for the convoluted reply, and thanks again for helping, much appreciated!
On-air light, trouble receiving int via OSC
I'd like to make a suggestion: Pick one set of objects to handle OSC, and just use those. It's in the nature of a tech forum for different people to have different opinions and offer multiple suggestions, but mixing and matching many different approaches can also lead to confusion.
So, for example, your screenshot -- at the top left, you have [packOSCstream] (why this and not [packOSC]? ** ) and then below, [oscformat]. That's a source of confusion. These two objects have quite different ways of handling OSC addresses (or what I've been calling "command paths") -- two idioms. Nah, this is a good way to introduce mistakes. So, pick one that you're more comfortable with.
** Ah, I see, [packOSC} help says "[packOSCstream] is a way to send OSC over TCP or serial connections" -- but you're using UDP, so, not relevant. Again, simplify: [packOSC] or [oscformat], pick one and stick with it.
Also -- you've got elements of this patch where it's already been explained why they are incorrect. If you connect a "send..." message box directly to a [netsend -u -b], it will not send an OSC-formatted message. Since you are sending to devices that expect OSC-formatted messages, for OSC it is always incorrect to pass a "send..." message directly to [netsend]. Never do this. But, in the top left part of your patch, I count 3 "send" message boxes that are patched directly to [netsend]. Delete those patch cables.
(Similarly, at the bottom of your patch, the line of objects coming directly down from [list trim] --> [route ch] --> [route 1 2 3 4] -- this is a part of my example patch that I had labeled with a comment saying "this will not work." Copying and pasting the non-working part is again going to be a source of confusion.)
~~
An OSC message has two parts.
- An address (for command) with slashes, e.g. /cs/chan/at/0.
- A list of arguments.
- The argument list always has datatype tags, even if you don't specify them.
- If you didn't write type tags, it will guess. In Pd, all numbers are floating-point, so outgoing OSC will format numbers as floating-point by default.
- The X32 documentation says that it expects an integer 1 or 0. So, in [oscformat], you can force a number in a specific position to be integer-formatted by giving "i" as the type tag.
So...
Which.. for the message [set /cs/chan/select/47(, might make sense, because there's the 47?
No, it's not the 47. The 47 is part of the command path. How do you know it's part of the command path? Because it's connected with slashes in the device docs. The command path is totally excluded from the type tags -- it's always a string.
It gets a bit confusing with [oscformat] because the vanilla OSC objects write both the OSC address and the arguments as lists (no slashes).
- [packOSC] way: [send /cs/chan/select/47(
- [oscformat] way: [set cs chan select 47, bang(
OK, let's look at those.
packOSC: 47 99 115 47 99 104 97 110 47 115 101 108 101 99 116 47 52 55 0 0 44 0 0 0
oscformat: 47 99 115 47 99 104 97 110 47 115 101 108 101 99 116 47 52 55 0 0 44 0 0 0
Notice that these are byte-for-byte identical. So these are just two different ways of expressing the same idea. (I do see in your screenshot where you're mixing and matching syntax, trying to use [oscformat] syntax with [packOSC] -- nope, this is not going to work. They have different programming interfaces.)
I suggest to slow down and do some smaller scale tests to make sure you can get the right result from the lighting board. Integration should come later.
hjh
On-air light, trouble receiving int via OSC
@jbaker It seems that maybe data can be requested from the X32 with an osc formatted message starting /formatsubscribe .... for specific parameters... and permanently? or just for a limited time...... and are future button presses on the console also (or only) returned...?
/web in the address.... can this be replaced with "IP:port"... ?
Complete and (so far) incomprehensible osc info here....... https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://tostibroeders.nl/wp-content/uploads/2020/02/X32-OSC.pdf&ved=2ahUKEwjq9e_w2JqMAxXCdqQEHXAeISkQFnoECB8QAQ&usg=AOvVaw2xQyrtSBeKrEBddafvVqiG
It would be great if you can find the return port number for osc on the X32.
It seems that on/off (enum) and 1/0 (integer) are interchangeable, but it is not clear (yet...!) whether they are part of the message header or data following the header.
all parameters must be big‐endian and 4‐byte aligned/padded, as per OSC specification.
padding is done with null bytes.
float parameters must be in range 0.0 – 1.0, e.g.:
0.0 0x00000000 (big-endian)
0.5 0x3f000000 (big-endian)
1.0 0x3f800000 (big-endian)
integer and float parameters are signed 32‐bit values.
strings must be null‐terminated.
enum parameters can be sent as strings or integers (see below).
boolean parameters will map to enum type {OFF, ON} (or OSC integer {0, 1})
blobs (arbitrary binary data) follow specific rules depending on the section they apply to (see later in this document)
Too much reading for me today...... maybe later...
David.
On-air light, trouble receiving int via OSC
Hello,
I've been working on this for a couple years now... I'm very close!
Hardware: Raspberry pi 3B
OS: Bullseye, pd .51
Peripheral hardware:
- Behringer X32 audio board. Physical and network MIDI out, can do OSC over MIDI sysex (osc documentation link)
- Colorsource AV board, can be controled via OSC
Here's my patch
Goal: When any of channels 1-4 are unmuted on the X32 audio board, a DMX light turns on (has 'on-air' stencil and a red gel attached to the front). When all 4 channels are muted, the light turns off.
The problem: This works- the issue is that sometimes pd or the X32 will mess up and a MIDI message is missed, so one of the 4 mute toggles (in pd) will be the opposite of what the actual mute status is of that channel.
My idea to fix: "Ask" what the mute status is of each channel every 10 messages or so.
Overview: I found the MIDI that the Behringer X32 spits out when muting channels, then used 'sel' to start, bondo sums and when the total gets to 4, an OSC message is sent to the lighting board to turn on the ON-air light. When it dips below 4, a message is sent via OSC to turn the light off.
I can't seem to get return values from the X32. With the X32 livetoolkit software I know that sending [/ch/02/mix/on] will return [/ch/02/mix/on ,i 1]. The send command doesn't need a value type (float, int, etc.), but the return value contains an int, which is either 1 or 0, which represents the mute as on or off. I can't get any return values from the board. I'm trying UDP with netsend -u -b 10.136.124.112 10023.
Also- I'm getting MIDI to the pi with the... UM-ONE midi to USB dongle. I forget the manufacturer but I think it's pretty common with Pi's and Pd.
If someone has a better idea that to achieve what I'm trying, I'm good with that too!
Any help would be appreciated! It feels so close and this will be my first 'new' thing I've made.
[SOLVED] TouchOSC for 'complete n00b'
Hallo good people
I have already searched the relevant forums, and the TouchOSC manual but I am still struggling to get OSC data into Purr Data.
I am able to successfully parse OSC data from, for example, Sonic Pi into PD (via localhost) on the same machine. I have recently installed TouchOSC on my Android tablet, and installed Protokol (network messaging monitor) on my MacBook. All the OSC messages from TouchOSC (tablet) show up inside Protokol (MacBook), but [netreceive -u -b], [listen 800( in PD shows nothing. Do I need to tell [netreceive] where the OSC data is coming from (the connect 192.x.x.x message doesn't work)?
I'm afraid terms like Host, Client, server etc mean nothing to me, so is there a step by step guide out there for my issue please?
[EDIT] Muppet - I had to close Protokol!! All working fine now. Told you I was a n00b :D
<3
Brendan
space in OSC node identifier?
@jameslo said:
I'd still like to know if spaces are legal and possible with [oscformat] though.
I'm a bit surprised to see this, but in fact, according to the OSC spec 1.0, spaces are not allowed in OSC command paths.
https://ccrma.stanford.edu/groups/osc/spec-1_0.html#osc-address-spaces-and-osc-addresses
Each OSC Method and each OSC Container other than the root of the tree has a symbolic name, an ASCII string consiting of printable characters other than the following:
-character- -name- -ASCII code (decimal)- ’ ’ space 32 # number sign 35 * asterisk 42 , comma 44 / forward slash 47 ? question mark 63 [ open bracket 91 ] close bracket 93 { open curly brace 123 } close curly brace 125
So Pd has no obligation to support spaces here.
I suppose it depends on the software's OSC handler. SuperCollider doesn't complain (contrary to the OSC spec):
n = NetAddr.localAddr; // send to myself
o = OSCFunc({ |msg|
msg.postln;
o.free;
}, '/test space');
n.sendMsg('/test space', 1);
prints: [ /test space, 1 ]
I did some other tests:
- "symbol patch 1" --> [list fromsymbol]: escape char 92 is not in the ASCII list.
- list "112 97 116 99 104 32 49" --> [list tosymbol]: resulting symbol prints with a backslash. I don't know if the backslash is stored internally, or if it's inserted only for the printed output. A quick look at the source code in x_list.c suggests that the backslash is not stored internally.
- list "112 97 116 99 104 32 49" --> [list tosymbol] --> [list prepend set] --> [list trim] --> [oscformat]: The printed bytes from oscformat do include char 92. But I couldn't see in the source code where the space is being escaped. (This long way around to build the "set" message is to be certain that there's no backslash in my input -- the backslash must be generated internally somewhere..)
So [oscformat] seems to be where the problem is happening -- but the OSC spec makes no promises that spaces will work, so there wouldn't be any justification to log a bug.
hjh
Using TouchOSC to draw into a 16 step array? communication back'n'forth? Show Array content in TouchOSC?
@whale-av said:
I am almost certain that Gui objects in TouchOSC can talk midi and OSC at the same time.
But I doubt that it will communicate over wireless (required for OSC messages) and USB at the same time.
GUI objects in TouchOSC can send Midi and OSC at the same time, and wired USB connection does work for both, no issues. no need for having the iPad on Wi-Fi. just takes a while for TouchOSC on the iPad to realize what the IP address of the laptop is.
The communications between Pd and touchOSC are set in the abstraction [osc-s-r] within the [globpitcharray1] patch in the zip I posted.
There is a TouchOSC layout plom.touchosc in the zip that should be used with this patch (for a test demo).
thanks for breaking this down for me!
You would need to fix the IP address of the Ipad (static address) and use that address for [netsend] and [netreceive] in [osc-s-r] ....... if you ever get over your fear of using Wi-Fi for this.... or just feel like trying it to see what it will do.......
yes, [osc-s-r]
is definitely where it's at. thanks for spelling out the [netsend]
and [netreceive]
to me, cos looking at the screenshot i had, i can now realize where to input 11000 and 11001 for send + receive. the connect
portion of the script was throwing me.
i hope i have it right now,
Using TouchOSC to draw into a 16 step array? communication back'n'forth? Show Array content in TouchOSC?
@beep.beep - i'm running fully usb-tethered with all wi-fi bluetooth mobiledata off. can you have a look and see if this will solve your "OSC only works with wi-fi" issue?
@esaruoho Confirmed! Using your clues I was able send OSC over USB with wifi disabled. Nice to discover that my hacky workaround is no longer necessary! I’ve updated my other TouchOSC thread to point back to our present thread here, if there’s more to discuss on this subject please continue to do so here instead of replying to multiple threads, it makes it quite difficult for others to follow over time.
When I connected my iPad to my Mac & ran “arp -a” in the Mac’s terminal, I only saw one listing: the iPad’s IP address (unlike your screenshot, where you had many entries). This did enable me to at least send from Pd to TouchOSC, but since no IP was listed for my Mac I couldn’t send in the other direction.
Then — for reasons unknown — after fiddling with netsend/netreceive for a bit, “arp -a” then returned a 2nd entry for “broadcasthost (255.255.255.255)”. I’m not a networking expert but some quick searching indicates that this IP can be used to broadcast messages over a local network, so I tried entering 255.255.255.255 for “Host” in TouchOSC and voila, I can send to Pd! This also works the other way with “connect 255.255.255.255 9000” into [netsend -u -b], which successfully sends to TouchOSC on port 9000. I don’t know if there’s an efficiency downside to using a broadcast IP versus a direct IP, but if not this seems to simplify things a lot!
@ddw_music looking at your earlier comment, I didn’t know about netreceive’s -f flag either, that’s great to know! I tried your autoconnect logic and it works nicely, although of course it still requires the iPad to be configured correctly before doing its magic. I guess if there’s truly no harm in leaving TouchOSC’s host set to 255.255.255.255 and “broadcasting” all outgoing OSC data, maybe that’s about as close to zero-config as one can get?
edit: the above tests were done with a 2016 Macbook Pro and iPad 5th gen; when I tried these approaches with my much older 2008 Macbook and iPad 4th gen (both with older OS's) I did not succeed... so this all might be dependent on relatively recent hardware/software.
Using TouchOSC to draw into a 16 step array? communication back'n'forth? Show Array content in TouchOSC?
@whale-av said:
The [netsend] and [netreceive] are inside [osc-s-r] which is inside [globpitcharray] about half way down on the right and side.
ok! found the [osc-s-r]
and set TouchOSC on macOS and TouchOSC on iPad to talk to 8000 and 9000. i am now able to get "from iPad to PD" controls working over OSC - and the array on PD does update.
what's not working, is the "back to iPad" color highlighting with steps, even after starting playback of array via metronome.
but pretty amazing that, in the end, even the arp -a
was not required to snoop the ipaddresses, since TouchOSC itself recognizes, without having internet access, on the iPad, via usb-tethering, the macOS IP address, and macOS is able to recognize the iPad IP address. this without any internet connectivity or wi-fi on required.
but i'm still vague on how to get the "back from PD to iPad" OSC connection going. but if i got this far, maybe there's hope!
Using TouchOSC to draw into a 16 step array? communication back'n'forth? Show Array content in TouchOSC?
@esaruoho said:
I could try again, but it looked like UDP required me to know the IP address of both the laptop and the iPad, and that really threw me (i don't know how to figure out what the IP address of the iPad is, or how to make sure it's always the same, same for macOS).
Ah right, for bidirectional communication.
Actually in the netreceive help file, there is a flag for this: "optional -f flag for from address & port outlet (0.51+)".
Help file example prints from: list ::ffff:127.0.0.1 57120
where ::ffff:127.0.0.1
is an IPv6 address.
So...
... should configure the [netsend] to send to the first address from which messages were received (and I did a quick test, which worked). If you enable "Ping" in TouchOSC, then it will automatically send a message to the computer, which will trigger the "connect" logic right away.
Incidentally, I didn't know about this feature (never used the "from" address in Pd). My thought process was, "Well... this is a very common requirement, so let me have a look at the [netreceive] help patch and see if there's anything about 'from'" -- and toward the lower right, there's a [print from] box. Hm. Then, what's different about the [netreceive] feeding it is that it isn't only "-u -b xxxx" but rather "-u -b -f xxxx"... what's that "-f"? Then, looking up from there a little bit, there's a list of object creation flags, where "-f" is explained.
So the solution exists, and documentation for that solution is actually reasonably clear.
i have maybe an hour every 2-3 days to try and get something going, and also feel a bit like there's no "TouchOSC with PureData for idiots" blog-post for iPad / macOS going on, or at least i haven't been able to find it.
This I fully understand.
Pd OSC sending, like this. It won't send anything until after you push a connect ip.ad.dr.ess port
message into the netsend inlet -- as noted above, you can get the parameters for the connect message from [netreceive].
... producing messages like /1/toggle1 1.0
or /1/toggle2 0.0
. This type of message format is what you need to change a control's value on the tablet.
It's also possible to "set" the OSC command path before providing the arguments -- but try the simple way first.
hjh