# [chuck-users] how to write to buffer

eduard eduard.aylon at gmail.com
Sat Nov 26 07:15:41 EST 2005

```Thanks Adam,

What I wanted to do is to apply some distortion function to an
audiofile. The step object you mentioned, gave me the idea to use
impulse object. Would you also use this approach?

WaveLoop audiofile => blackhole;
"foo.wav" => audiofile.path;
impulse i => dac;

while(true)
{
math.tanh( audiofile.last() ) => i.next; // i.value seems to
have disappeared???
1::samp => now
}

Thanks again for your tip.

Eduard

On 26 Nov 2005, at 04:54, Adam Tindale wrote:

> Hi,
>
> Great question. There are a few things that you have to understand
> in order to do this. When you connect multiple ugens to the input
> of another ugen the get summed. So, if connect three sinoscs to the
> dac they will get summed. If they all have an amplitude of one and
> the same frequency and phase then they will oscillate between -3
> and 3. Makes sense.
>
> Alright, you probably want to scale these things you put them into
> a gain and then into the dac. Then you set the .gain parameter to .
> 333333 and you will get -1 to 1. Fantastic. You probably already
> know this. But if you want to do ring modulation you can change
> the .op parameter of gain to 3, which is multiply, and the inputs
> will be multiplied against each other.
>
> You can check the manual for the .op parameters of gain. They are:
> – -1 passthrough
> – 0 no processing
> – 1 adds inputs (default)
> – 2 subtracts inputs
> – 3 multiplies inputs
> – 4 divides inputs
>
> For the example you gave, the solution is to connect two ugens to a
> gain that has the .op set to 1 (default). You add the DC bias by
> using the step object and setting it to k.
>
> ChucK has all sorts of effects you can use to put between your
> oscillator and the dac. You can also start doing different
> modulation techniques by exploiting the .op feature of gain.
>
> I hope this helps.
>
> --art
>
> On 25-Nov-05, at 6:30 PM, eduard wrote:
>
>> Hello all,
>>
>> How  can one apply some transformation to the output of an UGen an
>> connect it to dac?
>> For instance, if I want to add a constant k to the output of a
>> sine oscillator and then send this to dac, how should I do it?
>>
>> thanks,
>>
>> Eduard
>> _______________________________________________
>> chuck-users mailing list
>> chuck-users at lists.cs.princeton.edu
>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20051126/da6390f3/attachment.htm
```