# [PD] very compressed chip sounds (fwd)

Mathieu Bouchard matju at artengine.ca
Sat Oct 15 10:09:25 CEST 2011

```Le 2011-10-13 à 21:52:00, John Dunlap a écrit :

> Amazing efficiency! I'd really like to know how you put that together -
> it seems like an interesting approach to PD.
>
>> From: Mathieu Bouchard <matju at artengine.ca>
>> A simple synth playing notes of the scale... in two boxes (dac~ included).

It's my first use ever of [fexpr~]. However, I already knew quite a bit of
theory about things like this. You can get some of it in the pd help
files, or more in detail in Miller's book, and in even more detail in pd's
source code.

Each line (each semicolon-separated part) represents one outlet, and one
element of the \$y series : \$y1,\$y2,\$y3,... Note that \$y is a shortcut for \$y1.

\$y1 is a phasor with frequency 0.00012*44100.

\$y2 is a click generator by looking at sudden drops in \$y1.

\$y3 does a cycle of fifths (quintes) over two octaves. A fifth is 7 semitones.
Two octaves is 24 semitones.

\$y4 is a shortcut for adding 7*12 to the note number, doing [mtof~], and
converting that frequency from Hz to radians, where 44100 Hz = a full turn = 2π

\$y5 and \$y6 combine this angle with a radius of 0.9999 and converts this from
polar to cartesian, which needs a cos, a sin, and two *, and then computes a
[cpole~] whose 2nd inlet is not connected, and whose first inlet is \$y2
multiplied by 8. This causes [cpole~] to act as an oscillator, as it makes a
point spin around the centre by doing many small rotations. \$y5 and \$y6 are two
sinusoïdal waves whose phase difference is 90⁰, because one is the horizontal
position of the spinning point, and the other is the vertical position.

\$y7 and \$y8 just use sin as a waveshaper (nonlinear), which creates a bunch of
harmonics to make the sound richer.

The role of the 0.9999 radius factor is to make the wave decay with a factor of
0.9999 per sample, which is a loss of 0.01 % per sample. If you compute this :

log(½)/log(0.9999)/44.1 kHz = about 157.168 ms

This tells you that the amplitude drops by half every 157 ms. That's how we
control note duration. You can verify this by doing :

pow(0.9999, 157.168 ms * 44.1 kHz) = about ½

But the waveshaper complicates the decay a lot.

______________________________________________________________________
| Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC
```