```
// mathr - 2021-10-01 -
typedef double sample;
SR 48000
"dsp.h"
R sample

typedef struct
{
int reloaded;
double t;
R note[2][3];
BIQUAD env[2][3];
PHASOR osc[2][3], bosc[2][3];
} S;

int go(S *s, int nin, const float *in, int nout, float *out)
{
if (s->reloaded)
{
s->reloaded = 0;
panic(s);
}
R bpm = 138;
R hz = 35;
R cps = bpm / 60 / 4;
R t = (s->t += cps / SR);
R fade = pow
( envL(slow(4, t))
* envLR(rotL(4, slow(4, t))
), 2);
pair chords[3][4] =
{ { { 2, 4 }, { 1, 4 }, { 1, 5 }, { 4, 3 } }
, { { 1, 5 }, { 2, 6 }, { 2, 6 }, { 3, 4 } }
, { { 2, 6 }, { 1, 8 }, { 3, 8 }, { 2, 5 } }
};
R chord[2] = { 0, 0 };
R bass = 0;
for (int c = 0; c < 2; ++c)
{
for (int i = 0; i < 3; ++i)
{
R stereo = rotL(sine2(slow(4, t + (c - 0.5))) / 64, t);
R note = timeCat(chords[i], stereo);
R trig = (s->note[c][i] != note) * 500 * fade;
s->note[c][i] = note;
R q = mix(flatq, 5, envL(slow(8, t)));
R env = sine2(biquad(highpass(&s->env[c][i], cps * note, q), trig));
R osc = sine2(phasor(&s->osc[c][i], hz * note * 3));
R pulse = exp2(square(fast(4, t))) / 4;
R bosc = sine2(phasor(&s->bosc[c][i], hz * note * 3 * pulse));
bass += bosc;
chord[c] += env * osc;
}
}
bass *= fade;
for (int c = 0; c < nout; ++c) {
out[c] = c < 2 ? 0.2 * mix(chord[c], bass, 0.5) : 0;
}
return 0;
}
```

```
// mathr - 2021-10-06 -
typedef double R;
SR 48000
"dsp.h"
R sample
typedef struct
{
int reloaded;
double t;
R note[2][3];
BIQUAD env[2][3];
PHASOR osc[2][3],bosc[2][3];
}S;
int go(S *s,int nin,const float *in,int nout,float *out)
{
if (s->reloaded)
{
s->reloaded=0;
panic(s);
}
R bpm=138*4./3;
R hz=35;
R cps=bpm/60/4;
R t=(s->t+=cps/SR);
R fade=pow(envL(slow(4,t))*envLR(rotL(4,slow(4,t))),2);
pair chords[3][4]=
{{{4,4},{2,4},{2,5},{4,3}}
,{{2,5},{4,6},{3,6},{3,4}}
,{{4,6},{2,8},{4,8},{2,5}}};
R chord[2]={0,0};
R bass=0;
for(int c=0;c<2;++c){
for(int i=0;i<3;++i){
R stereo=rotL(sine2(slow(4,t+(c-0.5)))/64,t);
R note=timeCat(chords[i],stereo);
R trig=(s->note[c][i]!=note)*500*fade;
s->note[c][i]=note;
R q=mix(flatq,5,envL(slow(8,t)));
R env=sine2(biquad(highpass(&s->env[c][i],cps*note/3,q),trig));
R osc=square2(phasor(&s->osc[c][i],hz*note*3));
R pulse=exp2(square(fast(3,t)))/4;
R bosc=trisaw2(saw(slow(2,t)),phasor(&s->bosc[c][i],hz*note*3*pulse));
bass+=bosc;
chord[c]+=env*osc;
}
}
bass*=fade;
for (int c=0;c<nout;++c) {
out[c]=c<2?0.2*mix(chord[c],bass,0.5):0;
}
return 0;
}
```

```
// mathr - 2021-10-11 -

typedef double sample;
SR 48000
"dsp.h"
R sample

typedef struct
{
int reloaded;
double t;
R note[2][3];
BIQUAD env[2][3];
PHASOR osc[2][3][2];
} S;

int go(S *s, int inchannels, const float *in, int outchannels, float *out)
{
if (s->reloaded)
{
s->reloaded = 0;
panic(s);
}
R bpm = 138 * 4./6;
R hz = 35;
R cps = bpm / 60 / 4;
R t = (s->t += cps / SR);
R fade = pow
( envL(slow(4, t))
* envLR(rotL(4, slow(4, t))
), 2);
pair chords[3][4] =
{ { { 4, 4 }, { 2, 4 }, { 2, 5 }, { 4, 3 } }
, { { 2, 5 }, { 4, 6 }, { 3, 6 }, { 3, 4 } }
, { { 4, 6 }, { 2, 8 }, { 4, 8 }, { 2, 5 } }
};
R chord[2] = { 0, 0 };
for (int c = 0; c < 2; ++c)
{
for (int i = 0; i < 3; ++i)
{
R stereo = rotL(sine2(slow(4, t + (c - 0.5))) / 64, t);
R note = timeCat(chords[i], stereo);
R trig = (s->note[c][i] != note) * 500 * fade;
s->note[c][i] = note;
R q = mix(flatq, 5, envL(slow(8, t)));
R env = sine2(biquad(highpass(&s->env[c][i], cps * note, q), trig));
R osc = sine2(phasor(&s->osc[c][i][0], hz * (1 + (c - 0.5)/16) + (i - 1) / 30.0 + 1000 * env * sine2(phasor(&s->osc[c][i][1], hz * note))));
chord[c] += osc;
}
}
for (int c = 0; c < outchannels; ++c) {
out[c] = c < 2 ? 0.2 * chord[c] * fade : 0;
}
return 0;
}
```

Follow

// mathr 2021-10-21 looptober

typedef double sample;
SR 48000
"dsp.h"
R sample

typedef struct
{
int reloaded;
double t;
BIQUAD O[2][3];
DELAY D0;float b0[SR];
DELAY D1;float b1[SR];
} S;

int go(S *s,int nin,const float *in,int nout,float *out)
{
if (s->reloaded)
{
s->reloaded=0;
s->D0.length=SR;
s->D1.length=SR;
}
R bpm=138/2.;
R hz=35*3./2;
R cps=bpm/60/4;
R t=(s->t+=cps/SR);
R F=pow(envL(slow(2,t))*envLR(rotL(4,slow(2,t))),2);
pair H[3][4] =
{{{4,4},{4,4},{2,5},{6,3}}
,{{2,5},{6,6},{4,6},{4,4}}
,{{6,6},{2,8},{5,8},{3,5}}
};
R D[2]={delread4(&s->D1,125/hz),delread4(&s->D0,125/hz)};
R C[2]={D[0]*cosine2(t)-sine2(t)*D[1],D[0]*sine2(t)+cosine2(t)*D[1]};
C[0]*=2;
C[1]*=2;
R l=t;
t=pow(2,saw(slow(4,t)))-1;
for (int c=0;c<2;++c)
{
for (int i=0;i<3;++i)
{
R N=timeCat(H[i],fast(2,t));
R q=100;
R O=sine2(biquad(bandpass(&s->O[c][i],hz*N,q),C[c]));
C[c]+=O;
}
}
R K[2]={0,0};
for (int k=0;k<8;++k)
{
R E=pow(isaw(fast(2*pow(2,k),saw(t))),2);
R m=tanh(4*sine2(12*E)*(1+E))*(k==0?t:k==7?1-t:1);
K[0]+=cosine2(k/7.*l)*m;
K[1]+=sine2(k/7.*l)*m;
}
delwrite(&s->D0,tanh(K[0]+0.1*C[1]));
delwrite(&s->D1,tanh(K[1]+0.1*C[0]));
for (int c=0;c<nout;++c) {
out[c]=c<2?0.3*mix(C[c],K[c],0.5)*F:0;
}
return 0;
}

// unshrunk at code.mathr.co.uk/clive/blob/60

· · Web · 1 · 1 · 2

```
// mathr - 2021-10-31 -

typedef double sample;
SR 48000
"dsp.h"
R sample

typedef struct{DELAY d; float b[SR];}D;

typedef struct{
int reloaded;
double t;
BIQUAD O[2][4][16];
D d[4];
COMPRESS C[4];
HIP H[4];
}S;

int go(S *s,int nin,const float *in,int nout,float *out)
{if(s->reloaded){
s->reloaded=0;
panic(s);
for(int d=0;d<4;++d)
s->d[d].d.length = SR;
}
R bpm=138;
R cps=bpm/60/4;
R t=(s->t+=cps/SR);
R fade = pow(envL(slow(4,t))*envLR(slow(4,rotL(12,t))),16);
const R e=1000/cps/128;
R E[4];
for(int d=0;d<4;++d)
E[d]=delread4(&s->d[d].d,e);
R L[4]=
{E[0]*cosine2(t)-sine2(t)*E[0]
,E[0]*sine2(t)+cosine2(t)*E[1]
,E[0]*sine2(t)+cosine2(t)*E[2]
,E[0]*sine2(t)+cosine2(t)*E[3]
};
for(int c=0;c<4;++c)
{
for(int i=0;i<16;++i)
{
R n=mtof(30+3*i);
R g=0.1+0.2*fade;
R q=flatq;
R O=2*sine2(g*biquad(highpass(&s->O[0][c][i],n,q),L[c]));
O=2*sine2(g*biquad(lowpass(&s->O[1][c][i],n,q),O));
L[c]+=O;
}
}
for(int c=0;c<4;++c)
{
R C[2];
C[0]=L[c];
C[1]=L[c];
compress(C,&s->C[c],30,15,15,48,C);
L[c]=hip(&s->H[c],C[0],10);
}
R g=fade;
for(int d=0;d<4;++d)
delwrite(&s->d[d].d,tanh(g*L[d]+noise()*1e-6));
for(int c=0;c<nout;++c) {
out[c]=c<2?L[c+1]*(fade>0):0;
}
return 0;
}
```

Sign in to participate in the conversation
post.lurk.org

Welcome to post.lurk.org, an instance for discussions around cultural freedom, experimental, new media art, net and computational culture, and things like that.

<svg xmlns="http://www.w3.org/2000/svg" id="hometownlogo" x="0px" y="0px" viewBox="25 40 50 20" width="100%" height="100%"><g><path d="M55.9,53.9H35.3c-0.7,0-1.3,0.6-1.3,1.3s0.6,1.3,1.3,1.3h20.6c0.7,0,1.3-0.6,1.3-1.3S56.6,53.9,55.9,53.9z"/><path d="M55.9,58.2H35.3c-0.7,0-1.3,0.6-1.3,1.3s0.6,1.3,1.3,1.3h20.6c0.7,0,1.3-0.6,1.3-1.3S56.6,58.2,55.9,58.2z"/><path d="M55.9,62.6H35.3c-0.7,0-1.3,0.6-1.3,1.3s0.6,1.3,1.3,1.3h20.6c0.7,0,1.3-0.6,1.3-1.3S56.6,62.6,55.9,62.6z"/><path d="M64.8,53.9c-0.7,0-1.3,0.6-1.3,1.3v8.8c0,0.7,0.6,1.3,1.3,1.3s1.3-0.6,1.3-1.3v-8.8C66,54.4,65.4,53.9,64.8,53.9z"/><path d="M60.4,53.9c-0.7,0-1.3,0.6-1.3,1.3v8.8c0,0.7,0.6,1.3,1.3,1.3s1.3-0.6,1.3-1.3v-8.8C61.6,54.4,61.1,53.9,60.4,53.9z"/><path d="M63.7,48.3c1.3-0.7,2-2.5,2-5.6c0-3.6-0.9-7.8-3.3-7.8s-3.3,4.2-3.3,7.8c0,3.1,0.7,4.9,2,5.6v2.4c0,0.7,0.6,1.3,1.3,1.3 s1.3-0.6,1.3-1.3V48.3z M62.4,37.8c0.4,0.8,0.8,2.5,0.8,4.9c0,2.5-0.5,3.4-0.8,3.4s-0.8-0.9-0.8-3.4C61.7,40.3,62.1,38.6,62.4,37.8 z"/><path d="M57,42.7c0-0.1-0.1-0.1-0.1-0.2l-3.2-4.1c-0.2-0.3-0.6-0.5-1-0.5h-1.6v-1.9c0-0.7-0.6-1.3-1.3-1.3s-1.3,0.6-1.3,1.3V38 h-3.9h-1.1h-5.2c-0.4,0-0.7,0.2-1,0.5l-3.2,4.1c0,0.1-0.1,0.1-0.1,0.2c0,0-0.1,0.1-0.1,0.1C34,43,34,43.2,34,43.3v7.4 c0,0.7,0.6,1.3,1.3,1.3h5.2h7.4h8c0.7,0,1.3-0.6,1.3-1.3v-7.4c0-0.2,0-0.3-0.1-0.4C57,42.8,57,42.8,57,42.7z M41.7,49.5h-5.2v-4.9 h10.2v4.9H41.7z M48.5,42.1l-1.2-1.6h4.8l1.2,1.6H48.5z M44.1,40.5l1.2,1.6h-7.5l1.2-1.6H44.1z M49.2,44.6h5.5v4.9h-5.5V44.6z"/></g></svg>