RomanKubiak / ctrlr

Ctrlr
BSD 3-Clause "New" or "Revised" License
525 stars 61 forks source link

Callback errors with v5.6.23 (Juce 6.0.8) #260

Open bijlevel opened 3 years ago

bijlevel commented 3 years ago

I did compile the latest build (v5.6.23) on Mac, but when trying to use existing panels I get always the same error when using callBack methods:

Screenshot 2021-04-17 at 13 31 02

What could be the origin of these errors?

Godlike-Productions commented 3 years ago

I can't even find requestDataChanged anywhere in the repo

Godlike-Productions commented 3 years ago

OK, doing some more searching, the error windows seem to get created here.

https://github.com/RomanKubiak/ctrlr/blob/7fab6623d3a2b26b1bcc583568028552936fd487/Source/Lua/Methods/CtrlrLuaMethodManagerCalls.cpp

This might be a good place to start to narrow down this error. I'll keep searching for other potential places.

Out of curiosity, does this only happen with panels that are imported from other versions, or does it still happen if panels are created from scratch in this version?

bijlevel commented 3 years ago

Indeed this link gives me (or someone else...) a good start! I did a panel from scratch with one simple function sending only one Midi message and got the same kind of error(s). All imported panels from older versions also give the error on every function which is called when clicking on a button. At least that is what my experience is. I did not test it with other kind of functions which involve calling "something".

bijlevel commented 3 years ago

I think I found the reason for the errors. In older versions assigning a variable to and formatting a sysex message like this: syxProgram = {0xF0, 0x07, 0x00, 0x78, 0x14, 0x09, 0x40, 0x08, 0xF7} was no problem. In this latest version (5.6.23) this is apparently a problem and causes the overload mismatch. The solution is to format the message explicitly as a string, like this: "F0 07 00 78 14 09 40 08 F7". Other ways also are OK, as long as (I think) the outcome is a string. I hope I'm right, but at least my panel does now run without issues so far in this version.

Godlike-Productions commented 3 years ago

I think the bug must he in this file, though the only change has been to remove the luabind overload. As far as I can see it should still accept an array, but I'm definately no C++ guru.

It's weird because it seems to work fine in Windows.

https://github.com/RomanKubiak/ctrlr/blob/master/Source/MIDI/CtrlrMidiMessage.cpp

Godlike-Productions commented 3 years ago

Looking at this, I'm wondering is line 118 should be

MemoryBlock possibleMidiData = luaArrayToMemoryBlock(luaArray.getObject());

and not

MemoryBlock possibleMidiData = luaArrayTomemoryBlock(luaArray.getObject());

Normally all the ctrlr stuff is strictly lowerCamelCase.

This function is only referenced 4 times in this repo, though it looks like it still relies on luaBind.

https://github.com/RomanKubiak/ctrlr/search?q=luaArrayToMemoryBlock

Godlike-Productions commented 3 years ago

We've confirmed that it's just midi messages formatted as a table that cause the issue. MIDI messages in a memory block or string work fine. MemoryBlocks are probably the easiest conversion to make by using this code snippet.

requestMessage = {0xf0, 0x00, 0x00, 0x2f, 0x03, 0x01, 0x02, 0x00, 0xf7}
requestMessageMB = MemoryBlock()
requestMessageMB:createFromTable(requestMessage)
midi = CtrlrMidiMessage(requestMessageMB)
panel: sendMidiMessageNow (midi)
RomanKubiak commented 3 years ago

can you show me what causes an error ? a line in Lua ?

bijlevel commented 3 years ago

Sorry Roman, but I only found a kind of workaround and Godlike-Productions (aka the Puppeteer) did elaborate on this. See his comments. My guess is in this version (5.6.23) Lua does not accept a sysex message formatted as a table.

Godlike-Productions commented 3 years ago

can you show me what causes an error ? a line in Lua ?

Hi Roman. Basically this works.

requestMessage = {0xf0, 0x00, 0x00, 0x2f, 0x03, 0x01, 0x02, 0x00, 0xf7}
requestMessageMB = MemoryBlock()
requestMessageMB:createFromTable(requestMessage)
midi = CtrlrMidiMessage(requestMessageMB)
panel: sendMidiMessageNow (midi)

This also works

requestMessage = {0xf0, 0x00, 0x00, 0x2f, 0x03, 0x01, 0x02, 0x00, 0xf7}
requestMessageMB = MemoryBlock()
requestMessageMB:createFromTable(requestMessage)
midi = CtrlrMidiMessage(requestMessageMB:toHexString(1))
panel: sendMidiMessageNow (midi)

This does NOT work

requestMessage = {0xf0, 0x00, 0x00, 0x2f, 0x03, 0x01, 0x02, 0x00, 0xf7}
midi = CtrlrMidiMessage(requestMessage)
panel: sendMidiMessageNow (midi)

This is only an issue with OSX. They all work fine in Windows.

bijlevel commented 3 years ago

It is only an issue with Ctrlr v5.6.23 for Mac. Older versions, in particular the 5.3.xxx versions, work OK.

damiensellier commented 2 years ago

@Godlike-Productions You don't need all those lines to create a memoryblock:

just replace : panel:sendMidiMessageNow(CtrlrMidiMessage({x, y, z })) with panel:sendMidiMessageNow(CtrlrMidiMessage(MemoryBlock({x, y, z})))

where t={x, y, z } is already a table. since you can create a MB from a table you can get a volatile MB with just : MemoryBlock({x, y, z})

This way you can update all your "sendMidiMessageNow" instructions to the 5.5.0 version without to much hassle by just wrapping your table with MemoryBlock(t)

Fred-mller commented 2 years ago

Thank you, this is a great solution: "panel:sendMidiMessageNow(CtrlrMidiMessage(MemoryBlock({x, y, z})))"

Greeting, Fred