@PureData

Got #Gem working in the #WebBrowser again. Had to patch #GLU to make it use #Regal, then some patching of Gem to make the #OpenGL 1.0 and 1.1 functions go via Regal (I haven't figured out why I need to do that - something RegalGLEW related maybe - didn't need it for GLU).

Instructions at https://mathr.co.uk/empd/#build-gem work on Debian Buster (current stable) and Debian Bullseye (current testing), with scripts to set up a Debian chroot if you have a different system.

The example at https://mathr.co.uk/empd/examples/gemtest/ should be a colour changing spinning cube with simple (Regal-emulated fixed function pipeline) 3D lighting / shading, some browsers may need user interaction with the page to make it work due to Google policies...

I spent some time recently cleaning up my #EmPd stuff for compiling #LibPd #Pd #PureData with #Emscripten so you can run audio patches in the #WebBrowser (without pd-gui support, but you can build custom GUIs to make interactive things).

Instructions at

https://mathr.co.uk/empd/

Currently working on trying to support #Gem via Emscripten's #Regal port, but it's frustrating because Gem's `./configure` takes forever and I'm not skilled at #autoconf stuff to know how to fix it when weird things happen.

I heard #PurrData has a browser thing now too, maybe I should see how they do it. Don't know if they have Gem there.

worked a bit more, made a regular non-browser based version:

```

git clone https://code.mathr.co.uk/rodney.git

cd rodney

make rodney

./rodney

```

(note: still very CPU heavy, add --aa 1 to make it faster but uglier)

tested briefly on Debian Buster x86_64, there may still be memory leaks, deadlocks, or other badness...

https://mathr.co.uk/rodney/latest/

(note: very CPU heavy, add ?aa=1 to make it faster but uglier)

https://mathr.co.uk/kf/kf.html#kf-2.15.1.5

kf-2.15.1.5 released!

- fix long double rendering for hybrid formulas with abs

- fix typos breaking OpenCL floatexp bailout checks

- fix guessing for OpenCL floatexp

- fix endless reference loop in OpenCL

- merge changes from kf-2.14.10.6

https://mathr.co.uk/kf/kf.html#kf-2.14.10.6

kf-2.14.10.6 released!

- fix long double rendering for formulas with abs

- fix floatexp rendering for fractional bailout norm power

- fix some float conversion warnings and potential problems

- make prepare script modular (second argument determines libraries to build, default is all libraries)

- patch OpenEXR to try to fix issues with non-ASCII paths on Windows

#kf aka #KallesFraktaler #KallesFraktaler2 is #fast #DeepZoom #FreeSoftware for #EscapeTime #fractal like #MandelbrotSet #BurningShip etc. For Windows but works in Wine and is cross-compiled from Linux using MinGW.

Managed to fractalize a variant based on a sheared stack of toruses (such that the ends join up into a helix). Still has assumptions about the rise per revolution being small, but it turned out well. Rendered with "Raymond", my physically-inspired raytracer, using a material similar to water but more extreme in both index of refraction and absorption coefficients.

Render at 3840x2160 with 256 subframes took about 1.5 hours. Exported from FragM in EXR format, colour balance adjusted in Darktable, cropped/framed in GNU IMP.

Show thread

If you need a lot of harmonics, it can be done in parallel (SIMD? FPGA?) by using the relations:

$$

T_{2n} = T_n^2 - 1

T_{2n+1} = T_{n+1} T_n - x

$$

For the second kind, I think you can use these ones:

$$

U_{2n-1} = 2 T_n U_{n-1}

U_{2n} = T_{2n} + x U_{2n-1}

$$

(hope I didn't make any mistakes working that out)

Show thread

Implemented bandlimited PWM via difference of two bandlimited saws (constructed by additive synthesis):

```

vec2 saw(float t)

{

float s = sin(t);

float c = cos(t);

float su = 1.0;

float sv = 2.0 * c;

float cu = 1.0;

float cv = c;

float sgn = 1.0;

int k = 1;

float sum = 0.0;

float dsum = 0.0;

while (k <= 16)

{

float term = sgn * su / float(k++);

float dterm = sgn * cu;

sum += term;

dsum += dterm;

sgn = -sgn;

float sw = 2.0 * c * sv - su; su = sv; sv = sw;

float cw = 2.0 * c * cv - cu; cu = cv; cv = cw;

}

return vec2(s * sum, dsum);

}

```

(This computes the derivative too for waveform plotting purposes.)

Show thread

Oh! Cosines diverge as sum(1/k) diverges. Alternating signs just pushes the problem to the opposite phase (+/-PI).

Cosine harmonics of the form 2k+1 (eg for square wave) can be generated with the same efficiency as cosine harmonics of the form k (eg for sawtooth wave):

$$ T_{k+2} = 2 T_1 T_{k+1} - T_{k} $$

vs

$$ T_{2(k+2)+1} = 2 T_2 T_{2(k+1)+1} - T_{2k+1} $$

(the waveforms are defined with sines, but maybe cosines wouldn't sound too different)

Experimenting with Chebyshev polynomials to do additive synthesis based on a single sine and cosine value pair.

Rough estimate 5 floating point arithmetic operations for each additional next harmonic, of which 3 are for the polynomial recurrence and 2 are for gain and accumulation. Compared to 3 flops and 1 `sin()` call for the obvious way. The `sin()` call way can do sparse harmonics much more easily though.

Just realized I made a mistake in my realization that happens to result in ok images when the rise per revolution is small. Correcting: the line is perpendicular to the tangent of the curve which is not parallel to the axis when the curve is "tilted" as in a helix...

Figured out the single helix version, by realizing that the line through a point to the nearest point on the surface must lie on a plane containing the axis of the helix. There are three candidate points, conceptualized as the two neighbouring arcs above and below, and the arc opposite:

```

#version 330 compatibility

#define providesColor

#include "MathUtils.frag"

#include "Complex.frag"

#include "DE-Raytracer.frag"

#group Helix

uniform float HelixD; slider[0.0,2.0,10.0]

uniform float HelixR; slider[0.0,1.0,10.0]

uniform float Helixr; slider[0.0,0.5,10.0]

uniform float time;

float DE(vec3 q)

{

q.z += time * 2.0 * PI * HelixD;

float dz = mod(q.z + HelixD * atan(q.y, q.x) + PI * HelixD, 2.0 * PI * HelixD) - PI * HelixD;

float xy = length(q.xy);

float d1 = length(vec2(xy - HelixR, dz - PI * HelixD));

float d2 = length(vec2(xy + HelixR, dz));

float d3 = length(vec2(xy - HelixR, dz + PI * HelixD));

return min(min(d1, d2), d3) - Helixr;

}

vec3 baseColor(vec3 q, vec3 n)

{

return vec3(0.5) + 0.5 * cross(n, normalize(vec3(-1.0, 1.0, -1.0)));

}

```

Show thread

Implemented a double helix #DistanceEstimate based on an idea from #FragM's `Knot.frag` (not knighty's, the other one, based on forum posts by DarkBeam).

Not sure how to #fractal-ize it, wanted to turn it into a #helix of helices of helices etc. Nor how to make it a single helix (I only managed to colour the two halves individually...).

I think each strand is an Archimedean Serpentine, but I'm not 100% sure on terminology..

```

#version 330 compatibility

#define providesColor

#include "MathUtils.frag"

#include "Complex.frag"

#include "DE-Raytracer.frag"

#group Helix

uniform float HelixD; slider[0.0,2.0,10.0]

uniform float HelixR; slider[0.0,1.0,10.0]

uniform float Helixr; slider[0.0,0.5,10.0]

uniform float time;

float DE(vec3 q)

{

q.z += HelixD * time;

float t = (mod(q.z / HelixD + 0.5, 1.0) - 0.5) * 2.0 * PI;

q.xy *= mat2(cos(t), sin(t), -sin(t), cos(t));

q.z = 0;

float s = atan(HelixD / (2.0 * PI), HelixR);

q.yz *= mat2(cos(s), -sin(s), sin(s), cos(s));

return length(vec2(length(q.xy) - HelixR, q.z)) - Helixr;

}

vec3 baseColor(vec3 q, vec3 n)

{

q.z += HelixD * time;

float t = (mod(q.z / HelixD + 0.5, 1.0) - 0.5) * 2.0 * PI;

q.xy *= mat2(cos(t), sin(t), -sin(t), cos(t));

return vec3(0.5) + 0.5 * sign(q.x) * n;

}

```

#noisevember #novembeat #noisevembeat 18th

rhythmic beeping

source code composed in https://mathr.co.uk/barry/v2/ , rendered to WAV using barry command line version, trimmed to first 2^22 samples using Audacity, encoded with LAME.

```

: audio { c t -- o }

t t 0x401 c 2 * - * 17 t 16 >> 3 & + >> 0x11 t 18 >> 0xF & 1 + * & <<

i8

;

RUN audio

1 -> increment

0 -> time

```

Show thread

https://archive.org/details/mhrk258

> Ivano Pecorini - Barons Court [mhrk258]

> 2020-11-15

> CC By-NC

> ambient, experimental, electronic, electroacoustic, abstract

this afternoon's listening

#noisevember #novembeat #noisevembeat 17th

modulating PWM drone with echoed high pitched things and various fast kicks (with a bit of DC offset, sorry)

source code composed in https://mathr.co.uk/barry/v2/ , rendered to WAV using barry command line version.

```

: dup { x -- x x }

x x

;

: env { a t -- a }

a t ~ 0x7FFF & dup * 15 >> dup * 15 >> * 15 >>

;

: audio { c t | r s -- o }

t 15 >> 3 2 c * + * 7 & 6 % 1 + -> r

t 256 r + * 9 >> 0xFF & t 256 r - * 9 >> 0xFF & - 1 >>

r t t t * * * 0xFF & i8 i64 -> s

s 2 * 0xFF & i8 i64 t 0x4000 - env 0 >>

s 3 * 0xFF & i8 i64 t 0x7000 - env 1 >>

s 5 * 0xFF & i8 i64 t 0xA000 - env 2 >>

+ + t 14 >> 7 & 7 != *

r t * ~ 0x3FFF & dup * 15 >> dup * 15 >> 0x7F & 0x40 - t 20 >> 3 & 0 != *

+ t 19 >> 3 & 0 != *

+ 1 >>

i8

;

RUN audio

1 -> increment

0 -> time

```

(Previous one was 14th.)

Show thread

making art with maths and algorithms

Joined May 2018