Skip to content

Instantly share code, notes, and snippets.

View Enkerli's full-sized avatar

Alexandre Enkerli Enkerli

View GitHub Profile
@Enkerli
Enkerli / gist:3f3b4bf5134e3d1cfed5c0258dcea94c
Created November 4, 2016 06:06
Colour version of exercise 13-5 in Daniel Shiffman’s Learning Processing book (2015: 249). Enjoying the effect: https://www.dropbox.com/s/k3n7y6m85y49rn7/cartesian-spiral.png?dl=0
// Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com
// Exercise 13-5: Using Example 13-5, draw a spiral path. Start in the center and move
// outward. Note that this can be done by changing only one line of code and adding one line
// of code!
// A Polar coordinate, radius now starts at 0 to spiral outwards
float r = 1;
@Enkerli
Enkerli / spi-ctl-bpf.rb
Last active September 15, 2023 02:27
A Sonic Pi script (spi-ctl-bpf.rb) and a Processing one (spi_ctl_bpf.pde) to control a band pass filter using the mouse. Been having performance issues with the sound lagging behind. Setting `set_sched_ahead_time!` in Sonic Pi sounds like it helps, but not enough. Original code from Robin Newman: https://gist.github.com/rbnpi/ca5e80258c0c1296b1c…
set_sched_ahead_time! 0 # Setting that one to a negative value makes Sonic Pi complain, it sounds like.
with_fx :bpf do |s| # Setting up the fx to be controlled internally
synth :square, note: 32,release: 400 # Long release as the control will affect a single note
live_loop :ctl do # The loop is inside the fx as this is where the action will be.
ctl=sync "/ctl" # The OSC message which Processing sends, based on mouse coordinates.
rz=ctl[:args][0] # Assigning the first argument to resonance.
ct=ctl[:args][1] # Assigning the second argument to centre.
control s, res: rz, centre: ct # The actual control of the fx.
set_sched_ahead_time! -2 # Sounds like setting this again every time actually helps.
@Enkerli
Enkerli / skywriter_osc_client.py
Created November 25, 2016 05:09
Controlling Sonic Pi using Pimoroni's Skywriter HAT. A Python script to send OSC messages with xyz coordinates, and a Sonic Pi script to do something with those coordinates. Also works with Alexandre rANGEL's scale-based Sonic Pi script. https://gist.github.com/AlexandreRangel/e82072203fcf4b89f12003b1f1a957fa
"""Based on Small example OSC client from Python-OSC, and Synth.py from Pimoroni's Skywriter examples.
This sends the Skywriter HAT's xyz coordinates as OSC messages to Sonic Pi.
"""
import argparse
import random
import time
import skywriter
import os
import signal
@Enkerli
Enkerli / spi_osc_bridge.pde
Created November 25, 2016 07:45
Using TouchOSC to control Sonic Pi, with Processing as a bridge.
// Passing on OSC data to Sonic Pi
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myBroadcastLocation;
void setup() {
background(0);
frameRate(60);
@Enkerli
Enkerli / spi_mbe.rb
Created April 21, 2017 17:01
Sonic Pi script to create four-part harmony from incoming notes using the “rotating chords” effect pioneered by Robby Kilgore in his work with Michael Brecker. Video here: https://vimeo.com/214204872
# Thirty years ago, Robby Kilgore invented a neat harmonization effect for Michael Brecker: http://robbykilgore.com/?p=19
# The basic idea is that incoming notes are doubled by rotating intervals. So you get diverse chords from the same melodic notes.
# This script is an attempt to reproduce the same effect.
use_real_time # Prevents latency
use_synth :fm # Other interesting synth sounds for this: [:hoover, :prophet, :blade, :fm]
middle=[-8, -5, -7, -1].ring # Rotating intervals for the middle note of each chord.
low=[-12, -17, 0].ring # Rotating intervals for the “bass” note of each chord.
@Enkerli
Enkerli / tonespace_chords.rb
Created April 23, 2017 06:38
Sonic Pi script to emulate the tonespace MIDI harmonizer from mucoder.
use_real_time # Preventing latency
use_tuning :just, :c # Just Intonation, chords are diatonic in C major
with_fx :compressor, threshold: 0.1 do # Preventing clipping
with_fx :reverb do # Everything on the same reverb
with_fx :lpf, cutoff_slide: 0.02 do |filtre| # Everything on the same breath-controlled filter
baritone = synth :hoover, note: 0, release: 1000, amp: 0 # “Classic early 90’s rave synth”
tenor = synth :chipbass, note: 0, release: 1000, amp: 0 # “A 16 step triangle wave modelled after the 2A03 chip found in voice 3 of the NES games console.”
alto = synth :beep, note: 0, release: 1000, amp: 0 # Sine wave
soprano = synth :chiplead, note: 0, release: 1000, amp: 0 # “A slightly clipped square (pulse) wave with phases of 12.5%, 25% or 50% modelled after the 2A03 chip found in voices 1 and 2 of the NES games console.”
@Enkerli
Enkerli / rubato_synthdrome.rb
Created April 25, 2017 02:26
Sonic Pi script to auto-accompany a melodic line every four notes. Goes well with the idea that accompaniment would yield to a melody. https://en.wikipedia.org/wiki/Tempo_rubato#.22Accompaniment_yields.2Fadjusts_to_melody.22
use_real_time # Preventing latency
use_tuning :just, :c # Just Intonation
bass = (ring 48, 53, 48, 43, 53, 48, 55, 41) # Alternating between C, F, and G
with_fx :compressor, threshold: 0.1 do # Preventing clipping
with_fx :reverb do # Everything on the same reverb
melody = synth :prophet, note: 0, release: 1000, cutoff_slide: 0.02, amp: 0
live_loop :notes do
note_on, velocity = sync "/midi/USB_Midi_Cable/4/1/note_on" # Incoming notes from Yamaha WX-11 wind controller
if velocity > 0 # Only use actual note-ons
control melody, note: note_on, amp: velocity / 127.0 # Incoming note
@Enkerli
Enkerli / poster_synthdrome.rb
Created April 25, 2017 02:27
Sonic Pi script creating a countermelody through contrary motion.
use_real_time # Preventing latency
use_tuning :just, :c # Just Intonation
delta=counter=naute=idx=0
previous=60
gamme=(scale 50, :minor_pentatonic, num_octaves: 5)
counter_gamme=(scale 38, :minor_pentatonic, num_octaves: 2)
with_fx :compressor, threshold: 0.1 do # Preventing clipping
with_fx :reverb do # Everything on the same reverb
with_fx :lpf, cutoff_slide: 0.02 do |filtre|
@Enkerli
Enkerli / ringy_bendy.rb
Created May 5, 2017 00:43
Using lip control (“pitch bend”) to drive ring modulation in Sonic Pi using a WX-11 Wind Controller.
use_real_time # Preventing latency
use_tuning :just, :c # Just Intonation
with_fx :compressor, threshold: 0.2 do # Preventing clipping
with_fx :reverb, room: 0.8 do # Everything on the same reverb
with_fx :ring_mod, mix_slide: 0.02 do |ringy| # Everything on lip-controlled Ring Mod
with_fx :rlpf, res: 0.7, cutoff_slide: 0.02 do |lipf| # Everything on breath-controlled low-pass filter
tibi = synth :tb303, note: 0, wave: 1, pulse_width_slide: 0.02, res: 0.7, release: 1000, amp: 0 # TB-303-inspired pulse
prof = synth :prophet, note: 0, res: 0.8, release: 1000, amp: 0 # Prophet-like sub
live_loop :notes do
note_on, velocity = sync "/midi/USB_Midi_Cable/4/1/note_on" # Incoming notes from Yamaha WX-11 wind controller
@Enkerli
Enkerli / whammy_bendy.rb
Created May 5, 2017 03:50
Using lip pressure to control a “whammy bar” effect in Sonic Pi, driven by a Wind Controller.
use_real_time # Preventing latency
use_tuning :just, :c # Just Intonation
transpo=-12 # Transposition offset
with_fx :compressor, threshold: 0.2 do # Preventing clipping
with_fx :reverb, room: 0.8 do # Everything on the same reverb
with_fx :rlpf, res: 0.7, cutoff_slide: 0.02 do |lipf| # Everything on breath-controlled low-pass filter
with_fx :whammy, transpose_slide: 0.02, mix_slide: 0.02 do |wham| # Everything on a whammy bar
tibi = synth :tb303, note: 0, wave: 1, pulse_width_slide: 0.02, res: 0.7, release: 1000, amp: 0 # TB-303-inspired pulse
prof = synth :prophet, note: 0, res: 0.8, release: 1000, amp: 0 # Prophet-like sub
live_loop :notes do