[chuck-users] phase modulation and hard sync?

Jean Menezes da Rocha jean at menezesdarocha.info
Sat Jun 3 14:01:27 EDT 2017


Alexandre,

As far as I understand it, the .sync attribute is more like an identifier,
rather than a true numeric value (that is, 0 says you are syncing frequency
with frequency; 1 says that you are syncing phase with frequency; 2 says
you are doing true Frequency Modulation). As you are telling that no value
means no sound, one can infer that there is no default value for that, and
if you are feeding UGen => UGen, telling which is your sync method is
mandatory (but I can be mistaken, as usual).

As for your second question, my understanding of Phase Modulation (as
explained here <https://en.wikipedia.org/wiki/Phase_modulation>) is that
the carrier wave is supposed to be stationary frequency-wise, so this is
the expected behavior. What creates the effect of modulation is the
modulator's *amplitude* over the carrier's *phase*. There is a nice graphic
illustrating this here
<https://commons.wikimedia.org/wiki/File:Phase-modulation.gif#/media/File:Phase-modulation.gif>
.

ChucK's UGen documentation tells that the .phase value is a floating-point
number, which seems to be linear. As for the SinOsc object, it should be
cycled through a sine function (thus always keeping values between -1.0 and
1.0). In such case, very roughly put, the original phase is always 0, and
you can shift from a full cycle to the left (-1) through to a full cycle to
the right (+1).

I am probably missing some fine detail here, and hopefully someone with
more solid knowledge of ChucK's internals will provide you with a more
technical explanation. Unfortunately, my knowledge of SuperCollider is very
limited and I don't feel like I'm able to translate your code.

I will try and prepare some better example later when I have my computer
around.

Best regards!

Em sáb, 3 de jun de 2017 às 14:07, Alexandre Torres Porres <porres at gmail.com>
escreveu:

> Hi Jean, nice to meet and thanks for your help. I'm still having a hard
> time figuring this out. Let's try separate examples for both phase mod and
> sync, how about that?
>
> What puzzles me is the sync argument of SinOsc, it's not clear how it
> works, and I haven't found a good description or examples of it in the
> documentation. Maybe there is some and I missed it.
>
> So, I was trying to do either phase modulation or hard sync, and couldn't
> do it. Allow me to simplify your code and then I'll ask more questions.
>
>
> // ==========================
>
> // *mod* is the SinOsc which will modulate the phase of *carrier*
>
> SinOsc mod => SinOsc carrier => dac;
>
>
> 440 => carrier.freq; // set carrier frequency
>
> 1 => mod.gain; // set modulation index
>
>
> // set *carrier* oscillator to sync phase-wise with *mod*'s input
>
> // just in case: 0 = sync frequency to input; 1 = sync phase; 2 = FM!
>
> 1 => carrier.sync;
>
>
> // set modulation frequency
>
> while(true) {
>
>     100 => mod.freq;
>
>     1::second => now;
>
> }
>
> // ==========================
>
>
> So, question 1) About "1 => carrier.sync"; I don't get it. Why if I
> remove it I don't have phase modultion or any sound at all?
>
> Question 2) Why changing the carrier frequency seems to have no effect?
>
>
> So, let's compare to a simple phase modulation code in SuperCollider;
>
> {SinOsc.ar(201, SinOsc.ar(50), 2pi) ! 2}.play
>
> In SuperCollider, the phase input is in radians, hence, I'm setting the
> modulation index to 6.28 (2pi). Don't know how the phase is scaled in
> Chuck. But if it is linear, such as in Pd/Max, it should be "1" instead.
>
> Anyway, how to achieve the same result as the SuperCollider code?
>
> thanks
>
>
> 2017-06-03 12:43 GMT-03:00 Jean Menezes da Rocha <jean at menezesdarocha.info
> >:
>
>> Hello, Alexandre, good to see you here (you don't know me but I know your
>> work)!
>>
>> SinOsc has .phase and .sync attributes, which are pretty useful in this
>> case. I made a very
>> dirty and arbitrary example to show this working (using .sync, in this
>> case):
>>
>> // *pmod* is the SinOsc which will modulate the phase of *main*
>> SinOsc pmod => SinOsc main => dac;
>>
>> 440 => main.freq;
>>
>> // define index of modulation; it's fun to fiddle with this value!
>> 50 => pmod.gain;
>>
>> // set *main* to sync phase-wise with *pmod*'s input
>> // just in case: 0 = sync frequency to input; 1 = sync phase; 2 = FM!
>> 1 => main.sync;
>>
>> // loop to show phase modulation in action with random arbitrary values
>> while(true) {
>>     Math.random2f(63, 880) => pmod.freq;
>>     1::second => now;
>> }
>>
>> You can also do everything "by hand", mapping arbitrary values directly
>> into SinOsc's .phase attribute.
>>
>> Hope it helps!
>>
>> Cheers!
>>
>>
>> Em sex, 2 de jun de 2017 às 19:21, Alexandre Torres Porres <
>> porres at gmail.com> escreveu:
>>
>>> Hi, new to chuck here.
>>>
>>> Can SinOsc be hard synced by an impulse or something?
>>>
>>> And how would you do phase modulation with SinOsc?
>>>
>>> If you cannot do one or both with SinOsc, how would you do it?
>>>
>>> thanks
>>> _______________________________________________
>>> chuck-users mailing list
>>> chuck-users at lists.cs.princeton.edu
>>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>>>
>> --
>> Jean Menezes da Rocha
>> Compositor
>> Professor
>> Doutorando em Música pela Universidade Federal da Bahia
>>
>> _______________________________________________
>> chuck-users mailing list
>> chuck-users at lists.cs.princeton.edu
>> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>>
>>
> --
Jean Menezes da Rocha
Compositor
Professor
Doutorando em Música pela Universidade Federal da Bahia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20170603/c224262c/attachment-0001.html>


More information about the chuck-users mailing list