-- this does not do anything except creating an Osc message
OscMessage("/1/fader5", {
{tag="f", value=value}
)
-- but this creates an Osc message and also sends it somewhere
client:send(
OscMessage("/1/fader5", {
{tag="f", value=value}
})
?
Thanks for Spotting that!!
This fixes every slider and rotary send from renoise in my touchosc tool.
Now that I now I was going in the right direction, I should be able to apply this to the toggle buttons and push buttons, push buttons might be a chore.
Now I have to find out why I can’t get remote connections to the OSC server I make in renoise(only internal 127.0.0.1)
It’s the strangest issue so far. If I use 127.0.0.1 I can get all the messages I send internally.
If I change that to my private lan 192.168.255.255, I get this:
*** TestPad.lua:15: variable 'app' is not declared
*** stack traceback:
*** [C]: in function '_error'
*** [string "local mt = getmetatable(_G)..."]:29: in function
*** TestPad.lua:15: in main chunk
from this that I patched together from the Docs:
local OscMessage = renoise.Osc.Message
local OscBundle = renoise.Osc.Bundle
local server, socket_error = renoise.Socket.create_server(
"192.168.12.32", 8008, renoise.Socket.PROTOCOL_UDP)
if (socket_error) then
app:show_warning(("Failed to start the " ..
"OSC server. Error: '%s'"):format(socket_error))
return
end
---ithings address
local client, socket_error = renoise.Socket.create_client(
"192.168.12.34", 8007, renoise.Socket.PROTOCOL_UDP)
if (socket_error) then
app:show_warning(("Failed to start the " ..
"OSC client. Error: '%s'"):format(socket_error))
return
end
--------------------
server:run {
socket_message = function(socket, data)
-- decode the data to Osc
local message_or_bundle, osc_error = renoise.Osc.from_binary_data(data)
-- show what we've got
if (message_or_bundle) then
if (type(message_or_bundle) == "Message") then
print(("Got OSC message: '%s'"):format(tostring(message_or_bundle)))
elseif (type(message_or_bundle) == "Bundle") then
print(("Got OSC bundle: '%s'"):format(tostring(message_or_bundle)))
else
-- never will get in here
end
else
print(("Got invalid OSC data, or data which is not " ..
"OSC data at all. Error: '%s'"):format(osc_error))
end
client:send(("%s:%d: Thank you so much for the OSC message. " ..
"Here's one in return:"):format(socket.peer_address, socket.peer_port))
client:send(OscMessage("/flowers"))
end
}
local action_pattern_map = table.create{}
local function argument(name, type)
return { name = name, type = type }
end
---------------------
local function add_action(info)
assert(action_pattern_map[info.pattern] == nil,
"pattern is already registered")
assert(type(info.pattern) == "string" and type(info.handler) == "function",
"action info needs at least a pattern and handler function")
assert(not info.arguments or type(info.arguments) == "table",
"arguments should not be specified or should be a table")
assert(not info.description or type(info.description) == "string",
"description should not be specified or should be a string")
info.arguments = info.arguments or {}
info.description = info.description or "No description available"
action_pattern_map[info.pattern] = info
end
--------------------
add_action {
pattern = "/evaluate",
arguments = { argument("expression", "string") },
description = "Evaluate a custom Lua expression, like i.g:\n" ..
"'renoise.song().transport.bpm = 234'",
handler = function(expression)
print(("OSC Message: evaluating '%s'"):format(expression))
local succeeded, error_message = evaluate(expression)
if (not succeeded) then
print(("*** expression failed: '%s'"):format(error_message))
end
end,
}
---
add_action {
pattern = "/1/toggle1",
description = "Start playback or restart playing the current pattern. "..
"No arguments available.",
handler = function()
local play_mode = renoise.Transport.PLAYMODE_RESTART_PATTERN
renoise.song().transport:start(play_mode)
end,
}
-------------------
-- construct and send messages
client:send(
OscMessage("/1/toggle4", {
{tag="i", value=1}
})
)
I notice it’s mixture variable not included in the osc.lua snippet but the real question is:
Is this a drawback for creating servers?
The client has no problem sending messages on another port remotely, but I guess I’m just not sure what I’m doing wrong.