Middle Layer SDK (aka patching with Lua)

Hello again, I have a minor bug to report that I discovered while messing around!

When returning alternate views from the onLoadViews function ala Accents Scorpio “extended” view these controls are not visible in the scope editor (which is understandable, how would it even know?). It seems you can still assign sub chains to them, h̶o̶w̶e̶v̶e̶r̶ ̶t̶h̶i̶s̶ ̶c̶a̶n̶ ̶h̶a̶v̶e̶ ̶s̶t̶r̶a̶n̶g̶e̶ ̶e̶f̶f̶e̶c̶t̶s̶ ̶o̶n̶ ̶t̶h̶e̶ ̶s̶c̶o̶p̶e̶ ̶U̶I̶.

I was trying to think of a way to fix this (like using the controls table to render the scope view) but since lua tables are unsorted it’s kinda tricky.

Happy to provide more details if necessary!

Edit: I may have spoke too soon, after testing again it’s not clear to me that it has any effect on the scope view UI.

Hey Brian - I’m a little stumped by this one. The Voltage Bank unit from Accents doesn’t seem to be setting the stored S&H values that were saved in the .unit file when a unit preset is loaded. I can see the stored values in the resulting .unit file. Other things (e.g. index) get their values restored. Is this because there is no control defined/visible for these S&H Value parameters?

Do I need to handle this manually in serialize/deserialize functions?

From saved .unit preset file - sh3 is a TrackAndHold object. The 0.7 Value parameter that is stored does not seem to get set when the unit preset is loaded.

	["objects"] = {
		["sh3"] = {
			["params"] = {
				["Value"] = 0.7;
			};
		};

Looks like this is a problem with the Sample & Hold unit as well. The issue is that the generic parameter deserializer uses param:softSet(value) instead of param:hardSet(value). Soft setting takes time to ramp up to the target value but since the TrackAndHold object is in a held state it will never reach the target.

TLDR, Nothing that you need to do. I’ll have it fixed in the next release.

2 Likes

I hope I don’t start to TLDR out at 3 sentences. :joy: Ok, thanks for investigating. I spent a while trying to serialize manually and wasn’t getting anywhere. Sounds like there was nothing I could have done.

1 Like

Hey everyone! non-coder here. I want to get into this! I have basic experience (I admin SIEM systems and do parsing and query languages as my dayjob), I just need to learn how to work with these tools and with Lua.

How do I make use of what’s provided by Brian here? If anyone is patient enough to explain to me.

I made a video a while back. It may not be 100% up to date at this point but it is probably still a decent overview of the tools and process.

2 Likes

Yeah, I watched that video. thank you very much for that, it helped a lot. I’m going to try getting into this. unfortunately my knowledge in coding is a hodgepodge of advanced and basic information and I have to find a way to fill in the blanks.

1 Like

Fortunately, patching in the UI layer teaches you a lot of what you need to know to patch in the Middle Layer. The ML is another patching language. So while the syntax may look intimidating at first, there’s actually a lot of repetition. You’ll be creating objects, connecting them, and setting up tables of control definitions. The coding itself is largely calling a bunch of pre-written functions. *

There is a bit of a hurdle to the syntax, but I’d say the real challenge is in creating the signal flow, conditioning the signals, and getting the control structure right. The UI layer will help you learn that because you can see not only how everything is connected but also view the signal at the output of each unit.

*Ofc I only know what I know and I’m sure there are possibilities in the ML that I am unaware of. But you can get a lot done just using the functions Brian has made easy for us.

1 Like

Unfortunately I don’t have an ER-301 yet so I can’t do anything in the UI layer unless there is a way to emulate that?

I would say coding for a platform you don’t have access to is quite similar to driving a car with your eyes closed…

3 Likes

Maybe I shouldn’t mention this but I did find a way to view all the lua sources :stuck_out_tongue: Since lua is an interpreted language all the source files are included as plain text inside the kernel image. I just open it up in vim anytime I’m wondering what one of the middle layer functions does. Plus the c++ code is all included in the doxygen docs. But yea without an actual unit to test on you won’t get very far.

1 Like

Obviously. I was just wondering if an emulator was made since I saw a lot of screenshots on this forum. But I assume that’s just some internal functionality to take a screenshot.

I want to use this as an opportunity to learn Lua and CPP so I can develop my own tools for this. I did go into the doxygen and saw everything laid out in there. Just going to take a lot of reading and learning. I think I already have enough basics for the middle layer and all I need at this point is the actual module to start working on.

There is no emulator. The ER-301 device itself can capture screens to the SD card. I know, the wait is hard. :wink:

1 Like

Haha. I like your resourcefulness. :wink:

1 Like

I agree with the others who answered. I would wait until you have your ER-301. Developing in the Middle Layer is frustrating enough even with an ER-301! (Not going to be like that forever though.)

2 Likes

Patience is hard.
Question: What if for example I want to write something that doesn’t yet exist in the various modules, for example a waveshaper? If I write my own functions rather than use middle-layer patching, will the 301 be able to execute them?

Not at the moment. That requires another layer which is not available yet. Audio and frame rate calculations are coded in C/C++ but the RTOS does not currently provide the dynamic linking facilities needed to bring in user-generated machine code during run-time.

1 Like

Oh cool, if it’s available in the future that’d be amazing. You could make complex modules much more efficient.

I guess you can use a limiter to do similar things by layering bandpass filters. Though that would require a lot of processing power for something that can be done by one function if it were available.

Can’t wait for what the future brings! Wish you had an easier time blowing through tasks. There must be so much.

hey,

I’m still a bit confused about how much learning lua would help – and it’s relevant cos I do think that – with the right documentation – I can learn how to use it.

Could one program in lua to e.g. generate n random values between 0 and 1 of increasing size, as I was attempting here… on the one hand, I should be able to do that without lua, but, on the other, it’s great to learn new tricks if you can

In lua you can definitely generate a fixed number of constant voltages, in my experience it comes up so often I wrote a special function for it mConst :slight_smile:

As for your problem of trying to pick a new sample every time, you might consider this idea: S&H the last output value and use it to offset the next randomly chosen value in such a way that they can’t be the same. Idk the exact algo, but conceptually I think that would get you there.

2 Likes