Skip to content

Instantly share code, notes, and snippets.

View nicoder's full-sized avatar

Nicolas Dermine nicoder

View GitHub Profile
<?php
// https://adventofcode.com/2023/day/1/answer
$lines = file('data.txt');
$calibrationValues = getCalibrationValues($lines);
$sum = array_sum($calibrationValues);
/**
* @return int[]
@nicoder
nicoder / 20150202_sonic_pi.rb
Created February 2, 2015 05:06
20150202 sonic pi (start of the bass line of queen's 'another one bites the dust')
use_bpm 90
live_loop :bass do
use_synth :fm
use_synth_defaults release: 0.2
play_pattern_timed [45, 43], [0.25]
play_pattern_timed [40, 40], [1]
play_pattern_timed [40], [1.75]
play_pattern_timed [40, 40, 40, 43, 40, 45],
[0.25, 0.5, 0.5, 0.5, 0.25, 1.75]
live_loop :a do
sample :ambi_choir, amp: rrand(0.2, 0.7)
sleep 1
end
live_loop :b do
#sync :a
with_fx :echo do
play 60 + (ring 0, 12).tick, release: 0.2
play 60 + (ring 7, 9, 5, 4).stretch(8).look, release: 0.2, pan: 0.2
# adapted from robin newman:
# https://in-thread.sonic-pi.net/t/record-vocal-and-playback-with-effects/6202/5
use_bpm 60
use_real_time
i = 0
buffers = []
duration = 8
4.times do
live_loop :a do
with_fx :slicer, mix: rrand(0.5, 1) do
with_fx :vowel, mix: rrand(0.8, 1) do
use_synth :blade
play scale(60, :major).choose, pan: 0.5, release: rrand(0.25, 2)
use_synth (ring :dark_ambience, :fm).choose
play 60, pan: -0.5
play 60 + (ring -12, 12).choose, pan: -0.5
end
use_synth :pluck
live_loop :a do
with_fx :echo, mix: rrand(0, 1) do
play 60 - 12, pan: rrand(-1, -0.75)
play 60 - 24, pan: rrand(0.75, 1)
play 60 - 36, amp: rrand(0, 0.5) if one_in 2
play 60, pan: rrand(-0.5, 0)
end
with_fx :echo do
live_loop :a do
with_fx :reverb do
play 60, pan: -1
play (ring 60, 62, 65, 60).stretch(4).tick, pan: 1
end
sleep 1
end
live_loop :b do
#sync :a
live_loop :a do
use_synth :fm
play 60 - (ring 12, 7, 5).stretch(4).tick
sleep 1
end
live_loop :b do
sync :a
with_fx :echo do
play 72 + (ring 0, 2, 4).mirror.tick
live_loop :a do
play 60
sleep 1
end
live_loop :b do
sync :a
sleep (line 0.4, 0.6, steps: 20).choose
play 60 + (ring 4, 5).stretch(4).tick
end
live_loop :foo do
with_fx [:reverb, :distortion, :echo].choose do
live_audio :voice, amp: 3
end
sleep 8
end
live_loop :a do
sample :drum_bass_soft
sleep 1