Supercollider tips, Q/A

Two approaches I think could help out:

  1. using the code as-is, I was able to run it with the following rules:
// select this line, and cmd-enter to evaluate it (load the file
// into a variable called b, used below)
b=Buffer.read(s,"/Users/admin/Desktop/scal.aif");

// select this from one parenthesis all the way to the other
// and cmd-enter to evaluate (plays the buffer)
// cmd-period will kill the audio... you can rerun it though!
(
{
var trig, rate, pos, sig, rec;
trig = Dust.ar(3);
rate = TChoose.kr(trig, [-2, 1, 2, -3, -0.75]);
pos = TRand.ar(0, BufFrames.ir(b), trig);
sig = PlayBuf.ar(2, b, loop: 1);
rec = Phasor.ar(trig, K2A.ar(rate), 0, BufFrames.ir(b), pos);
BufWr.ar(sig, b, rec);
sig
}.play;
)

// this line frees up the buffer, select + run it last to cleanup
// when you're finished
b.free;
  1. or, modify the code to not use a global variable b - it’s now one big block you can run all at once easily by doing cmd-a (select all) cmd-enter (evaluate):
(
{
var buf, trig, rate, pos, sig, rec;
buf = Buffer.read(s,"/Users/admin/Desktop/scal.aif");
trig = Dust.ar(3);
rate = TChoose.kr(trig, [-2, 1, 2, -3, -0.75]);
pos = TRand.ar(0, BufFrames.ir(b), trig);
sig = PlayBuf.ar(2, b, loop: 1);
rec = Phasor.ar(trig, K2A.ar(rate), 0, BufFrames.ir(b), pos);
BufWr.ar(sig, b, rec);
sig
}.play;
)

Other things to try:

  • Double check the path to your file is 100% correct.
  • I think SuperCollider will play AIFF? :thinking: so it should be fine. But FWIW I tested with a WAV!

Hope these help!

1 Like

thanks for the help!!

tried the first version you shared

this is the error after trying to load the buffer

→ Buffer(0, nil, nil, nil, /Users/admin/Desktop/scal.aif)

maybe my path is wrong?

I really have no idea what I’m doing, so thank you very much

As long as that’s printed in green with nothing else, I think that means you’ve loaded the file successfully! :slight_smile: Here’s a screenshot of me evaluating the first line with a file that’s on my laptop, after I’ve booted my server. That line in the console is telling us that a buffer was successfully read! It’s not playing - but it’s loaded and ready for further use (that’s the next snippet).

This would be an example of an error (tetrax-fake.wav isn’t a real file on my filesystem). You can see it does still print the green bit (confusing!) but the next line says could not be opened telling us there was actually a problem. If you’re seeing additional info like that, there could be something funky going on. If you see a lot of red text it might mean there’s an error in the syntax it’s trying to run (copy pasted wrong, didn’t select the full line, etc). One thing to note is we want to use regular double quotes " not fancy double quotes . I think you’ve got this correct but I accidentally included the wrong quotes for a hot second in my post above (fixed now) so just double checking! (But yeah check the filename maybe - should it be scale not scal etc?)

Once you get your file loaded, evaluating the second bit should hopefully work! If your file (like mine) is stereo you might see some oddity about channel mismatch because the code is built for mono, but it’ll still play. Another thing to note is that since the SuperCollider code is playing in mono it will only come out of your left speaker (see the oscilloscope below [click: Server => Show Scope in the menu bar to get this to show]). My laptop’s left speaker is hosed so I occasionally am left wondering why there’s no output on my computer :slight_smile:

Hope this helps a bit! Feel free to post a screenshot if you’re still running into issues!

And also no worries, SuperCollider was confusing to me at first too… I’ve found it’s been well worth the effort to stick with though!

topicality

Hope this isn’t intruding on the thread too much - happy to move elsewhere if needed!

5 Likes

awesome! got it working. not sure why but this morning it just worked. now to dig in more and see what’s actually going on here

thanks again

  • maybe we should move this to the bigger supercollider thread?
1 Like

done!
also, this was such a rad exchange! so heartening <333
thank you @cfd90 for all the kind help!

4 Likes

agreed dan.

after all these years, this community still gives so much :heart:

3 Likes

ok, here’s a very newbie question: what’s the most idiomatic way to do a dry/wet mix, e.g. if i have a PitchShifted version of a signal and i want to have a 50/50 mix between that and the unshifted version (or any other arbitrary mix)?

I tend to use XFade2.ar(drySig, wetSig, wetAmt) where wetAmt should run -1 to 1 (meaning 0 is 50% blend).

2 Likes

Hello everyone !
I have a weird question:

p = ProxySpace.push(s)

(
SynthDef(\ring1,{|f = 45, a = 9, d = 0.6, pan = 0, amp = 1, out = 0|
		var sig, env;
		env = Line.kr(0,1,d);
		env = FreeSelfWhenDone.kr(env);
		sig = Impulse.ar(0);
		sig = Ringz.ar(sig,f,d,a);
		Out.ar(out,sig)
	}).add;

SynthDef(\test, {|freq| Out.ar(0, SinOsc.ar(freq, 0, EnvGen.ar(Env.perc, doneAction: 2)))}).add;
)
~sine = Pbind(\instrument,\test, \dur,0.25)
~sine = Pbind(\instrument,\ring1, \dur,0.25)
~sine.play
~sine.stop

Using this code, when I launch ring1 it behave normally (waiting for ~sine.play, stopping with ~sine.stop) but when I switch to \test, it’ll start making sound right away and stop won’t do anything.

So yeah I’m kinda confuse, does it happen to you to ? Do you have any idea of what is going on ?
I even rebooted my computer, which did nothing

EDIT : Found It,
I need to use a variable in the Out.ar(bus) instead of hardcoding it, but if someone knows why I’d like to know…
Is “out” some kind of reserved keyword, using the bus to “mute” the proxy node ?
I tried with other variable name and it doesn’t work in the same way