Hi everyone,
Sorry if the question is too simple but I can’t find any information about it.
I would like to be able to interpolate values between different presets, in different ways, linearly, exponentially and logarithmically, giving an interpolation time.
How can I morph from one element of the preset list to another?
(
Ndef(\sine,{ |freq = 440, amp = 0.1|
var out = SinOsc.ar(freq,mul: amp);
out;
}
)
)
(
Ndef(\sine).addSpec(\freq, ControlSpec( 20.0, 14000.0, \exp, 0, 70, "Hz") );
Ndef(\sine).addSpec(\amp, ControlSpec( 0.0, 1.0, \lin, 0, 1) );
)
Ndef(\sine).gui;
Ndef(\sine).play;
// Quarks.install("JITLibExtensions"); // required Quark for preset
NdefPreset(\sine); // make a preset instance
ProxyPresetGui(NdefPreset(\sine)); // and it's GUI. stores preset as text file
// this is the text of the presets
///// NdefPreset('sine') settings:
List[
('0' -> [ [ 'amp', 0.3 ], [ 'freq', 1922 ] ]),
('1' -> [ [ 'amp', 0.5 ], [ 'freq', 440 ] ])
]
Thank you in advance
I hope this helps you.
You can also check out the docs ProxyPreset | SuperCollider 3.13.0 Help
Ndef.clear;
(
// define control spces to be used -
Ndef(\foo).addSpec(\carFreq, Spec.specs[\freq]);
Ndef(\foo).addSpec(\modFreq, Spec.specs[\freq]);
Ndef(\foo).addSpec(\pmindex, ControlSpec(-4.0, 4.0));
Ndef(\foo).addSpec(\modphase, ControlSpec(-4.0, 4.0));
Ndef(\foo, {
var sig = PMOsc.ar(
carfreq: \carFreq.kr(200.0),
modfreq: \modFreq.kr(200.0),
pmindex: \pmindex.kr(0.0) * [1.0, 1.01],
modphase: \modphase.kr(0.0),
) * SinOscFB.ar(0.7, feedback: 1.8);
sig;
}).play(vol: 0.2).gui;
)
// setup preset morpher
p = NdefPreset(Ndef(\foo))
// tweak params in gui
// and store it as a preset yes
p.addSet(\yes);
// tweak params in gui and store another preset
p.addSet(\no);
// check if preset got picked up
p.settings;
// randomly jump between the the two presets
p.morph(1.0.rand.postln, \yes, \no);
// fade to preset yes
p.xfadeTo(target: \yes, dur: 3);
// fade from preset \yes to preset \no in an exponential manner
({
var steps = 1000;
var time = 10;
steps.do({|i|
p.morph(i.linexp(0, steps, 0.0001, 1), \yes, \no);
(time/steps).wait;
});
"Finished".postln;
}.fork;
)
// or use gui
NdefPresetGui(p, numItems: 6);
1 Like