Home › Forums › Development › Change requests › OSC. String as an argument.
- This topic has 6 replies, 3 voices, and was last updated 7 years, 4 months ago by fundorin.
-
AuthorPosts
-
December 4, 2016 at 2:13 pm #70422
Reaper can send OSC command for selected track name as this: “/track/name, “Reverb Bus”, where “Reverb Bus” is a value for command “/track/name”.
Ctrlr adds all command values in the table, named “arguments”. The format it uses for values is userdata. You can extract floating number out of userdata with string.format(arguments[0].f), where “f” means float.
I can easily get this type of commands/values when OSC message from Reaper is received, no matter is it a single message or bundled.The problem begins when Reaper sends strings as values, like “Reverb Bus”. I’ve tried arguments[0].s, but it only returns 1 character number, which can be converted to a character by string.format(%c, arguments[0].s). The problem is that there’s no way to pick other letters in the word. Correct me, if I’m wrong.
- This topic was modified 7 years, 4 months ago by fundorin.
December 6, 2016 at 5:30 am #70447I’d say that this might be similar to how text is sent over Sysex, where it is sent as hex either as MIDI bytes, or as a bitstream.
This is how I do it for SYSEX
receiveProgramName = function(sysexData) -- assume checks that data is valid PC3 program header have passed local messageSize = sysexData:getSize() local name = "" -- check received data is for same program as request local a={} for i=0,30 do -- this collects first 23 bytes and puts them into array a. This should include the program name. a=data:getByte(i) end --for receivedProgramNum = a[5]*128+a[6] -- need to add a flag for Forte to push byte numbers up by 1 -- For Debug -- console (string.format("Received Program: %s", receivedProgramNum)) -- console (string.format("Sent Program: %s", nPrg)) if nPrg ~= receivedProgramNum then -- this is required because PC3 returns next valid object if requested object doesn't exist return else if messageSize < 12 then return else j=11 while a[j] ~= 0x00 do name = name..symbols[a[j]] j=j+1 end --while prgName[receivedProgramNum]=": "..name -- update Program Received currentProg = string.format(nPrg) panel:getComponent("recProg"):setComponentText(currentProg) -- This needs to be moved outside of this function and called when all dumps are completed. Temporarily called though the if below -- We don't need to waste resources and time building the string every time we receive a request. if writeListBoxStringFlag==true then str = "" for i = 1,4224 do str = string.format("%s%04d%s\n", str,i,prgName) end --for updateListBoxes() writeListBoxStringFlag = false end --if end --if end --if end
The symbols are as below. I think I pinched this from the Miniak panel, so kudos to the author.
initializePanel = function() symbols = { [0]="","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|", "|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|", " ","!","\"","#","$","%","&","'","(",")","*","+",",","-",".","/", "0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?", "@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O", "P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_", "'","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o", "p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","|"} symbols2 = { [0]="","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|", "|","|","|","|","|","|","|","|","|","|","|","|","|","|","|","|", " ","!","\"","#","$","%","&","\'","(",")","*","+",",","-",".","/", "0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?", "@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O", "P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_", "'","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o", "p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","|"}
- This reply was modified 7 years, 4 months ago by Puppeteer.
- This reply was modified 7 years, 4 months ago by Puppeteer.
- This reply was modified 7 years, 4 months ago by Puppeteer.
- This reply was modified 7 years, 4 months ago by Puppeteer.
The Puppeteer
http://godlike.com.auDecember 6, 2016 at 7:49 am #70453There’s a problem with a very first step of your code, if one tries to adopt it to OSC:
local messageSize = sysexData:getSize()
Both
local messageSize = arguments:getSize()
and
local messageSize = arguments[0]:getSize()
wuold return an error “Error message: [string “onOSCMessage”]:19: attempt to call method ‘getSize’ (a nil value)” to console, cause agruments is userdata.
P.S. I’ve posted about this issue in several threads, so you can check details and example in this thread, if you like.
December 6, 2016 at 10:57 pm #70469Hi fundorin,
can you please guide me how you are getting/setting OSC into Ctrlr? I would like to look into your problem but for some reason I can only send OSC from Ctrlr but am not receiving anything. I tried Reaper, Lemur and Touch OSC to send on different ports (even 9999 using your version of the OSC-Demo panel) but no luck. Since you are able to see incoming OSC messages in console I’m pretty sure I am doing something wrong and not the software.
Thanks!December 7, 2016 at 5:13 pm #70497Hi, proton. You need to go to midi settings of Ctrlr, enable OSC, choose UDP and ports 9999.
December 7, 2016 at 9:05 pm #70500Hmm, sure, this is what I did but still nothing comes into Ctrlr when I send OSC to it.
Are you using Ctrlr in stand-alone mode or you test it as a VST or AU plugin?
Do I need to do pay attention to something more than port I send to?
I thought “Slider1” will receive and move as soon as it gets values on the proper channel and from a proper Address. One thing I just realize is that “Slider1” in that particular case is sending integers and Reaper or Lemur are sending floats. Can this be the issue? Thanks!December 7, 2016 at 9:14 pm #70501I’m using Ctrlr in standalone mode in Windows 10, but it works the same way as VST.
You only need one port in settings, actually. Slider1 purpose is only for sending OSC.
Pink window’s purpose is to show osc commands, but it didn’t work for me, sometimes, so in my demo panel all osc feedback is only shown in Lua console.I’ve tried now and it wasn’t working for me, either. Then, I closed all other panels in Ctrlr, except OSC2 panel, restarted Ctrlr and now I can see OSC feedback in the console again.
http://i.imgur.com/ncZxpR3.png
-
AuthorPosts
- The forum ‘Change requests’ is closed to new topics and replies.