Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how do I "add (something from dirt-hacks) to supercollider startup file"? #259

Closed
jwaldmann opened this issue Jan 20, 2022 · 11 comments · Fixed by #260
Closed

how do I "add (something from dirt-hacks) to supercollider startup file"? #259

jwaldmann opened this issue Jan 20, 2022 · 11 comments · Fixed by #260

Comments

@jwaldmann
Copy link

It's recommended at https://github.com/musikinformatik/SuperDirt/blob/develop/hacks/README.scd but I don't see what to write where.

I am using this startup file https://github.com/musikinformatik/SuperDirt/blob/develop/superdirt_startup.scd

Do I put some "include" directive there? Or do I literally copy the code? In both cases- where? (before, inside, or after other declarations/statements?)

@jwaldmann
Copy link
Author

jwaldmann commented Jan 20, 2022

ah, is this #231 (comment) ?

I still don't get it. I put this extra line (loadRelative ...)) in startup.scd:

(
s.reboot {
  ...
	s.waitForBoot {
		~dirt = SuperDirt(2, s); // two output channels, increase if you want to pan across more channels
		loadRelative("../../software/music/SuperDirt/hacks/adding-a-compressor.scd");
...

then when starting sclang, I get

...
loading synthdefs in /home/waldmann/.local/share/SuperCollider/downloaded-quarks/SuperDirt/classes/../synths/zzzzz-core-modules-that-come-last.scd
ERROR: syntax error, unexpected '(', expecting $end
  in interpreted text
  line 19 char 1:

  (
  ^
  SynthDef("dirt_compressor" ++ ~dirt.numChannels, { |dryBus, effectBus, gate = 1|
-----------------------------------
ERROR: Command line parse failed

loading 217 sample banks:
...

@telephon
Copy link
Contributor

Hi @jwaldmann, it is confusing, yes.
I've added a bit of documentation (#260), please let me know if it is clearer and works for you …

@jwaldmann
Copy link
Author

jwaldmann commented Jan 26, 2022

Thanks! I was still getting the above syntax error. The file I wanted to include https://github.com/musikinformatik/SuperDirt/blob/develop/hacks/adding-a-compressor.scd has this structure

( ~dirt.orbits.do { ... };  )
( SynthDef ... )
( SynthDef ... )
( SynthDef ... )

The error message refers to the beginning of the second block. Are we just missing separators here?
Adding semi-colons makes it work:

( ~dirt.orbits.do { ... };  ) ;
( SynthDef ... )              ;
( SynthDef ... )              ;
( SynthDef ... )

Well, "work" - at least it gives no syntax errors, so we can start thinking about semantics ...

@telephon
Copy link
Contributor

The main thing is that the file (like all other files in the folder) are not meant to be used that way. It is not like a module system. I decided to use this "extension by example" style to encourage a more active involvement with the code. It is also a common way supercollider is organised: files which have many snippets of code that you can use, but not intended to be used all at once. This allows you to vary it in place, by writing series of minor modifications. It is more tedious out of the box, but more flexible to experiment with.

@telephon
Copy link
Contributor

telephon commented Jan 26, 2022

If you wanted to have a file you can load, you'd copy the variant you prefer in a file like this:

(
// add a compressor module
(
~dirt.orbits.do { |x|
	x.globalEffects = [
		GlobalDirtEffect(\dirt_delay, [\delaytime, \delayfeedback, \delaySend, \delayAmp, \lock, \cps]),
		GlobalDirtEffect(\dirt_reverb, [\size, \room, \dry]),
		GlobalDirtEffect(\dirt_leslie, [\leslie, \lrate, \lsize]),
		GlobalDirtEffect(\dirt_rms, [\rmsReplyRate, \rmsPeakLag]).alwaysRun_(true),
		GlobalDirtEffect(\dirt_monitor, [\limitertype]).alwaysRun_(true),
	]
};
);


// now play with different variants while you listen to tidal:


// a dirty hyperbolic tangens
(
SynthDef("dirt_compressor" ++ ~dirt.numChannels, { |dryBus, effectBus, gate = 1|
	var signal = In.ar(dryBus, ~dirt.numChannels);

	signal = (signal * 5).tanh;
	signal = signal * EnvGen.kr(Env.asr, gate, doneAction:2);
	Out.ar(effectBus, signal);
}, [\ir, \ir]).add;

s.freeAll; // restart all synths
)
)

@telephon
Copy link
Contributor

( ~dirt.orbits.do { ... };  ) ;
( SynthDef ... )              ;
( SynthDef ... )              ;
( SynthDef ... )

the syntax correction is correct, but the SynthDefs override each other (they all have the same name).

@jwaldmann
Copy link
Author

The main thing is that the file (like all other files in the folder) are not meant to be used that way. It is not like a module system. I decided to use this "extension by example" style ...

Yes, I see now. Perhaps make this intended usage more explicit in the README of that directory? Something like:

  • you can use synthdefs from these files for SC live coding [this is addressing people who know SC, and probably don't need help]
  • or [addressing people who only know Tidal, like me] you can make them available for Tidal live coding by writing a collection of synthdefs to a file, and loading this file from your SC startup file (or from your sclang session?)
  • in such a collection of synthdefs (and other declarations? statements?) , each is terminated a by semi-colon, (and the collection is enclosed in a parentheses?).
  • see https://github.com/musikinformatik/SuperDirt/blob/develop/hacks/adding-global-effects.scd for accessing parameters of synthdefs.
  • In the startup file, write ... [the include command, you already have this text]

@telephon
Copy link
Contributor

@jwaldmann
Copy link
Author

Yes, fine! - This issue was actually brought up by students (they wanted side chain compression for Tidal). I will point them to these improved instructions, and I'll forward any remaining complaints :-)

@telephon
Copy link
Contributor

Yes, thanks, that would be good :) It is hard for me to un-understand these things.

@telephon
Copy link
Contributor

please feel free to reopen this issue with suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants