~ubuntu-branches/debian/stretch/bristol/stretch

« back to all changes in this revision

Viewing changes to bristol/envelope.c

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-04-23 09:49:32 UTC
  • mfrom: (1.2.1 upstream) (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100423094932-btfvxmt11hv8dj4p
Tags: 0.60.0-4
* Switch back to deb format 1.0, bug#578693 has been fixed.
* Refresh and improvements, another attempt to fix FTBFS on
  hppa,sparc,s390.
* Drop debian/patches/02-implicit_pointer_conversion.patch patch,
  applied upstream.
* Patch to fix FTBFS on hurd-i386.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
/*
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
5
5
 *
6
6
 *
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.
11
11
 *
12
12
 *   This program is distributed in the hope that it will be useful,
15
15
 *   GNU General Public License for more details.
16
16
 *
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/>.
20
19
 *
21
20
 */
22
21
/*#define BRISTOL_DBG */
102
101
                offset = 0;
103
102
 
104
103
#ifdef BRISTOL_DBG
105
 
        printf("param(%i, %f)\n", index, value);
 
104
        printf("env param(%i, %f)\n", index, value);
106
105
#endif
107
106
 
108
107
        switch (index) {
245
244
        cgain = local->cgain;
246
245
        ob = specs->spec.io[ENV_OUT_IND].buf;
247
246
 
 
247
        /*
 
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);
 
252
         */
 
253
 
248
254
        if (voice->flags & BRISTOL_KEYOFF)
249
255
        {
250
256
                voice->flags |= BRISTOL_KEYOFFING;
267
273
                if ((voice->baudio->voicecount > 1) || (param->param[6].float_val != 0))
268
274
                        cgain = 1.0;
269
275
                local->cstate = STATE_ATTACK;
 
276
                /*
 
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).
 
282
                 *
 
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
 
291
                 * at max speed.
 
292
                 *
 
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.
 
296
                 */
 
297
                if ((~voice->flags & BRISTOL_KEYREON) &&
 
298
                        (voice->offset > 0) && (voice->offset < count))
 
299
                {
 
300
                        if (voice->baudio->midiflags & BRISTOL_MIDI_DEBUG1)
 
301
                                printf("envelope trigger offset %i frames\n", voice->offset);
 
302
 
 
303
                        memset(ob, 0.0f, voice->offset * sizeof(float));
 
304
                        ob += voice->offset;
 
305
                        count -= voice->offset;
 
306
                }
270
307
        } else if (voice->flags & BRISTOL_KEYREON)
271
308
                local->cstate = STATE_ATTACK;
272
309
 
273
310
        if (voice->flags & (BRISTOL_KEYON|BRISTOL_KEYREON))
274
311
        {
 
312
                /*
 
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);
 
316
                 */
275
317
                /* Rezero gain */
276
318
                if (param->param[6].float_val != 0)
277
319
                        cgain = 1.0;