File: bristolprophet1.c

package info (click to toggle)
bristol 0.60.10-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 15,652 kB
  • sloc: ansic: 124,457; sh: 10,579; makefile: 111
file content (642 lines) | stat: -rw-r--r-- 18,849 bytes parent folder | download | duplicates (3)
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
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642

/*
 *  Diverse Bristol audio routines.
 *  Copyright (c) by Nick Copeland <nickycopeland@hotmail.com> 1996,2012
 *
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, see <http://www.gnu.org/licenses/>.
 *
 */
/*#define DEBUG */

#include "bristol.h"
#include "bristolmm.h"
#include "bristolprophet1.h"

/*
 * Use of these pro1 global buffers will be an issue with use of multiple
 * audio threads, unless we ensure a single thread deals with any given algo
 * type, since then they are only used sequencially.
 *
 * These should really be hidden in the pMods structure for multiple instances.
 */
static float *freqbuf = (float *) NULL;
static float *tfreqbuf = (float *) NULL;
static float *lfobuf = (float *) NULL;
static float *wmodbuf = (float *) NULL;
static float *dmodbuf = (float *) NULL;
static float *adsrbuf = (float *) NULL;
static float *filtbuf = (float *) NULL;
static float *noisebuf = (float *) NULL;
static float *oscbbuf = (float *) NULL;
static float *oscabuf = (float *) NULL;
static float *scratchbuf = (float *) NULL;

static float *tribuf = (float *) NULL;
static float *sqrbuf = (float *) NULL;
static float *rampbuf = (float *) NULL;

extern int s440holder;

int
pro1Controller(Baudio *baudio, u_char operator, u_char controller,
float value)
{
	int ivalue = value * CONTROLLER_RANGE;

#ifdef DEBUG
	printf("bristolPro1Control(%i, %i, %f) %i\n", operator, controller, value,
		ivalue);
#endif

	if (operator != 126)
		return(0);

	switch (controller) {
		case 0:
			baudio->glide = value * value * baudio->glidemax;
			break;
		case 2:
			baudio->gtune = 1.0
				+ (baudio->note_diff - 1)
				* (value * 2 - 1);

			buildCurrentTable(baudio, baudio->gtune);
			alterAllNotes(baudio);
			break;
		case 3:
			if (ivalue == 0)
				baudio->mixflags &= ~P1_FE_WHEEL;
			else
				baudio->mixflags |= P1_FE_WHEEL;
			break;
		case 4:
			((pmods *) baudio->mixlocals)->oscbmod = value;
			break;
		case 5:
			if (ivalue == 0)
				baudio->mixflags &= ~P1_OSCB_WHEEL;
			else
				baudio->mixflags |= P1_OSCB_WHEEL;
			break;
		case 6:
			((pmods *) baudio->mixlocals)->lfomod = value;
			break;
		case 7:
			if (ivalue == 0)
				baudio->mixflags &= ~P1_LFO_WHEEL;
			else
				baudio->mixflags |= P1_LFO_WHEEL;
			break;
		case 8:
			if (ivalue == 0)
				baudio->mixflags &= ~BRISTOL_GLIDE_AUTO;
			else
				baudio->mixflags |= BRISTOL_GLIDE_AUTO;
			break;
		case 9:
			if (ivalue == 0)
				baudio->mixflags &= ~P1_REPEAT;
			else
				baudio->mixflags |= P1_REPEAT;
			break;

		case 10:
			baudio->mixflags &= ~(P1_OSCA_F_WM|P1_OSCA_F_DM);
			if (ivalue == 2)
				baudio->mixflags |= P1_OSCA_F_WM;
			else if (ivalue == 0)
				baudio->mixflags |= P1_OSCA_F_DM;
			break;
		case 11:
			baudio->mixflags &= ~(P1_OSCA_PW_WM|P1_OSCA_PW_DM);
			if (ivalue == 2)
				baudio->mixflags |= P1_OSCA_PW_WM;
			else if (ivalue == 0)
				baudio->mixflags |= P1_OSCA_PW_DM;
			break;
		case 12:
			baudio->mixflags &= ~(P1_OSCB_F_WM|P1_OSCB_F_DM);
			if (ivalue == 2)
				baudio->mixflags |= P1_OSCB_F_WM;
			else if (ivalue == 0)
				baudio->mixflags |= P1_OSCB_F_DM;
			break;
		case 13:
			baudio->mixflags &= ~(P1_OSCB_PW_WM|P1_OSCB_PW_DM);
			if (ivalue == 2)
				baudio->mixflags |= P1_OSCB_PW_WM;
			else if (ivalue == 0)
				baudio->mixflags |= P1_OSCB_PW_DM;
			break;
		case 14:
			baudio->mixflags &= ~(P1_FILT_WM|P1_FILT_DM);
			if (ivalue == 2)
				baudio->mixflags |= P1_FILT_WM;
			else if (ivalue == 0)
				baudio->mixflags |= P1_FILT_DM;
			break;

		case 18:
			if (ivalue == 0)
				baudio->mixflags &= ~P1_LFO_B;
			else
				baudio->mixflags |= P1_LFO_B;
			break;
		case 19:
			if (ivalue == 0)
				baudio->mixflags &= ~P1_KBD_B;
			else
				baudio->mixflags |= P1_KBD_B;
			break;

		case 20:
			((pmods *) baudio->mixlocals)->mix_a = value * 32;
			break;
		case 21:
			((pmods *) baudio->mixlocals)->mix_b = value * 32;
			break;
		case 22:
			((pmods *) baudio->mixlocals)->mix_n = value * 32;
			break;
		case 23:
			((pmods *) baudio->mixlocals)->f_envlevel = value;
			break;
		case 24:
			if (ivalue == 0)
				baudio->mixflags &= ~P1_LFO_RAMP;
			else
				baudio->mixflags |= P1_LFO_RAMP;
			break;
		case 25:
			if (ivalue == 0)
				baudio->mixflags &= ~P1_LFO_TRI;
			else
				baudio->mixflags |= P1_LFO_TRI;
			break;
		case 26:
			if (ivalue == 0)
				baudio->mixflags &= ~P1_LFO_SQR;
			else
				baudio->mixflags |= P1_LFO_SQR;
			break;
		case 27:
			if (ivalue == 0)
				baudio->mixflags &= ~BRISTOL_MULTITRIG;
			else
				baudio->mixflags |= BRISTOL_MULTITRIG;
		case 28:
			if (ivalue == 0)
				baudio->mixflags &= ~P1_DRONE;
			else
				baudio->mixflags |= P1_DRONE;
			break;
	}
	return(0);
}

/*
 * Preops will do noise, and one oscillator - the LFO.
 */
int
operatePro1Preops(audioMain *audiomain, Baudio *baudio,
bristolVoice *voice, register float *startbuf)
{
	register int samplecount = audiomain->samplecount;

#ifdef DEBUG
	if ((audiomain->debuglevel & BRISTOL_DEBUG_MASK) > BRISTOL_DEBUG5)
		printf("operatePro1Preops(%x, %x, %x) %i\n",
			baudio, voice, startbuf, baudio->cvoices);
#endif

	bristolbzero(lfobuf, audiomain->segmentsize);
	bristolbzero(noisebuf, audiomain->segmentsize);
	bristolbzero(wmodbuf, audiomain->segmentsize);

	/*
	 * Third oscillator. We do this first, since it may be used to modulate
	 * the first two oscillators. No mods on LFO - wmodbuf is zeros at moment.
	 */
	audiomain->palette[(*baudio->sound[2]).index]->specs->io[0].buf = NULL;
	audiomain->palette[(*baudio->sound[2]).index]->specs->io[1].buf = tribuf;
	audiomain->palette[(*baudio->sound[2]).index]->specs->io[2].buf = sqrbuf;
	audiomain->palette[(*baudio->sound[2]).index]->specs->io[3].buf = NULL;
	audiomain->palette[(*baudio->sound[2]).index]->specs->io[4].buf = lfobuf;
	audiomain->palette[(*baudio->sound[2]).index]->specs->io[5].buf = rampbuf;

	/*
	 * Operate oscillator 3. LFO...
	 */
	(*baudio->sound[2]).operate(
		(audiomain->palette)[16],
		voice,
		(*baudio->sound[2]).param,
		baudio->locals[voice->index][2]);

	/* Now mix according to the LFO flags: */
	if (baudio->mixflags & (P1_LFO_SQR|P1_LFO_RAMP|P1_LFO_TRI))
	{
		bristolbzero(lfobuf, audiomain->segmentsize);
		if (baudio->mixflags & P1_LFO_TRI)
			bufmerge(tribuf, 12.0, lfobuf, 1.0, samplecount);
		if (baudio->mixflags & P1_LFO_SQR)
			bufmerge(sqrbuf, 12.0, lfobuf, 1.0, samplecount);
		if (baudio->mixflags & P1_LFO_RAMP)
			bufmerge(rampbuf, 12.0, lfobuf, 1.0, samplecount);
	} else
		/*
		 * If there were no flags then put a bit more gain into the LFO buffer
		 * which contains a sine wave.
		 */
		bufmerge(tribuf, 0.0, lfobuf, 12.0, samplecount);
/* LFO OVER */

	return(0);
}

int
operateOnePro1(audioMain *audiomain, Baudio *baudio,
bristolVoice *voice, register float *startbuf)
{
	register int samplecount = audiomain->samplecount, i;
	register float *bufptr;

	/*
	 * We need to run through every bristolSound on the baudio sound chain.
	 * We need to pass the correct set of parameters to each operator, and
	 * ensure they get the correct local variable set.
	 */
	bufptr = freqbuf;

	bristolbzero(freqbuf, audiomain->segmentsize);
	bristolbzero(dmodbuf, audiomain->segmentsize);
	bristolbzero(wmodbuf, audiomain->segmentsize);
	bristolbzero(adsrbuf, audiomain->segmentsize);
	bristolbzero(filtbuf, audiomain->segmentsize);
	bristolbzero(oscabuf, audiomain->segmentsize);

/* NOISE - This should go in a poly call.... */
	/*
	 * Noise - we do this early for the same reason as oscillator 3
	 */
	audiomain->palette[(*baudio->sound[7]).index]->specs->io[0].buf = noisebuf;
	(*baudio->sound[7]).operate(
		(audiomain->palette)[4],
		voice,
		(*baudio->sound[7]).param,
		voice->locals[voice->index][7]);
/* NOISE OVER */

	if ((baudio->mixflags & BRISTOL_MULTITRIG) == 0)
		voice->flags &= ~BRISTOL_KEYREON;
	if (baudio->mixflags & P1_DRONE)
		voice->flags &= ~BRISTOL_KEYOFF;

/* ADSR - POLY MOD */
	/*
	 * Run the ADSR for the filter, reusing the startbuf. We need this for the
	 * mods routing.
	 */
	audiomain->palette[(*baudio->sound[3]).index]->specs->io[0].buf = adsrbuf;
	(*baudio->sound[3]).operate(
		(audiomain->palette)[1],
		voice,
		(*baudio->sound[3]).param,
		voice->locals[voice->index][3]);
/* ADSR - POLY MOD - OVER */

/* Mod bus routing */
	/*
	 * We have two mod busses, one is direct and the other is controlled by
	 * the wheel mod. We need to add flags before this can be done here but
	 * we can just fill the buffers for now (testing):
	 */
	if (baudio->mixflags & P1_FE_WHEEL)
		bufmerge(adsrbuf, baudio->contcontroller[1], wmodbuf, 0.0, samplecount);
	else
		bufmerge(adsrbuf, 1.0, dmodbuf, 0.0, samplecount);

	if (baudio->mixflags & P1_LFO_WHEEL)
		bufmerge(lfobuf,
			((pmods *) baudio->mixlocals)->lfomod * baudio->contcontroller[1],
			wmodbuf, 1.0, samplecount);
	else
		bufmerge(lfobuf, ((pmods *) baudio->mixlocals)->lfomod * 1.0,
			dmodbuf, 1.0, samplecount);

	if (baudio->voicecount == 1) {
		if (baudio->mixflags & P1_OSCB_WHEEL)
			bufmerge(oscbbuf, ((pmods *) baudio->mixlocals)->oscbmod
					* baudio->contcontroller[1], wmodbuf, 1.0, samplecount);
		else
			bufmerge(oscbbuf, ((pmods *) baudio->mixlocals)->oscbmod,
				dmodbuf, 1.0, samplecount);
	}
/* Mod bus routing done */

/* OSC B FIRST */
	/*
	 * This has to be done late since we may have to mod itself. Note that we
	 * actually need an lfobuf per voice if we want to have osc B mod itself
	 * in poly mode.
	 */
	bristolbzero(oscbbuf, audiomain->segmentsize);

	/*
	 * Second oscillator
	 */
	audiomain->palette[(*baudio->sound[1]).index]->specs->io[0].buf
		= tfreqbuf;
	audiomain->palette[(*baudio->sound[1]).index]->specs->io[1].buf
		= scratchbuf;
	audiomain->palette[(*baudio->sound[1]).index]->specs->io[2].buf
		= oscbbuf;

	/*
	 * Fill tmpbuf1 with our frequency information - should already have it
	 * done, including mods? The Second oscillator may not be doing glide, 
	 * controlled by the UNISON flag. If we do not have unison, then force 
	 * dfreq and cfreq together (temporarily?).
	 */
	fillFreqTable(baudio, voice, freqbuf, samplecount, 1);
	if (baudio->mixflags & P1_KBD_B)
		/*
		 * See if glide is in unison.
		 */
		bufmerge(freqbuf, 1.0, tfreqbuf, 0.0, samplecount);
	else {
		bufptr = tfreqbuf;

		for (i = 0; i < samplecount; i+=8)
		{
			/**bufptr++ = 0.1 + baudio->contcontroller[1] / 2; */
			*bufptr++ = 0.1;
			*bufptr++ = 0.1;
			*bufptr++ = 0.1;
			*bufptr++ = 0.1;
			*bufptr++ = 0.1;
			*bufptr++ = 0.1;
			*bufptr++ = 0.1;
			*bufptr++ = 0.1;
		}
	}

	if (baudio->mixflags & P1_LFO_B)
		bufmerge(tfreqbuf, 0.0, tfreqbuf, 0.25, samplecount);

	bristolbzero(scratchbuf, audiomain->segmentsize);

	/*
	 * This needs to be fixed however I cannot test it right now:
	 *	The ADSR should be amplified in as a function of the voice frequency
	 *	so that it is constand for every note and can then stay in tune.
	 */
#warning osc mod needs amplification by frequency
	if (baudio->mixflags & P1_OSCB_F_WM)
		bufmerge(wmodbuf, 1.0, tfreqbuf, 1.0, samplecount);
	else if (baudio->mixflags & P1_OSCB_F_DM)
		bufmerge(dmodbuf, 1.0, tfreqbuf, 1.0, samplecount);

	if (baudio->mixflags & P1_OSCB_PW_WM)
		bufmerge(wmodbuf, 24.0, scratchbuf, 0.0, samplecount);
	else if (baudio->mixflags & P1_OSCB_PW_DM)
		bufmerge(dmodbuf, 24.0, scratchbuf, 0.0, samplecount);

	/*
	 * And finally operate this oscillator
	 */
	(*baudio->sound[1]).operate(
		(audiomain->palette)[8],
		voice,
		(*baudio->sound[1]).param,
		voice->locals[voice->index][1]);
/* OSC B -DONE */

/* More mod routing for OSC-B */
	if (baudio->voicecount > 1) {
		if (baudio->mixflags & P1_OSCB_WHEEL)
			bufmerge(oscbbuf, ((pmods *) baudio->mixlocals)->oscbmod
					* baudio->contcontroller[1], wmodbuf, 1.0, samplecount);
		else
			bufmerge(oscbbuf, ((pmods *) baudio->mixlocals)->oscbmod,
				dmodbuf, 1.0, samplecount);
	}
/* Done rest of mod source routing */

/* OSC A */
	/*
	 * First insert our buffer pointers, we do this by inserting the buffers
	 * into the existing opspec structures.
	 */
	audiomain->palette[(*baudio->sound[0]).index]->specs->io[0].buf
		= freqbuf;
	audiomain->palette[(*baudio->sound[0]).index]->specs->io[1].buf
		= scratchbuf;
	audiomain->palette[(*baudio->sound[0]).index]->specs->io[2].buf
		= oscabuf;
	audiomain->palette[(*baudio->sound[0]).index]->specs->io[3].buf
		= oscbbuf;

	/*
	 * If we have any mods on the oscillators, we need to put them in here.
	 * This should be under the control of polypressure and/or
	 * channelpressure?
	 */
	if (baudio->mixflags & P1_OSCA_F_WM)
		bufmerge(wmodbuf, 1.0, freqbuf, 1.0, samplecount);
	else if (baudio->mixflags & P1_OSCA_F_DM)
		bufmerge(dmodbuf, 1.0, freqbuf, 1.0, samplecount);

	bristolbzero(scratchbuf, audiomain->segmentsize);

	if (baudio->mixflags & P1_OSCA_PW_WM)
		bufmerge(wmodbuf, 24.0, scratchbuf, 0.0, samplecount);
	else if (baudio->mixflags & P1_OSCA_PW_DM)
		bufmerge(dmodbuf, 24.0, scratchbuf, 0.0, samplecount);

	(*baudio->sound[0]).operate(
		(audiomain->palette)[8],
		voice,
		(*baudio->sound[0]).param,
		voice->locals[voice->index][0]);
/* OSC A - DONE */

	/* The mixer will normalise the signals so that the filter is driven */
	bufmerge(oscabuf, ((pmods *) baudio->mixlocals)->mix_a,
		freqbuf, 0.0, samplecount);
	bufmerge(oscbbuf, ((pmods *) baudio->mixlocals)->mix_b,
		freqbuf, 1.0, samplecount);
	bufmerge(noisebuf, ((pmods *) baudio->mixlocals)->mix_n,
		freqbuf, 1.0, samplecount);

/* FILTER */
	/* 
	 * If we have mods on the filter, apply them here. For the Xa we need to
	 * consider the 4pole option for secondary filtering.
	 */
	bristolbzero(scratchbuf, audiomain->segmentsize);

	if (baudio->mixflags & P1_FILT_WM)
		bufmerge(wmodbuf, 0.5 * ((pmods *) baudio->mixlocals)->f_envlevel,
			scratchbuf, 0.0, samplecount);
	else if (baudio->mixflags & P1_FILT_DM)
		bufmerge(dmodbuf, ((pmods *) baudio->mixlocals)->f_envlevel,
			scratchbuf, 0.0, samplecount);

	/*
	 * Run the mixed oscillators into the filter. Input and output buffers
	 * are the same.
	 */
	audiomain->palette[(*baudio->sound[4]).index]->specs->io[0].buf = freqbuf;
	audiomain->palette[(*baudio->sound[4]).index]->specs->io[1].buf =scratchbuf;
	audiomain->palette[(*baudio->sound[4]).index]->specs->io[2].buf = filtbuf;
	(*baudio->sound[4]).operate(
		(audiomain->palette)[3],
		voice,
		(*baudio->sound[4]).param,
		voice->locals[voice->index][4]);
/* FILTER - DONE */

/* FINAL STAGE */
	/*
	 * Run the ADSR for the final stage amplifier, reusing the startbuf.
	 */
	if (baudio->mixflags & P1_REPEAT)
	{
		if ((((pmods *) baudio->mixlocals)->lfohist > 0) & (lfobuf[0] <= 0))
			voice->flags |= BRISTOL_KEYREON;
	}
	((pmods *) baudio->mixlocals)->lfohist = lfobuf[0];

	audiomain->palette[(*baudio->sound[5]).index]->specs->io[0].buf = adsrbuf;
	(*baudio->sound[5]).operate(
		(audiomain->palette)[1],
		voice,
		(*baudio->sound[5]).param,
		voice->locals[voice->index][5]);
	/*
	 * Run the mixed oscillators into the amplifier. Input and output buffers
	 * are the same.
	 */
	audiomain->palette[(*baudio->sound[6]).index]->specs->io[0].buf = filtbuf;
	audiomain->palette[(*baudio->sound[6]).index]->specs->io[1].buf = adsrbuf;
	audiomain->palette[(*baudio->sound[6]).index]->specs->io[2].buf =
		baudio->leftbuf;
	(*baudio->sound[6]).operate(
		(audiomain->palette)[2],
		voice,
		(*baudio->sound[6]).param,
		voice->locals[voice->index][6]);

/* FINAL STAGE - DONE */
	return(0);
}

/* Not used */
int
operatePro1Postops(audioMain *audiomain, Baudio *baudio,
bristolVoice *voice, register float *startbuf)
{
	return(0);
}

int
bristolPro1Destroy(audioMain *audiomain, Baudio *baudio)
{
printf("removing one pro1\n");
/*
	bristolfree(freqbuf);
	bristolfree(tfreqbuf);
	bristolfree(scratchbuf);
	bristolfree(dmodbuf);
	bristolfree(adsrbuf);
	bristolfree(filtbuf);
	bristolfree(oscbbuf);
	bristolfree(oscabuf);
*/
	return(0);
}

int
bristolPro1Init(audioMain *audiomain, Baudio *baudio)
{
	printf("initialising one pro1\n");

	baudio->soundCount = 8; /* Number of operators in this voice (MM) */

	/*
	 * Assign an array of sound pointers.
	 */
	baudio->sound = (bristolSound **)
		bristolmalloc0(sizeof(bristolOP *) * baudio->soundCount);
	baudio->effect = (bristolSound **)
		bristolmalloc0(sizeof(bristolOP *) * baudio->soundCount);

	/*
	 * Two main oscillators plus LFO, two envelopes, one filter, one amp, noise
	 */
	initSoundAlgo(8, 0, baudio, audiomain, baudio->sound);
	initSoundAlgo(8, 1, baudio, audiomain, baudio->sound);
	initSoundAlgo(16, 2, baudio, audiomain, baudio->sound);
	/* An ADSR */
	initSoundAlgo(1, 3, baudio, audiomain, baudio->sound);
	/* A filter */
	initSoundAlgo(3, 4, baudio, audiomain, baudio->sound);
	/* Another ADSR */
	initSoundAlgo(1, 5, baudio, audiomain, baudio->sound);
	/* An amplifier */
	initSoundAlgo(2, 6, baudio, audiomain, baudio->sound);
	/* An noise source */
	initSoundAlgo(4, 7, baudio, audiomain, baudio->sound);

	baudio->param = pro1Controller;
	baudio->destroy = bristolPro1Destroy;
	baudio->operate = operateOnePro1;
	baudio->preops = operatePro1Preops;
/* 	baudio->postops = operatePro1Postops; */

	if (freqbuf == 0)
		freqbuf = (float *) bristolmalloc0(audiomain->segmentsize);
	if (tfreqbuf == 0)
		tfreqbuf = (float *) bristolmalloc0(audiomain->segmentsize);
	if (scratchbuf == 0)
		scratchbuf = (float *) bristolmalloc0(audiomain->segmentsize);
	if (dmodbuf == 0)
		dmodbuf = (float *) bristolmalloc0(audiomain->segmentsize);
	if (adsrbuf == 0)
		adsrbuf = (float *) bristolmalloc0(audiomain->segmentsize);
	if (filtbuf == 0)
		filtbuf = (float *) bristolmalloc0(audiomain->segmentsize);
	if (oscbbuf == 0)
		oscbbuf = (float *) bristolmalloc0(audiomain->segmentsize);
	if (oscabuf == 0)
		oscabuf = (float *) bristolmalloc0(audiomain->segmentsize);
	if (noisebuf == (float *) NULL)
		noisebuf = (float *) bristolmalloc0(audiomain->segmentsize);
	if (lfobuf == (float *) NULL)
		lfobuf = (float *) bristolmalloc0(audiomain->segmentsize);
	if (wmodbuf == (float *) NULL)
		wmodbuf = (float *) bristolmalloc0(audiomain->segmentsize);
	if (sqrbuf == (float *) NULL)
		sqrbuf = (float *) bristolmalloc0(audiomain->segmentsize);
	if (rampbuf == (float *) NULL)
		rampbuf = (float *) bristolmalloc0(audiomain->segmentsize);
	if (tribuf == (float *) NULL)
		tribuf = (float *) bristolmalloc0(audiomain->segmentsize);

	baudio->mixlocals = (float *) bristolmalloc0(sizeof(pmods));
	return(0);
}