# Phase modulation

Source code and result:

### Simple phase modulation

In the phase modulation, the carrier phase angle is modified accordingly to the formula . The instantaneous pulsation is the derivative of the phase angle: . If we set , we see that the instantaneous pulsation is similar to the one from the simple frequency modulation. This explains the equivalence of the two modulations. On the other hand, the modulation index of the phase modulation is equal to the proportionality constant of the modulating signal, , and hence it is independant of the modulator frequency.

### Realization with Csound

We take the simple frequency modulation implementation where we replace the frequency modulation algorithm by the one represented in the following diagram: ```         sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

instr 2
idur        = p3
iamp        = p4
icarcps     = cpspch(p5)
iratio      = p6
indxmul     = p7 / 6.2831853      ;p7/(2*pi)
imodcps     = icarcps / iratio

kndx        adsr      0.4, 0.5, 0.1, 0.05
;in Phase Modulation, modulation index is independant from modulator frequency
kmod        =         kndx * indxmul
amod        oscili    1, imodcps, 1
aphi        phasor    icarcps
aphi        =         frac(aphi + kmod*amod)
acar        tablei    aphi, 1, 1, 0, 1
kenv        adsr      0.1, 0.2, 0.8, 0.2
out       iamp * kenv * acar
endin

```

To realize the operation, we increment the signal phase angle in accordance with the carrier frequency:

```aphi        phasor    icarcps
```

Then we add the modulation effect to the phase angle:

```aphi        =         frac(aphi + kmod*amod)
```

We use a normalized table length (i.e. equal to 1.0). So we only keep the fractional part of the precedent sum. The score is the same one as in the last example except for the number of the called instrument (2 instead of 1).

### Comparing with simple frequency modulation

The two intruments are put together in this csd file. The score plays each note twice, once with instrument #1 and once with instrument #2. We can hear that the audio result is identical for both kind of modulation.