Skip to content

Commit 4c71d4b

Browse files
authored
Add Sigma script (#369)
* Initial commit. Docs mostly written, workflow planned out. Just need to write the darned thing now * Update the readme & menu * Add the voltage bins * Use lockable shift knobs, allow dynamic routing of ain. Implement the output voltage control (v1), add a simple debugging GUI. Script is finally being tested on live hardware * Implement spread calculations, add a new class to manage setting the output voltages at a desired time in the future * Update the docs * Revert to paired gate + CV outputs; this lets us coordinate triggers with CV changes. Fewer overall outputs, but this feels like a good trade-off for functionality * Remove the doc section about gate configuration * Linting * Be explicit about what knob modes we're setting in the b1 handler. Update the UI while scrolling through the bin modes * Update arp to use the new random_extras.shuffle function * Create experimental.bisect module, put bisect_left in that instead of in sigma.py * Modify bisect_left so it doesn't raise an exception and just silently clamps lo to zero if needed * Add the list of ain destinations to the i/o section * Typo * Forgot to save the file before committing previously * Add missing newline * Copy the entirety of bisect from the source; it's not that big and we might as well include all of it for convenience * Linting
1 parent aeb3a73 commit 4c71d4b

File tree

7 files changed

+623
-12
lines changed

7 files changed

+623
-12
lines changed

software/contrib/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ A 2-6 output sequential switch. The analogue input is mirrored to one of the ou
194194
<i>Author: [chrisib](https://github.com/chrisib)</i>
195195
<br><i>Labels: random, sequential switch</i>
196196

197+
### Sigma \[ [documentation](/software/contrib/sigma.md) | [script](/software/contrib/sigma.py) \]
198+
Random CV, optionally quantized, voltages based on controllable normal distributions. Inspired by Magnetic Freak's Gaussian module.
199+
200+
<i>Author: [chrisib](https://github.com/chrisib)</i>
201+
<br><i>Labels: random, quantizer</i>
202+
197203
### Smooth Random Voltages \[ [script](/software/contrib/smooth_random_voltages.py) \]
198204
Random CV with adjustable slew rate, inspired by: https://youtu.be/tupkx3q7Dyw.
199205

software/contrib/arp.py

+1-12
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,14 @@
99
from europi_script import EuroPiScript
1010

1111
from experimental.quantizer import CommonScales, SEMITONE_LABELS, VOLTS_PER_OCTAVE, VOLTS_PER_SEMITONE, SEMITONES_PER_OCTAVE
12+
from experimental.random_extras import shuffle
1213

1314
import random
1415

1516
MODE_ASCENDING = 0
1617
MODE_DESCENDING = 1
1718
MODE_RANDOM = 2
1819

19-
def shuffle(l):
20-
"""Shuffle a list randomly
21-
22-
Replacement for random.shuffle, which doesn't exist in micropython
23-
24-
@param l The list to shuffle
25-
"""
26-
for i in range(len(l)):
27-
n = random.randint(i, len(l)-1)
28-
tmp = l[i]
29-
l[i] = l[n]
30-
l[n] = tmp
3120

3221
class Arpeggio:
3322
def __init__(self, scale, mode):

software/contrib/menu.py

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
["RadioScanner", "contrib.radio_scanner.RadioScanner"],
5454
["Scope", "contrib.scope.Scope"],
5555
["Seq. Switch", "contrib.sequential_switch.SequentialSwitch"],
56+
["Sigma", "contrib.sigma.Sigma"],
5657
["Smooth Rnd Volts", "contrib.smooth_random_voltages.SmoothRandomVoltages"],
5758
["StrangeAttractor", "contrib.strange_attractor.StrangeAttractor"],
5859
["Traffic", "contrib.traffic.Traffic"],

software/contrib/sigma.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Sigma -- Gaussian CV Generator
2+
3+
This script is inspired by [Magnetic Freak's](https://magnetic-freak.com/) Gaussian module.
4+
Please see the [user manual](https://magnetic-freak.com/wp-content/uploads/2022/08/Gaussian_Eurorack_UserGuide.pdf)
5+
for details on the original module and a deeper dive into the mathematics used in this script.
6+
7+
## Gaussian Distributions
8+
9+
The Gaussian or Normal distribution is a bell-shaped curve often used in statistics. Unlike rolling a d20 in
10+
Dungeons and Dragons, where there is an equal chance of the roll being 1, 2, 3, ..., 19, or 20, a normal distribution
11+
is more likely to produce numbers in the middle of its range and less likely to produce numbers at the extremes. The
12+
way in which this probability changes is determined by the standard deviation of the curve, written using the
13+
Greek letter Sigma in statistics.
14+
15+
## Inputs & Outputs
16+
17+
Inputs:
18+
- `din`: an external clock signal to trigger sampling. The pulse width of this signal controls the output
19+
pulse width
20+
- `ain`: assignable CV control (can be disabled, or assigned to control `mean`, `standard deviation`, `jitter` or
21+
`bin mode`)
22+
- `b1`: shift button; hold to change `k1` and `k2` modes
23+
- `b2`: cycles through `ain` routing
24+
- `k1`: mean control / shift: jitter control
25+
- `k2`: spread control / shift: binning/quantizer mode select
26+
27+
`k1` or `k2` will act as an attenuator for the assigned control (mean/spread/jitter/binning).
28+
29+
Outputs are divided into 3 pairs: `cv1 & cv 4`, `cv2 & cv 5`, and `cv3 & cv 6`. `cv1-3` output gate signals
30+
with a duration equivalent to the duty cycle of the incoming clock on `din`. `cv4-6` output random control
31+
voltages according to the spread & mean controls and the binning mode.
32+
33+
## Distrubution Control
34+
35+
The following description assumes the binning mode is set to `continuous`.
36+
37+
Changing `k1` will move the average output voltage of the outputs. Keeping the knob near-vertical will keep the
38+
averate output close to 5V.
39+
40+
Increasing `k2` will increase the standard deviation of the outputs. At the lowest setting the outputs will be
41+
effectively locked to the mean set by `k1`. As `k2` increases the spread of output voltages increases.
42+
43+
## Jitter Control
44+
45+
By default all six output channels update simultaneously. By applying positive voltage to `ain` the outputs can be
46+
desynchronized, updating at random intervals. `cv1 & 4` will always trigger in-time with the clock on `din`,
47+
but the other pairs will trigger at normally-distributed intervals after `cv1`.
48+
49+
## Binning and Quantize modes
50+
51+
The CV outputs on can be configured to either oscillate between fixed voltage levels, output
52+
quantized 1V/Octave pitch levels, or a continuous smooth voltage.
53+
54+
In Bin mode the output voltage will oscillate between values chosen from the levels below:
55+
56+
| # Bins | CV Output Levels | Delta (V) |
57+
|--------|-----------------------------------------------------|-----------|
58+
| 2 | 0V, 10V | 10V |
59+
| 3 | 0V, 5V, 10V | 5V |
60+
| 6 | 0V, 2V, 4V, 6V, 8V, 10V | 2V |
61+
| 7 | 0V, 1.7V, 3.4V, 5V, 6.6V, 8.3V, 10V | 1.7V |
62+
| 9 | 0V, 1.25V, 2.5V, 3.75V, 5V, 6.25V, 7.5V, 8.75V, 10V | 1.25V |
63+
64+
In Quantize mode, the output voltage will be quantized to 1V/Octave scales with the following resolution:
65+
66+
| Quantize Mode | Delta (V) |
67+
|---------------|-----------|
68+
| Tone | 0.16667 |
69+
| Semitone | 0.08333 |
70+
| Quartertone | 0.41667 |
71+
| Continuous | inf`*` |
72+
73+
Output will be in the range 0-10V
74+
75+
`*` Not actually infinte, but as high-resolution as the DAC chips will allow

0 commit comments

Comments
 (0)