[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-users] Editing SynthDef's in a pop-up window (or other modes of reducing clutter)
I have been working on a tool for live performance which generates synths and patterns on the fly from pre-made templates. The templates are written as functions which return Strings; these strings can be inserted into a Document and then interpreted with the following function:
(
~i = { |insertion|
var doc = Document.current;
doc.insertText(insertion, doc.selectionStart);
insertion.interpret;
};
);
An example SynthDef template is as follows:
(
~peas = { |pulseid|
var pulsefilts, pulsehipasses, pulsemods, pulsenoises, pulseoscs;
pulsefilts = [
"BMoog.ar(mix, ffreq.clip(50, SampleRate.ir / 2.5), q, mode)",
"Resonz.ar(mix, ffreq.clip(50, SampleRate.ir / 2.5), 1 - q)",
"RHPF.ar(mix, (freq * " ++ rrand(2.0, 16.0).round(0.1) ++ ").clip(50, SampleRate.ir / 2.5), 1 - q)",
"RLPF.ar(mix, (freq * " ++ rrand(2.0, 16.0).round(0.1) ++ ").clip(50, SampleRate.ir / 2.5), 1 - q)"
];
pulsehipasses = [
"BHiPass" ++ [ "", "4" ].choose ++ "",
"RHPF"
];
pulsemods = [
"",
".atan",
".distort",
".softclip",
".tanh"
];
pulsenoises = [
"LF" ++ [ "", "Brown" ].choose ++ "Noise" ++ [ 1, 2 ].choose ++ ""
];
pulseoscs = [
"LFCub",
"LFPar",
"SinOsc",
"SinOscFB"
];
"(
SynthDef(\\pe" ++ pulseid ++ ", { |amp = 0.2, balance = 0, curve = -4, detune = 0, dur = 1, freq = 440, outbus, rmfreq = 8000|
var env = Env.perc(0.001, dur, amp, curve);
var envgen = EnvGen.kr(env, doneAction: 2);
var osc = " ++ pulseoscs.choose ++ ".ar((freq + [ detune, detune.neg ]) * SinOsc.ar(" ++ rrand(400, 4000) ++ " + [ detune.squared.neg, detune.squared ], mul: 2, add: 1)) * " ++ [ "LFCub", "LFPar", "LFTri", "Pulse", "Saw", "SinOsc" ].choose ++ ".ar(rmfreq).range(0.0, 1.0);
var noise = " ++ pulsenoises.choose ++ ".ar(" ++ rrand(4000, 12000) ++ ") * " ++ rrand(0.1, 0.25).round(0.001) ++ ";
var hipass = " ++ pulsehipasses.choose ++ ".ar(noise, " ++ rrand(4000, 8000) ++ ", " ++ rrand(0.5, 1).round(0.01) ++ ");
var mix = osc + hipass;
var bal = Balance2.ar(mix[0], mix[1], balance) * envgen;
Out.ar(outbus, bal);
}).add;
);
"
};
);
This can be inserted into a Document with ~i.(~peas.(0)), which creates a synth with a random oscillator, filter, noise source, and so on.
Lately, I have been thinking that I would prefer to avoid clutter. I would rather not have to insert all code into the Document to evaluate it. What I'd like is to be able to somehow evaluate certain code (like SynthDef's) without inserting it into a Document, and then be able to edit it in a pop-up window or similar when I want.
I have no idea how to do this. Is there a way to edit a SynthDef in a pop-up window so it doesn't have be edited directly in the Document? Or are there other ways to avoid clutter so only the code I need to edit in performance is present in the Document, and other code can be edited elsewhere when needed?
Phil
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/