<div dir="ltr">Hi Jean, nice to meet and thanks for your help. I&#39;m still having a hard time figuring this out. Let&#39;s try separate examples for both phase mod and sync, how about that?<div><br></div><div>What puzzles me is the sync argument of SinOsc, it&#39;s not clear how it works, and I haven&#39;t found a good description or examples of it in the documentation. Maybe there is some and I missed it.</div><div><br></div><div>So, I was trying to do either phase modulation or hard sync, and couldn&#39;t do it. Allow me to simplify your code and then I&#39;ll ask more questions.</div><div><br></div><div><br class="gmail-Apple-interchange-newline">// ==========================<br></div><div>







<p class="gmail-p1">// *mod* is the SinOsc which will modulate the phase of *carrier*</p>
<p class="gmail-p2"><span class="gmail-s1">SinOsc</span><span class="gmail-s2"> </span>mod<span class="gmail-s2"> </span>=&gt;<span class="gmail-s2"> </span><span class="gmail-s1">SinOsc</span><span class="gmail-s2"> </span>carrier<span class="gmail-s2"> </span>=&gt;<span class="gmail-s2"> </span><span class="gmail-s3">dac</span>;</p>
<p class="gmail-p3"><br></p>
<p class="gmail-p1"><span class="gmail-s4">440</span><span class="gmail-s2"> =&gt; carrier.freq; </span>// set carrier frequency</p>
<p class="gmail-p1"><span class="gmail-s4">1</span><span class="gmail-s2"> =&gt; mod.gain; </span>// set modulation index</p>
<p class="gmail-p3"><br></p>
<p class="gmail-p1">// set *carrier* oscillator to sync phase-wise with *mod*&#39;s input</p>
<p class="gmail-p1">// just in case: 0 = sync frequency to input; 1 = sync phase; 2 = FM!</p>
<p class="gmail-p2"><span class="gmail-s4">1</span><span class="gmail-s5"> </span>=&gt;<span class="gmail-s5"> </span>carrier.sync; </p>
<p class="gmail-p3"><br></p>
<p class="gmail-p1">// set modulation frequency</p>
<p class="gmail-p4">while<span class="gmail-s2">(</span>true<span class="gmail-s2">) {</span></p>
<p class="gmail-p2"><span class="gmail-s2">    </span><span class="gmail-s4">100</span><span class="gmail-s2"> </span>=&gt;<span class="gmail-s2"> </span>mod.freq;</p>
<p class="gmail-p4"><span class="gmail-s2">    </span><span class="gmail-s4">1</span><span class="gmail-s2">::</span>second<span class="gmail-s2"> =&gt; </span>now<span class="gmail-s2">;</span></p>
<p class="gmail-p2">}</p>
<p class="gmail-p5">// ==========================</p><p class="gmail-p5"><br></p><p class="gmail-p5">So, question 1) About &quot;<span class="gmail-s1">1</span> <span class="gmail-s2">=&gt;</span> <span class="gmail-s2">carrier.sync&quot;; </span>I don&#39;t get it. Why if I remove it I don&#39;t have phase modultion or any sound at all?</p><p class="gmail-p5">Question 2) Why changing the carrier frequency seems to have no effect?</p><p class="gmail-p5"></p></div><div><div class="gmail_extra"><br></div><div class="gmail_extra">So, let&#39;s compare to a simple phase modulation code in SuperCollider;</div><div class="gmail_extra"><br></div><div class="gmail_extra">{SinOsc.ar(201, SinOsc.ar(50), 2pi) ! 2}.play<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">In SuperCollider, the phase input is in radians, hence, I&#39;m setting the modulation index to 6.28 (2pi). Don&#39;t know how the phase is scaled in Chuck. But if it is linear, such as in Pd/Max, it should be &quot;1&quot; instead.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Anyway, how to achieve the same result as the SuperCollider code?</div><div class="gmail_extra"><br></div><div class="gmail_extra">thanks</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">2017-06-03 12:43 GMT-03:00 Jean Menezes da Rocha <span dir="ltr">&lt;<a href="mailto:jean@menezesdarocha.info" target="_blank">jean@menezesdarocha.info</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello, Alexandre, good to see you here (you don&#39;t know me but I know your work)!<br><br>SinOsc has .phase and .sync attributes, which are pretty useful in this case. I made a very<div>dirty and arbitrary example to show this working (using .sync, in this case):</div><div><br></div><div><div><font face="monospace">// *pmod* is the SinOsc which will modulate the phase of *main*</font></div><div><font face="monospace">SinOsc pmod =&gt; SinOsc main =&gt; dac;</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">440 =&gt; main.freq;</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">// define index of modulation; it&#39;s fun to fiddle with this value!</font></div><div><font face="monospace">50 =&gt; pmod.gain;</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">// set *main* to sync phase-wise with *pmod*&#39;s input</font></div><div><font face="monospace">// just in case: 0 = sync frequency to input; 1 = sync phase; 2 = FM!</font></div><div><font face="monospace">1 =&gt; main.sync;</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">// loop to show phase modulation in action with random arbitrary values</font></div><div><font face="monospace">while(true) {</font></div><div><font face="monospace">    Math.random2f(63, 880) =&gt; pmod.freq;</font></div><div><font face="monospace">    1::second =&gt; now;</font></div><div><font face="monospace">}</font></div></div><div><font face="monospace"><br></font></div><div><font size="2">You can also do everything &quot;by hand&quot;, mapping arbitrary values directly into SinOsc&#39;s .phase attribute.</font></div><div><font size="2"><br></font></div><div><font size="2">Hope it helps!</font></div><div><font size="2"><br></font></div><div><font size="2">Cheers!</font></div><div><br></div></div><br><div class="gmail_quote"><div><div class="gmail-h5"><div dir="ltr">Em sex, 2 de jun de 2017 às 19:21, Alexandre Torres Porres &lt;<a href="mailto:porres@gmail.com" target="_blank">porres@gmail.com</a>&gt; escreveu:<br></div></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail-h5"><div dir="ltr">Hi, new to chuck here.<div><br></div><div>Can SinOsc be hard synced by an impulse or something?</div><div><br></div><div>And how would you do phase modulation with SinOsc?</div><div><br></div><div>If you cannot do one or both with SinOsc, how would you do it?</div><div><br></div><div>thanks</div></div></div></div>
______________________________<wbr>_________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu" target="_blank">chuck-users@lists.cs.<wbr>princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" rel="noreferrer" target="_blank">https://lists.cs.princeton.<wbr>edu/mailman/listinfo/chuck-<wbr>users</a><span class="gmail-HOEnZb"><font color="#888888"><br>
</font></span></blockquote></div><span class="gmail-HOEnZb"><font color="#888888"><div dir="ltr">-- <br></div><div><div dir="ltr">Jean Menezes da Rocha<div>Compositor</div><div>Professor</div><div>Doutorando em Música pela Universidade Federal da Bahia</div></div></div>
</font></span><br>______________________________<wbr>_________________<br>
chuck-users mailing list<br>
<a href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.<wbr>princeton.edu</a><br>
<a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" rel="noreferrer" target="_blank">https://lists.cs.princeton.<wbr>edu/mailman/listinfo/chuck-<wbr>users</a><br>
<br></blockquote></div><br></div></div></div>