File: fused_loop.c

package info (click to toggle)
freebirth 0.3.2-9.2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 3,632 kB
  • ctags: 640
  • sloc: ansic: 4,724; makefile: 89; sh: 1
file content (597 lines) | stat: -rw-r--r-- 19,452 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
/* generated file -- don't edit */
#include <unistd.h>
#include <math.h>
#include <endian.h>
#include "freebirth.h"
/* borrowed from glib2 */
#define SHORT_SWAP_LE_BE(val)  ((short) ( \
    (short) ((short) (val) >> 8) |     \
    (short) ((short) (val) << 8)))
static void swap_endian(short *data, int length)
{
       int i;
       for (i = 0; i < length; i += 1, data++)
               *data = SHORT_SWAP_LE_BE(*data);
}

sample_producer *sp[31];

int play_buffer(gpointer data, gint source, GdkInputCondition condition)
{
  int i;
  short buffer[TBASS_BUFF_SIZE * 2];
  
  sample samp0;
  sample samp1;
  sample samp2;
  sample samp3;
  sample samp4;
  sample samp5;
  sample samp6;
  sample samp7;
  sample samp8;
  sample samp9;
  sample samp10;
  sample samp11;
  sample samp12;
  sample samp13;
  sample samp14;
  sample samp15;
  sample samp16;
  sample samp17;
  sample samp18;
  sample samp19;
  sample samp20;
  sample samp21;
  sample samp22;
  sample samp23;
  sample samp24;
  sample samp25;
  sample samp26;
  sample samp27;
  sample samp28;
  sample samp29;
  sample samp30;

  int seq_off = sequencer->current_sample_offset;
  int seq_spb = sequencer->spb;
  event_list *el;
  int j;

  sample *n0_table = ((raw_wave *)sp[0])->table;
  int n0_length = ((raw_wave *)sp[0])->length;
  sample n0_s1, n0_s2;
  double n0_ci_w, n0_ci_f, n0_pitch = ((raw_wave *)sp[0])->pitch;

  sample *n1_table = ((raw_wave *)sp[1])->table;
  int n1_length = ((raw_wave *)sp[1])->length;
  sample n1_s1, n1_s2;
  double n1_ci_w, n1_ci_f, n1_pitch = ((raw_wave *)sp[1])->pitch;

  sample *n2_table = ((raw_wave *)sp[2])->table;
  int n2_length = ((raw_wave *)sp[2])->length;
  sample n2_s1, n2_s2;
  double n2_ci_w, n2_ci_f, n2_pitch = ((raw_wave *)sp[2])->pitch;

  sample *n3_table = ((raw_wave *)sp[3])->table;
  int n3_length = ((raw_wave *)sp[3])->length;
  sample n3_s1, n3_s2;
  double n3_ci_w, n3_ci_f, n3_pitch = ((raw_wave *)sp[3])->pitch;

  sample *n4_table = ((raw_wave *)sp[4])->table;
  int n4_length = ((raw_wave *)sp[4])->length;
  sample n4_s1, n4_s2;
  double n4_ci_w, n4_ci_f, n4_pitch = ((raw_wave *)sp[4])->pitch;

  int n5_phase_offset = ((osc *)sp[5])->phase_offset;
  double n5_freq_offset = ((osc *)sp[5])->freq_offset;
  int n5_freq = ((osc *)sp[5])->freq;
  int n5_phase_factor = n5_phase_offset / n5_freq;
  sample *n5_table = ((osc *)sp[5])->table;
  int n5_i = ((osc *)sp[5])->current_index;

  int n6_phase_offset = ((osc *)sp[6])->phase_offset;
  double n6_freq_offset = ((osc *)sp[6])->freq_offset;
  int n6_freq = ((osc *)sp[6])->freq;
  int n6_phase_factor = n6_phase_offset / n6_freq;
  sample *n6_table = ((osc *)sp[6])->table;
  int n6_i = ((osc *)sp[6])->current_index;

  int n7_phase_offset = ((osc *)sp[7])->phase_offset;
  double n7_freq_offset = ((osc *)sp[7])->freq_offset;
  int n7_freq = ((osc *)sp[7])->freq;
  int n7_phase_factor = n7_phase_offset / n7_freq;
  sample *n7_table = ((osc *)sp[7])->table;
  int n7_i = ((osc *)sp[7])->current_index;

  int n8_blend = ((blender *)sp[8])->blend_factor;
  int n8_strength0 = ((blender *)sp[8])->strength[0];
  int n8_strength1 = ((blender *)sp[8])->strength[1];
  int n8_strength2 = ((blender *)sp[8])->strength[2];

  int n9_attack = ((env *)sp[9])->attack;
  int n9_release = ((env *)sp[9])->release;

  int n10_fc = ((filter *)sp[10])->fc;
  float n10_Q = ((filter *)sp[10])->Q;
  float n10_s;

  int n11_attack = ((env *)sp[11])->attack;
  int n11_release = ((env *)sp[11])->release;

  int n12_amp0 = ((mixer *)sp[12])->amplitude[0];
  int n12_amp1 = ((mixer *)sp[12])->amplitude[1];
  int n12_amp2 = ((mixer *)sp[12])->amplitude[2];
  int n12_amp3 = ((mixer *)sp[12])->amplitude[3];
  int n12_amp4 = ((mixer *)sp[12])->amplitude[4];
  int n12_amp5 = ((mixer *)sp[12])->amplitude[5];
  int n12_mute0 = ((mixer *)sp[12])->mute_map[0];
  int n12_mute1 = ((mixer *)sp[12])->mute_map[1];
  int n12_mute2 = ((mixer *)sp[12])->mute_map[2];
  int n12_mute3 = ((mixer *)sp[12])->mute_map[3];
  int n12_mute4 = ((mixer *)sp[12])->mute_map[4];
  int n12_mute5 = ((mixer *)sp[12])->mute_map[5];

  int n13_i = ((delay *)sp[13])->d_index;
  int n13_size = ((delay *)sp[13])->delay_size;
  int n13_feedback = ((delay *)sp[13])->feedback;
  sample *n13_buf = ((delay *)sp[13])->delay_buffer;

  int n14_i = ((delay *)sp[14])->d_index;
  int n14_size = ((delay *)sp[14])->delay_size;
  int n14_feedback = ((delay *)sp[14])->feedback;
  sample *n14_buf = ((delay *)sp[14])->delay_buffer;

  int n15_i = ((delay *)sp[15])->d_index;
  int n15_size = ((delay *)sp[15])->delay_size;
  int n15_feedback = ((delay *)sp[15])->feedback;
  sample *n15_buf = ((delay *)sp[15])->delay_buffer;

  int n16_amp0 = ((mixer *)sp[16])->amplitude[0];
  int n16_amp1 = ((mixer *)sp[16])->amplitude[1];
  int n16_amp2 = ((mixer *)sp[16])->amplitude[2];
  int n16_mute0 = ((mixer *)sp[16])->mute_map[0];
  int n16_mute1 = ((mixer *)sp[16])->mute_map[1];
  int n16_mute2 = ((mixer *)sp[16])->mute_map[2];


  int n18_amp0 = ((mixer *)sp[18])->amplitude[0];
  int n18_amp1 = ((mixer *)sp[18])->amplitude[1];
  int n18_amp2 = ((mixer *)sp[18])->amplitude[2];
  int n18_amp3 = ((mixer *)sp[18])->amplitude[3];
  int n18_amp4 = ((mixer *)sp[18])->amplitude[4];
  int n18_amp5 = ((mixer *)sp[18])->amplitude[5];
  int n18_mute0 = ((mixer *)sp[18])->mute_map[0];
  int n18_mute1 = ((mixer *)sp[18])->mute_map[1];
  int n18_mute2 = ((mixer *)sp[18])->mute_map[2];
  int n18_mute3 = ((mixer *)sp[18])->mute_map[3];
  int n18_mute4 = ((mixer *)sp[18])->mute_map[4];
  int n18_mute5 = ((mixer *)sp[18])->mute_map[5];

  int n19_i = ((delay *)sp[19])->d_index;
  int n19_size = ((delay *)sp[19])->delay_size;
  int n19_feedback = ((delay *)sp[19])->feedback;
  sample *n19_buf = ((delay *)sp[19])->delay_buffer;

  int n20_i = ((delay *)sp[20])->d_index;
  int n20_size = ((delay *)sp[20])->delay_size;
  int n20_feedback = ((delay *)sp[20])->feedback;
  sample *n20_buf = ((delay *)sp[20])->delay_buffer;

  int n21_i = ((delay *)sp[21])->d_index;
  int n21_size = ((delay *)sp[21])->delay_size;
  int n21_feedback = ((delay *)sp[21])->feedback;
  sample *n21_buf = ((delay *)sp[21])->delay_buffer;

  int n22_i = ((delay *)sp[22])->d_index;
  int n22_size = ((delay *)sp[22])->delay_size;
  int n22_feedback = ((delay *)sp[22])->feedback;
  sample *n22_buf = ((delay *)sp[22])->delay_buffer;

  int n23_i = ((delay *)sp[23])->d_index;
  int n23_size = ((delay *)sp[23])->delay_size;
  int n23_feedback = ((delay *)sp[23])->feedback;
  sample *n23_buf = ((delay *)sp[23])->delay_buffer;

  int n24_i = ((delay *)sp[24])->d_index;
  int n24_size = ((delay *)sp[24])->delay_size;
  int n24_feedback = ((delay *)sp[24])->feedback;
  sample *n24_buf = ((delay *)sp[24])->delay_buffer;

  int n25_amp0 = ((mixer *)sp[25])->amplitude[0];
  int n25_amp1 = ((mixer *)sp[25])->amplitude[1];
  int n25_amp2 = ((mixer *)sp[25])->amplitude[2];
  int n25_amp3 = ((mixer *)sp[25])->amplitude[3];
  int n25_amp4 = ((mixer *)sp[25])->amplitude[4];
  int n25_amp5 = ((mixer *)sp[25])->amplitude[5];
  int n25_mute0 = ((mixer *)sp[25])->mute_map[0];
  int n25_mute1 = ((mixer *)sp[25])->mute_map[1];
  int n25_mute2 = ((mixer *)sp[25])->mute_map[2];
  int n25_mute3 = ((mixer *)sp[25])->mute_map[3];
  int n25_mute4 = ((mixer *)sp[25])->mute_map[4];
  int n25_mute5 = ((mixer *)sp[25])->mute_map[5];

  int n26_i = ((all_pass *)sp[26])->d_index;
  int n26_size = ((all_pass *)sp[26])->delay_size;
  int n26_feedback = ((all_pass *)sp[26])->feedback;
  sample *n26_buf = ((all_pass *)sp[26])->delay_buffer;

  int n27_i = ((all_pass *)sp[27])->d_index;
  int n27_size = ((all_pass *)sp[27])->delay_size;
  int n27_feedback = ((all_pass *)sp[27])->feedback;
  sample *n27_buf = ((all_pass *)sp[27])->delay_buffer;


  int n29_amp0 = ((mixer *)sp[29])->amplitude[0];
  int n29_amp1 = ((mixer *)sp[29])->amplitude[1];
  int n29_amp2 = ((mixer *)sp[29])->amplitude[2];
  int n29_amp3 = ((mixer *)sp[29])->amplitude[3];
  int n29_amp4 = ((mixer *)sp[29])->amplitude[4];
  int n29_amp5 = ((mixer *)sp[29])->amplitude[5];
  int n29_amp6 = ((mixer *)sp[29])->amplitude[6];
  int n29_amp7 = ((mixer *)sp[29])->amplitude[7];
  int n29_mute0 = ((mixer *)sp[29])->mute_map[0];
  int n29_mute1 = ((mixer *)sp[29])->mute_map[1];
  int n29_mute2 = ((mixer *)sp[29])->mute_map[2];
  int n29_mute3 = ((mixer *)sp[29])->mute_map[3];
  int n29_mute4 = ((mixer *)sp[29])->mute_map[4];
  int n29_mute5 = ((mixer *)sp[29])->mute_map[5];
  int n29_mute6 = ((mixer *)sp[29])->mute_map[6];
  int n29_mute7 = ((mixer *)sp[29])->mute_map[7];

  int n30_amp0 = ((mixer *)sp[30])->amplitude[0];
  int n30_amp1 = ((mixer *)sp[30])->amplitude[1];
  int n30_amp2 = ((mixer *)sp[30])->amplitude[2];
  int n30_amp3 = ((mixer *)sp[30])->amplitude[3];
  int n30_amp4 = ((mixer *)sp[30])->amplitude[4];
  int n30_amp5 = ((mixer *)sp[30])->amplitude[5];
  int n30_amp6 = ((mixer *)sp[30])->amplitude[6];
  int n30_amp7 = ((mixer *)sp[30])->amplitude[7];
  int n30_mute0 = ((mixer *)sp[30])->mute_map[0];
  int n30_mute1 = ((mixer *)sp[30])->mute_map[1];
  int n30_mute2 = ((mixer *)sp[30])->mute_map[2];
  int n30_mute3 = ((mixer *)sp[30])->mute_map[3];
  int n30_mute4 = ((mixer *)sp[30])->mute_map[4];
  int n30_mute5 = ((mixer *)sp[30])->mute_map[5];
  int n30_mute6 = ((mixer *)sp[30])->mute_map[6];
  int n30_mute7 = ((mixer *)sp[30])->mute_map[7];

  for (i = 0; i < TBASS_BUFF_SIZE; i++) {
    seq_off++;
    if (seq_off >= seq_spb) {
      sequencer->current_step++;
      if (sequencer->current_step >= sequencer->length)
        sequencer->current_step = 0;
      sequencer->callback(sequencer->current_step);
      seq_off -= seq_spb;
      el = sequencer->event_map[sequencer->current_step];
      for (j=0; j < el->length; j++) {
        event *e = el->events[j];
        e->fire(e, sequencer->victims[e->seq_handle]);
      }
    }

    if (((raw_wave *)sp[0])->current_index >= n0_length)
      samp0 = 0;
    else {
      n0_ci_f = modf(((raw_wave *)sp[0])->current_index, &n0_ci_w);
      n0_s1 = n0_table[(int)n0_ci_w];
      n0_s2 = n0_table[(int)n0_ci_w +1];
      ((raw_wave *)sp[0])->current_index += n0_pitch;
      samp0 = (n0_s2 - n0_s1) * n0_ci_f + n0_s1;
    }

    if (((raw_wave *)sp[1])->current_index >= n1_length)
      samp1 = 0;
    else {
      n1_ci_f = modf(((raw_wave *)sp[1])->current_index, &n1_ci_w);
      n1_s1 = n1_table[(int)n1_ci_w];
      n1_s2 = n1_table[(int)n1_ci_w +1];
      ((raw_wave *)sp[1])->current_index += n1_pitch;
      samp1 = (n1_s2 - n1_s1) * n1_ci_f + n1_s1;
    }

    if (((raw_wave *)sp[2])->current_index >= n2_length)
      samp2 = 0;
    else {
      n2_ci_f = modf(((raw_wave *)sp[2])->current_index, &n2_ci_w);
      n2_s1 = n2_table[(int)n2_ci_w];
      n2_s2 = n2_table[(int)n2_ci_w +1];
      ((raw_wave *)sp[2])->current_index += n2_pitch;
      samp2 = (n2_s2 - n2_s1) * n2_ci_f + n2_s1;
    }

    if (((raw_wave *)sp[3])->current_index >= n3_length)
      samp3 = 0;
    else {
      n3_ci_f = modf(((raw_wave *)sp[3])->current_index, &n3_ci_w);
      n3_s1 = n3_table[(int)n3_ci_w];
      n3_s2 = n3_table[(int)n3_ci_w +1];
      ((raw_wave *)sp[3])->current_index += n3_pitch;
      samp3 = (n3_s2 - n3_s1) * n3_ci_f + n3_s1;
    }

    if (((raw_wave *)sp[4])->current_index >= n4_length)
      samp4 = 0;
    else {
      n4_ci_f = modf(((raw_wave *)sp[4])->current_index, &n4_ci_w);
      n4_s1 = n4_table[(int)n4_ci_w];
      n4_s2 = n4_table[(int)n4_ci_w +1];
      ((raw_wave *)sp[4])->current_index += n4_pitch;
      samp4 = (n4_s2 - n4_s1) * n4_ci_f + n4_s1;
    }

    samp5 = n5_table[n5_i + n5_phase_factor];
    n5_i += n5_freq + (n5_freq * n5_freq_offset) / MAX_FREQ_OFFSET;
    if (n5_i + n5_phase_factor >= RATE)
      n5_i = n5_i + n5_phase_factor - RATE;

    samp6 = n6_table[n6_i + n6_phase_factor];
    n6_i += n6_freq + (n6_freq * n6_freq_offset) / MAX_FREQ_OFFSET;
    if (n6_i + n6_phase_factor >= RATE)
      n6_i = n6_i + n6_phase_factor - RATE;

    samp7 = n7_table[n7_i + n7_phase_factor];
    n7_i += n7_freq + (n7_freq * n7_freq_offset) / MAX_FREQ_OFFSET;
    if (n7_i + n7_phase_factor >= RATE)
      n7_i = n7_i + n7_phase_factor - RATE;

    samp8 = (samp5 * n8_strength0 / n8_blend) + (samp6 * n8_strength1 / n8_blend) + (samp7 * n8_strength2 / n8_blend);

    if (((env *)sp[9])->current_index < n9_attack)
      samp9 = (SAMPLE_MAX - ((env *)sp[9])->start)  * ((env *)sp[9])->current_index / n9_attack + ((env *)sp[9])->start;
    else if (((env *)sp[9])->current_index < (n9_attack + n9_release))
      samp9 = -SAMPLE_MAX * (((env *)sp[9])->current_index - n9_attack) / n9_release + SAMPLE_MAX;
    else
      samp9 = 0;
    ((env *)sp[9])->current_index++;

    filter_set_coeffs((filter *)sp[10], n10_fc *
                      (samp9 * (SAMPLE_MAX - LIMIT) / SAMPLE_MAX + LIMIT) /
                      SAMPLE_MAX, n10_Q);
    n10_s = filter_process_sample((filter *)sp[10], samp8);
    if (n10_s > SAMPLE_MAX) n10_s = SAMPLE_MAX;
    else if (n10_s < SAMPLE_MIN) n10_s = SAMPLE_MIN;
    samp10 = n10_s;

    if (((env *)sp[11])->current_index < n11_attack)
      samp11 = ((SAMPLE_MAX - ((env *)sp[11])->start)  * ((env *)sp[11])->current_index /
           n11_attack + ((env *)sp[11])->start) * samp10 / SAMPLE_MAX;
    else if (((env *)sp[11])->current_index < (n11_attack + n11_release))
      samp11 = (-SAMPLE_MAX * (((env *)sp[11])->current_index - n11_attack) / n11_release + SAMPLE_MAX) *
           samp10 / SAMPLE_MAX;
    else
      samp11 = 0;
    ((env *)sp[11])->current_index++;

    if(n12_mute0 > 0)
	 n12_amp0 = 0;
if(n12_mute1 > 0)
	 n12_amp1 = 0;
if(n12_mute2 > 0)
	 n12_amp2 = 0;
if(n12_mute3 > 0)
	 n12_amp3 = 0;
if(n12_mute4 > 0)
	 n12_amp4 = 0;
if(n12_mute5 > 0)
	 n12_amp5 = 0;

    samp12 = (samp0 * n12_amp0 / MIX_MAX_AMP) + (samp1 * n12_amp1 / MIX_MAX_AMP) + (samp2 * n12_amp2 / MIX_MAX_AMP) + (samp3 * n12_amp3 / MIX_MAX_AMP) + (samp4 * n12_amp4 / MIX_MAX_AMP) + (samp11 * n12_amp5 / MIX_MAX_AMP);

    if (n13_i >= n13_size)
      n13_i = 0;
    samp13 = n13_buf[n13_i];
    n13_buf[n13_i] = samp12 + n13_buf[n13_i] * n13_feedback / MAX_FEEDBACK;
    n13_i++;

    if (n14_i >= n14_size)
      n14_i = 0;
    samp14 = n14_buf[n14_i];
    n14_buf[n14_i] = samp13 + n14_buf[n14_i] * n14_feedback / MAX_FEEDBACK;
    n14_i++;

    if (n15_i >= n15_size)
      n15_i = 0;
    samp15 = n15_buf[n15_i];
    n15_buf[n15_i] = samp14 + n15_buf[n15_i] * n15_feedback / MAX_FEEDBACK;
    n15_i++;

    if(n16_mute0 > 0)
	 n16_amp0 = 0;
if(n16_mute1 > 0)
	 n16_amp1 = 0;
if(n16_mute2 > 0)
	 n16_amp2 = 0;

    samp16 = (samp13 * n16_amp0 / MIX_MAX_AMP) + (samp14 * n16_amp1 / MIX_MAX_AMP) + (samp15 * n16_amp2 / MIX_MAX_AMP);

    samp17 = samp16;

    if(n18_mute0 > 0)
	 n18_amp0 = 0;
if(n18_mute1 > 0)
	 n18_amp1 = 0;
if(n18_mute2 > 0)
	 n18_amp2 = 0;
if(n18_mute3 > 0)
	 n18_amp3 = 0;
if(n18_mute4 > 0)
	 n18_amp4 = 0;
if(n18_mute5 > 0)
	 n18_amp5 = 0;

    samp18 = (samp0 * n18_amp0 / MIX_MAX_AMP) + (samp1 * n18_amp1 / MIX_MAX_AMP) + (samp2 * n18_amp2 / MIX_MAX_AMP) + (samp3 * n18_amp3 / MIX_MAX_AMP) + (samp4 * n18_amp4 / MIX_MAX_AMP) + (samp11 * n18_amp5 / MIX_MAX_AMP);

    if (n19_i >= n19_size)
      n19_i = 0;
    samp19 = n19_buf[n19_i];
    n19_buf[n19_i] = samp18 + n19_buf[n19_i] * n19_feedback / MAX_FEEDBACK;
    n19_i++;

    if (n20_i >= n20_size)
      n20_i = 0;
    samp20 = n20_buf[n20_i];
    n20_buf[n20_i] = samp18 + n20_buf[n20_i] * n20_feedback / MAX_FEEDBACK;
    n20_i++;

    if (n21_i >= n21_size)
      n21_i = 0;
    samp21 = n21_buf[n21_i];
    n21_buf[n21_i] = samp18 + n21_buf[n21_i] * n21_feedback / MAX_FEEDBACK;
    n21_i++;

    if (n22_i >= n22_size)
      n22_i = 0;
    samp22 = n22_buf[n22_i];
    n22_buf[n22_i] = samp18 + n22_buf[n22_i] * n22_feedback / MAX_FEEDBACK;
    n22_i++;

    if (n23_i >= n23_size)
      n23_i = 0;
    samp23 = n23_buf[n23_i];
    n23_buf[n23_i] = samp18 + n23_buf[n23_i] * n23_feedback / MAX_FEEDBACK;
    n23_i++;

    if (n24_i >= n24_size)
      n24_i = 0;
    samp24 = n24_buf[n24_i];
    n24_buf[n24_i] = samp18 + n24_buf[n24_i] * n24_feedback / MAX_FEEDBACK;
    n24_i++;

    if(n25_mute0 > 0)
	 n25_amp0 = 0;
if(n25_mute1 > 0)
	 n25_amp1 = 0;
if(n25_mute2 > 0)
	 n25_amp2 = 0;
if(n25_mute3 > 0)
	 n25_amp3 = 0;
if(n25_mute4 > 0)
	 n25_amp4 = 0;
if(n25_mute5 > 0)
	 n25_amp5 = 0;

    samp25 = (samp19 * n25_amp0 / MIX_MAX_AMP) + (samp20 * n25_amp1 / MIX_MAX_AMP) + (samp21 * n25_amp2 / MIX_MAX_AMP) + (samp22 * n25_amp3 / MIX_MAX_AMP) + (samp23 * n25_amp4 / MIX_MAX_AMP) + (samp24 * n25_amp5 / MIX_MAX_AMP);

    if (n26_i >= n26_size)
      n26_i = 0;
    samp26 = (long)n26_buf[n26_i] +
         (samp25 * -n26_feedback / MAX_FEEDBACK);
    n26_buf[n26_i] = samp25 + (long)n26_buf[n26_i] * n26_feedback / MAX_FEEDBACK;
    n26_i++;

    if (n27_i >= n27_size)
      n27_i = 0;
    samp27 = (long)n27_buf[n27_i] +
         (samp26 * -n27_feedback / MAX_FEEDBACK);
    n27_buf[n27_i] = samp26 + (long)n27_buf[n27_i] * n27_feedback / MAX_FEEDBACK;
    n27_i++;

    samp28 = samp27;

    if(n29_mute0 > 0)
	 n29_amp0 = 0;
if(n29_mute1 > 0)
	 n29_amp1 = 0;
if(n29_mute2 > 0)
	 n29_amp2 = 0;
if(n29_mute3 > 0)
	 n29_amp3 = 0;
if(n29_mute4 > 0)
	 n29_amp4 = 0;
if(n29_mute5 > 0)
	 n29_amp5 = 0;
if(n29_mute6 > 0)
	 n29_amp6 = 0;
if(n29_mute7 > 0)
	 n29_amp7 = 0;

    samp29 = (samp0 * n29_amp0 / MIX_MAX_AMP) + (samp1 * n29_amp1 / MIX_MAX_AMP) + (samp2 * n29_amp2 / MIX_MAX_AMP) + (samp3 * n29_amp3 / MIX_MAX_AMP) + (samp4 * n29_amp4 / MIX_MAX_AMP) + (samp11 * n29_amp5 / MIX_MAX_AMP) + (samp17 * n29_amp6 / MIX_MAX_AMP) + (samp28 * n29_amp7 / MIX_MAX_AMP);

    if(n30_mute0 > 0)
	 n30_amp0 = 0;
if(n30_mute1 > 0)
	 n30_amp1 = 0;
if(n30_mute2 > 0)
	 n30_amp2 = 0;
if(n30_mute3 > 0)
	 n30_amp3 = 0;
if(n30_mute4 > 0)
	 n30_amp4 = 0;
if(n30_mute5 > 0)
	 n30_amp5 = 0;
if(n30_mute6 > 0)
	 n30_amp6 = 0;
if(n30_mute7 > 0)
	 n30_amp7 = 0;

    samp30 = (samp0 * n30_amp0 / MIX_MAX_AMP) + (samp1 * n30_amp1 / MIX_MAX_AMP) + (samp2 * n30_amp2 / MIX_MAX_AMP) + (samp3 * n30_amp3 / MIX_MAX_AMP) + (samp4 * n30_amp4 / MIX_MAX_AMP) + (samp11 * n30_amp5 / MIX_MAX_AMP) + (samp17 * n30_amp6 / MIX_MAX_AMP) + (samp28 * n30_amp7 / MIX_MAX_AMP);
    if ((samp29 < CLIP) && (samp29 >-CLIP))
      buffer[2 * i] = (short)samp29;
    else if (samp29 > 0)
      buffer[2 * i] = (short)MIX_MAX_AMP-(CLIP_A/(CLIP_B+samp29));
    else
      buffer[2 * i] = (short)-(MIX_MAX_AMP-(CLIP_A/(CLIP_B-samp29)));
    if ((samp30 < CLIP) && (samp30 >-CLIP))
      buffer[2 * i + 1] = (short)samp30;
    else if (samp30 > 0)
      buffer[2 * i + 1] = (short)MIX_MAX_AMP-(CLIP_A/(CLIP_B+samp30));
    else
      buffer[2 * i + 1] = (short)-(MIX_MAX_AMP-(CLIP_A/(CLIP_B-samp30)));
  }

#if __BYTE_ORDER == __BIG_ENDIAN
  swap_endian(buffer, 2 * TBASS_BUFF_SIZE);
#endif
  write(fd, buffer, 2 * TBASS_BUFF_SIZE * sizeof(short));

  sequencer->current_sample_offset = seq_off;






  ((osc *)sp[5])->current_index = n5_i;

  ((osc *)sp[6])->current_index = n6_i;

  ((osc *)sp[7])->current_index = n7_i;






  ((delay *)sp[13])->d_index = n13_i;

  ((delay *)sp[14])->d_index = n14_i;

  ((delay *)sp[15])->d_index = n15_i;




  ((delay *)sp[19])->d_index = n19_i;

  ((delay *)sp[20])->d_index = n20_i;

  ((delay *)sp[21])->d_index = n21_i;

  ((delay *)sp[22])->d_index = n22_i;

  ((delay *)sp[23])->d_index = n23_i;

  ((delay *)sp[24])->d_index = n24_i;


  ((all_pass *)sp[26])->d_index = n26_i;

  ((all_pass *)sp[27])->d_index = n27_i;




  return 1;
}