






Moderators: electrogear, exonerate
streamin GreenBool;
streamboolout Out;
Out = (GreenBool != 0); //Non-zero to true bitmask.streamin Trigger; //Green bool will work here
streamin Factor; //Decay control (0 ... 1) = (short ... long)
streamout Envelope;
float OldTrigger=0; float Small=1e-020;
// Iterate
Envelope = Envelope * Factor; //Decay
Envelope = Envelope & (Envelope>Small); //Kill de-normals
// Set to one on leading edge of trigger pulse
Envelope = Envelope + (1-Envelope) & (Trigger>OldTrigger);
OldTrigger = Trigger;1) The envelope will need the "Trigger" property ticking to work with mono/mono4 signals - by default it is only in "automatic mode" for triggering only by messages from the poly voice manager.

tester wrote:'m still lost? "Trigger property ticking" ? Where and what to change?
tester wrote:I tried second example, but I'm afraid that I don't follow it yet. "Factor" values below 1 are soundless, and =1 just produce continuous (or just verly slow fading) sound.
p.s.: Generally I would need something, that allows to retrig the fade from 1 down - during ongoing fading too

tester wrote:Ah - my english failed.
cyto wrote:(endValue/beginValue)^(1/samples)
trogluddite wrote:Thankyou Martin, I had a feeling it wasn't anything too complicated.
I also found the scaler from the old schematic that I used - very similar power function, but I think this one was scaled for a different end value. My end value of 1e-20 in the code is just an arbitrary very small number to eliminate de-normals - it is way below the threshold of hearing, so the "audible" part of the envelope may seem a bit short when calculating to that end point. The equation used in my schematic is...
e ^ ( (-1000 / SampleRate ) / MilliSeconds)
...where e is Euler's number (about 2.71828).
Though, I understand the confusion, because I (umm) borrow a lot of martinvicanek's work. Regarding the Euler approach: I have used this myself in the past for certain exponential envelopes but I believe that to be fully workable, you need to incorporate a "feedback arm" into the mix. Generally, I have used the coefficient 2PI*normFrequency (which involves a intermediate calculation to put the time period into terms of Hertz) and then have used the transfer function out=in(1-coeff)+out(coeff) where in is the starting value (one in this case). (This is from memory, BTW, have not tested - i may have gotten the mults mixed up). In that case, you're essentially using a simple LPF to achieve the envelope. I think in tester's case, where you just need a simple exponential decay, this may be overkill, but there are certainly cases where you are moving between different values where this may be more appropriate. I guess it all depends on the situation.
. Not too cheap business anyway. Such instrument is "made" of several frequency bands, which fade differently however. What I need - is a manual control of that fading times. Fading type is between linear to a little bit indented (exp), so it would be good to have some control over that too (I guess - simple input with range "from/to" would be enough).cyto wrote:He he. I know there are a lot of "Martins" on this board, but I am not one of them
tester wrote:unusual instrument
Too much SM thinking.tester wrote:Okay, just tested, and this is it. But now things get a little bit more complicated. Cyto - could you add something to the code that would allow to set very short and smooth transition on retrig? Sizes in miliseconds (<5 ms I guess). The thing is - when envelope is retriggered, then transition tends to produce noticable "digital click". I'd like to make it more like analog soft hit, and I guess this is the direction (correct me if I'm wrong).
tester wrote:p.s.: when duplicated many times in the schematic (like 4x12) - SM becomes unstable and crashes often (I'm thinking to reach a target with c.a. 10x30 different envelopes) - to which part of the code could it be related? Is it possible to make some performance improvement by producing envelopes based on one main theme? (i.e. ratio based time lenght, so results of main code would be just scaled somehow?)
Users browsing this forum: No registered users and 1 guest