supercollider
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| supercollider [2024/09/15 18:07] – discord | supercollider [2025/03/05 19:10] (current) – smj-edison | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Directions ====== | ====== Directions ====== | ||
| - | Use the '' | + | Use the '' |
| - | Install | + | * '' |
| - | Add yourself to the audio group. | + | Install '' |
| + | |||
| + | * '' | ||
| + | |||
| + | Add yourself to the audio group and reboot. | ||
| + | |||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | Configure jack to use your audio device in '' | ||
| + | |||
| + | * This is a bit more involved. | ||
| + | * Run this command: | ||
| + | * <file bash> | ||
| + | * Or, manually: | ||
| + | * Start by running '' | ||
| + | * You'll get a huge list of audio device. Try and find one that says something about HD-Audio, being generic, and being analog. You'll want the string that looks like '' | ||
| + | * Now, go to '' | ||
| + | * Add a section that looks like this: | ||
| + | * <file tcl> | ||
| + | [... top of ifs] | ||
| + | } elseif {$:: | ||
| + | exec jack_control dps device hw: | ||
| + | exec jack_control dps period 256 | ||
| + | } | ||
| + | [... rest of ifs] | ||
| + | </ | ||
| + | * Install the SuperDirt library by running <file bash> | ||
| + | * It should be set up! | ||
| Starting code to make audio: | Starting code to make audio: | ||
| Line 11: | Line 39: | ||
| <file tcl> | <file tcl> | ||
| Wish Supercollider plays sound foo { | Wish Supercollider plays sound foo { | ||
| - | Pan2.ar(SinOsc.ar(440) * 0.5, 0.0); | + | Pan2.ar(SinOsc.ar(440) * 0.5, 0.0); // This is Supercollider synth code |
| } | } | ||
| </ | </ | ||
| + | |||
| + | Code to play a note when it is wished for: | ||
| + | <file tcl> | ||
| + | set noteSemitones [dict create A 0 B 2 C 3 D 5 E 7 F 8 G 10] | ||
| + | set accidentalSemitones [dict create "#" | ||
| + | |||
| + | When /player/ wishes to play note /note/ { | ||
| + | regexp {^([A-Ga-g])([0-9]? | ||
| + | set noteSt [dict get $noteSemitones $note] | ||
| + | set modSt [dict get $accidentalSemitones $accidental] | ||
| + | set st [expr { $noteSt + $modSt }] | ||
| + | set noteFreq [expr { 440.0 * (2.0 ** (($octave == "" | ||
| + | set soundName note-$player-$note | ||
| + | Wish Supercollider sound $soundName attr freq is $noteFreq | ||
| + | Wish Supercollider plays sound $soundName { | ||
| + | arg freq = 440.0; | ||
| + | var envgen; | ||
| + | envgen = EnvGen.kr(Env.adsr(sustainLevel: | ||
| + | Pan2.ar(Saw.ar(freq) * 0.5 * envgen, 0.0); | ||
| + | } | ||
| + | |||
| + | When the clock time is /t/ { | ||
| + | When /nobody/ claims $soundName has start time /startTime/ { | ||
| + | Hold $soundName { Claim $soundName has start time $t } | ||
| + | } | ||
| + | When $player has region /r/ & $soundName has start time /startTime/ { | ||
| + | # set radius [expr { max([region width $r], [region height $r])/2 + 10 }] | ||
| + | set radius [expr { ($t - $startTime) * 500 }] | ||
| + | Wish $player draws a circle with radius $radius color red | ||
| + | } | ||
| + | } | ||
| + | On unmatch { Hold $soundName { } } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== Troubleshooting ===== | ||
| + | |||
| + | |||
| + | May need to kill/ | ||
| + | |||
| + | For testing, try running the Supercollider interpreter separately with '' | ||
| + | |||
| + | If you just can't get it working you can run Supercollider as a server on a separate device and connect. | ||
| + | * To do that, start by installing Supercollider on your host device of choice, and write down its IP. | ||
| + | * Now, run the server side using this code: | ||
| + | * < | ||
| + | s.options.protocol = \tcp; // set to use tcp | ||
| + | s.options.bindAddress = " | ||
| + | s.options.maxLogins = 2; // set to correct number of clients | ||
| + | s.boot(); | ||
| + | </ | ||
| + | * Moving back to the folk side, you'll have to edit '' | ||
| + | * There will be a block labelled '' | ||
| + | * < | ||
| + | o = ServerOptions.new; | ||
| + | o.protocol_(\tcp); | ||
| + | t = Server.remote(\remote, | ||
| + | t.addr.connect; | ||
| + | t.startAliveThread( 0 ); | ||
| + | t.doWhenBooted({ " | ||
| + | Server.default = t; | ||
| + | s = t; | ||
| + | </ | ||
| + | |||
| + | TODO: add audio debugging page that can be printed? | ||
supercollider.1726423665.txt.gz · Last modified: by discord
