Do you mean something like this? https://www.youtube.com/watch?v=UiS6EpzXXEk
There is no straightforward answer. It's possible but requires lots of expressions.
Selecting a frequency range instead of just one band. The first problem is that you need to know which frequency corresponds to the numerical input in the Spec2 expression. I have never tested this out. Here is a little SFX loop that can help you: https://drive.google.com/file/d/0B9p...it?usp=sharing
It visualises the value of var(18). So, place a SetVar event, set it to variable 18, and set it to mousex * 1000 (because the sfx loop visualises a value between 0 and 999 so a value of 745 corresponds to an x position of 0.745). Then place a horizontal line with enough points (see first tutorial) and use a PreMoveY with the spec2 expression: Spec2(0.5, idx)*10. Place a centered vertical line under it and use a ShiftX event set to the expression mousex. Now you should see which frequency corresponds to the input in Spec2. So play a sine wave at 50 Hz, move the mouse around so the vertical line is over the peak and note down the displayed number. Do the same for the other frequencies.
The next problem is that you don't want a single frequency, you want a range. I think the only way is to average over the spec2 values. Do this by a repeat expression in the SizeY event of your effect (or a SetVar):
Code:
minFreq = 0; //These are the values you found previously.
maxFreq = 1;
a = 0;
i = 0;
repeat(50, //Increase '50' for accuracy, decrease for performance
assign(a, a+Spec2(0.5, (i*0.02)*(maxFreq - minFreq)+minFreq)) //If you changed the '50' in the previous line, change the '0.02' to 1/(thatvalue)
& assign(i, i+1)
);
result = a/50; //Scale as you like
I haven't tested this but I think it's correct. So now you have the raw input.
Attack and decay time. Unless you want to go really complicated, there is a simple solution with a minor drawback: damping. The drawback is that you can't control attack and decay time independently. But it will smooth out the movement. This is how you damp:
Code:
setdamp(factor, frequency, name);
result = damp(input, name);
The factor controls the behaviour of the damping. Set it to 1 so it doesn't oscillate. The frequency is the speed. Don't put it too low or the effect will lag, but don't put it too high either. About 2-5 (to your taste) should do it. Name is some name you can give it. Important: this can also be an integer (it will work erratically if it isn't an integer). So if you are in a loop, you can give it a name like "loop*totalLoops+1" and it will damp each loop independently. See the living manual for more information about damping.
The second part needs the actual thing you are going to damp, in this case a. It's important to note down that damping only works with an argument between 0 and 1! Which is convenient because now I don't have to say anything about restricting the output.
So up to now we have:
Code:
minFreq = 0; //These are the values you found previously.
maxFreq = 1;
setdamp(1, 3, somename);
a = 0;
i = 0;
repeat(50, //Increase '50' for accuracy, decrease for performance
assign(a, a+Spec2(0.5, (i*0.02)*(maxFreq - minFreq)+minFreq)) //If you changed the '50' in the previous line, change the '0.02' here to 1/(thatvalue)
& assign(i, i+1)
);
result = damp(a, somename);
If you are continuously hitting the maximum limit, divide a in the final line by some number until you get a value you like.
Threshold. If you only want the event to trigger when a goes over a certain value, you can do something like this:
(place before the final line).
This picks the largest value between a or 0.1 so if a is smaller, it will override a with 0.1.