Proper Random Unit

In my units I do a lot of triggered randomisation and I wonder if it would be cheaper CPU wise to do this in Lua.
All I do it’s the classic NoiseGenerator into S&H and Rectify, then encapsulate the whole thing and duplicate it anywhere I need it, but I would love to see this done with some additional properties like “Random NoRepeat” and “Avoid Repeating the last N values”.

Anybody wants to take this on?? :wink:

1 Like

Pingable Scaled Random in Accents ticks the box on a lot of what you’re asking for. Have you looked at it? Rectification is accomplished by adjusting gain and offset (I think each set to 0.5, but would have to load it up and look again to make sure).

I’ll have a think on the no repeat stuff. My gut tells me it would be difficult to pull off in the middle layer and would better be done once the lower level sdk is available. But my gut has been initially wrong about that before, and some revelation occurred to me later. Like for example the Motion Sensor.

Even if the no repeat stuff is possible, I think it would definitely work against your wish of cheaper CPU. :slight_smile:


If I’m correct Pinged Scaled Random takes 2% cpu? About the same as my own implementation (before I know of this) done on the ER-301 (no middle layer).

As the OP, I’d like to throw these all over the place, but 2% quickly adds up. Which leaves me the feeling it must be possible to do more efficiently. I mean in lua it’s like


This should be doable with less than 2% cpu usage. Obviously I’m fine with “control rate” (is there even such a thing in the ER-310?) and also that the cpu usage rising if pinged extensively.

The lua layer is a patching layer. Far as I know it’s not possible to generate or process signals in the ER-301 with lua code. But even if you could, I’d think the white noise object that’s being used from the c++ layer would be more efficient since it’s compiled rather than interpreted.

The Pingable Scaled Random does include the GridQuantizer, which probably takes some CPU (whether you engage it or not, via the menu). Having a version that doesn’t include it could be a possible CPU reduction. I guess it would be similar to building it into the UI layer except you’d shed whatever overhead is taken up by the extra unit containers for white noise, S&H, offset, and a VCA.

I’ll add it to my list of things to try and see if it makes a difference. Outside of that, it sounds like more of a c++ layer thing that Brian would have to address at this point in time. :slight_smile:

I think you’re right, and I’m getting less and less enthusiastic about learning the middle layer, and more and more eagerly awaiting the code-to-the-metal c++ layer :grinning:

I’m excited for the c++ layer as well. But I do think the middle layer is worth learning. You’ll still need to know the middle layer in order to make use of anything you might develop in the lower layer. Or at least that’s my understanding.

Yep - it’s virtually impossible for me to imagine how you would code in C++ and not use the middle layer on the ER-301 - I may of course be wrong, but I am pretty certain this is how it works because the Lua Middle Layer is what connects the DSP components together; this is essential for some parts of the process, you’re not going to be able to bypass the channel ins and outs for example.

I also think there’s still a pretty limitless supply of fun, useful things that could be built in the middle layer alone. The set of DSP objects Brian has out there to work with is pretty extensive. Just my opinion. :slight_smile:

1 Like

This is correct.

Ok, I’m warming up, then :smile:

1 Like

To compare the two random units (Accents and mine) I inserted 10 copies and measured the rise in CPU from the “floor” of 3% that the ER-301 uses when doing nothing.

Accents: 3%->14% = each unit use 1.1%
Mine: 3%->18% = each unit use 1.5%

So a bit smaller than the 2% I hinted at earlier, plus Accents seems a bit more efficient than mine…

Not sure it this an even slightly valid way to measure CPU usage for units, though, to take it with a grin of salt :smiley:

That seems like a good way to measure to me. It’s probably accurate enough. Do the UI level units you build include a grid quantizer? If I made a version that doesn’t have a grid quantizer, and it lightened the CPU load by a few 0.x%, do you feel it is worth doing?

I’m trying to strike a good balance with Accents. I don’t want to fill the insert screen with 500 units just because I can. I try to make sure each unit is useful/valuable enough to merit taking up real estate on the insert screen. That’s pretty subjective, of course.

If a simpler version could lower the CPU usage, that would be great. I just need trigger in and 0-1 output… I use these all the time, all over the place, so…

Probably not the correct thread Joe, but thanks for the efforts you have made in this regard…it took me a good while to get to 0.4 and then to the movement from Joe’s Bespoke to Accents…so I’ve not said thank you up until now, but it’s really very generous of you and much appreciated.

1 Like

You are welcome, @sixnon! I enjoy building these units and it always makes me happy to hear that others are getting some use out of them. Glad you made your way to 0.4. It’s splendid isn’t it? :slight_smile:

1 Like

It is indeed, quite a bit of newness to find my way around and a lot on with work elsewhere, hence my tardy thanks.