```
// 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;
}
```

// 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

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.