Home › Forums › General › Programming › Some code that kill ctrlr and hung up windows
- This topic has 14 replies, 4 voices, and was last updated 8 years, 9 months ago by Puppeteer.
-
AuthorPosts
-
September 10, 2011 at 10:45 pm #440
Last night i try to made debug panel (based on DEMO – Midi.panel) for sysex transmit and receive from my supernova 2.
I found that toString function dont work. May be becouse supernova transmitted 2 bulk dumps (297 and 99 bytes) at single programm sysex
I try to use char conversion but CTRL was unstable and my PC is hunged.bugged panel:
http://www.speedyshare.com/files/302635 … 0v1a.panel2 sysex from 1 program request:
http://www.speedyshare.com/files/30263599/sn1a.syx
http://www.speedyshare.com/files/30263600/sn1b.syxSeptember 10, 2011 at 11:10 pm #3275This panel is broken, and i’m afraid you broke it using LUA the wrong way. You need to be careful how you use LUA cause you can damage more that just the panel. If you look at the XML of your panel (just open the panel file in any text editor)
[code:e09wlm5z]
<modulator modulatorValueExpression="modulatorValue" modulatorValueExpressionReverse="midiValue"
modulatorIsStatic="1" modulatorGlobalVariable="-1" modulatorMuteOnStart="0"
modulatorExcludeFromSnapshot="0" modulatorLinkedToPanelProperty="– None"
modulatorLinkedToModulatorProperty="– None" modulatorLinkedToModulator="– None"
modulatorBaseValue="0" modulatorCustomIndex="0" modulatorCustomIndexGroup="0"
luaModulatorValueChange="" modulatorMax="65536" modulatorValue="97"
vstIndex="22" name="lcd_name" uiLabelText="block22" Label text="block111">
[/code:e09wlm5z]
the last property is "Label text" that’s and invalid property and breaks the entire XML document, that causes crashes all over the place. You did this in your lua function assignValues297[code:e09wlm5z]
panel:getModulatorByName("lcd_name"):setPropertyString ("Label text", "block111")
[/code:e09wlm5z]i don’t know where you got the "Label text" property name from, but it’s invalid, all the possible properties for each component/modulator/panel are documented in the API DOcs here: api/namespace_ids.html use only those.
Also you declared a LUA method like:
[code:e09wlm5z]
function Sn2 single program dump req ()
end
[/code:e09wlm5z]you can’t do that, you need to at least grasp the basics of the LUA programming language (no spaces/tabs/newline in any of the variable,object,function names, ever i don’t think a programming language exists that allows this)
September 11, 2011 at 7:22 am #3276Thanks for answers. I wrote my last program more than 6 years ago. I think that i need some practice and good examples to make good ctrlr panels.
I have only one question now.
I tried to load sysex message in uiLCDLabel using yours DEMO – Midi.panel
My code is similar to yours (differs only size of message):
My:
[code:3ev0t66t]midiMessageReceived = function(midiMessage)
s = midiMessage:getSize()
if s == 297 then
out = panel:getModulatorByName("outputLabel")
out:getComponent():setPropertyString ("uiLabelText", midiMessage:toString())
console("received program data")
end
end[/code:3ev0t66t]
Yours:
[code:3ev0t66t]midiMessageReceived = function(midiMessage)
s = midiMessage:getSize()
if s == 300 then
out = panel:getModulatorByName("outputLabel")
out:getComponent():setPropertyString ("uiLabelText", midiMessage:toString())
console("received program data")
end
end[/code:3ev0t66t]But when device send sysex i`m catch error:
http://www.speedyshare.com/files/30265282/error.jpgpanel:
http://www.speedyshare.com/files/302652 … i_ed.panelCan you show simple way to display preset names using toString function.
I make some without toString function:
[code:3ev0t66t]pND = midiMessage:getLuaData():getRange(10,15) –extract name of preset
outname = panel:getModulatorByName("lcd_name") –choose component to display
presetname:getComponent():setPropertyString ("uiLabelText", string.char(pND:getByte(0),pND:getByte(1),pND:getByte(2),pND:getByte(3),pND:getByte(4),pND:getByte(5),pND:getByte(6),pND:getByte(7))) — this is my variant of replacement of notworking setPropertyString ("uiLabelText", pND:toString())[/code:3ev0t66t]
I know that string.char is not implemented in ctrlr but this work.September 11, 2011 at 9:49 pm #3277here is an example how you can get the ascii string if it’s encoded in the midi message
[code:3ilam9yx]
mod = panel:getModulatorByName("modulator-1") — first i find my modulator
midi = mod:getMidiMessage() — here i fetch it’s midi message (this will be available in the next build but you can use any MIDI message)
console (midi:toString()) — this is how the message looks like in HEX form
f0 52 6f 6d 61 6e f7ascii = midi:getLuaData():getRange(1, 5) — i’m interested in 5 bytes starting from byte indexed 1 (second byte)
console (ascii:toString()) — since ASCII conversion is natural, a simple toString() should workRoman — and there you go, my name in a MIDI Message
[/code:3ilam9yx]September 11, 2011 at 10:08 pm #3278This code (output to console) worked fine but i need to dispaly preset name (extracted from sysex dump) in editor.
[code:38x98niq]presetname = panel:getModulatorByName("labelx")
presetname:getComponent():setPropertyString ("uiLabelText", pND:toString())[/code:38x98niq]I try to use toString function to assign text to label component and receive error.
Can you provide working example where hex dump is loaded in label as ascii text?
September 11, 2011 at 10:19 pm #3279i think this error is because the setPropertyString only takes a std::string and the toString() method return a String (internal juce String class), and since LUA does not know about casting i need to fix that, i’ll make it work with the new build. For now you can try
[code:1r7illfy]
text = pND:toString()
presetname:getComponent():setPropertyString ("uiLabelText", text)
[/code:1r7illfy]September 12, 2011 at 5:54 pm #3280I try to use intermediate variable before post my previous post. ” title=”Wink” />
I`m received similar error:
[code:11m70m0q]lua runtime error
[C]:-1(method setPropertyString) no matching overload found,
candidates:
void setPropertyString(CtrlrLuaObject&,std::string
const&,std::string const&)[/code:11m70m0q]I`m wait next release.
Also i found next bugs:
1. Modulators work wrong when synth transmit NRPN. All modullators that tuned to transmit NRPN (cc99,cc98,cc6) affected by NRPN cc99 cc98.
For example
i used cc99=0 cc98=16 for knob1
and cc99=0 cc98=14 for knob2
My synth receive this perfectly. But when i`m try to rotate knob1 on my synth in panel rotated knob1 and knob2
2. When i use cc or NRPN in modulator and sysex window not empty next time when i`m load panel modulator transmit sysex instead of CC or NRPNSeptember 12, 2011 at 6:23 pm #32811. this is true and i really don’t know if working around it is a good idea, a NRPN is built of 4 (or 3) CC messages so what Ctrlr does is valid, but i understand your problem, i’ll try to work around it but i can’t promise anything really it will be hard
2. i’ll have a look what’s wrong here.
July 6, 2015 at 5:01 pm #51987I know this is an old thread, but I was wondering if the API docs are still available somewhere. This link is dead
all the possible properties for each component/modulator/panel are documented in the API DOcs here: api/namespace_ids.html use only those.
The Puppeteer
http://godlike.com.auJuly 6, 2015 at 5:27 pm #51993You should always look at the methods what() and how()
the how() just print all available regeistered classes
what(object)
prints all available methods on an object, just use it on a modulator/component/whatever and get some answers
July 6, 2015 at 6:05 pm #52002I can get what() to run (eg set a push button that runs what(panel))
But how(panel) returns this error
At line [-1]: [C]
What: C
Namewhat: global
Name: class_names
Error message: std::runtime_error: ‘Trying to use unregistered class’This is my function
WhatMethod = function(--[[ CtrlrModulator --]] mod, --[[ number --]] value) how(panel) end
Is that how it’s supposed to be used?
The Puppeteer
http://godlike.com.auJuly 6, 2015 at 6:27 pm #52013Try to use the Lua Console for this like so:
how()
what(panel)[ENTER]July 7, 2015 at 11:12 am #52076Hi Atom,
how() in the console returns an error
ERROR: std::runtime_error: ‘Trying to use unregistered class’
what(panel) works fine though.
The Puppeteer
http://godlike.com.auJuly 7, 2015 at 11:39 am #52080how(panel:getModulatorByName()) gives wich parameters to put and in wich form.it ‘s like you do a LUA error ,this is the way i use how(). not sure it is correct
July 7, 2015 at 1:50 pm #52087Thanks, that works.
The Puppeteer
http://godlike.com.au -
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.