Skip to content

Instantly share code, notes, and snippets.

View thormagnusson's full-sized avatar

thor magnusson thormagnusson

View GitHub Profile
s.boot
Event
a = EventStream.new(())
SynthDef(\click, {arg freq=50; Out.ar(0, Ringz.ar(Impulse.ar(0.1), [freq, freq+1], 0.1) * Line.ar(1,0,0.1,1,0,2))}).add
a = ().asEventStream
How to fix Pure Data not launching (crashing on startup) where this is not working:
https://puredata.info/docs/faq/help-pd-crashes-on-startup-on-mac-osx-10-7
0) Open the Terminal.app (can be found in Applications/Utilities)
1) type
sudo pico /etc/hosts
into the terminal
@thormagnusson
thormagnusson / gist:ee21f017ef34cabb4b1d
Created June 29, 2015 19:26
Recording, saving and reloading slider values
(
a = [];
t = Main.elapsedTime;
w = Window.new.front;
r = Slider(w, Rect(100, 140, 200, 20))
.action_({ arg sl;
a = a.add([Main.elapsedTime-t, sl.value*1000]);
});
)
Verifying I am +thormagnusson on my passcard. https://onename.com/thormagnusson
if(theOscMessage.checkAddrPattern("/pitch")==true) {
pitch = theOscMessage.get(0).floatValue();
println(pitch);
}
@thormagnusson
thormagnusson / recursion
Created August 31, 2014 15:04
Temporal Recursion in SuperCollider
// recursion
f = {arg a;
a = a+1;
a.postln;
if(a<10, { thisFunction.value(a) })
};
f.(2)
@thormagnusson
thormagnusson / Rationals
Last active August 29, 2015 14:04
Recursive Rational Number Algorithm in SuperCollider
// version 1 - didn't work well on numbers such as 1.0666666666667
// a recursive algorithm for finding the Rational Number from a floating point ratio
a = { arg ratio=1, num=1, den=1, oldnum=1;
var max = 1000;
ratio = ratio.value;
num = num+1;
if(num == max, {num = oldnum; oldnum = oldnum+1; den = den+1; });

Keybase proof

I hereby claim:

  • I am thormagnusson on github.
  • I am thormagnusson (https://keybase.io/thormagnusson) on keybase.
  • I have a public key whose fingerprint is F402 9408 AEA1 3F6C 0B69 6C4F 4B2B C218 B8AC 520E

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am thormagnusson on github.
  • I am thormagnusson (https://keybase.io/thormagnusson) on keybase.
  • I have a public key whose fingerprint is F402 9408 AEA1 3F6C 0B69 6C4F 4B2B C218 B8AC 520E

To claim this, I am signing this object:

@thormagnusson
thormagnusson / gist:11290382
Created April 25, 2014 13:54
Record and Play Buffers in SuperCollider
b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav"); // remember to free the buffer later.
b = Buffer.alloc(s, s.sampleRate * 2.0, 1);
b.bufnum
x = {arg rate=1; RecordBuf.ar(SoundIn.ar(0), b, 0, preLevel:0.5, loop:1)}.play;
a = {arg rate=1; PlayBuf.ar(1, b, rate, loop:1)}.play
b.free;
a.set(\rate, -0.5)