# [chuck-users] phase modulation and hard sync?

Alexandre Torres Porres porres at gmail.com
Sat Jun 3 13:07:01 EDT 2017

```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

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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20170603/c2d8723c/attachment.html>
```