Putting a number range on a Sample & Hold signal?

#1

Basically, I’m working on a patch that uses a sample & hold to produce a random signal, but I’d like for the number produced to be within a certain range. Is there an expression I can use to make that happen?

Also, weird other question that’s not really a question but more of a point of curiosity: what is the point of the Constant node? As far as I can tell it does exactly what the Knob does, but with the only real difference of not being exposable?

Anyway, thanks as always, you guys.

1 Like
#2

The clamp expression should allow you to restrict the range. For example, if you want the range to be between 5 and 20 you would edit the expression node to be “clamp(x,5,20)” where x would be an input restricted to that range.

2 Likes
#3

This is how I would do it

Random Window.audulus (2 KB)

4 Likes
#4

@taylor can correct me if I am wrong, but there was a time before the expression node, so that was a way you could enter a constant value. These days it’s a nice convenient way to tunes something by ear without having to constantly opening up expression edit window to edit a number.

1 Like
#5

Ah, okay, that makes sense. I end up just using the knob for that, but I get it now. Thanks for your input, guys!

#6

The only hitch I can see with the clamp function is that the distribution of your values might have big bumps at the clamp levels in your output range. The clamp expression maps all out of range inputs to the clamp value, so you’d get distribution bumps proportional to the percentage of the random generator’s being clamped.

Mapping the 0-1 random output to the range you want flattens it out.

Here’s a rig I made today to test out the three situations. (off work a few days and this is more fun than laundry—plus I kind of wanted to know)

Clamped Random Histogram.audulus (383.5 KB)

2 Likes
#7

Ok, that is a really fun little tool for testing distribution.

Which reminds me, you can use a spline to unevenly distribute values.

Random Value Spline Distrobution.audulus (139.1 KB)

2 Likes
#8

I’ll have to try out the spline!

1 Like
#9

Yeah, that spline distribution thing is cool! Actually, I was wondering whether one could randomly control spline or mapper points, but it doesn’t seem like it’s possible. Then again, I’ve been wrong many, many times about this program, haha.

1 Like
#10

I would love to have the ability to dynamically control the points in a spline or mapper as well have have a mapper node with multiple inflection points (more than one curve). Might be a good add to the feature request thread Feature Request Megathread

3 Likes
#11

The constant node is sort of like an internal trimpot. It’s not meant to be a primary control, but you can have it there as an easy way of tweaking a parameter later. It’s also good for experimenting with values when you don’t want a knob to pop up on your UI. I don’t personally use it much, but others seem to like it

2 Likes