? for felix - mapping control buses into patches

View: New views
4 Messages — Rating Filter:   Alert me  

? for felix - mapping control buses into patches

by James Harkins-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Felix,

I have a quite useful feature that was working in 3.2, but now causes problems in the up-to-date library. For a number of control parameters, I use a GenericGlobalControl object in my library, which is basically a wrapper for a control bus with some other capabilities.

To integrate global controls into patches, I included these methods:

// patch support: use like KrNumberEditor
instrArgFromControl { |control|
^lag.notNil.if({ Lag.kr(In.kr(control, 1), lag) },
{ In.kr(control, 1) });
}
addToSynthDef { |synthDef, name|
synthDef.addIr(name, bus.index)
}
// protect against the bus number being changed (not sure if it really works)
rate { ^\scalar }

In 3.2, this is all fine.

For some reason, including a GenericGlobalControl object in a patch's argument list now causes the output to go haywire. An example:

s.boot;

(
Instr([\analysis, \ampEnv], { |bus, numChan = 1, env, topValue, lowRatio, thresh = 0.5,
attack = 2, decay = 3, sustain = 0.8, release = 4, ampRelease = 0.5, envCurve|
var gate;
gate = Amplitude.kr(In.ar(bus, 1), releaseTime:ampRelease) > thresh;
// you can have controls for some envelope parameters
// if you pass in an Env, value is ignored
env = env.value(lowRatio, attack, decay, sustain, release, envCurve);
EnvGen.kr(env, gate) * topValue
}, [\audiobus, \numChannels,
ObjectSpec({ |lowRatio, attack, decay, sustain, release, envCurve|
Env([lowRatio, 1, sustain, lowRatio], [attack, decay, release],
curve:envCurve, releaseNode:2)
}),
nil, nil, nil, nil, nil, nil, nil, #[0.001, 2, \lin, 0.01, 0.5], ObjectSpec(\linear)]
);

m = MixerChannel(\test, s, 1, 2);
g = GenericGlobalControl(\ffreq, nil, 440, \freq);
r = GenericGlobalControl(\ratio, nil, 1);
)

(
p = g.play(Instr([\analysis, \ampEnv]), [
m.inbus.index, 1, nil, 10500, r, 0.3, 2.4, 3.5, 0.65, 4.5,
1, \exponential
], m.effectgroup, \addToHead);
)

// this is the control bus where "p" ought to send its output
g.index
--> 2

// but it really outputs to kr bus 0
// that kr bus holds the mixer's level - so the mixer is now adding 80.4 dB to its signal
p.synth.trace;


So my main question is whether the approach in GenericGlobalControl is valid or not -- and if not, what is the correct way to make GenericGlobalControl work transparently with Patch?

Thanks --
hjh


: H. James Harkins

: jamshark70@...

: http://www.dewdrop-world.net

.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:


"Come said the Muse,

Sing me a song no poet has yet chanted,

Sing me the universal."  -- Whitman



_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: ? for felix - mapping control buses into patches

by felix-38 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


does it have or create a PatchOut object ?

actually I think you need to implement synthArg
which should return the argument for the synth, namely your output bus index

though I would expect if that wasn't implemented then it would get a nil or an error.  not return 0.



On Sun, May 4, 2008 at 10:47 PM, James Harkins <jamshark70@...> wrote:
Hi Felix,

I have a quite useful feature that was working in 3.2, but now causes problems in the up-to-date library. For a number of control parameters, I use a GenericGlobalControl object in my library, which is basically a wrapper for a control bus with some other capabilities.

To integrate global controls into patches, I included these methods:

// patch support: use like KrNumberEditor
instrArgFromControl { |control|
^lag.notNil.if({ Lag.kr(In.kr(control, 1), lag) },
{ In.kr(control, 1) });
}
addToSynthDef { |synthDef, name|
synthDef.addIr(name, bus.index)
}
// protect against the bus number being changed (not sure if it really works)
rate { ^\scalar }

In 3.2, this is all fine.

For some reason, including a GenericGlobalControl object in a patch's argument list now causes the output to go haywire. An example:

s.boot;

(
Instr([\analysis, \ampEnv], { |bus, numChan = 1, env, topValue, lowRatio, thresh = 0.5,
attack = 2, decay = 3, sustain = 0.8, release = 4, ampRelease = 0.5, envCurve|
var gate;
gate = Amplitude.kr(In.ar(bus, 1), releaseTime:ampRelease) > thresh;
// you can have controls for some envelope parameters
// if you pass in an Env, value is ignored
env = env.value(lowRatio, attack, decay, sustain, release, envCurve);
EnvGen.kr(env, gate) * topValue
}, [\audiobus, \numChannels,
ObjectSpec({ |lowRatio, attack, decay, sustain, release, envCurve|
Env([lowRatio, 1, sustain, lowRatio], [attack, decay, release],
curve:envCurve, releaseNode:2)
}),
nil, nil, nil, nil, nil, nil, nil, #[0.001, 2, \lin, 0.01, 0.5], ObjectSpec(\linear)]
);

m = MixerChannel(\test, s, 1, 2);
g = GenericGlobalControl(\ffreq, nil, 440, \freq);
r = GenericGlobalControl(\ratio, nil, 1);
)

(
p = g.play(Instr([\analysis, \ampEnv]), [
m.inbus.index, 1, nil, 10500, r, 0.3, 2.4, 3.5, 0.65, 4.5,
1, \exponential
], m.effectgroup, \addToHead);
)

// this is the control bus where "p" ought to send its output
g.index
--> 2

// but it really outputs to kr bus 0
// that kr bus holds the mixer's level - so the mixer is now adding 80.4 dB to its signal
p.synth.trace;


So my main question is whether the approach in GenericGlobalControl is valid or not -- and if not, what is the correct way to make GenericGlobalControl work transparently with Patch?

Thanks --
hjh


: H. James Harkins

: jamshark70@...

: http://www.dewdrop-world.net

.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:


"Come said the Muse,

Sing me a song no poet has yet chanted,

Sing me the universal."  -- Whitman



_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel




_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: ? for felix - mapping control buses into patches

by James Harkins-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Okay, thanks for the tip. I'll check it out when I can.

It has a ControlPatchOut -- its bus variable is Bus(control, 2, 1, localhost), as it should be. I also looked at the s_new message, and it does have 'out', 2 at the end. That tells me that the Control created for 'out' doesn't listen to initialization by OSC.

Not top priority for me at the moment -- it might take some debugging statements in the control building code, which I can do later on but not in the next couple of days.

hjh

Oh, PS... found this in ServerTools\synthDef.sc:

+ Object {
synthArg { ^this }
}

:)

On May 5, 2008, at 11:25 AM, felix wrote:


does it have or create a PatchOut object ?

actually I think you need to implement synthArg
which should return the argument for the synth, namely your output bus index

though I would expect if that wasn't implemented then it would get a nil or an error.  not return 0.


: H. James Harkins

: jamshark70@...

: http://www.dewdrop-world.net

.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:


"Come said the Muse,

Sing me a song no poet has yet chanted,

Sing me the universal."  -- Whitman



_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: ? for felix - mapping control buses into patches

by James Harkins-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On May 5, 2008, at 11:25 AM, felix wrote:

actually I think you need to implement synthArg
which should return the argument for the synth, namely your output bus index

Old post... I finally got around to this... thanks, adding synthArg { ^this.index } to GenericGlobalControl works beautifully.
hjh

: H. James Harkins

: jamshark70@...

: http://www.dewdrop-world.net

.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:


"Come said the Muse,

Sing me a song no poet has yet chanted,

Sing me the universal."  -- Whitman



_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel