|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
EnvGen gotcha - fix or document?I found a rather annoying gotcha today with timed envelope releases.
Is this something that should be fixed, or just documented? It's fairly easy to work around -- but it was **not easy** to track down. When releasing an envelope by setting the gate argument to a value < -1.0, the envelope always terminates at 0, even if the final node value in the envelope definition is nonzero, and even if EnvGen's levelBias parameter is nonzero. Example below. I tend to think this is worthy of a code fix. If I write an Env whose minimum level is 1 and maximum is 2, it's reasonable to expect the EnvGen output to remain within that range throughout (provided that the default level scale and level bias values are used). The fix would be to terminate the envelope with the final level value * levelScale + levelBias. I could post a patch later -- didn't have time to look at the EnvGen source code this morning. Objections or other comments? hjh s.boot; ~sensitivity = { |value, sensitivity| (value-1) * sensitivity + 1 }; SynthDef(\eek, { |freq = 440, gate = 1, ffreq = 1000, fsens = 0, out = 0| var sig = Saw.ar(freq), ampenv = EnvGen.kr(Env.adsr, gate, doneAction: 2), fcurve = EnvGen.kr(Env(#[2, 1], #[0.5], curve: -3), gate); ffreq = ffreq * ~sensitivity.value(fcurve, fsens); Out.ar(out, RLPF.ar(sig, ffreq, 0.1, ampenv) ! 2); }).send(s); a = Synth(\eek, [fsens: 5]); a.release; // this is OK // this release will cause the RLPF to blow up -- TURN THE VOLUME DOWN FIRST // (that's the volume on your sound system -- output values may be as high as 1e+15 // so the server's volume control will probably not help you much) a = Synth(\eek, [fsens: 5]); a.release(0.1); // setting levelBias to 1 exhibits the same ugly behavior // proving that EnvGen ignores levelBias for a timed release (!) SynthDef(\eek, { |freq = 440, gate = 1, ffreq = 1000, fsens = 0, out = 0| var sig = Saw.ar(freq), ampenv = EnvGen.kr(Env.adsr, gate, doneAction: 2), fcurve = EnvGen.kr(Env(#[1, 0], #[0.5], curve: -3), gate, levelBias: 1); ffreq = ffreq * ~sensitivity.value(fcurve, fsens); Out.ar(out, RLPF.ar(sig, ffreq, 0.1, ampenv) ! 2); }).send(s); // workaround - this works but why do I have to waste a UGen by adding 1 explicitly? SynthDef(\eek, { |freq = 440, gate = 1, ffreq = 1000, fsens = 0, out = 0| var sig = Saw.ar(freq), ampenv = EnvGen.kr(Env.adsr, gate, doneAction: 2), fcurve = EnvGen.kr(Env(#[1, 0], #[0.5], curve: -3), gate) + 1; ffreq = ffreq * ~sensitivity.value(fcurve, fsens); Out.ar(out, RLPF.ar(sig, ffreq, 0.1, ampenv) ! 2); }).send(s); -- James Harkins /// dewdrop world 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-dev mailing list info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880 archive: http://www.listarc.bham.ac.uk/marchives/sc-dev/ search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ |
|
|
Re: EnvGen gotcha - fix or document?Sounds right to me, behavior should be predictable.
RJK On Jun 24, 2008, at 11:41 AM, James Harkins wrote: > I found a rather annoying gotcha today with timed envelope releases. > Is this something that should be fixed, or just documented? > > It's fairly easy to work around -- but it was **not easy** to track > down. > > When releasing an envelope by setting the gate argument to a value < > -1.0, the envelope always terminates at 0, even if the final node > value in the envelope definition is nonzero, and even if EnvGen's > levelBias parameter is nonzero. Example below. > > I tend to think this is worthy of a code fix. If I write an Env whose > minimum level is 1 and maximum is 2, it's reasonable to expect the > EnvGen output to remain within that range throughout (provided that > the default level scale and level bias values are used). The fix would > be to terminate the envelope with the final level value * levelScale + > levelBias. > > I could post a patch later -- didn't have time to look at the EnvGen > source code this morning. > > Objections or other comments? > hjh > > s.boot; > > ~sensitivity = { |value, sensitivity| > (value-1) * sensitivity + 1 > }; > > SynthDef(\eek, { |freq = 440, gate = 1, ffreq = 1000, fsens = 0, > out = 0| > var sig = Saw.ar(freq), > ampenv = EnvGen.kr(Env.adsr, gate, doneAction: 2), > fcurve = EnvGen.kr(Env(#[2, 1], #[0.5], curve: -3), gate); > ffreq = ffreq * ~sensitivity.value(fcurve, fsens); > Out.ar(out, RLPF.ar(sig, ffreq, 0.1, ampenv) ! 2); > }).send(s); > > a = Synth(\eek, [fsens: 5]); > a.release; // this is OK > > // this release will cause the RLPF to blow up -- TURN THE VOLUME > DOWN FIRST > // (that's the volume on your sound system -- output values may be as > high as 1e+15 > // so the server's volume control will probably not help you much) > a = Synth(\eek, [fsens: 5]); > a.release(0.1); > > > // setting levelBias to 1 exhibits the same ugly behavior > // proving that EnvGen ignores levelBias for a timed release (!) > SynthDef(\eek, { |freq = 440, gate = 1, ffreq = 1000, fsens = 0, > out = 0| > var sig = Saw.ar(freq), > ampenv = EnvGen.kr(Env.adsr, gate, doneAction: 2), > fcurve = EnvGen.kr(Env(#[1, 0], #[0.5], curve: -3), gate, > levelBias: 1); > ffreq = ffreq * ~sensitivity.value(fcurve, fsens); > Out.ar(out, RLPF.ar(sig, ffreq, 0.1, ampenv) ! 2); > }).send(s); > > > // workaround - this works but why do I have to waste a UGen by adding > 1 explicitly? > SynthDef(\eek, { |freq = 440, gate = 1, ffreq = 1000, fsens = 0, > out = 0| > var sig = Saw.ar(freq), > ampenv = EnvGen.kr(Env.adsr, gate, doneAction: 2), > fcurve = EnvGen.kr(Env(#[1, 0], #[0.5], curve: -3), gate) + 1; > ffreq = ffreq * ~sensitivity.value(fcurve, fsens); > Out.ar(out, RLPF.ar(sig, ffreq, 0.1, ampenv) ! 2); > }).send(s); > > -- > James Harkins /// dewdrop world > 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-dev mailing list > > > info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/ > MusicTechnology/880 > archive: http://www.listarc.bham.ac.uk/marchives/sc-dev/ > search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ > _______________________________________________ sc-dev mailing list info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880 archive: http://www.listarc.bham.ac.uk/marchives/sc-dev/ search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ |
|
|
Re: EnvGen gotcha - fix or document?I think this is the fix - it needs to be introduced into
EnvGen_next_k, EnvGen_next_ak and the CHECK_GATE macro for next_aa. Haven't tested, but in theory this is the right thing. hjh if (unit->m_prevGate <= 0. && gate > 0.) { unit->m_stage = -1; unit->mDone = false; unit->m_released = false; counter = 0; } else if (gate <= -1.f && unit->m_prevGate > -1.f) { // cutoff int numstages = (int)ZIN0(kEnvGen_numStages); float dur = -gate - 1.f; counter = (int32)(dur * SAMPLERATE); counter = sc_max(1, counter); unit->m_stage = numstages; unit->m_shape = shape_Linear; // old // unit->m_grow = -level / counter; // unit->m_endLevel = 0.; // hjh unit->m_endLevel = ZIN0(unit->mNumInputs - 4) * ZIN0(kEnvGen_levelScale) + ZIN0(kEnvGen_levelBias); unit->m_grow = (unit->m_endLevel - level) / counter; } else if (unit->m_prevGate > 0.f && gate <= 0.f On Tue, Jun 24, 2008 at 12:18 PM, ronald kuivila <rkuivila@...> wrote: > Sounds right to me, behavior should be predictable. > > RJK > > On Jun 24, 2008, at 11:41 AM, James Harkins wrote: > >> I found a rather annoying gotcha today with timed envelope releases. >> Is this something that should be fixed, or just documented? >> >> It's fairly easy to work around -- but it was **not easy** to track down. >> >> When releasing an envelope by setting the gate argument to a value < >> -1.0, the envelope always terminates at 0, even if the final node >> value in the envelope definition is nonzero, and even if EnvGen's >> levelBias parameter is nonzero. Example below. -- James Harkins /// dewdrop world 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-dev mailing list info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880 archive: http://www.listarc.bham.ac.uk/marchives/sc-dev/ search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ |
|
|
Re: EnvGen gotcha - fix or document?This patch passes my test case from before, and others to make sure levelScale and levelBias are properly applied. Last chance to object... I'll commit tomorrow AM. hjh Index: LFUGens.cpp =================================================================== --- LFUGens.cpp (revision 7637) +++ LFUGens.cpp (working copy) @@ -1988,8 +1988,13 @@ counter = sc_max(1, counter); unit->m_stage = numstages; unit->m_shape = shape_Linear; - unit->m_grow = -level / counter; - unit->m_endLevel = 0.; + unit->m_endLevel = ZIN0(unit->mNumInputs - 4) * ZIN0(kEnvGen_levelScale) + ZIN0(kEnvGen_levelBias); + unit->m_grow = (unit->m_endLevel - level) / counter; } else if (unit->m_prevGate > 0.f && gate <= 0.f && unit->m_releaseNode >= 0 && !unit->m_released) { counter = 0; @@ -2205,8 +2210,13 @@ counter = sc_max(1, counter); unit->m_stage = numstages; unit->m_shape = shape_Linear; - unit->m_grow = -level / counter; - unit->m_endLevel = 0.; + unit->m_endLevel = ZIN0(unit->mNumInputs - 4) * ZIN0(kEnvGen_levelScale) + ZIN0(kEnvGen_levelBias); + unit->m_grow = (unit->m_endLevel - level) / counter; } else if (unit->m_prevGate > 0.f && gate <= 0.f && unit->m_releaseNode >= 0 && !unit->m_released) { counter = 0; @@ -2439,8 +2449,8 @@ counter = sc_max(1, counter) + i; \ unit->m_stage = numstages; \ unit->m_shape = shape_Linear; \ - unit->m_grow = -level / counter; \ - unit->m_endLevel = 0.; \ + unit->m_endLevel = ZIN0(unit->mNumInputs - 4) * ZIN0(kEnvGen_levelScale) + ZIN0(kEnvGen_levelBias); \ + unit->m_grow = (unit->m_endLevel - level) / counter; \ nsmps = i; \ break; \ } else if (prevGate > 0.f && gate <= 0.f \ : H. James Harkins : http://www.dewdrop-world.net .::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..: "Come said the Muse, Sing me a song no poet has yet chanted, Sing me the universal." -- Whitman |
|
|
Re: EnvGen gotcha - fix or document?I think you shouldn't write
ZIN0(unit->mNumInputs - 4) this would break if someone was to add an argument. Better use the index defined in: enum { kEnvGen_gate, kEnvGen_levelScale, kEnvGen_levelBias, kEnvGen_timeScale, kEnvGen_doneAction, kEnvGen_initLevel, kEnvGen_numStages, kEnvGen_releaseNode, kEnvGen_loopNode }; >This patch passes my test case from before, and others to make sure >levelScale and levelBias are properly applied. > >Last chance to object... I'll commit tomorrow AM. >hjh > >Index: LFUGens.cpp >=================================================================== >--- LFUGens.cpp (revision 7637) >+++ LFUGens.cpp (working copy) >@@ -1988,8 +1988,13 @@ > counter = sc_max(1, counter); > unit->m_stage = numstages; > unit->m_shape = shape_Linear; >- unit->m_grow = -level / counter; >- unit->m_endLevel = 0.; >+ unit->m_endLevel = ZIN0(unit->mNumInputs - 4) * >ZIN0(kEnvGen_levelScale) + ZIN0(kEnvGen_levelBias); >+ unit->m_grow = (unit->m_endLevel - level) / counter; > } else if (unit->m_prevGate > 0.f && gate <= 0.f > && unit->m_releaseNode >= 0 && !unit->m_released) { > counter = 0; >@@ -2205,8 +2210,13 @@ > counter = sc_max(1, counter); > unit->m_stage = numstages; > unit->m_shape = shape_Linear; >- unit->m_grow = -level / counter; >- unit->m_endLevel = 0.; >+ unit->m_endLevel = ZIN0(unit->mNumInputs - 4) * >ZIN0(kEnvGen_levelScale) + ZIN0(kEnvGen_levelBias); >+ unit->m_grow = (unit->m_endLevel - level) / counter; > } else if (unit->m_prevGate > 0.f && gate <= 0.f > && unit->m_releaseNode >= 0 && !unit->m_released) { > counter = 0; >@@ -2439,8 +2449,8 @@ > counter = sc_max(1, counter) + i; \ > unit->m_stage = numstages; \ > unit->m_shape = shape_Linear; \ >- unit->m_grow = -level / counter; \ >- unit->m_endLevel = 0.; \ >+ unit->m_endLevel = >ZIN0(unit->mNumInputs - 4) * ZIN0(kEnvGen_levelScale) + >ZIN0(kEnvGen_levelBias); \ >+ unit->m_grow = (unit->m_endLevel - >level) / counter; \ > nsmps = i; \ > break; \ > } else if (prevGate > 0.f && gate <= 0.f \ > > >: H. James Harkins > >: <mailto:jamshark70@...>jamshark70@... > >: <http://www.dewdrop-world.net>http://www.dewdrop-world.net > >.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..: > > >"Come said the Muse, > >Sing me a song no poet has yet chanted, > >Sing me the universal." -- Whitman -- . _______________________________________________ sc-dev mailing list info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880 archive: http://www.listarc.bham.ac.uk/marchives/sc-dev/ search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ |
|
|
?spam? Re: EnvGen gotcha - fix or document?The value that I'm after is the level of the last envelope node, whose index is not part of the enumeration. The index depends on how many nodes are in the envelope. Would new arguments be added before the envelope nodes, or after? If it's after, then ZIN0(unit->mNumInputs - 4) would break, but that would introduce other complexities in locating the new argument, because its index would be variable. If we need the index to be consistent, then a new arg would have to go before the envelope nodes. In that case, ZIN0(unit->mNumInputs - 4) would still be correct -- but, there are other hardcoded values that would break, namely int stageOffset = (unit->m_stage << 2) + 9 So in the interest of supporting future arguments, should we have enum { kEnvGen_gate, kEnvGen_levelScale, kEnvGen_levelBias, kEnvGen_timeScale, kEnvGen_doneAction, kEnvGen_initLevel, kEnvGen_numStages, kEnvGen_releaseNode, kEnvGen_loopNode, kEnvGen_nodeOffset }; And then... int stageOffset = (unit->m_stage << 2) + kEnvGen_nodeOffset ? hjh On Jun 26, 2008, at 1:28 AM, Julian Rohrhuber wrote:
: H. James Harkins : http://www.dewdrop-world.net .::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..: "Come said the Muse, Sing me a song no poet has yet chanted, Sing me the universal." -- Whitman |
|
|
Re: EnvGen gotcha - fix or document?On Jun 26, 2008, at 8:33 AM, James Harkins wrote:
Forgot this... then I could get the last level using ((ZIN0(kEnvGen_numStages) - 1) << 2) + kEnvGen_nodeOffset But I think a better policy would be to disallow arguments after the envelope nodes. hjh : H. James Harkins : http://www.dewdrop-world.net .::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..: "Come said the Muse, Sing me a song no poet has yet chanted, Sing me the universal." -- Whitman |
|
|
Re: ?spam? Re: EnvGen gotcha - fix or document?>
>So in the interest of supporting future arguments, should we have > >enum { > kEnvGen_gate, > kEnvGen_levelScale, > kEnvGen_levelBias, > kEnvGen_timeScale, > kEnvGen_doneAction, > kEnvGen_initLevel, > kEnvGen_numStages, > kEnvGen_releaseNode, > kEnvGen_loopNode, > kEnvGen_nodeOffset > >}; > >And then... > > int stageOffset = (unit->m_stage << 2) + kEnvGen_nodeOffset it would read much better like this. >? > >hjh > > >On Jun 26, 2008, at 1:28 AM, Julian Rohrhuber wrote: > >>I think you shouldn't write >>ZIN0(unit->mNumInputs - 4) >>this would break if someone was to add an argument. Better use the >>index defined in: >> >>enum { >> kEnvGen_gate, >> kEnvGen_levelScale, >> kEnvGen_levelBias, >> kEnvGen_timeScale, >> kEnvGen_doneAction, >> kEnvGen_initLevel, >> kEnvGen_numStages, >> kEnvGen_releaseNode, >> kEnvGen_loopNode >>}; >> >> >> >> >>>This patch passes my test case from before, and others to make >>>sure levelScale and levelBias are properly applied. >>> >>>Last chance to object... I'll commit tomorrow AM. >>>hjh >>> >>>Index: LFUGens.cpp >>>=================================================================== >>>--- LFUGens.cpp (revision 7637) >>>+++ LFUGens.cpp (working copy) >>>@@ -1988,8 +1988,13 @@ >>> counter = sc_max(1, counter); >>> unit->m_stage = numstages; >>> unit->m_shape = shape_Linear; >>>- unit->m_grow = -level / counter; >>>- unit->m_endLevel = 0.; >>>+ unit->m_endLevel = ZIN0(unit->mNumInputs - 4) * >>>ZIN0(kEnvGen_levelScale) + ZIN0(kEnvGen_levelBias); >>>+ unit->m_grow = (unit->m_endLevel - level) / counter; >>> } else if (unit->m_prevGate > 0.f && gate <= 0.f >>> && unit->m_releaseNode >= 0 && !unit->m_released) { >>> counter = 0; >>>@@ -2205,8 +2210,13 @@ >>> counter = sc_max(1, counter); >>> unit->m_stage = numstages; >>> unit->m_shape = shape_Linear; >>>- unit->m_grow = -level / counter; >>>- unit->m_endLevel = 0.; >>>+ unit->m_endLevel = ZIN0(unit->mNumInputs - 4) * >>>ZIN0(kEnvGen_levelScale) + ZIN0(kEnvGen_levelBias); >>>+ unit->m_grow = (unit->m_endLevel - level) / counter; >>> } else if (unit->m_prevGate > 0.f && gate <= 0.f >>> && unit->m_releaseNode >= 0 && !unit->m_released) { >>> counter = 0; >>>@@ -2439,8 +2449,8 @@ >>> counter = sc_max(1, counter) + i; \ >>> unit->m_stage = numstages; \ >>> unit->m_shape = shape_Linear; \ >>>- unit->m_grow = -level / counter; \ >>>- unit->m_endLevel = 0.; \ >>>+ unit->m_endLevel = >>>ZIN0(unit->mNumInputs - 4) * ZIN0(kEnvGen_levelScale) + >>>ZIN0(kEnvGen_levelBias); \ >>>+ unit->m_grow = (unit->m_endLevel - >>>level) / counter; \ >>> nsmps = i; \ >>> break; \ >>> } else if (prevGate > 0.f && gate <= 0.f \ >>> >>> >>>: H. James Harkins >>> >>>: >>><<mailto:jamshark70@...>mailto:jamshark70@...><mailto:jamshark70@...>jamshark70@... >>> >>>: >>><<http://www.dewdrop-world.net>http://www.dewdrop-world.net><http://www.dewdrop-world.net>http://www.dewdrop-world.net >>> >>>.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..: >>> >>> >>>"Come said the Muse, >>> >>>Sing me a song no poet has yet chanted, >>> >>>Sing me the universal." -- Whitman >>> >> >> >>-- >> >> >> >> >> >>. >> >>_______________________________________________ >>sc-dev mailing list >> >> >>info (subscribe and unsubscribe): >><http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880>http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880 >>archive: >><http://www.listarc.bham.ac.uk/marchives/sc-dev/>http://www.listarc.bham.ac.uk/marchives/sc-dev/ >>search: >><http://www.listarc.bham.ac.uk/lists/sc-dev/search/>http://www.listarc.bham.ac.uk/lists/sc-dev/search/ >> > > >: H. James Harkins > >: <mailto:jamshark70@...>jamshark70@... > >: <http://www.dewdrop-world.net>http://www.dewdrop-world.net > >.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..: > > >"Come said the Muse, > >Sing me a song no poet has yet chanted, > >Sing me the universal." -- Whitman -- . _______________________________________________ sc-dev mailing list info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880 archive: http://www.listarc.bham.ac.uk/marchives/sc-dev/ search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/ |
|
|
Re: EnvGen gotcha - fix or document?On Jun 26, 2008, at 7:03 PM, Julian Rohrhuber wrote:
Okay, another try -- I have to admit, though, that I'm not at all crazy about this: unit->m_endLevel = ZIN0((int (ZIN0(kEnvGen_numStages)-1) << 2) + kEnvGen_nodeOffset) * ZIN0(kEnvGen_levelScale) + ZIN0(kEnvGen_levelBias); ... which looks hopelessly clunky next to jmc's pristine style, and I don't see that there is any real benefit to it. It doesn't make sense to add any EnvGen arguments at the end, since the input list is supposed to end with the Env definition, but that's the only reason for the added complication. Just asking again because Julian objected to my original change, but I really think this is cleaner and easier to understand: unit->m_endLevel = ZIN0(unit->mNumInputs - 4) * ZIN0(kEnvGen_levelScale) + ZIN0(kEnvGen_levelBias); hjh Index: LFUGens.cpp =================================================================== --- LFUGens.cpp (revision 7637) +++ LFUGens.cpp (working copy) @@ -1926,7 +1926,10 @@ kEnvGen_initLevel, kEnvGen_numStages, kEnvGen_releaseNode, - kEnvGen_loopNode + kEnvGen_loopNode, + // 'kEnvGen_nodeOffset' must always be last + // if you need to add an arg, put it before this one + kEnvGen_nodeOffset }; void EnvGen_Ctor(EnvGen *unit) @@ -1988,8 +1991,10 @@ counter = sc_max(1, counter); unit->m_stage = numstages; unit->m_shape = shape_Linear; - unit->m_grow = -level / counter; - unit->m_endLevel = 0.; + // first ZIN0 gets the last envelope node's level, then apply levelScale and levelBias + unit->m_endLevel = ZIN0((int (ZIN0(kEnvGen_numStages)-1) << 2) + kEnvGen_nodeOffset) + * ZIN0(kEnvGen_levelScale) + ZIN0(kEnvGen_levelBias); + unit->m_grow = (unit->m_endLevel - level) / counter; } else if (unit->m_prevGate > 0.f && gate <= 0.f && unit->m_releaseNode >= 0 && !unit->m_released) { counter = 0; @@ -2033,7 +2038,7 @@ //Print("stage %d\n", unit->m_stage); //Print("initSegment\n"); //out = unit->m_level; - int stageOffset = (unit->m_stage << 2) + 9; + int stageOffset = (unit->m_stage << 2) + kEnvGen_nodeOffset; if (stageOffset + 4 > unit->mNumInputs) { // oops. @@ -2205,8 +2210,14 @@ counter = sc_max(1, counter); unit->m_stage = numstages; unit->m_shape = shape_Linear; - unit->m_grow = -level / counter; - unit->m_endLevel = 0.; + unit->m_endLevel = ZIN0((int (ZIN0(kEnvGen_numStages)-1) << 2) + kEnvGen_nodeOffset) + * ZIN0(kEnvGen_levelScale) + ZIN0(kEnvGen_levelBias); + unit->m_grow = (unit->m_endLevel - level) / counter; } else if (unit->m_prevGate > 0.f && gate <= 0.f && unit->m_releaseNode >= 0 && !unit->m_released) { counter = 0; @@ -2241,7 +2252,7 @@ } else { unit->m_stage++; initSegment: - int stageOffset = (unit->m_stage << 2) + 9; + int stageOffset = (unit->m_stage << 2) + kEnvGen_nodeOffset; if (stageOffset + 4 > unit->mNumInputs) { // oops. @@ -2439,8 +2450,9 @@ counter = sc_max(1, counter) + i; \ unit->m_stage = numstages; \ unit->m_shape = shape_Linear; \ - unit->m_grow = -level / counter; \ - unit->m_endLevel = 0.; \ + unit->m_endLevel = ZIN0((int (ZIN0(kEnvGen_numStages)-1) << 2) + kEnvGen_nodeOffset) \ + * ZIN0(kEnvGen_levelScale) + ZIN0(kEnvGen_levelBias); \ + unit->m_grow = (unit->m_endLevel - level) / counter; \ nsmps = i; \ break; \ } else if (prevGate > 0.f && gate <= 0.f \ @@ -2489,7 +2501,7 @@ } else { unit->m_stage++; initSegment: - int stageOffset = (unit->m_stage << 2) + 9; + int stageOffset = (unit->m_stage << 2) + kEnvGen_nodeOffset; if (stageOffset + 4 > unit->mNumInputs) { // oops. : H. James Harkins : http://www.dewdrop-world.net .::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..: "Come said the Muse, Sing me a song no poet has yet chanted, Sing me the universal." -- Whitman |
| Free Forum Powered by Nabble | Forum Help |