./ts i.wav o.wav

#include <complex.h>

#include <math.h>

#include <sndfile.h>

#include <fftw3.h>

#define C 2

#define F 65536

#define A 2048

#define J 1

#define O (A/4)

double w[A],a[A][C],b[A][C];double _Complex p[F],q[F],r[C][F],u[C][F],v[C][F];int main(int K,char**V){SF_INFO m={0};SNDFILE*f=sf_open(V[1],SFM_READ,&m);SF_INFO n={0,m.samplerate,m.channels,SF_FORMAT_WAV|SF_FORMAT_FLOAT,0,0};SNDFILE*g=sf_open(V[2],SFM_WRITE,&n);fftw_plan T=fftw_plan_dft_1d(F,p,q,FFTW_FORWARD,FFTW_PATIENT|FFTW_DESTROY_INPUT);fftw_plan S=fftw_plan_dft_1d(F,q,p,FFTW_BACKWARD,FFTW_PATIENT|FFTW_DESTROY_INPUT);for(int i=0;i<A;++i)w[i]=(0.5-0.5*cos(6.283185307179586*i/A))*8.2e-3;for(int c=0;c<C;++c)for(int i=0;i<F;++i){r[c][i]=0;u[c][i]=0;v[c][i]=1;}while(A==sf_readf_double(f,&a[0][0],A)){sf_seek(f,J-A,SEEK_CUR);for(int c=0;c<C;++c){for(int i=0;i<A;++i){if(i<A-O)b[i][c]=b[i+O][c];else b[i][c]=0;}for(int i=0;i<A;++i)p[i]=w[i]*a[i][c];for(int i=A;i<F;++i)p[i]=0;fftw_execute(T);for(int i=0;i<F;++i){r[c][i]=u[c][i];u[c][i]=q[i];double _Complex l0=u[c][i]/r[c][i];l0/=cabs(l0);double _Complex l=l0;for(int s=O/J;s>1;s>>=1)l*=l;v[c][i]*=l;v[c][i]/=cabs(v[c][i]);if(v[c][i]==0||!(v[c][i]==v[c][i])||isinf(cabs(v[c][i])))v[c][i]=1;q[i]=cabs(u[c][i])*v[c][i];}fftw_execute(S);for(int i=0;i<A;++i)b[i][c]+=w[i]*p[i];}sf_writef_double(g,&b[0][0],O);}return 0;}

Seaside sunrise at the end of July.

Process: In GNU IMP: downscale photo to 10%, convert to indexed palette with 6 colours, convert back to RGB, perform edge detection with Laplace operator (border policy white), invert colours, threshold at (1,255) to black and white (as much white as possible). Then save as PPM and run potrace from the command line, without any options, giving an EPS file with the same stem. Load this back into GNU IMP, at 600dpi with strong antialiasing settings. Downscale to 720p greyscale JPEG for web, keep the high resolution for printing (445dpi fits nicely on A4 paper, with 15mm border on left/right/top (bigger bottom border).

Working on some music stuff, thinking of algorithms that might work nicely on an #Amiga #A500 or #A500Plus (currently implemented in C on a modern machine, but it uses 16bit integer maths for the most part, probably needs optimisations to replace divisions with faster things).

There are 3 tables of 16384 signed 8-bit audio data, which get repeatedly filtered in-place by some hacky moving average stuff while they are played in a loop.

For the final version I'll probably end up reimplementing it in inline-assembler in Amiga E.

Number of walks within N^3 (the first octant of Z^3) starting at (0,0,0) and consisting of n steps taken from {(-1, -1, 1), (-1, 0, 0), (0, 1, 1), (1, 0, -1), (1, 0, 1)}.

a(6) = 2021

#TwentyTwentyOne #calendar #anaglyph #stereoscopic

Show thread

Seems there is #comet #neowise visible at the moment! Not sure I'll get to see it, 4am is a bit early/late.

https://www.theregister.com/2020/07/11/neowise_comet_spotting/

> If you're in the northern hemisphere, and gazing up at the right moment – around 4am local time, July 10 to 15, looking northeast; and potentially an hour after sunset, July 14 to 23, looking northwest – you should catch a glimpse of the comet, C/2020 F3 NEOWISE. And local time really does mean the time wherever you are.

COVID

Oh, the page has changed since I posted the link. Here's the image that was on the page. (BBC credited it to Reuters).

Show thread

COVID

I fixed #Bolsonaro 's mask.

Original image credit: Reuters via BBC https://www.bbc.co.uk/news/world-latin-america-53319517

Number of partitions of n into distinct parts >= 4; a(61) = 2021. PPM export rendered as a byte string. Not sure about the colour scheme. This one is stretched vertically more at the top (small parts) than the bottom (big parts) for aesthetic reasons.

Show thread

Number of partitions of n into distinct parts >= 4; pictured: a(47) = 447.

No gaps this time. Scanlines are doubled to get a better aspect ratio.

Will probably try to do the full a(61) = 2021 as high resolution (vector) graphics for the final image, these textures are starting to look pretty nice

Show thread

I worked a bit on some ideas for a 2021 #calendar, raiding the Online Encyclopedia of Integer Sequences #OEIS for inspiration.

Implemented the basic algorithm of one so far: the sum of all the parts of all the partitions of 43 into 9 primes is 2021. (There are 47 partitions, 2021 is the product of two adjacent #PrimeNumbers 43 * 47). Making it prettier is a task for later.

```

python -m SimpleHTTPServer 8089

```

In UserLAnd seems to work fine in Chrome on the same tablet. Tested with Barry compiled from C source on the tablet.

Show thread

Trying to debug why shallow zooms in #KF and/or disabling series approximation causes weird artifacts where the directional analytic distance estimate used for fake lighting effects ("slope colouring") doesn't line up between successive frames when rendering exponential maps, causing bad seams.

At deep zooms with series approximation, Mandelbrot set is fine, but other fractals are still buggy (I tested Burning Ship and Buffalo).

Today I implemented analytic DE for the hybrid fractal formula editor using dual numbers, and it has no problems whatsoever.

My current temptation is to delete most of the old formulas (given that they are at least partially broken) and replace them with example settings for the hybrid editor. Will have to benchmark this carefully in case it's too much slower.

But I need to fix the Mandelbrot set implementation, as using it without series approximation is much slower.

https://archive.org/details/kf-exp-map-flat-1

#fractal #zoom #video calculated in #KF (515 keyframes forming an #ExponentialMap) in 66mins wall clock time, then assembled and encoded into a 3min video in 12mins wall clock time. Should be a part of the next major KF release come September time or so.

I implemented the video assembler in #CPlusPlus using #OpenGL #GLSL #shaders to colour the raw iteration data, wasn't hard to modify my earlier flat keyframe interpolator to work with exponential map slices. https://mathr.co.uk/zoom

The colouring is based on directional distance estimate - close to the fractal is black, with rainbow tinges surrounding desaturating to white far from the fractal.

Magnet Mandelbulb (hopefully correct this time).

Looks much less interesting, and is much harder to render (needed to reduce DE multiplier and increase subframe count to get it to look acceptable).

Show thread

making art with maths and algorithms

Joined May 2018