# Putting a number range on a Sample & Hold signal?

**URL:** <https://forum.audulus.com/t/putting-a-number-range-on-a-sample-hold-signal/890>\
**Category:** Build\
**Created:** [August 10, 2018, 3:58pm UTC](https://forum.audulus.com/t/putting-a-number-range-on-a-sample-hold-signal/890 "2018-08-10T15:58:51Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![NotBasho](https://forum.audulus.com/user_avatar/forum.audulus.com/notbasho/32/218_2.png) [@NotBasho](https://forum.audulus.com/u/NotBasho)\
**Post date:** [August 10, 2018, 3:58pm UTC](https://forum.audulus.com/t/putting-a-number-range-on-a-sample-hold-signal/890/1 "2018-08-10T15:58:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![RileyGuy](https://forum.audulus.com/user_avatar/forum.audulus.com/rileyguy/32/90_2.png) [@RileyGuy](https://forum.audulus.com/u/RileyGuy)\
**Post date:** [August 10, 2018, 4:59pm UTC](https://forum.audulus.com/t/putting-a-number-range-on-a-sample-hold-signal/890/2 "2018-08-10T16:59:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![robertsyrett](https://forum.audulus.com/user_avatar/forum.audulus.com/robertsyrett/32/6507_2.png) [@robertsyrett](https://forum.audulus.com/u/robertsyrett)\
**Post date:** [August 10, 2018, 8:55pm UTC](https://forum.audulus.com/t/putting-a-number-range-on-a-sample-hold-signal/890/3 "2018-08-10T20:55:43Z")

</div>

This is how I would do it 🙂

 ![42%20PM](https://discourse.carlnet.ddnsgeek.com/uploads/default/original/2X/7/7e321145ee0585de3a7893acfe680a8535526f50.png)  
[Random Window.audulus](https://discourse.carlnet.ddnsgeek.com/uploads/default/original/2X/f/fc14dc796dcd61d3cf8a9d8a53ec4e6ad1896dac.audulus) (2 KB)

---

<div class="post-metadata">

**Author:** ![robertsyrett](https://forum.audulus.com/user_avatar/forum.audulus.com/robertsyrett/32/6507_2.png) [@robertsyrett](https://forum.audulus.com/u/robertsyrett)\
**Post date:** [August 10, 2018, 11:18pm UTC](https://forum.audulus.com/t/putting-a-number-range-on-a-sample-hold-signal/890/4 "2018-08-10T23:18:44Z")

</div>

> [@NotBasho](#):
>
> what is the point of the Constant node?

@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.

---

<div class="post-metadata">

**Author:** ![NotBasho](https://forum.audulus.com/user_avatar/forum.audulus.com/notbasho/32/218_2.png) [@NotBasho](https://forum.audulus.com/u/NotBasho)\
**Post date:** [August 10, 2018, 11:59pm UTC](https://forum.audulus.com/t/putting-a-number-range-on-a-sample-hold-signal/890/5 "2018-08-10T23:59:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dcLargo](https://forum.audulus.com/letter_avatar_proxy/v4/letter/d/dec6dc/32.png) [@dcLargo](https://forum.audulus.com/u/dcLargo)\
**Post date:** [August 11, 2018, 5:26am UTC](https://forum.audulus.com/t/putting-a-number-range-on-a-sample-hold-signal/890/6 "2018-08-11T05:26:06Z")

</div>

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](https://discourse.carlnet.ddnsgeek.com/uploads/default/original/2X/2/2c397fe10a383cc8b47b2774431a169c1813de48.audulus) (383.5 KB)

 ![CD530870-26A0-42F6-81DF-9D7660718AAD](https://discourse.carlnet.ddnsgeek.com/uploads/default/original/2X/4/488bea375a4dba210de7a3d625c2c95f3ead6d96.jpg)

---

<div class="post-metadata">

**Author:** ![robertsyrett](https://forum.audulus.com/user_avatar/forum.audulus.com/robertsyrett/32/6507_2.png) [@robertsyrett](https://forum.audulus.com/u/robertsyrett)\
**Post date:** [August 11, 2018, 7:22am UTC](https://forum.audulus.com/t/putting-a-number-range-on-a-sample-hold-signal/890/7 "2018-08-11T07:22:54Z")

</div>

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

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

 ![51%20AM](https://discourse.carlnet.ddnsgeek.com/uploads/default/original/2X/e/e3b610e118df764d0befa900355676a40393c31a.png)  
[Random Value Spline Distrobution.audulus](https://discourse.carlnet.ddnsgeek.com/uploads/default/original/2X/f/f5a37164fc3ac4f9ce0008b8787ce7a9983ed9be.audulus) (139.1 KB)

---

<div class="post-metadata">

**Author:** ![dcLargo](https://forum.audulus.com/letter_avatar_proxy/v4/letter/d/dec6dc/32.png) [@dcLargo](https://forum.audulus.com/u/dcLargo)\
**Post date:** [August 11, 2018, 2:28pm UTC](https://forum.audulus.com/t/putting-a-number-range-on-a-sample-hold-signal/890/8 "2018-08-11T14:28:24Z")

</div>

I’ll have to try out the spline!

---

<div class="post-metadata">

**Author:** ![NotBasho](https://forum.audulus.com/user_avatar/forum.audulus.com/notbasho/32/218_2.png) [@NotBasho](https://forum.audulus.com/u/NotBasho)\
**Post date:** [August 11, 2018, 9:58pm UTC](https://forum.audulus.com/t/putting-a-number-range-on-a-sample-hold-signal/890/9 "2018-08-11T21:58:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![stschoen](https://forum.audulus.com/user_avatar/forum.audulus.com/stschoen/32/42_2.png) [@stschoen](https://forum.audulus.com/u/stschoen)\
**Post date:** [August 12, 2018, 2:30pm UTC](https://forum.audulus.com/t/putting-a-number-range-on-a-sample-hold-signal/890/10 "2018-08-12T14:30:10Z")

</div>

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](https://discourse.audulus.com/t/feature-request-megathread/82?u=stschoen)

---

<div class="post-metadata">

**Author:** ![biminiroad](https://forum.audulus.com/user_avatar/forum.audulus.com/biminiroad/32/6749_2.png) [@biminiroad](https://forum.audulus.com/u/biminiroad)\
**Post date:** [August 15, 2018, 3:21pm UTC](https://forum.audulus.com/t/putting-a-number-range-on-a-sample-hold-signal/890/11 "2018-08-15T15:21:29Z")

</div>

> [@NotBasho](#):
>
> what is the point of the Constant node?

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 🙂
