Re: NamedControl and Ndefs, and NamedControl example issue
[email protected] Mon, 11 Jan 2021 15:00:35 +0000
| Newsgroups | gmane.comp.audio.supercollider.devel |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_52FDE58E-3FC4-47B6-9DD9-A0802497BA4D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 8 Jan 2021, at 14:00, adcxyz-A2/[email protected] wrote: >=20 >>=20 >>=20 >> I think it should follow normal scope rules, i.e. local first. So: >>=20 >> 1 NamedControl or addSpec (I think these should be treated as = equivalent in precedence, so if you supply a spec for a NamedControl = that replaces a previous spec added by either method ) >> 2 [Maybe intermediate levels?] >> 3 Global Specs Dict >> 4 Guess >>=20 >> This seems least surprising to me. (At 3 we might actually improve = the heuristics a bit, i.e. freq2 could reasonably be matched with \freq = assuming the val is within range, though of course that=E2=80=99s not a = JITLib issue!) 1 answers the question of what happens when source is = redefined. In keeping with existing practice though, I think it = shouldn=E2=80=99t change the value unless it=E2=80=99s now outside the = spec range? >>=20 >> What do you think? >>=20 >=20 > Makes sense - so for clarity,=20 > any spec given in an internal NamedControl always also gets put into = addSpec (Halo)? I think so. Will this be dependant on JITLibExtensions btw? Would be = nice to have it in core. >=20 >=20 > This only gets weird when people use both addSpec and \param.kr = <http://param.kr/>(spec: ) constructions;=20 > then the latest one decides, which is fine I guess.=20 >=20 > /// quick code sketch for trying out how this feels:=20 >=20 > // ---------- extFindSpec.sc :=20 >=20 > + AbstractPlayControl { > findSpec { ^nil } > } > + SynthDefControl { > findSpec { |paramKey| > var specs =3D synthDef.metadata[\specs]; > if (specs.isNil) { ^nil }; > ^specs[paramKey] > } > } >=20 > + NodeProxy { > findSpec { |paramKey| > var spec; > this.objects.do { |obj| > spec =3D obj.findSpec(paramKey); > if (spec.notNil) { ^spec } > }; > ^spec > } >=20 > // does not put this in addSpec yet,=20 > // does not work for gui yet! > getSpec { > ^this.getSpec ?? { this.findSpec } > } > } > // ----------=20 >=20 > Ndef('a', Pbind()).play; >=20 > Ndef('a', Pbind(\degree, Pbrown(0, 14, 3), \dur, 0.25)).play; >=20 > Ndef('a').put(5, \filter -> { |in| > var decay =3D \decay.kr <http://decay.kr/>(3, spec: [1, 100, = \exp]); > CombL.ar <http://combl.ar/>(in, 0.25, > [0.08333, 0.1667], > decay > ) > }); >=20 > Ndef('a').findSpec(\decay); // finds spec > Ndef('a').findSpec(\nope); // nil Nice. NdefGui doesn=E2=80=99t pick it up for me though? >=20 >=20 > ///// noticed a bug:=20 > ///// when jumping to spec arg, this works > Ndef(\x, { > x =3D \coef.kr <http://coef.kr/>(0, spec: [-0.99, 0.99]); > }); > // specs exist > Ndef('x').objects[0].synthDef.metadata >=20 > Ndef(\x, { > x =3D \coef.kr <http://coef.kr/>(0, lag: 1, spec: [-0.99, = 0.99]); > }); > // now they don't: why?=20 > Ndef('x').objects[0].synthDef.metadata Super odd! I=E2=80=99m guessing perhaps to do with the fact that the = latter produces a LagControl rather than a Control? S. --Apple-Mail=_52FDE58E-3FC4-47B6-9DD9-A0802497BA4D Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; = charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; = -webkit-nbsp-mode: space; line-break: after-white-space;" class=3D""><br = class=3D""><div><br class=3D""><blockquote type=3D"cite" class=3D""><div = class=3D"">On 8 Jan 2021, at 14:00, <a href=3D"mailto:adcxyz-A2/[email protected]" = class=3D"">adcxyz-A2/[email protected]</a> wrote:</div><br = class=3D"Apple-interchange-newline"><div class=3D""> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8" = class=3D""><div style=3D"word-wrap: break-word; -webkit-nbsp-mode: = space; line-break: after-white-space;" class=3D""><div = class=3D""><blockquote type=3D"cite" class=3D""><div class=3D""><div = style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: = 12px; font-style: normal; font-variant-caps: normal; font-weight: = normal; letter-spacing: normal; text-align: start; text-indent: 0px; = text-transform: none; white-space: normal; word-spacing: 0px; = -webkit-text-stroke-width: 0px; text-decoration: none;" class=3D""><br = class=3D""><div class=3D""><br class=3D""></div>I<span = class=3D"Apple-converted-space"> </span><i class=3D"">think</i><span = class=3D"" style=3D"font-style: normal;"> it should follow normal = scope rules, i.e. local first. So:</span></div><div style=3D"caret-color: = rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: = normal; font-variant-caps: normal; font-weight: normal; letter-spacing: = normal; text-align: start; text-indent: 0px; text-transform: none; = white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; = text-decoration: none;" class=3D""><span class=3D"" style=3D"font-style: = normal;"><br class=3D""></span></div><div style=3D"caret-color: rgb(0, = 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; = font-variant-caps: normal; font-weight: normal; letter-spacing: normal; = text-align: start; text-indent: 0px; text-transform: none; white-space: = normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; = text-decoration: none;" class=3D"">1 NamedControl or addSpec (I think = these should be treated as equivalent in precedence, so if you supply a = spec for a NamedControl that replaces a previous spec added by either = method )</div><div style=3D"caret-color: rgb(0, 0, 0); font-family: = Helvetica; font-size: 12px; font-style: normal; font-variant-caps: = normal; font-weight: normal; letter-spacing: normal; text-align: start; = text-indent: 0px; text-transform: none; white-space: normal; = word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: = none;" class=3D"">2 [Maybe intermediate levels?]</div><div = style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: = 12px; font-style: normal; font-variant-caps: normal; font-weight: = normal; letter-spacing: normal; text-align: start; text-indent: 0px; = text-transform: none; white-space: normal; word-spacing: 0px; = -webkit-text-stroke-width: 0px; text-decoration: none;" class=3D"">3 = Global Specs Dict</div><div style=3D"caret-color: rgb(0, 0, 0); = font-family: Helvetica; font-size: 12px; font-style: normal; = font-variant-caps: normal; font-weight: normal; letter-spacing: normal; = text-align: start; text-indent: 0px; text-transform: none; white-space: = normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; = text-decoration: none;" class=3D"">4 Guess</div><div style=3D"caret-color:= rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: = normal; font-variant-caps: normal; font-weight: normal; letter-spacing: = normal; text-align: start; text-indent: 0px; text-transform: none; = white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; = text-decoration: none;" class=3D""><br class=3D""></div><div = style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: = 12px; font-style: normal; font-variant-caps: normal; font-weight: = normal; letter-spacing: normal; text-align: start; text-indent: 0px; = text-transform: none; white-space: normal; word-spacing: 0px; = -webkit-text-stroke-width: 0px; text-decoration: none;" class=3D"">This = seems least surprising to me. (At 3 we might actually improve the = heuristics a bit, i.e. freq2 could reasonably be matched with \freq = assuming the val is within range, though of course that=E2=80=99s not a = JITLib issue!) 1 answers the question of what happens when source is = redefined. In keeping with existing practice though, I think it = shouldn=E2=80=99t change the value unless it=E2=80=99s now outside the = spec range?</div><div style=3D"caret-color: rgb(0, 0, 0); font-family: = Helvetica; font-size: 12px; font-style: normal; font-variant-caps: = normal; font-weight: normal; letter-spacing: normal; text-align: start; = text-indent: 0px; text-transform: none; white-space: normal; = word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: = none;" class=3D""><br class=3D""></div><div style=3D"caret-color: rgb(0, = 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; = font-variant-caps: normal; font-weight: normal; letter-spacing: normal; = text-align: start; text-indent: 0px; text-transform: none; white-space: = normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; = text-decoration: none;" class=3D"">What do you think?</div><div = style=3D"caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: = 12px; font-style: normal; font-variant-caps: normal; font-weight: = normal; letter-spacing: normal; text-align: start; text-indent: 0px; = text-transform: none; white-space: normal; word-spacing: 0px; = -webkit-text-stroke-width: 0px; text-decoration: none;" class=3D""><br = class=3D""></div></div></blockquote><div class=3D""><br = class=3D""></div><div class=3D"">Makes sense - so for = clarity, </div><div class=3D"">any spec given in an internal = NamedControl always also gets put into addSpec = (Halo)?</div></div></div></div></blockquote><div><br class=3D""></div>I = think so. Will this be dependant on <span style=3D"caret-color: = rgb(0, 0, 0);" class=3D"">JITLibExtensions btw? Would be nice to have it = in core.</span><blockquote type=3D"cite" class=3D""><div class=3D""><div = style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; line-break: = after-white-space;" class=3D""><div class=3D""><div class=3D""><br = class=3D""></div><div class=3D"">This only gets weird when people use = both addSpec and \<a href=3D"http://param.kr/" = class=3D"">param.kr</a>(spec: ) constructions; </div><div = class=3D"">then the latest one decides, which is fine I = guess. </div><div class=3D""><br class=3D""></div><div class=3D"">///= quick code sketch for trying out how this feels: </div><div = class=3D""><br class=3D""></div><div class=3D""><div class=3D"">// = ---------- extFindSpec.sc : </div><div class=3D""><br = class=3D""></div><div class=3D"">+ AbstractPlayControl {</div><div = class=3D""><span class=3D"Apple-tab-span" style=3D"white-space:pre"> = </span>findSpec { ^nil }</div><div class=3D"">}</div><div class=3D"">+ = SynthDefControl {</div><div class=3D""><span class=3D"Apple-tab-span" = style=3D"white-space:pre"> </span>findSpec { |paramKey|</div><div = class=3D""><span class=3D"Apple-tab-span" style=3D"white-space:pre"> = </span>var specs =3D synthDef.metadata[\specs];</div><div class=3D""><span= class=3D"Apple-tab-span" style=3D"white-space:pre"> = </span>if (specs.isNil) { ^nil };</div><div class=3D""><span = class=3D"Apple-tab-span" style=3D"white-space:pre"> = </span>^specs[paramKey]</div><div class=3D""><span = class=3D"Apple-tab-span" style=3D"white-space:pre"> = </span>}</div><div class=3D"">}</div><div class=3D""><br = class=3D""></div><div class=3D"">+ NodeProxy {</div><div class=3D""><span = class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>findSpec = { |paramKey|</div><div class=3D""><span class=3D"Apple-tab-span" = style=3D"white-space:pre"> </span>var spec;</div><div = class=3D""><span class=3D"Apple-tab-span" style=3D"white-space:pre"> = </span>this.objects.do { |obj|</div><div class=3D""><span = class=3D"Apple-tab-span" style=3D"white-space:pre"> = </span>spec =3D obj.findSpec(paramKey);</div><div class=3D""><span = class=3D"Apple-tab-span" style=3D"white-space:pre"> = </span>if (spec.notNil) { ^spec }</div><div class=3D""><span = class=3D"Apple-tab-span" style=3D"white-space:pre"> = </span>};</div><div class=3D""><span class=3D"Apple-tab-span" = style=3D"white-space:pre"> </span>^spec</div><div = class=3D""><span class=3D"Apple-tab-span" style=3D"white-space:pre"> = </span>}</div><div class=3D""><br class=3D""></div><div class=3D""><span = class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>// does = not put this in addSpec yet, </div><div class=3D""><span = class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>// does = not work for gui yet!</div><div class=3D""><span class=3D"Apple-tab-span" = style=3D"white-space:pre"> </span>getSpec {</div><div = class=3D""><span class=3D"Apple-tab-span" style=3D"white-space:pre"> = </span>^this.getSpec ?? { this.findSpec }</div><div class=3D""><span = class=3D"Apple-tab-span" style=3D"white-space:pre"> = </span>}</div><div class=3D"">}</div><div class=3D"">// = ---------- </div></div><div class=3D""><br = class=3D""></div></div><div class=3D""><div class=3D"">Ndef('a', = Pbind()).play;</div><div class=3D""><br class=3D""></div><div = class=3D"">Ndef('a', Pbind(\degree, Pbrown(0, 14, 3), \dur, = 0.25)).play;</div><div class=3D""><br class=3D""></div><div = class=3D"">Ndef('a').put(5, \filter -> { |in|</div><div = class=3D""><span class=3D"Apple-tab-span" style=3D"white-space: pre;"> = </span>var decay =3D \<a href=3D"http://decay.kr/" = class=3D"">decay.kr</a>(3, spec: [1, 100, \exp]);</div><div = class=3D""><span class=3D"Apple-tab-span" style=3D"white-space: pre;"> = </span><a href=3D"http://combl.ar/" class=3D"">CombL.ar</a>(in, = 0.25,</div><div class=3D""><span class=3D"Apple-tab-span" = style=3D"white-space: pre;"> </span>[0.08333, = 0.1667],</div><div class=3D""><span class=3D"Apple-tab-span" = style=3D"white-space: pre;"> </span>decay</div><div = class=3D""><span class=3D"Apple-tab-span" style=3D"white-space: pre;"> = </span>)</div><div class=3D"">});</div><div class=3D""><br = class=3D""></div><div class=3D"">Ndef('a').findSpec(\decay); // finds = spec</div><div class=3D"">Ndef('a').findSpec(\nope); // = nil</div></div></div></div></blockquote><div><br class=3D""></div>Nice. = NdefGui doesn=E2=80=99t pick it up for me though?<br = class=3D""><blockquote type=3D"cite" class=3D""><div class=3D""><div = style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; line-break: = after-white-space;" class=3D""><div class=3D""><div class=3D""><br = class=3D""></div><div class=3D""><br class=3D""></div><div = class=3D"">///// noticed a bug: </div><div class=3D"">///// when = jumping to spec arg, this works</div><div class=3D"">Ndef(\x, = {</div><div class=3D""><span class=3D"Apple-tab-span" = style=3D"white-space: pre;"> </span>x =3D \<a href=3D"http://coef.kr/" = class=3D"">coef.kr</a>(0, spec: [-0.99, 0.99]);</div><div = class=3D"">});</div><div class=3D"">// specs exist</div><div = class=3D"">Ndef('x').objects[0].synthDef.metadata</div><div class=3D""><br= class=3D""></div><div class=3D"">Ndef(\x, {</div><div class=3D""><span = class=3D"Apple-tab-span" style=3D"white-space: pre;"> </span>x =3D \<a = href=3D"http://coef.kr/" class=3D"">coef.kr</a>(0, lag: 1, spec: [-0.99, = 0.99]);</div><div class=3D"">});</div><div class=3D"">// now they don't: = why? </div><div = class=3D"">Ndef('x').objects[0].synthDef.metadata</div></div></div></div><= /blockquote><div><br class=3D""></div>Super odd! I=E2=80=99m guessing = perhaps to do with the fact that the latter produces a LagControl rather = than a Control?</div><div><br class=3D""></div><div>S.</div><div><br = class=3D""></div><div><br class=3D""></div></body></html>= --Apple-Mail=_52FDE58E-3FC4-47B6-9DD9-A0802497BA4D-- _______________________________________________ sc-dev mailing list info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx archive: http://www.listarc.bham.ac.uk/marchives/sc-dev/ search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/