Re: [chuck-users] phase modulation and hard sync?
Hi Alexandre,
If you look at the complete formula here (under "spectral analysis" - for sure it is better then my explanation):
https://en.wikipedia.org/wiki/Frequency_modulation_synthesis?wprov=sfla1
You can see that alongside the Carrier Frequency there's the phase. This one is a sine wave (that goes from -1 to 1). Now we can consider SinOsc on ChucK, the same that the first sin in the formula above. Everything is feeding SinOsc in ChucK can be considered the same that all the stuff into parenthesis. Thus the argument you pass to SinOsc ( oscil.freq(certainFreq) ) is the Carrier Frequency (a fixed argument) and the the signal coming out from the Fm oscillator (scaled with a given value Am/Fm or ModInd, it is the same) is modulation factor that makes the Carrier Freq oscillate.
Now 2pi is needed only if you deal with a ramp, with a phasor. Cause Phasor*2pi gives you a sine. If you already have a sine there is no need to use 2pi.
Cheers,
Mario
Sent from my Wiko ROBBYOn Jun 4, 2017 17:20, Alexandre Torres Porres
2pi is already there if you are using a phase input, cause it seems the phase is normalized (0 to 1 instead of 0 - 2pi) in Chuck.
What I mean is how to implement the same result with both frequency and phase modulation in a Chuck code, using SinOsc.
All these things have to be adjusted
But if the phase input wasn't normalized to 0-1, like is the case with SuperCollider, you don't need it.
cheers
2017-06-04 13:09 GMT-03:00 mario.buoninfante
: Hi Alexandre,
In my implementation there's no need to use 2pi. That is required if you're using a phasor (in math terms). In that case you need 2pi to have the angular frequency. But if you're using instead a Sine wave there's no need, cause 2pi is already there. Looking at the formula I posted before, the Fm oscillator is the phase parameter, while the Cm is the frequency. You can consider them as an offset (Cm) and an deviation from it (Fm). The index mod is equal to Am/Fm, but of course the parameter that you can use with an oscillator is the amplitude (Am), thus from the previous one you have Am = Fm*modInd
Cheers, Mario
Sent from my Wiko ROBBY
On Jun 4, 2017 16:39, Alexandre Torres Porres
wrote: btw, for adjusting the index, you're just multiplying the frequency to the index, you should also multiply it by 2pi (like Jean found out by accident).
2017-06-04 12:29 GMT-03:00 Alexandre Torres Porres
: 2017-06-04 4:24 GMT-03:00 mario buoninfante
: this is the simplest modulation, that usually is considered as FM, but in the end is a PM.
Well, as I see it, it should be either FM or PM, it can't be one but in the end is something else. And your code is can only (not usually) be considered FM.
But it seems you're saying both are related, without getting into details - which is something we've already discussed here, and I've also pointed out (with no details either). But the bottom line is that they're different, and the same input parameters generate different results. Though I've said before the parameters can be "converted"/"adjusted" to sound the same.
Namely, the same modulation index does not generate the same result (Jean noticed that), and I can add the detail that the same modulating signal/waveform generate different results too. For example, a triangular wave modulating the phase is the same as a square wave modulating the frequency. So, they're quite different.
In terms of sine waves, what we've been doing so far, if you modulate the phase with a sine wave, you need to modulate the frequency with a cosine wave.
Like I pointed before, if you're going for a phase modulation implementation, you should just modulate the phase instead of trying to replicate it via frequency modulation, cause it's just more convenient to do directly via phase modulation if you want it to behave like that.
And that not
2017-06-04 13:59 GMT-03:00 mario.buoninfante
Now 2pi is needed only if you deal with a ramp, with a phasor. Cause Phasor*2pi gives you a sine. If you already have a sine there is no need to use 2pi.
Hi, let me try to be clearer. Phasor * 2pi going through a sine function gives you a sine wave. SinOsc can also be drive by a Phasor. Such as this. Phasor p => SinOsc osc => dac; 440 => p.freq; 1 => osc.sync; 4::second => now; In this case, you get a sine wave and you don't need to multiply the phasor by 2pi, because the input is normalized, from 0-1 What I was trying to say is that if you have a modulating index in phase modulation, and you want to replicate it in frequency modulation, you alsop need to multiply it by 2pi. I'm not challenging the math or equations, just adding an implementation detail in Chuck code. I know I wasn't clear about it, sorry. Hope it's clear now. But my main point was something else. It is true that if you multiply the index value by the modulation frequency value, such as in your code, you sort of get a similar behaviour than you'd get with phase modulation. But there's another detail missing if you're to really convert it. One thing about this conversion is that the waveform/function of the modulation signal needs to also be adjusted. In terms of sine waves, if you have the phase signal being modulated by a sine wave, you need to modulate the frequency with a cosine wave. With other waveforms it gets more complicated. By the way, the rule of thumb (multiply the index by the frequency) also changes, that is important to note as well. My main point is just that it's just best to implement via phase modulation, if that's the behaviour you want. cheers
Hi Alexandre, mea culpa, you were right about the modulation index using Phasor! :D here we are the 2 implementation, one with Phasor and SinOsc sync(1) (in the previous mail I said sync(2) but I meant sync(1) ), and one without Phasor but just with 2 SinOsc: Phasor phasor => Gain g => SinOsc carrier => dac; SinOsc mod => g; carrier.sync(1); phasor.freq(100); modInd(5,200); //change parameters here and listen the result while( true ){ second => now; } fun void modInd( int i, int fm ){ //arguments: modulation index, modulation frequency float am; i/6.283185307 => am; mod.freq(fm); mod.gain(am); } //////////////////////////////////////////////////////// //////////////////////////////////////////////////////// // m = mod osc; c = carrier osc; SinOsc m => Gain g => SinOsc c => dac; Step cm => g; //cm = carrier freq in Hz while( true ){ modInd(5, 200); //change parameters here and listen the result cm.next(100); second => now; } fun void modInd( float i, float f ){ //arg: modInd, freq mod float am; i*f => am; //(modInd = Am/Fm), then (Am = modInd*Fm) m.freq(f); m.gain(am); } On 04/06/17 22:44, Alexandre Torres Porres wrote:
2017-06-04 13:59 GMT-03:00 mario.buoninfante
mailto:mario.buoninfante@gmail.com>: Now 2pi is needed only if you deal with a ramp, with a phasor. Cause Phasor*2pi gives you a sine. If you already have a sine there is no need to use 2pi.
Hi, let me try to be clearer. Phasor * 2pi going through a sine function gives you a sine wave. SinOsc can also be drive by a Phasor. Such as this.
Phasorp => SinOscosc => dac;
440=>p.freq;
1=>osc.sync;
4::second=> now;
In this case, you get a sine wave and you don't need to multiply the phasor by 2pi, because the input is normalized, from 0-1
What I was trying to say is that if you have a modulating index in phase modulation, and you want to replicate it in frequency modulation, you alsop need to multiply it by 2pi.
I'm not challenging the math or equations, just adding an implementation detail in Chuck code. I know I wasn't clear about it, sorry. Hope it's clear now.
But my main point was something else. It is true that if you multiply the index value by the modulation frequency value, such as in your code, you sort of get a similar behaviour than you'd get with phase modulation. But there's another detail missing if you're to really convert it.
One thing about this conversion is that the waveform/function of the modulation signal needs to also be adjusted. In terms of sine waves, if you have the phase signal being modulated by a sine wave, you need to modulate the frequency with a cosine wave.
With other waveforms it gets more complicated. By the way, the rule of thumb (multiply the index by the frequency) also changes, that is important to note as well.
My main point is just that it's just best to implement via phase modulation, if that's the behaviour you want.
cheers
hi Alexandre, last but not the least, the point we're I was lost is that I got confused cause I achieved the same results. to summarize (it's more for myself ;) ) with Phasor is PM without it isn't. just it's simple achieve the same result, cause some scenarios allow that. It's a tough ground, and I got confused about that. I have to say thank you, cause it was such a long time I didn't spend time about "musical math" stuff ;) . and this was a good occasion to do that. anyway, I hope the Phasor implementation I attached before was useful. that is correct and seems to be quite simple. ;) cheers, Mario On 04/06/17 22:44, Alexandre Torres Porres wrote:
2017-06-04 13:59 GMT-03:00 mario.buoninfante
mailto:mario.buoninfante@gmail.com>: Now 2pi is needed only if you deal with a ramp, with a phasor. Cause Phasor*2pi gives you a sine. If you already have a sine there is no need to use 2pi.
Hi, let me try to be clearer. Phasor * 2pi going through a sine function gives you a sine wave. SinOsc can also be drive by a Phasor. Such as this.
Phasorp => SinOscosc => dac;
440=>p.freq;
1=>osc.sync;
4::second=> now;
In this case, you get a sine wave and you don't need to multiply the phasor by 2pi, because the input is normalized, from 0-1
What I was trying to say is that if you have a modulating index in phase modulation, and you want to replicate it in frequency modulation, you alsop need to multiply it by 2pi.
I'm not challenging the math or equations, just adding an implementation detail in Chuck code. I know I wasn't clear about it, sorry. Hope it's clear now.
But my main point was something else. It is true that if you multiply the index value by the modulation frequency value, such as in your code, you sort of get a similar behaviour than you'd get with phase modulation. But there's another detail missing if you're to really convert it.
One thing about this conversion is that the waveform/function of the modulation signal needs to also be adjusted. In terms of sine waves, if you have the phase signal being modulated by a sine wave, you need to modulate the frequency with a cosine wave.
With other waveforms it gets more complicated. By the way, the rule of thumb (multiply the index by the frequency) also changes, that is important to note as well.
My main point is just that it's just best to implement via phase modulation, if that's the behaviour you want.
cheers
participants (3)
-
Alexandre Torres Porres
-
mario buoninfante
-
mario.buoninfante