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
|
/*
grain4.h:
Copyright (C) 1994, 1995 Allan S C Lee, John ffitch
This file is part of Csound.
The Csound Library is free software; you can redistribute it
and/or modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
Csound 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with Csound; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
*/
#define MAXVOICE 128
typedef struct {
OPDS h;
MYFLT *ar, *xamp, *ivoice, *iratio;
MYFLT *imode, *ithd, *ifn, *ipshift;
MYFLT *igskip;
MYFLT *igskip_os;
MYFLT *ilength, *kgap, *igap_os, *kgsize, *igsize_os, *iatt, *idec;
MYFLT *iseed, *ipitch1, *ipitch2, *ipitch3, *ipitch4, *ifnenv;
int32 fpnt[MAXVOICE], cnt[MAXVOICE], gskip[MAXVOICE], gap[MAXVOICE];
int32 gsize[MAXVOICE], stretch[MAXVOICE], mode[MAXVOICE];
MYFLT pshift[MAXVOICE], phs[MAXVOICE];
int16 grnd;
//int32 clock;
int32 gskip_os;
int32_t gstart, gend, glength;
MYFLT gap_os, gsize_os;
FUNC *ftp, *ftp_env;
} GRAINV4;
/*
ar - audio results
xamp - amplitude
ivoice - number of voices
iratio - ratio of the speed of the gskip pointer relative to audio sample rate.
0.5 will be half speed.
imode - +1 grain pointer move forward (same direction of the gskip pointer),
-1 backward (oppose direction fo the gskip pointer) or 0 for random
ithd - threshold, if the sample signal is smaller then ithd, it will be skiped
ifn - function table number
ipshift - pitch shift control. If ipshift set to 0, pitch will be set randomly
up and dow an octave. If ipshift set to 1, 2, 3 or 4, up to four different
pitches can be set amount all the voices set in ivoice, optional parmaters
ipitch1, ipitch2, ipitch3 and ipitch4 will be used.
igskip - initial skip from the beginning of the function table in sec.
igskip_os - gskip pointer random offset in sec, 0 will be no offset.
ilength - length of the table to be used start from igskip in sec.
kgap - gap in sec.
igap_os - gap random offset in % of the gap size, 0 will be no offset.
kgsize - grain size in sec.
igsize_os - grain size random offset in % of grain size.
iatt - attack in % of grain size.
idec - decade in % of grain size.
[iseed] - optional, seed for the random number generator, default is 0.5.
[ipitch1], [ipitch2], [ipitch3], [ipitch4] - optional, pitch shift parameter
if ipshift set to 1, 2, 3 or 4. Range: 0.1 (down 10 octave) to
10 (up 10 octave). Default value is 1, original pitch.
[ifnenv] Optional function table number to be used to generate the
shape of the rise and decade of envlop.
*/
|