Author |
Message |
Ataxian
Joined: Mar 03, 2009 Posts: 11 Location: UK
|
Posted: Sun Mar 08, 2009 12:03 pm Post subject:
Changing parameters of stored patterns. |
 |
|
Say I have the following PDef:
Code: |
(
Pdef
(
\Pattern1,
Pbind
(
\instrument, "bass",
\midinote, 40,
\dur, Pseq([0.75, 0.25, 0.25, 0.25, 0.5], inf), //Infinite Repeat
\legato, Pseq([0.9, 0.3, 0.3, 0.3, 0.3], 1),
\amp, 0.5,
\detune, 0.005
)
);
)
|
Why can't I change the \midinote using this command:
Code: |
Pdef(\Pattern1).set(\midinote, 15);
|
Is there a preferred method for storing a pattern, referring to it by a unique name and changing its parameters?
Thank you. |
|
Back to top
|
|
 |
dewdrop_world

Joined: Aug 28, 2006 Posts: 858 Location: Guangzhou, China
Audio files: 4
|
|
Back to top
|
|
 |
Ataxian
Joined: Mar 03, 2009 Posts: 11 Location: UK
|
Posted: Mon Mar 09, 2009 6:49 am Post subject:
|
 |
|
Thanks James, I have read the article and have the following code working perfectly but it only brings another question to mind that I haven't been able to solve.
Here is the working code:
Code: |
(
SynthDef("bass",
{
arg freq = 440, gate = 1, amp = 0.5, slideTime = 0.17, ffreq = 1100, width = 0.15,
detune = 1.005, preamp = 4;
var sig,
// --------------------------------------------------
env = Env.adsr(0.01, 0.3, 0.4, 0.1);
freq = Lag.kr(freq, slideTime);
sig = Mix(VarSaw.ar([freq, freq * detune], 0, width, preamp)).distort * amp
* EnvGen.kr(env, gate, doneAction: 2);
sig = LPF.ar(sig, ffreq);
// --------------------------------------------------
Out.ar(0, sig ! 2)
}).load(s);
)
(
//Pdefn(\Pattern1).set(\instrument, \midinote, \dur, \legato, \amp, \detune);
// Set Pattern1 environment first with initial values
Pdefn(\Pattern1).set(\midinote, 40);
// Need to refer to Pattern1 environment in some way so create a variable = envir
e = Pdefn(\Pattern1).envir;
// Define Pattern1
Pdefn //(key,Pattern)
(
\Pattern1,
{
arg e;
Pbind
(
\instrument, "bass",
\midinote, e.midinote,
\dur, Pseq([1.0,1.0,1.0,1.0], inf), //Infinite Repeat
\legato, Pseq([0.9, 0.3, 0.3, 0.3, 0.3], 1),
\amp, 0.5,
\detune, 0.005
)
}
).asStream;
p = Pseq([Pdefn(\Pattern1)], inf).play;
)
// Change the midinote via the control environment
Pdefn(\Pattern1).set(\midinote, 60);
|
The question is this:
How can I set the midinote via the environment so it affects the next note played (next note in the sequence) rather than having to wait for the sequence to finish before the midinote value is updated.
A more on the fly approach would be most welcome.
Thank you. |
|
Back to top
|
|
 |
dewdrop_world

Joined: Aug 28, 2006 Posts: 858 Location: Guangzhou, China
Audio files: 4
|
Posted: Mon Mar 09, 2009 7:28 pm Post subject:
|
 |
|
That's JITLib stuff, which I don't use extensively. Julian Rohrhuber is the main author of JITLib, but he doesn't hang around here, only on the mailing list.
My approach to this problem is outlined here. It's a heavier weight structure than pattern proxies, but it also takes on more responsibilities.
That document is a bit old... since then, I made another syntax possible to change the parameter:
Code: | BP(\cmaj).degree = Pbrown(0, 7, 2, inf); |
James _________________ ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net |
|
Back to top
|
|
 |
Ataxian
Joined: Mar 03, 2009 Posts: 11 Location: UK
|
Posted: Mon Mar 09, 2009 7:49 pm Post subject:
|
 |
|
Link doesn't work...
Using ~out and JITLib doesn't allow for .set commands only replacement of the entire Pattern.
I could do this by resending the entire Pdefn each time one arg in the Pdefn is changed, would this be recommended? |
|
Back to top
|
|
 |
dewdrop_world

Joined: Aug 28, 2006 Posts: 858 Location: Guangzhou, China
Audio files: 4
|
Posted: Tue Mar 10, 2009 7:40 am Post subject:
|
 |
|
Ataxian wrote: | Link doesn't work...
Using ~out and JITLib doesn't allow for .set commands only replacement of the entire Pattern.
I could do this by resending the entire Pdefn each time one arg in the Pdefn is changed, would this be recommended? |
The link is working for me...??
http://www.dewdrop-world.net/sc3/tutorials/forums.html?id=6
JITLib is more than NodeProxy (~out = ...). Pdef, Pdefn are all part of JITLib. I only rarely use them so I am not the best person to ask.
What I do know about Pdef etc. is... Pdefn is not meant for "event patterns" (Pbind and cousins). Pdefn should be only for "value patterns."
Code: | // these are value patterns - they generate values to use in Pbind
Pdefn(\degree, Pwhite(0, 7, inf));
Pdefn(\dur, Pwrand(#[0.25, 0.5, 0.75], #[3, 2, 1].normalizeSum, inf));
Pdef(\whitekeys, Pbind(
\degree, Pdefn(\degree),
\dur, Pdefn(\dur)
)).play; |
Then, to change the degrees:
Code: | Pdefn(\degree, Pseries(2, Prand(#[-1, 1], inf), inf).fold(-4, 11)); |
I don't know where this .set is coming from. Seems more complicated than necessary.
Anyway, if you have more questions about this, ask Julian on the mailing list. I don't know all the nuances.
James _________________ ddw online: http://www.dewdrop-world.net
sc3 online: http://supercollider.sourceforge.net |
|
Back to top
|
|
 |
Ataxian
Joined: Mar 03, 2009 Posts: 11 Location: UK
|
Posted: Tue Mar 10, 2009 6:25 pm Post subject:
|
 |
|
After posting to the mailing list Julian came up with the following (in case anyone reading this was interested):
for me it seems to change immediately.
I needed to use store rather than load.
if you write:
\midinote, Pfunc { e.midinote },
this should work out.
As for the website, I'm getting the following:
This is your custom 404 "Not found" Error page. This page is displayed whenever a file that a web browser requests is not found on your website.
If you would like to change this page, edit the file "404.html" in your "www" dir.
Important!!!!
If you use Microsoft Internet Explorer, please read this important article about "404" pages. It will save you a lot of frustration!
Force IE5 to display your 404 and not its own
You may also wish to read this article:
click here for Microsoft Knowledge Base article |
|
Back to top
|
|
 |
dewdrop_world

Joined: Aug 28, 2006 Posts: 858 Location: Guangzhou, China
Audio files: 4
|
|
Back to top
|
|
 |
|