1 #ifndef UGGAB_H
2 #define UGGAB_H
3 /*
4     uggab.h:
5 
6     Copyright (C) 1998 Gabriel Maldonado, John ffitch
7 
8     This file is part of Csound.
9 
10     The Csound Library is free software; you can redistribute it
11     and/or modify it under the terms of the GNU Lesser General Public
12     License as published by the Free Software Foundation; either
13     version 2.1 of the License, or (at your option) any later version.
14 
15     Csound is distributed in the hope that it will be useful,
16     but WITHOUT ANY WARRANTY; without even the implied warranty of
17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18     GNU Lesser General Public License for more details.
19 
20     You should have received a copy of the GNU Lesser General Public
21     License along with Csound; if not, write to the Free Software
22     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23     02110-1301 USA
24 */
25 
26 /********************************************/
27 /* wrap and mirror UGs by Gabriel Maldonado */
28 /********************************************/
29 
30 typedef struct {
31     OPDS  h;
32     MYFLT *xdest, *xsig, *xlow, *xhigh;
33 } WRAP;
34 
35 typedef struct {
36     OPDS  h;
37     MYFLT *kout, *ksig, *kthreshold, *kmode;
38     MYFLT old_sig;
39 } TRIG;
40 
41 typedef struct {
42     OPDS  h;
43     MYFLT *r, *val1, *val2, *point, *imin, *imax;
44     MYFLT point_factor;
45 } INTERPOL;
46 
47 typedef struct  {
48     OPDS        h;
49     MYFLT       *out, *amp, *freq, *ift, *iphs;
50     FUNC        *ftp;
51     int32       tablen;
52     double      tablenUPsr;
53     double      phs;
54 } POSC;
55 
56 typedef struct  {
57     OPDS        h;
58     MYFLT       *out, *amp, *freq, *kloop, *kend, *ift, *iphs;
59     FUNC        *ftp;
60     int32        tablen;
61     MYFLT       fsr;
62     double      phs, looplength;
63 } LPOSC;
64 
65 typedef struct {
66     OPDS        h;
67     MYFLT       *ar, *argums[VARGMAX];
68 } SUM;
69 
70 typedef struct {
71     OPDS        h;
72     MYFLT       *ar, *asig, *kcf, *kbw, *ord, *sep, *iflag, *iscl, *istor;
73     int32_t     scale, loop;
74     AUXCH       aux;
75     AUXCH       buffer;
76     MYFLT       *yt1, *yt2;
77 } RESONY;
78 
79 typedef struct {
80     OPDS        h;
81     MYFLT       *ar, *asig, *kincr ;
82     double      index;
83     int32       sample_index;
84     MYFLT       value;
85 } FOLD;
86 
87 typedef struct {
88         OPDS    h;
89         MYFLT   *out, *freq, *retrig, *iphase, *argums[VARGMAX];
90         MYFLT   args[VARGMAX];
91         double  phs;
92         int32_t     nsegs;
93 } LOOPSEG;
94 
95 /* Complexity of args leads to confusion */
96 typedef struct {
97   MYFLT *start;
98   MYFLT *type;
99   MYFLT *time;
100 } T3SEG;
101 
102 typedef struct {
103         OPDS    h;
104         MYFLT   *out, *freq, *retrig, *iphase;
105         T3SEG   argums[VARGMAX/3];
106         double  phs;
107         int32_t nsegs;
108 } LOOPTSEG;
109 
110 typedef struct {
111         OPDS    h;
112         MYFLT   *out, *kphase, *argums[VARGMAX];
113         MYFLT   args[VARGMAX];
114         int32_t nsegs;
115 } LOOPSEGP;
116 
117 typedef struct {  /* gab f1 */
118         OPDS    h;
119         MYFLT   *kr, *ksig, *ktime;
120         MYFLT   current_val, current_time, incr, val_incremented, old_time;
121         int32_t flag;
122 } LINETO;
123 
124 typedef struct {  /* gab f1 */
125         OPDS    h;
126         MYFLT   *kr, *ksig, *ktime, *ktrig;
127         MYFLT   current_val, current_time, incr, val_incremented, old_time;
128         int32_t flag;
129 } LINETO2;
130 
131 typedef struct {
132         OPDS    h;
133         MYFLT   *out, *AverageAmp,*AverageFreq, *randAmountAmp, *randAmountFreq;
134         MYFLT   *ampMinRate, *ampMaxRate, *cpsMinRate, *cpsMaxRate, *ifn, *iphs;
135         MYFLT   xcpsAmpRate, xcpsFreqRate;
136         double  lphs, tablenUPkr;
137         int32   tablen, phsAmpRate, phsFreqRate;
138         MYFLT   num1amp, num2amp, num1freq, num2freq, dfdmaxAmp, dfdmaxFreq;
139         FUNC    *ftp;
140 } VIBRATO;
141 
142 typedef struct {
143         OPDS    h;
144         MYFLT   *out, *AverageAmp,*AverageFreq,*ifn;
145         MYFLT   xcpsAmpRate, xcpsFreqRate;
146         double  lphs, tablenUPkr;
147         int32   tablen, phsAmpRate, phsFreqRate;
148         MYFLT   num1amp, num2amp, num1freq, num2freq, dfdmaxAmp, dfdmaxFreq;
149         FUNC    *ftp;
150 } VIBR;
151 
152 typedef struct {
153         OPDS    h;
154         MYFLT   *out, *gamp, *amp1, *cps1, *amp2, *cps2, *amp3, *cps3, *option;
155         int32_t flag;
156         int32   phs1,phs2,phs3;
157         MYFLT   num1a,num2a, dfdmax1, num1b,num2b, dfdmax2, num1c,num2c, dfdmax3;
158 } JITTER2;
159 
160 typedef struct {
161         OPDS    h;
162         MYFLT   *ar, *amp, *cpsMin, *cpsMax;
163         MYFLT   xcps;
164         int32   phs;
165         int32_t initflag;
166         MYFLT   num1, num2, dfdmax;
167 } JITTER;
168 
169 typedef struct {
170         OPDS    h;
171         MYFLT   *ar, *amp, *cpsMin, *cpsMax;
172         double  si;
173         double  phs;
174         int32_t initflag, cod;
175         MYFLT   num0, num1, num2, df0, df1,c3, c2;
176 } JITTERS;
177 
178 #define oneUp31Bit      (4.656612875245796924105750827168e-10)
179 
180 #define randGab   (MYFLT) ((double)                                       \
181         (((csound->holdrand = csound->holdrand * 214013 + 2531011) >> 1)  \
182          & 0x7fffffff) * oneUp31Bit)
183 #define BiRandGab (MYFLT) ((double)                                       \
184         (csound->holdrand = csound->holdrand * -214013 + 2531011) * oneUp31Bit)
185 
186 typedef struct  {
187         OPDS    h;
188         MYFLT   *out, *tableNum;
189         int32_t pfn;
190         FUNC    *ftp;
191 } DURAND;
192 
193 typedef struct  {
194         OPDS    h;
195         MYFLT   *out, *min, *max, *tableNum;
196         int32_t pfn;
197         FUNC    *ftp;
198 } CURAND;
199 
200 typedef struct  {
201         OPDS    h;
202         MYFLT   *out, *min, *max;
203 } RANGERAND;
204 
205 /* mode and fstval arguments added */
206 /* by Francois Pinot, jan. 2011    */
207 typedef struct {
208         OPDS    h;
209         MYFLT   *ar, *min, *max, *xcps, *mode, *fstval;
210         int16   cpscod;
211         int32   phs;
212         MYFLT   num1, num2, dfdmax;
213 } RANDOMI;
214 
215 /* mode and fstval arguments added */
216 /* by Francois Pinot, jan. 2011    */
217 typedef struct {
218         OPDS    h;
219         MYFLT   *ar, *min, *max, *xcps, *mode, *fstval;
220         int16   cpscod;
221         int32   phs;
222         MYFLT   num1;
223 } RANDOMH;
224 
225 typedef struct {
226         OPDS    h;
227         MYFLT   *ar, *rangeMin, *rangeMax, *cpsMin, *cpsMax;
228         double  si;
229         double  phs;
230         int32_t initflag, rangeMin_cod, rangeMax_cod;
231         MYFLT   num0, num1, num2, df0, df1,c3, c2;
232 } RANDOM3;
233 
234 #endif /* UGGAB_H */
235