Device freezes when using simple Lua function [SOLVED]

My device keeps freezing.
It only freezes on the controls that have the oscPairSelect1() and oscPairSelect2() function assigned in the json.
Do I am doing something wrong here?
The function seems to do what it supposed to do. It sends 1 osc pair select message until we switch to the other pair.

You can replicate it by loading this preset.
Just go to the “OSC PAIR1” or “OSC PAIR2” page and keep twisting the “OSC fine” but any other control will do.
At some point the Electra One freezes. But in the console app nothing appears in the logs.

The template:
[[Electra One App]]

.epr file:
Ensoniq Mirage Soundprocess (14).epr (74.7 KB)

Lua script

mirageSoundProcessDeviceId = 9

incCount1 = 1

incCount2 = 1

-- getPatchNumberByte function is added in the patch request and reponse in the json
-- it fetches the value from parameterNumber 40 (patch select) on the moment the patch request button is pressed
-- so that the same patch is requested as parameterNumber 40 (patch select) is set to.
function getPatchNumberByte()
local parameterNumber = 40

patchNumber = parameterMap.get (mirageSoundProcessDeviceId, PT_SYSEX, parameterNumber )

return (patchNumber)

end



-- oscPairSelect1 and oscPairSelect2 send a osc pair select message once, after that reset the counter of the other function. 
-- so if we switch to that page the corresponding osc pair select message is send out once again.
-- controls belonging to osc pair 1 have the function oscPairSelect1 added in the json .epr file and controls osc pair 2 
-- oscPairSelect2

function oscPairSelect1()

if incCount1 == 1 then
 device = devices.get (mirageSoundProcessDeviceId)
 midi.sendSysex (PORT_1, {  0, 0, 35, 1, 67, 60, 1, 0 })
 incCount1 = incCount1 + 1
-- reset the other counter so the message will be send for pair 2 once we switch to that controls 
incCount2 = 1
 end

end

function oscPairSelect2()

if incCount2 == 1 then
 device = devices.get (mirageSoundProcessDeviceId)
 midi.sendSysex (PORT_1, {  0, 0, 35, 1, 67, 60, 2, 0 })
 incCount2 = incCount2 + 1

incCount1 = 1
 end

end

I don’t have a Mirage, but the template (with the LUA code pasted in) does not lock up no matter how much I twist.
Maybe the Mirage is sending back something that is causing a problem?

Try unplugging the MIDI Out from the Mirage and see what happens, but here, with lots of twisting, no lockup.

(and believe me - I’ve been locking up my ElectraOne and/or PC quite a bit during my preset development…)

hey thanks for checking.
it lock up for me as well when the Mirage is disconnected.
So its not the mirage.

did you twist knob on the oscillator pages? the controls trigger the osc pair select function.

I have cleared all my presets by sending an empty one to all the slots.
Then reloaded the presets and the issue persists.
I then re-flashed the firmware, templates where not affected but the issue still persist.

Only when I keep twisting a know which have the oscPairSelect funtions attached this issue occurs.

yes, I was on the oscillator pages as you mentioned. I was rotating the Fine controls for both and then twisting other knobs and it was stable for me. I can try some other tests later today if that same template is still a problem.

That would be great.
You have to really keep rotating the “fine controll” or others for a while.
I loaded the preset and lua code via Electra One App and after uploading I kept dialing “OSC A Fine” after a while the Electra One froze up.

1 Like

I did get it to lock up. But only when I had the log console running. If I was not in the App Editor and did not have the console log running, it never locked up. With the console log open, the controls began to stutter and not change values, then locked up solid.

2 Likes

hmm. I will replicate it to see what is happening there. Thanks for providing all the input!

I have the same issue with the Electra One just connected to usb power not to a computer.

Hi Martin, would you have time to look at this sometime?

I have been trying to make it work but the Electra One keeps freezing.

It’s not a pleasant experience editing the mirage and having to restart the one so often meanwhile loosing all parameter settings.

I you have another solution to make the “oscillator pair 1 or 2 select work” that is fine by me.

Cheers Tim

Hi Tim, I have it on my todo. I had a few moments when I planned to sit down and review it. Unfortunately, we are quite overwhelmed with number of orders coming in and I want to make sure people will get their Electras on time. It feels it will be a little bit calmer today, if I have a moment, this is really high up on my list. With other few issues reported by other users lately.

Hi Martin, sure understand. Will be more patient.

I did some tests
I use the e.one console to read the memory consumption.

1 made 2 controls both with a function assigned: oscPairSelect1() and oscPairSelect2()
Same lua code is used in 2 presets. 1 with 2 controls and another with many copies of a control ( to saturate the memory ), I found that commented out data is not send to the e.one.

mirageSoundProcessDeviceId = 1
incCount1 = 1
incCount2 = 1


function oscPairSelect1()

if incCount1 == 1 then
device = devices.get (mirageSoundProcessDeviceId)
 midi.sendSysex (PORT_1, {  0, 0, 35, 1, 67, 60, 1, 0 })

 incCount1 = incCount1 + 1

incCount2 = 1

 end

end


function oscPairSelect2()

if incCount2 == 1 then
 device = devices.get (mirageSoundProcessDeviceId)
 midi.sendSysex (PORT_1, {  0, 0, 35, 1, 67, 60, 2, 0 })
 incCount2 = incCount2 + 1


incCount1 = 1
 end

end

2 controls 2 controlls.epr (1.4 KB)

  1. the preset with controls does not freeze.
  2. The electra one console shows “2 controls” above the free memory bar.
  3. 73 % free memory is indicated

many controls copied many controls.epr (207.7 KB)

  1. the preset with “many controls” freezes,
  2. only 15 % free ram is indicated
  3. the console app shows “no preset” above the memory indicator

many controls unique
many controls unique.epr (48.2 KB)

  1. the preset with “many controls unique” freezes,
  2. only 46 % free ram is indicated
  3. the console app shows “many controls unique” above the memory indicator
1 Like

collectgarbage("collect")
Adding a single cycle garbage collection works as a workaround. My template does not freeze anymore.

collectgarbage("count")
Adding only to print the gc count to the end of the function in the “many controls” template and the e.one gets crazy. Some distortion on the display and its freezes after a while when twisting the knops.

freeze-and-gc-count.txt (170.4 KB)

Anyhow I have a workaround. Hope this helps cheers T

Hi Tim, thanks for your input! I was able to replicate the issue and I have a good fix for it. It will be resolved in the upcoming release.

1 Like

Wow you are fast! great, looking forward to a new juicy release

Of of curiosity does your fix have to do with the garbage collector setup of the lua interpreter?

Thanks a lot

Cheers Tim

1 Like

Yup, it was related to the the garbage collection. Your and @oldgearguy input helped me to locate and fix the issue. Thanks for that!

The fix is ready and was verified to work. It will be included in the upcoming release.

2 Likes

fixed in release 2.1.4