This patch is meant to be a complement to my video (posted below), which explores some more complex applications of sample and holds, namely as the foundation for shift registers and sequencers. It is the second in a series that began with a “Basics” video and patch (https://patchstorage.com/s-and-h1-basics-a-patch-to-complement-my-video-on-sample-and-hold-basics/).
Shift registers — or Turing machines — utilize a combination of chained sample and holds (acting as a form of recursive or looping memory) and a probability gate to develop patterns that slowly (or quickly) change over time. I make use of them quite a lot in generative patches, because they allow for a melody that changes over time while feeling self-consistent. The example generative shift register I include in this patch has options for 4- 8- or 11 step counts, tools to attenuate and quantize its output, and a simple synth voice to demonstrate the shift register. Additionally, a 5-step shift register can be applied to the output panning of the synth voice.
Shift registers aren’t just limited to generative applications. Since they can be used to store memory and loop that stored memory, they make an excellent foundation for a step sequencer. To create this, we really need little more than a shift register, an input source — in the case of this patch, a two-octave keyboard module — and a pair of switches to choose between the input device and a closed loop, with the keyboard gate providing the initial trigger for the sample and holds and an LFO providing sequent triggers when switched to the looped notes. The shift register holds eight notes (although it could certainly hold many more with additional sample and holds). I added some additional features — the ability to edit the sequencer as it was playing, to audition the notes before you begin recording, and a counter to switch from the input device to the automated sequence. Once again, there is a synth voice used to demonstrate the sequencer.
By introducing feedback from the sample and hold’s output to its input, the module can take on the properties of a counter — a simple but useful device for adding and subtracting sums. With little more than a sample and hold acting as a counter and a switch, you can make a sequencer, with the sample and hold propelling the switch from one input to the next and the switch’s inputs acting as a note or value bank. If you add a fair amount of logic and switches, though, you can create a sequencer that moves forward, backward, as a pendulum (forward and backward), stochastically (often described as ‘drunk walk’ where the sequencer generally moves in one direction but occasionally backtracks), or by random selection. In this example, we have 16 steps, with the ability to limit to fewer as desired. Additionally, the values used to input the steps are lighted as the sequence moves, in whatever direction it moves. Once again, we have a synth voice (that ends up being too loud in the video, because I decided to use a sawtooth for a change and its higher harmonic content came back to bite me….) to demonstrate the sequence.
Page breakdown. Individual pages are labeled as well as I could; I have a pretty limited number of letters I can devote to describing a page’s content. Each of the “patchlets” in this video have an empty page between them, so if you are importing them into another patch, keep that in mind, as I think it will help identifying what to grab.
Shift register / Turing machine (pages 0-4)
“Shift reg” (page 0)
This page features the first four sample and holds utilized in the shift register. It also features a probability gate composed of clocked multiplier and random modules, which feed into the positive and negative inputs of a comparator, respectively. The other input of the multiplier can be biased to produce more ‘instability’ — lower values will cause fewer new values to be inserted into the shift register (with a value of 0 locking the shift register in place); high values will cause more ‘instability,’ by introducing more new values. These values determine how often the probability gate goes high, which controls a switch that either loops the last sample and hold back to the input of the first (stable) or introduces a random value (unstable).
The clock for the shift register (a square LFO) is located on this page, along with some value modules used to make the timing of the probability gate and the shift register’s sampling window align.
“Shift reg ext” (page 1)
The shift register actually extends to 11 sample and holds. The switch at the bottom of this page is connected to the fourth sample and hold (the one used on the first page in the example), the eighth sample and hold, or the 11th sample and hold — if you replace the connection between the fourth sample and hold on page 0 and the first input of the CV switch with a connection from the output of this switch, you can select between 4-, 8-, and 11-step shift register lengths.
“Quant” (page 2)
This page uses a multiplier to attenuate the signal from the first sample and hold in the shift register’s output. This attenuated signal is then quantized.
“Pan reg” (page 3)
This is a second shift register, which can be sent to the panner used in the demonstration voice. It is five steps long, but otherwise identical in construction to the first shift register (and clocked by the same clock sources). This is meant to illustrate potential uses for a shift register beyond just note generation.
“Voice” (page 4)
A simple oscillator+VCA synth voice for demonstration purposes. There are two buttons on the page. One will mute the synth. The other will toggle the connection from the panning shift register to the panner on and off.
Play-in step sequencer (pages 6-9)
“Step seq input” (page 6)
At the top of this page is a two-octave keyboard module, used for note input.
At the bottom is a pushbutton labeled “Record.” This button will also pause the sequence once a sequence has been recorded (to reset the sequence recording process use the pushbutton on page 8). Prior to recording, the keyboard module can be used to play the demo voice directly, to audition a sequence before recording it.
The output of the record button is inverted by a comparator, and this is used so that when recording is off, the synth voice is heard on the demo voice (page 9); its output is connected to the switches on page 8, setting them to channel 3 when record is ‘off’.
“Step seq shift reg” (page 7)
This is the eight-note shift register, which stores the sequence. The sequence is produced by entering notes via the keyboard, then locking the sequence into a loop, so as the clock triggers the sample and holds, the notes cycle through the sample and holds, allowing the sequence to play.
“Logic counter” (page 8)
There is a lot going on on this page, so let’s start with the simplest. In the top right corner is the square LFO functioning as a clock for the sequence.
Two three-input switches occupy the top left corner. These control how the sequence operates. On channel one, the inputs are the keyboard note output and the gate output. On channel two, the inputs are the last (eighth) sample and hold in the shift register and the clock (square LFO). One channel three, the inputs are once again the note output and gate output of the keyboard module.
The outputs of the switches goes to the first sample and hold input from the shift register on the previous page and -all- of the sample and holds’ trigger inputs, so when the switch is on channel 1, the keyboard’s notes are entered into the first sample and hold’s input, while the gates from the keyboard cause the sample and holds to cycle so their memory can be filled. The outputs also go to the sample and hold controlling the demo voice’s oscillator (on page 9), with the top switch’s output going to its input and the bottom switch’s output going to its trigger input. The bottom switch’s input also goes to the ADSR gate input.
The gate signal from the keyboard is also inverted on this page and sent to the channel select of channel 1. This is so that when the keyboard is played while the sequence is running, the input for the shift register is sent to channel 1 of the switch handling notes.
Just to go through how all this switching madness works (it makes more sense in practice; this was the result of me solving problems on the fly like ‘how do I get it so I can enter notes via the keyboard while the sequence is running?’ which led to the third inputs of the switches):
When the recording button is off, the switch is on channel three, so the note and gate outputs from the keyboard connect to the demo voice. Notes are also entered into the shift register, but they aren’t heard.
When recording is on, the switch is on channel one, the notes are again heard as they’re entered, and they are once again entered into the shift register. Now, however, the counter begins counting. This replaces any notes that had been entered into the shift register when auditioning a sequence with the live keyboard prior to recording. When the number of notes entered reaches eight notes…
The switches switch to channel two, where the last note of the shift register is fed back into the first, and the LFO clock is sent to all the sample and holds’ trigger inputs.
Playing the keyboard at this point will force the top switch, which controls pitch information, back to channel 1, while the bottom switch remains on the clock signal, so new notes can be entered into the sequence via the keyboard.
There is a counter on this page. Its purpose is to change the channel of the switches once the shift register has been filled, automatically initiating the sequence once it’s prepared. The record button on page 6 is sent to the multiplier controlling the input and feedback of the counter, so it will only begin advancing once recording has begun. The counter can be reset using a pushbutton on the right side of the page. There is also a value module in the middle of the page that sets the increment amount for the counter.
“Step seq voice” (page 9)
Another simple demonstration voice; this one uses a filter and a more complex envelope. There is, once again, a pushbutton to mute the synth. The sample and hold on this page is used to prevent the oscillator from being affected by a note played on the keyboard while the sequence is running until the next clock signal.
Forward/backward/pendulum/stochastic/random sequencer (page 11-17)
“Frwd bkwd seq” (page 11)
This is kind of where all the magic happens.
In the top left corner is the sample and hold, which functions as the counter for the patch, thus propelling the switch through its inputs.
Beneath this is a multiplier used to control the feedback of the sample and hold, as well as the new values being added to the input.
There is a square wave LFO which acts as clock for the sequencer.
The output of the sample and hold goes to two comparators.
With the first comparator (I will sometimes refer to this elsewhere as the ‘counting up comparator’ or something like that), it connects to the negative input of the comparator. As the sample and hold climbs, it eventually passes the positive input (more on how the positive input is set later in the patch notes) and the comparator’s output drops to 0. The comparator is connected to the multiplier used in regulating the sample and hold feedback, via a switch on the bottom of the page. When the sample and hold is counting up (when the sequence is moving forward), this will drop the sample and hold back to zero.
With the second comparator (I will sometimes refer to this elsewhere as the ‘counting down comparator’ or something like that), the sample and hold connects to the positive input of the comparator, and the negative input is set by a connection from the increment amount, slightly attenuated. This works like the first comparator, except it goes low when the sample and hold falls below the increment amount (i.e. reaches 0). This, again, resets the sample and hold when the sequencer moves backward.
The outputs of these two comparators are connected to the inputs of the aqua switch at the bottom of the page, then the output of that switch is connected to second input of the multiplier.
This second comparator is inverted by a third comparator. This third comparator is eventually connected to the second input of the blue switch on this page, after being attenuated to fit the step count on page 17 (more on this later). This is conected to the input of the sample and hold directly, so that when the counter is counting down from one (or whatever value corresponds to the maximum number of steps) to zero, as the second comparator goes low, this comparator goes high, and its (potentially attenuated) output is fed into the sample and hold, so the count down will begin again.
In the bottom left corner of the page are a value module and a CV invert. These represent the increment and decrement amounts (the CV invert inverts the value module). The values used for these are based on the total number of steps used in the sequencer; since the maximum number of steps is 16, the increment amount is determined by the formula 1 / (X-1) where X = the number of steps/channels used. Since we want a maximum of 16 steps, this gets filled in as 1/15 = .0666666666666666 (I can keep going, but I think you get the point… but if not … 666666666666666666) or .0666 (close enough for our purposes). The increment and decrement values are then connected to the yellow switch below the multiplier (and the output of the switch is connected to the multiplier). Increment values are used when the sequence is counting up (moving forward); decrement amounts are used when it is counting down (moving backward).
“Pend stoch” (page 12)
This is where the pendulum and stochastic modes are put together.
I realized when reviewing this patchlet that the order — though reflective of how I built the patch — was not ideal how the patch might best be explained. So I’m going to jump to….
“Mode select” (page 16)
… to help explain how the various modes are switched on or off. (This next part will combine explanations of pages 12, 16, and 17.)
On this page, you will find a set of five radio buttons (like we saw in the first video/patch).
The UI buttons used for the radio buttons are lime when deselected and sky when selected, and the are labeled: Forward, backward, pendulum, stochastic, and random.
The button selected is controlled by the sample and hold in the middle of the page.
This sample and hold controls a five-channel CV out switch. The input of this switch is biased to 1.000, so depending on what channel it is on, it sends a value of 1 to various destinations, allowing those modes to function.
For the first output, corresponding to the forward motion, nothing is connected. The forward sequencer works when all of the switches are on channel 1, so we don’t want to send anything to them.
For the second output, corresponding to the backward motion, the output is connected to all of the switches on page 11.
For the third output, corresponding to the pendulum motion, the output is connected to a CV switch on page 12 (see how we came back to it?).
On page 12 are two comparators which invert the comparators used to reset the sample and hold for counting up and counting down. So, they essentially go high whenever one process or the other is completed. The outputs of these comparators connect to a flip flop. The flip flop changes state at the end of each cycle. The output of the switch is connected to the yellow (increment/decrement) and aqua (reset comparators) switches on page 11 (but not the blue switch, since we don’t want to feed the sample and hold a value when the comparators count down, as they will begin to count up again at that point). So, each time the flip flop changes state, the direction of the sequencer changes, too, as the counting mechanisms switch from counting up to counting down, etc..
For the fourth output, corresponding to the stochastic, or drunk walk, motion, the output is connected to a multiplier. The drunk walk is determined by a probability gate; when the gate is high, the sequencer moves backward; when the gate is low, the sequencer moves forward. The probability is determined by a value module on this page labeled “step back probability” — when this value is at 0, the sequencer will move forward, as the output of the gate will always remain low. When this value is at 1, the sequencer will move backward, as the output of the gate will always remain high. When the value is set at .5, there are equal chances of moving forward or backward. Points in between yield different probabilities of forward or backward movement. Since the sequencer will always move forward (aka its default position) when probability is 0, the connection from the CV out switch on page 16 to the multiplier means that the probability gate will only have an affect on the motion of the sequencer when a value of 1 is sent from the switch (which only happens when stochastic mode is selected).
The comparator (the output of the probability gate) is connected to all three switches on page 11.
For the fifth output, corresponding to the random motion, the output is sent two places. First, it sent to a multiplier on page 17. A random module is connected to this multiplier. The output of a steps module is also connected to the multiplier (the output of this steps module attenuates the range of the random module to the appropriate number of steps in the patch — more on this shortly). The output of the multiplier is connected to the input of the sample and hold, so it samples these (potentially attenuated) random values at each clock tick. (Like in the previous mode, the multiplier sends nothing when the switch isn’t connected to it.)
The other destination for this switch output is the negative input of the counting up comparator’s negative input. This holds the comparator permanently low, which keeps the other inputs (the increment/decrement value and the output of the sample and hold itself) from reaching the sample and hold, so that they don’t interfere with the values generated by the random module.
So, now, let’s jump back to….
“Note input” (page 13)
On this page is the CV in switch that holds the “steps” of the sequencer. The sample and hold’s output connects to channel select of this switch, so as the sample and hold counts up or down, the switch changes channels.
The inputs of the switch are connected to the value modules on the bottom of the page (these have been set to show notes). You can use these to change the sequenced notes used for the patch.
“Note indication” (page 14)
A value of 1 is sent to the value modules on the previous page, to show the progress of the sequence. This causes the value modules to light up as they go to 1.
The output of the CV out switch used on this page corresponds to each of the value modules.
Its channel select is also determined by the sample and hold, but if you look on the bottom of the page there are two sets of two value modules. These are used as buffer delays for the signals.
The first set of value modules delays (ever so slightly) the output of the sample and hold before it reaches the channel select of the switch.
The second set of value modules delays (ever so slightly) the output of the clock LFO before it reaches the input of the CV out switch (this clock signal is what is used to send the value modules to one).
The reason for this delay is so that the sequence doesn’t produce values of 1 as the value modules go high.
That is prevented by….
“Voice” (page 15)
The sample and hold in the top left corner of the demo voice page. Its input is our switch on page 13, and it is clocked by the clock LFO, once again delayed by two value modules (this allows the switch to catch up to the appropriate step). It samples the appropriate note, then, when the CV out switch sends a value of 1 to that note, it won’t affect the synth (or whatever else you might want to connect to the sequencer output).
The rest of this page is occupied by the synth voice, which is once again, a very simple oscillator + VCA affair. Once again, there is a pushbutton on the page to mute the voice.
Finally, on…
“Rnd mode seqlng” (page 17)
The value module in the top left corner controls the length of the sequence. This value module is sent through a steps module, sent to 16 steps, which will quantize (although not in a melodic sense) the output of the value module, so it corresponds to a division of 1 / 15 * X (where X is less than or equal to 15). So, if we set the value module to something lower than 1.000, this might produce 12/15, limiting the step count to 13 steps (a value of 0 is step 1).
This quantized value is then used in a few ways.
It attenuates the output of the random module, as already mentioned in passing.
It also attenuates the inverted counting down comparator’s output (the third comparator on page 11), so that when the backwards motion is reset, it resets to the appropriate highest step number.
A slightly attenuated (98.85%) connection is also made to the counting up comparator’s positive input, setting the threshold the sample and hold must surpass to send the comparator low.
In these patchlets I don’t address gate sequencing, but gate sequencing for any of these types of sequencers or shift registers could be accomplished by recording values of 0 or 1 into the appropriate buffers (shift registers or switch inputs) and then multiplying the output by the clock. (Some effort may be required to make sure the output of the buffer and the clock correspond; generally, a short delay will need to be applied to the clock, prior to multiplication.)
If you want to copy and paste these patchlets into your own patches, the outputs (ignoring the demo voices) are:
Shift register / Turing machine (pages 0-4):
The output of the quantizer on page 2 (notes). The output of the third value module on page 0 (gates).
Play-in step sequencer (pages 6-9):
The output of the sample and hold on page 9 (notes). The output of the bottom switch on page 8 (gates).
Forward/backward/pendulum/stochastic/random sequencer (page 11-17):
The output of the sample and hold on page 15 (notes). The output of the second value module on page 15 (gates).
