# [PD] d-scale abstraction with rjdj

Frank Barknecht fbar at footils.org
Sat Jun 18 08:51:39 CEST 2011

```Hi,

On Fri, Jun 17, 2011 at 10:45:45AM -0400, Pagano, Patrick wrote:
> But here is an FM glitcher using d-scale and Tonalatonal, I patch I found
> on list a few years ago that is RIPE for rjDJ-ness
> Maybe you can look at these and help me make em a little more spiffy, or
> at very least get tonal working!

Okay, that's a bit of tedious work. but doable. The patches only use
[sort], which you can replace by [list-sort] with [list-rdrip] from the
[list]-abstractions. They only use [sort 1] which is ascending sort i.e.
a naked [list-sort].

A bit more tricky to replace are the expr-constructs used. Fortunatly
[d-scale] is only used as [d-scale -1 1 1 100 100]. This is sufficiently
similar to [m_scale -1 1 1 100 dB] from the rj-library, so I'd just use
that.

Another expression used several times is this:

expr~ if (\$v1 == 0, 0, (if (\$v1 < 0, -1, 1)))

This is a signum function for signals. You can replace this with the sgn~.pd
from the "purepd" collection in CVS/Pd-extended. Make sure to also get
the lt~.pd and gt~.pd abstractions. Alternatively you can also get away
with this:

[inlet~]
|\
| [abs~]
|  |
[/~]
|
[outlet~]

I.e. divide a signal by its absolute value. Division of 0/0 in Pd here
gives 0 again, so you're cheating okay around this exceptional case.

The other expr-expression just require some work to explode them into
normal math objects. You will gain a bit of execution speed by this, as
expr is a bit slower than exploded math.

Ciao
--
Frank

```