Sonic Pi Scripts

Jumping-off points for Sonic Pi!

Aphex Twin Style LFO Step Glitch Effect
Aphex Twin Style LFO Step Glitch Effect

Aphex Twin Style LFO Step Glitch Effect

This instrument chops up a sample programmatically and applies FX based on LFO step positions. Randomness is introduced across various parameters using ‘choose’.

What it sounds like:

Code:

### Aphex Twin Style LFO Step Glitch Effect
### Author: Shea Kennedy
### About: This live_loop instrument chops up a sample programmatically and applies FX based on LFO step positions.
### Randomness is introduced across various parameters using 'choose'.

### INITIALIZE MASTER VALUES
# This sets the project BPM.
use_bpm 96
# This sets the random seed (affects any portion of the code that uses randomness).
use_random_seed 0

### AUTOMATION
# This imitates a tri LFO which has 32 steps. It begins at a value of 120, and ends at a value of 60, then mirrors.
lfo1 = (line 120, 60, inclusive: true, steps: 32).mirror
# This imitates a tri LFO which has 4 steps. It begins at a value of 0.7, and ends at a value of 0.99, then mirrors.
lfo2 = (line 0.7, 0.99, inclusive: true, steps: 4).mirror

### LEVELS
# This variable controls the instrument's volume. Can be set between 0 and 1 (Higher values could result in distortion or clipping).
inst0_lvl = 1

### LIVE LOOPS
live_loop :krushbeat do
  # Only proceeds if instrument's volume is not zero.
  if(inst0_lvl != 0)
    # The level FX will apply the current amp volume to the loop.
    with_fx :level, amp: inst0_lvl  do
      # This generates a tick which is used to progress through the LFO steps using 'look'.
      puts tick
      # This adds krush FX with a cutoff and resonance that follow the LFO patterns. The mix of the FX randomly fluctuates between 1 and 0.
      with_fx :krush, cutoff: lfo1.look, res: lfo2.look, mix: choose([1, 0]) do
        # Using the sample loop_breakbeat, the rate of the loop's chop randomly fluctuates between 1, 2, 4, and 16x the original speed.
        # Onset is used in a ring to cycle between a sequence of transient strating points in the audio sample, then mirrors.
        # The beat is stretched across 4 bars with a sample release of 0.01.
        sample :loop_breakbeat, rate: choose([1, 2, 4, 16]), onset: (ring 7,5,5,5,1,2,8,9).mirror.look, beat_stretch: 4, release: 0.01
      end
    end
  end
  # The loop sleeps depending on the value in the ring as the tick progresses through the steps.
  sleep (ring 0.25, 0.25, 0.25, 0.25, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.125, 0.125).look
end

One comment on "Aphex Twin Style LFO Step Glitch Effect"

Leave a Reply

Your email address will not be published. Required fields are marked *