File: pitch.h

package info (click to toggle)
csound 1%3A6.18.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 63,220 kB
  • sloc: ansic: 192,643; cpp: 14,149; javascript: 9,654; objc: 9,181; python: 3,376; java: 3,337; sh: 1,840; yacc: 1,255; xml: 985; perl: 635; lisp: 411; tcl: 341; lex: 217; makefile: 128
file content (325 lines) | stat: -rw-r--r-- 9,474 bytes parent folder | download | duplicates (5)
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
#ifndef PITCH_H
#define PITCH_H
/*
    pitch.h:

    Copyright (C) 1999 John ffitch, Istvan Varga, Peter Neubcker,
                       rasmus ekman, Phil Burk

    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
*/

                        /*                                      PITCH.H */
#include "spectra.h"
#include "uggab.h"

typedef struct {
        OPDS    h;
        MYFLT   *koct, *kamp;
        MYFLT   *asig;
        MYFLT   *iprd, *ilo, *ihi, *idbthresh;
                                /* Optional */
        MYFLT   *ifrqs, *iconf, *istrt, *iocts, *iq, *inptls, *irolloff, *istor;
        double  c1, c2, prvq;
#define MAXFRQS 120
        SPECDAT wsig;
        int32_t     nfreqs, ncoefs, dbout, scountdown, timcount;
        MYFLT   curq, *sinp, *cosp, *linbufp;
        int32_t     winlen[MAXFRQS], offset[MAXFRQS];
        DOWNDAT downsig;
        WINDAT  sinwindow, octwindow;
        AUXCH   auxch1, auxch2;
        int32_t     pdist[MAXPTL], nptls, rolloff;
        MYFLT   pmult[MAXPTL], confact, kvalsav, kval, kavl, kinc, kanc;
        MYFLT   *flop, *fhip, *fundp, *oct0p, threshon, threshoff;
        int32_t     winpts, jmpcount, playing;
        SPECDAT wfund;
} PITCH;

typedef struct {
        OPDS    h;
        MYFLT   *cnt;
        void    *clk;
        int32_t     c;
} CLOCK;

typedef struct {
        OPDS    h;
        MYFLT   *r;
        MYFLT   *a;
        void    *clk;
} CLKRD;

typedef struct {
        OPDS    h;
        MYFLT   *val;
        MYFLT   *index;
} SCRATCHPAD;

typedef struct {
        OPDS    h;
        MYFLT   *ins;
        MYFLT   *onoff;
} MUTE;

typedef struct {
        OPDS    h;
        MYFLT   *cnt;
        MYFLT   *ins;
        MYFLT   *opt;
        MYFLT   *norel;
} INSTCNT;

typedef struct {
    OPDS        h;
    MYFLT       *instrnum, *ipercent, *iopc;    /* IV - Oct 31 2002 */
} CPU_PERC;

typedef struct {
    OPDS    h;
    MYFLT   *sr, *kamp, *kcps, *ifn, *ifreqtbl, *iamptbl, *icnt, *iphs;
    FUNC    *ftp;
    FUNC    *freqtp;
    FUNC    *amptp;
    uint32_t     count;
    int32_t     inerr;
    AUXCH   lphs;
} ADSYNT;

typedef struct {
    OPDS        h;
    MYFLT       *sr, *kamp, *ktona, *kbrite, *ibasef, *ifn;
    MYFLT       *imixtbl, *ioctcnt, *iphs;
    int32       lphs[10];
    int32_t         octcnt;
    MYFLT       prevamp;
    FUNC        *ftp;
    FUNC        *mixtp;
} HSBOSC;

typedef struct {
    OPDS    h;
    MYFLT   *kcps, *krms, *asig, *imincps, *imaxcps, *icps,
            *imedi, *idowns, *iexcps, *irmsmedi;
    MYFLT   srate;
    MYFLT   lastval;
    int32   downsamp;
    int32   upsamp;
    int32   minperi;
    int32   maxperi;
    int32   index;
    int32   readp;
    int32   size;
    int32   peri;
    int32   medisize;
    int32   mediptr;
    int32   rmsmedisize;
    int32   rmsmediptr;
    int32_t     inerr;
    AUXCH   median;
    AUXCH   rmsmedian;
    AUXCH   buffer;
} PITCHAMDF;

typedef struct {
        OPDS    h;
        MYFLT   *sr, *xcps, *kindx, *icnt, *iphs;
        AUXCH   curphs;
} PHSORBNK;

/* pinkish opcode... Two methods for generating pink noise */

/* Gardner method space req */
#define GRD_MAX_RANDOM_ROWS   (32)

typedef struct {
    OPDS        h;
    MYFLT       *aout;
    MYFLT       *xin, *imethod, *iparam1, *iseed, *iskip;
    int32       ampinc;         /* Scale output to range */
    uint32      randSeed;     /* Used by local random generator */
                                /* for Paul Kellet's filter bank */
    double      b0, b1, b2, b3, b4, b5, b6;
                                /* for Gardner method */
    int32       grd_Rows[GRD_MAX_RANDOM_ROWS];
    int32       grd_NumRows;    /* Number of rows (octave bands of noise) */
    int32       grd_RunningSum; /* Used to optimize summing of generators. */
    int32_t         grd_Index;      /* Incremented each sample. */
    int32_t         grd_IndexMask;  /* Index wrapped by ANDing with this mask. */
    MYFLT       grd_Scalar;     /* Used to scale to normalize generated noise. */
} PINKISH;

typedef struct {
        OPDS    h;
        MYFLT   *aout;
        MYFLT   *ain, *imethod, *limit, *iarg;
        MYFLT   arg, lim, k1, k2;
        int32_t     meth;
} CLIP;

typedef struct {
        OPDS    h;
        MYFLT   *ar;
        MYFLT   *amp, *freq, *offset;
        uint32_t     next;
} IMPULSE;

typedef struct {
        int32   cnt,acnt;
        MYFLT   alpha;
        MYFLT   val, nxtpt;
        MYFLT   c1;
} NSEG;

typedef struct {
        OPDS    h;
        MYFLT   *rslt, *argums[VARGMAX];
        NSEG    *cursegp;
        int32   nsegs;
        int32   segsrem, curcnt;
        MYFLT   curval, curinc, alpha;
        MYFLT   curx;
        AUXCH   auxch;
        int32   xtra;
        MYFLT   finalval, lastalpha;
} TRANSEG;

typedef struct {
        OPDS    h;
        MYFLT   *rslt, *kamp, *beta;
        MYFLT   last, lastbeta, sq1mb2, ampmod;
        int32_t     ampinc;
} VARI;

typedef struct {
        OPDS    h;
        MYFLT   *ar, *ain, *fco, *res, *dist, *istor;
        MYFLT   ay1, ay2, aout, lastin;
} LPF18;

typedef struct {
        OPDS    h;
        MYFLT   *ar, *ain, *rep, *len;
        AUXCH   auxch;
        int32_t     length;         /* Length of buffer */
        int32_t     cnt;            /* Repetions of current cycle */
        int32_t     start;          /* Start of current cycle */
        int32_t     current;        /* takeout point */
        int32_t     direction;      /* Need to check direction of crossing */
        int32_t     end;            /* Insert point */
        MYFLT   lastsamp;       /* So we can test changes */
        int32_t     noinsert;       /* Flag to say we are losing input */
} BARRI;

typedef struct {
        OPDS    h;
        MYFLT   *sr, *xamp, *xcps, *ifn, *iphs;
        MYFLT   lphs;
        FUNC    *ftp;
} XOSC;

typedef struct {
        OPDS    h;
        MYFLT   *ans;
        MYFLT   *pnum;
} PFUN;

typedef struct {
        OPDS    h;
        MYFLT   *ans;
        MYFLT   *pnum;
        AUXCH   pfield;
} PFUNK;

typedef struct {
        OPDS    h;
        MYFLT   *ans;
        MYFLT   *asig;
        MYFLT   *kwind;
        MYFLT   *imaxsize;
        MYFLT   *iskip;
        AUXCH   b;
        MYFLT   *buff;
        MYFLT   *med;
        int32_t     ind;
        int32_t     maxwind;
} MEDFILT;

int32_t Foscaa(CSOUND *, XOSC *p);
int32_t Foscak(CSOUND *, XOSC *p);
int32_t Foscka(CSOUND *, XOSC *p);
int32_t Fosckk(CSOUND *, XOSC *p);
int32_t Foscset(CSOUND *, XOSC *p);
int32_t GardnerPink_init(CSOUND *, PINKISH *p);
int32_t GardnerPink_perf(CSOUND *, PINKISH *p);
int32_t adsynt(CSOUND *, ADSYNT *p);
int32_t adsyntset(CSOUND *, ADSYNT *p);
int32_t clip(CSOUND *, CLIP *p);
int32_t clip_set(CSOUND *, CLIP *p);
int32_t clockoff(CSOUND *, CLOCK *p);
int32_t clockon(CSOUND *, CLOCK *p);
int32_t clockread(CSOUND *, CLKRD *p);
int32_t clockset(CSOUND *, CLOCK *p);
int32_t scratchread(CSOUND *, SCRATCHPAD *p);
int32_t scratchwrite(CSOUND *, SCRATCHPAD *p);
int32_t cpuperc(CSOUND *, CPU_PERC *p);
int32_t cpuperc_S(CSOUND *, CPU_PERC *p);
int32_t hsboscil(CSOUND *, HSBOSC *p);
int32_t hsboscset(CSOUND *, HSBOSC *p);
int32_t impulse(CSOUND *, IMPULSE *p);
int32_t impulse_set(CSOUND *, IMPULSE *p);
int32_t instcount(CSOUND *, INSTCNT *p);
int32_t instcount_S(CSOUND *, INSTCNT *p);
int32_t totalcount(CSOUND *, INSTCNT *p);
int32_t kphsorbnk(CSOUND *, PHSORBNK *p);
int32_t ktrnseg(CSOUND *, TRANSEG *p);
int32_t ktrnsegr(CSOUND *csound, TRANSEG *p);
int32_t lpf18db(CSOUND *, LPF18 *p);
int32_t lpf18set(CSOUND *, LPF18 *p);
int32_t mac(CSOUND *, SUM *p);
int32_t maca(CSOUND *, SUM *p);
int32_t macset(CSOUND *, SUM *p);
int32_t maxalloc(CSOUND *, CPU_PERC *p);
int32_t mute_inst(CSOUND *, MUTE *p);
int32_t maxalloc_S(CSOUND *, CPU_PERC *p);
int32_t mute_inst_S(CSOUND *, MUTE *p);
int32_t pfun(CSOUND *, PFUN *p);
int32_t pfunk_init(CSOUND *, PFUNK *p);
int32_t pfunk(CSOUND *, PFUNK *p);
int32_t phsbnkset(CSOUND *, PHSORBNK *p);
int32_t phsorbnk(CSOUND *, PHSORBNK *p);
int32_t pinkish(CSOUND *, PINKISH *p);
int32_t pinkset(CSOUND *, PINKISH *p);
int32_t pitch(CSOUND *, PITCH *p);
int32_t pitchamdf(CSOUND *, PITCHAMDF *p);
int32_t pitchamdfset(CSOUND *, PITCHAMDF *p);
int32_t pitchset(CSOUND *, PITCH *p);
int32_t trnseg(CSOUND *, TRANSEG *p);
int32_t trnsegr(CSOUND *csound, TRANSEG *p);
int32_t trnset(CSOUND *, TRANSEG *p);
int32_t trnset_bkpt(CSOUND *, TRANSEG *p);
int32_t trnsetr(CSOUND *csound, TRANSEG *p);
int32_t varicol(CSOUND *, VARI *p);
int32_t varicolset(CSOUND *, VARI *p);
int32_t waveset(CSOUND *, BARRI *p);
int32_t wavesetset(CSOUND *, BARRI *p);
int32_t medfiltset(CSOUND *, MEDFILT *p);
int32_t medfilt(CSOUND *, MEDFILT *p);
int32_t kmedfilt(CSOUND *, MEDFILT *p);
#endif /* PITCH_H */