User Tools

Site Tools


supercollider

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
supercollider [2024/09/15 19:30] discordsupercollider [2025/03/05 19:10] (current) smj-edison
Line 1: Line 1:
 ====== Directions ====== ====== Directions ======
  
-Use the ''jmg/supercollider'' branch until it's merged into main.+Use the ''jmg/supercollider'' folk branch until it's merged into main.
  
   * ''git checkout jmg/supercollider''   * ''git checkout jmg/supercollider''
  
-Install ''supercollider'', the alsa utilities, and ''tcl-udp'' through apt. +Install ''supercollider'', the alsa utilities, ''ghc'', and ''tcl-udp'' through apt. 
  
-  * ''sudo apt install supercollider alsa-utils tcl-udp''+  * ''sudo apt install supercollider alsa-utils tcl-udp ghc''
  
 Add yourself to the audio group and reboot. Add yourself to the audio group and reboot.
Line 17: Line 17:
  
   * This is a bit more involved.   * This is a bit more involved.
-  * Start by running ''aplay -L''+  * Run this command: 
-  * 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 ''hw:CARD=Generic_1,DEV=0'' and starts with ''hw''+    * <file bash>aplay -L | grep -E 'hw:CARD=.*,DEV=0' | sed -n 's/^\(hw:CARD=.*,DEV=0\).*$/\1/p'</file> 
-  * Now, go to  ''virtual-programs/music.folk'' and look for the big block of if-elseif checks, and add your own instance+     * Or, manually: 
 +       * Start by running ''aplay -L''
 +       * 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 ''hw:CARD=Generic_1,DEV=0'' and starts with ''hw''
 +    * Now, go to  ''virtual-programs/music.folk'' and look for the big block of if-elseif checks, and add your own instance
     * Add a section that looks like this:     * Add a section that looks like this:
     * <file tcl>     * <file tcl>
Line 29: Line 32:
 [... rest of ifs] [... rest of ifs]
 </file> </file>
 +  * Install the SuperDirt library by running <file bash>echo 'include("SuperDirt");' | QT_QPA_PLATFORM=offscreen sclang</file>
   * It should be set up!   * It should be set up!
  
Line 42: Line 46:
 <file tcl> <file tcl>
 set noteSemitones [dict create A 0 B 2 C 3 D 5 E 7 F 8 G 10] set noteSemitones [dict create A 0 B 2 C 3 D 5 E 7 F 8 G 10]
-set modSemitones [dict create "#" 1 b -1 "" 0]+set accidentalSemitones [dict create "#" 1 b -1 "" 0]
  
 When /player/ wishes to play note /note/ { When /player/ wishes to play note /note/ {
-    set noteName [string index $note 0] +    regexp {^([A-Ga-g])([0-9]?)([#b]?)$} $note -> note octave accidental 
-    set noteMod [string index $note 1] +    set noteSt [dict get $noteSemitones $note
-    set noteSt [dict get $noteSemitones $noteName+    set modSt [dict get $accidentalSemitones $accidental]
-    set modSt [dict get $modSemitones $noteMod]+
     set st [expr { $noteSt + $modSt }]     set st [expr { $noteSt + $modSt }]
-    set noteFreq [expr { 440.0 * (2.0 ** ($st / 12.0)) }] +    set noteFreq [expr { 440.0 * (2.0 ** (($octave == "" ? 0 : ($octave - 4)) + $st / 12.0)) }]
-    Wish $player is labelled "noteFreq is $noteFreq"+
     set soundName note-$player-$note     set soundName note-$player-$note
     Wish Supercollider sound $soundName attr freq is $noteFreq     Wish Supercollider sound $soundName attr freq is $noteFreq
Line 57: Line 59:
         arg freq = 440.0;         arg freq = 440.0;
         var envgen;         var envgen;
-        envgen = EnvGen.kr(Env.adsr(sustainLevel: 0.2)); +        envgen = EnvGen.kr(Env.adsr(sustainLevel: 0.1)); 
-        Pan2.ar(SinOsc.ar(freq) * 0.5 * envgen, 0.0);+        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 { } }
 } }
 </file> </file>
Line 91: Line 105:
 s = t; s = t;
 </file> </file>
 +
 +TODO: add audio debugging page that can be printed?
supercollider.1726428627.txt.gz · Last modified: 2024/09/15 19:30 by discord

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki