Joined: Nov 29, 2006 Posts: 25 Location: Lyndonville VT USA
Audio files: 2
G2 patch files: 6
Posted: Fri Dec 08, 2006 3:00 pm Post subject:
using a .WAV file as an envelope. Subject description: my first useful chuck program.
this is one of my first chuck programs above and beyond the examples.
it requires that env.wav be in the same directory as the source.
env.wav is simply a short envelope i recorded with my nord g2 and trimmed in audacity. comments and critique welcome.
Joined: Aug 16, 2006 Posts: 53 Location: northern california
Posted: Mon Dec 11, 2006 8:15 pm Post subject:
Hi electroboz,
this looks really useful. Though looking through your code, you might find the following aspect of ugens useful for improving the performance of your patch.
All ugens have a .op parameter, which specifies how they deal with multiple inputs. the default is for the ugen to just add multiple inputs, but specifying 3 for .op will cause the ugen to multiply its inputs together. Since this happens "below the hood" so to speak its a lot better CPU-wise than multiplying in ChucK, with the added benefit of being updated every sample.
oh.. i've just checked out your patch..
yes.. i also recommend using .op .. (you can read it in Gain section)
i usually use a Gain to apply this type of envelope.
more convenient and less codes.
All ugens have a .op parameter, which specifies how they deal with multiple inputs. the default is for the ugen to just add multiple inputs, but specifying 3 for .op will cause the ugen to multiply its inputs together. Since this happens "below the hood" so to speak its a lot better CPU-wise than multiplying in ChucK, with the added benefit of being updated every sample.
Hmmmm, the manual only mentions -1, 0 and 1 as .op functions that all ugens have. Sounds like a issue for the manual-erata on the Wiki? _________________ Kassen
Also, two pages later in the ChucK manual, the manual contradicts itself by describing all 6 valid values of .op (in the Gain reference), when just before it had listed only 3...
I didn't see the manual as contradicting itself myself; I figured that Gain had some features not found in other Ugens which seemed natural since most Ugens have features not found elsewhere. that might've been naive _________________ Kassen
Joined: Nov 29, 2006 Posts: 25 Location: Lyndonville VT USA
Audio files: 2
G2 patch files: 6
Posted: Tue Dec 12, 2006 3:52 pm Post subject:
thanks for the feedback. i'm just getting back into programming (thanks in no small part to chuck).
I didn't know about the .op functionality, but i do now, thank you =).
The reason I didn't apply the envelope to the gain ugen (but did to the oscillator's.gain) was so I could add more oscillators to the gain object and not have them all follow just one envelope, and still retain 1 easy volume control.
That was by no means a finished "product". I intend to write a class for this type of thing. It was really just a demo to see if i could do it.
i usually use a Gain ugen to apply envelope
because when i'm working with an oscillator as the source
(before applying amplitude envelope)
i might have to chuck the oscillator with some other signal
(for frequency set / phasemod / fm as in syncing)
for example, here.. i wanna have 1 sine osc FMing another sine osc
and i wanna apply envelopes to both oscs' amplitude.
i've gotto do this.
Code:
// SinOsc (with gain envelope) FMing SinOsc (with gain envelope) to dac
SinOsc s1 => Gain g1 => SinOsc s2 => Gain g2 => dac;
// a phasor sets gain of the modulating oscillator
Phasor LFO1 => g1;
// Gain method = multiply (for use as an envelope)
// modulating oscillator frequency = 1100hz
// modulation index = 500
// LFO rate = 2hz
3 => g1.op;
1100 => s1.freq;
500 => s1.gain;
2 => LFO1.freq;
// envelope 1 (for setting volumn) to low-pass filter (to smooth the volumn change
// .. this will be the amplitude envelope of the carrier oscillator
Step env1 => LPF f1 => g2;
// s2 will be FMed by amplitude-enveloped s1's signal
// Gain method = multiply (for use as an envelope)
// low-pass center frequency for the amplitude control value = 5hz
2 => s2.sync;
3 => g2.op;
5 => f1.freq;
// try changing the main env value over time..
// the main LFO, FM mechanism works automatically.
while(true) {
0.7 => env1.next;
3::second => now;
0.0 => env1.next;
0.5::second => now;
}
anyway, actually this patch can be adjusted to the way electroboz apply to an osc..
Code:
// the difference is here:
// we chuck both s1 and LFO1 directly into s2
// and set s2's gain option to 3 (multiply)
// so we don't have to use gain number 1 anymore.
// it works well, and it looks clean..
// but this way is still not flexible for future changes in code.
SinOsc s1 => SinOsc s2 => Gain g2 => dac;
Phasor LFO1 => s2;
but i still stick with using Gain
coz i think it's more flexible..
for example, we can chuck some more signals into an oscillator
so that it can use another gain option that's set in that oscillator.
Another advantage of Gain is that it can help a lot with readability. I like calling Gain's stuff like "mixer" or "muter" and for me that helps in keeping it all managable, I also find it helps when later replacing parts of the strucutre.
It's still good that we discovered another bit of missing documention. _________________ Kassen
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum