3
3
* Diverse Bristol audio routines.
4
* Copyright (c) by Nick Copeland <nickycopeland@hotmail.com> 1996,2009
4
* Copyright (c) by Nick Copeland <nickycopeland@hotmail.com> 1996,2010
7
7
* This program is free software; you can redistribute it and/or modify
8
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
9
* the Free Software Foundation; either version 3 of the License, or
10
10
* (at your option) any later version.
12
12
* This program is distributed in the hope that it will be useful,
15
15
* GNU General Public License for more details.
17
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
* along with this program; if not, see <http://www.gnu.org/licenses/>.
22
21
/*#define BRISTOL_DBG */
104
103
#ifdef BRISTOL_DBG
105
printf("param(%i, %f)\n", index, value);
104
printf("env param(%i, %f)\n", index, value);
245
244
cgain = local->cgain;
246
245
ob = specs->spec.io[ENV_OUT_IND].buf;
248
* The offsets are only provided once so if we have it then it's function is
249
* actually similar to note_off. Anyway.
250
if ((voice->offset >= 0) && (voice->flags & BRISTOL_KEYOFF))
251
printf("%i: env off offset %i\n", voice->key.key, voice->offset);
248
254
if (voice->flags & BRISTOL_KEYOFF)
250
256
voice->flags |= BRISTOL_KEYOFFING;
267
273
if ((voice->baudio->voicecount > 1) || (param->param[6].float_val != 0))
269
275
local->cstate = STATE_ATTACK;
277
* This is for Jack Sample Accurate support. It is a compromise as I am
278
* not a great fan of the feature: the envelope will delay its attack
279
* event by the number of frames indicated in the voice offset, that
280
* offset is taken from the Jack event (it is zero for all other bristol
281
* MIDI interface drivers).
283
* State changes will not be sample accurate in the first version - they
284
* are more work as the current operation has to continue until the time
285
* of the event. Note off is not such a big deal as having a bit of
286
* decay will mask out the exact point of the note. One consideration is
287
* application to REON event but a REON is going to be masked by the
288
* current output anyway. Since all these events are related to Jack
289
* then NOTE_OFF and REON are still accurate to the period, ie, they
290
* will behave consistently across different plays and when mastering
293
* Features other than envelope sync (and the existing LFO sync) are
294
* not likely to get considered - this is an analogue emulator and I
295
* don't really want things like general oscillator sync.
297
if ((~voice->flags & BRISTOL_KEYREON) &&
298
(voice->offset > 0) && (voice->offset < count))
300
if (voice->baudio->midiflags & BRISTOL_MIDI_DEBUG1)
301
printf("envelope trigger offset %i frames\n", voice->offset);
303
memset(ob, 0.0f, voice->offset * sizeof(float));
305
count -= voice->offset;
270
307
} else if (voice->flags & BRISTOL_KEYREON)
271
308
local->cstate = STATE_ATTACK;
273
310
if (voice->flags & (BRISTOL_KEYON|BRISTOL_KEYREON))
313
* This accepts note on offsets from Jack. Note off offsets will be
314
* based on period size for now.
315
printf("%i: env on offset %i\n", voice->key.key, voice->offset);
275
317
/* Rezero gain */
276
318
if (param->param[6].float_val != 0)