Last active
March 31, 2019 00:08
-
-
Save sinewalker/1374e40a8778cce8538db09ab1ee7811 to your computer and use it in GitHub Desktop.
8-bit retro chip arp "chord" in Sonic Pi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define :chiparp do |notes, duration, c_amp=0.8, c_Hz=30, c_sust_ratio=1, c_step=1| | |
tx=bt(1) # seconds for 1 beat | |
in_thread do | |
use_bpm 60 # normalise bpm to 1 beat per second | |
c_speed = 1.0/c_Hz #the chip speed is better converted from Hz | |
count = (duration * tx / c_speed) | |
use_synth :chiplead | |
use_synth_defaults amp: c_amp, sustain: c_speed*c_sust_ratio, | |
attack: 0, decay: 0, release: 0 | |
puts "chip arp!"; puts notes; puts duration; puts count; puts tx | |
n = 0 | |
with_debug false do | |
count.times do | |
play notes[n] | |
wait c_speed | |
n = n + c_step | |
end | |
end | |
end | |
end | |
define :chiparp_wait do |notes, dur| | |
# Use defaults | |
##| chiparp notes, dur | |
# or override them (amp, speed, sust_ratio, direction) | |
chiparp notes, dur, 1.6,25,0.8,-1 | |
wait dur | |
end | |
##### | |
# dinky tune - do better! | |
# but this demonstrates chiparp arpegio rate is independant of the global BPM, yet stretches to fit beats | |
use_bpm 80 | |
use_synth :chiplead | |
play_pattern_timed [:Bb4, :D5], [1, 1] | |
4.times do | |
chiparp_wait((chord :e5, :minor), 2) | |
##| chiparp_wait((chord :b4, :minor, invert: 1), 1) | |
chiparp_wait((chord :a4, :minor), 1) | |
chiparp_wait((chord :a4, :minor, invert: 1), 1) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Params to
chiparp
:notes
: a Ring of notes to apegiateduration
: the length to arpegiate (in beats)c_amp
: chip amplifiction (default is 0.8)c_Hz
: arp frequency (steps per second, bigger is faster) (default is 30Hz)c_sust_ratio
: the ration of sound to silence for each step in the arp. Greate than 1 is allowed, it makes the chiparp become smoother, more chord-like (default is 1, meaining 1:0 sound/silence)c_step
: the step size through thenotes
ring. +1 and -1 are most useful (negative makes it arp backwards) (default is +1)Function
chiparp_wait
is just a wrapper forchiparp
that also waits until the arp has completed it's duration.The function to use depends on the musical effect you're after