Skip to content

Instantly share code, notes, and snippets.

Avatar

Sam Aaron samaaron

View GitHub Profile
@samaaron
samaaron / keepalive.erl
Last active Sep 27, 2021
TCP kill switch
View keepalive.erl
-module(keepalive).
-export([start/1, init/1, loop/1]).
start(DaemonPortNum) ->
spawn_link(?MODULE, init, [DaemonPortNum]).
init(DaemonPortNum) ->
io:format("connecting to Daemon via TCP...~n", []),
{ok, DaemonSocket} = gen_tcp:connect({127,0,0,1}, DaemonPortNum, [
View keybase.md

Keybase proof

I hereby claim:

  • I am samaaron on github.
  • I am samaaron (https://keybase.io/samaaron) on keybase.
  • I have a public key whose fingerprint is FAE0 DB04 1B34 4F6F 0702 93B5 85D8 A2FD 323A F9A0

To claim this, I am signing this object:

@samaaron
samaaron / jam.rb
Created Dec 26, 2016 — forked from poppingtonic/jam.rb
Sonic PI Livecoding Snippet #1
View jam.rb
live_loop :lloop do
with_fx :reverb, room: 0.5 do
with_fx :compressor do
sample :bd_boom, amp: 10, rate: 1
end
end
with_fx :reverb, room: 0.5 do
with_fx :krush, amp: 2, cutoff: 100 do
with_fx :slicer, probability: 0, phase: 0.125, mix: 0.5 do
use_synth :dsaw
View synth_code_078rpy
define :eggs do |co=130|
time_warp 0 do
with_fx :reverb,room: 1 do
with_fx :krush, amp: 2, mix: 0.3 do
time_warp -0.01 do
play :e0, release: 8, cutoff: co, note_slide: 0.01, cutoff_slide: 2 do
control cutoff: 130
16.times do
control note: (scale, :e0, :minor_pentatonic).choose
View sonic-pi-blocks.rb
define :foo do |&block|
block.call("hello")
end
foo do |m|
puts "#{m} Sam"
end
View melodic_sonic_pi.rb
# Melodic Fun w/ Sonic Pi
# Playing basic notes with either MIDI numbers or
# note names:
comment do
play 70
sleep 1
play :C4
sleep 2
end
View funterpreter.rb
# Based on conversations with Dan Friedman and Jason Hemann
# To evaluate use Sonic Pi...
define :valof do |exp, env={}|
return exp if exp.is_a? Numeric
return env[exp] if exp.is_a? Symbol
if exp.is_a?(Array) && exp[0] == :lambda
lambda do |a|
x = exp[1][0]
View Bizet Beats
# Coded by Sam Aaron
bizet_bass = (ring :d, :r, :r, :a, :f5, :r, :a, :r)
#bizet_bass = (ring :d, :r, :r, :Bb, :g5, :r, :Bb, :r)
live_loop :bizet do
with_fx :reverb, room: 1, mix: 0.3 do
with_fx :slicer, phase: 0.125 do
synth :blade, note: :d4, release: 8, cutoff: 100, amp: 1.5
end
16.times do
View Synced Random Streams
# Both live loops play in total rhythmical sync.
# Notice that they are both using the same seed
# One in Ruby and the other in the synthdef ;-)
# Note: needs Sonic Pi v2.7 to work correctly
live_loop :foo do
use_random_seed 10
64.times do
View sonic-pi-triplets.rb
## Sonic Pi triplets example
## http://sonic-pi.net
live_loop :triplets do
density 3 do
play :e4, release: 0.1
sleep 1
end
end