Sending Osc From Globaloscactions.lua

Hi

I’m trying to send OSC from GlobalOscActions.lua. Could anyone provide an as simple as possible example that does this? I first tried this

  
renoise.Osc.Message("/luck/flowers")  
  

but it doesn’t seem to get through. Is the above really possible, just like that? If so what port is it sending over - 8000 like for reception? Are there anything prepended to this message, like if I send /renoise/stuff I have to add handler for /stuff in GlobalOscActions.lua (makes sense, but very frustrating when you don’t know it).

Ok, so I took another approach. Found some code snips and came up with this

  
OscMessage = renoise.Osc.Message  
  
local client, socket_error = renoise.Socket.create_client(  
 "localhost", 8000, renoise.Socket.PROTOCOL_UDP)  
  
if (socket_error) then   
 renoise.app():show_warning(("Failed to start the " ..   
 "OSC client. Error: '%s'"):format(socket_error))  
 return  
end  
  

and inside the handler for sending:

  
client:send(OscMessage("/luck/flowers"))  
  

But I get:

Renoise LOG> Exception: wrong type of message
Renoise LOG> OSC: Error while parsing OSC message: /luck/flowers (wrong type of message)

What exactly does “wrong type of message” mean?

what port is it sending over - 8000 like for reception?

Since the built-in OSC server in Renoise defaults to port 8000, you have to create your OSC client for another port than that one.
I just made a test with Renoise <-> pure-data, basically adding the client part to GlobalOscActions.lua, like you have done, but on port 8008.

local OscMessage = renoise.Osc.Message
local OscBundle = renoise.Osc.Bundle

-- open a socket connection to the server
local client, socket_error = renoise.Socket.create_client(
"localhost", 8008, renoise.Socket.PROTOCOL_UDP)

if (socket_error) then
renoise.app():show_warning(("Failed to start the " ..
"OSC client. Error: '%s'"):format(socket_error))
return
end

add_global_action {
pattern = "/transport/custom",
description = "Custom action",

arguments = nil,
handler = function()
print("triggered custom OSC action: /transport/custom")
print("client",client)
client:send(
OscMessage("/renoise_pd/transport/bpm", {
{tag="f", value=renoise.song().transport.bpm}
})
)

end
}

On my PC, the message is now received by Renoise on port 8000, and the reply is sent on port 8008.

Then, in pure-data, I can listen for any message on port 8008 and decide which one to act on.
The following patch will print /renoise_pd/transport/bpm 110 in the PD console (a really simple patch, as it will catch any message sent to port 8008)

pd_osc_receive.png?raw=1
The “renoise_pd” prefix is just one I randomly selected, you can enter whatever pattern you want to.

Btw: printing debug messages (tracing) is easy, just enable the lua scripting console and add “print”, “rprint” (for table) statements where you need it.

Thanks a bunch, will try this as soon as I get back to my computer!

Ok, now it’s working!

I was almost there, just the port 8000 that should be 8008 + chuck silently fails if you’re listening for events like “/fromrenoise/song/number_of_tracks,” (no data send along), but in fact are receiving “/fromrenoise/song/number_of_tracks, i” (with int data send along).

Lesson learned: until you have poked a hole through OSC, take very small steps :slight_smile:

Thanks again for the example and suggestions!