- struct synth_bird *bird = birdsynth_malloc_create( "" );
-
- int f0=2500, o1=0, f1=30;
- int adsr=0;
-
- int o0[4]={0,0,0,0};
-
- float c0=0.0f, c1=0.0f, c2=0.0f, c3=0.0f; /* signature coefficients */
- int l=44100/2, /* length of thing */
- x=0, /* frame of thing */
- a=0; /* 0: silence 1: signature */
-
- float poly=0.0f;
-
- for(int _=0;_<44100*30;_++){
- x ++;
- if( x >= l ){ /* do new thing */
- if( a ){
- int retrigger = rand() % 4;
- a=0;
- if( retrigger ) l=rand_seconds(0.03,0.1);
- else l=rand_seconds(0.5,10.0);
- }
- else{
- c0=rand_float(-1.0,1.0);
- c1=rand_float(-1.0,1.0);
- c2=rand_float(-0.1,0.1);
- c3=rand_float(-0.5,1.5);
- l=rand_seconds(0.05,0.5);
- a=1;
- }
- x=0;
- }
-
- if(a){
- adsr += 40;
- if( adsr > 44100 ) adsr = 44100;
- }
- else{
- adsr -= 40;
- if( adsr < 0 ) adsr = 0;
- }
-
- o1 += f1;
- o1 = o1 % 44100;
-
- float s1 = sine_44100_1( o1 );
- float level = adsr;
- level *= (1.0f/44100.0f);
-
- if( a )
- {
- float t = ((float)x * (1.0f/(float)l))*2.0f - 1.0f,
- tt = t*t,
- ttt = tt*t;
-
- poly = c0+t*c1+tt*c2+ttt*c3;
- }
-
- int fm = s1*100.0f*(1.0f+poly*0.5f) + poly*500.0f;
-
- int ff = f0+fm;
- o0[0] = WRAP1S( o0[0] + ff*1 );
- o0[1] = WRAP1S( o0[1] + ff*2 );
- o0[2] = WRAP1S( o0[2] + ff*3 );
- o0[3] = WRAP1S( o0[3] + ff*4 );
-
- float v[4];
- sine_44100_4( o0, v );
- float s0 = v[0] +
- v[1] * 0.5f +
- v[2] * 0.25f +
- v[3] * 0.125f;
- s0 *= level;
-
- float stereo[2] = { s0, s0 };
- //vg_dsp_process( stereo, stereo );
-
- int16_t l = stereo[0] * 10000.0f,
- r = stereo[1] * 10000.0f;