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
|
/*
ugnorman.h:
Copyright 2004 Alex Norman
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
*/
/* ats-csound version 0.1
* Mon May 10 19:44:46 PDT 2004
* header file for all of the ATScsound functions by Alex Norman
*/
#include "stdopcod.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
typedef struct atsdataloc {
double amp;
double freq;
} ATS_DATA_LOC;
typedef struct _randiats { /* the data for the randi UG */
int32_t size; /* size of the frame in samples this should be sr/freq. */
int32_t cnt; /* sample position counter */
int32 a1; /* first amplitude value */
int32 a2; /* next amplitude value */
} RANDIATS;
typedef struct _atsnzaux {
double buf[25];
MYFLT phaseinc[25];
MYFLT nfreq[25];
RANDIATS randinoise[25];
} atsnzAUX;
typedef struct atsstruct {
double magic; /* ats magic number */
double sampr; /* sampling rate */
double frmsz; /* frame size in samples */
double winsz; /* window size in samples */
double npartials; /* number of partials */
double nfrms; /* number of frames */
double ampmax; /* max amplitude */
double freqmax; /* max frequency */
double dur; /* duration seconds */
double type; /* Ats Frame type 1-4 */
} ATSSTRUCT;
typedef struct _atsinfo {
OPDS h;
/* the return value, the ats file and a location selection */
MYFLT *ireturn, *ifileno, *ilocation;
} ATSINFO;
/* structures to pass data to the opcodes */
typedef struct _atsread {
OPDS h;
/* outputs (2) and inputs */
MYFLT *kfreq, *kamp, *ktimpnt, *ifileno, *ipartial;
/* indicates the maximun frame */
int32_t maxFr;
/* a flag used to indicate if we've steped out of the time range */
/* of the data, so we do not print too many warnings */
int32_t prFlg;
/* points to the start of the data */
double *datastart;
/* tells the location of the partal to output */
/* and the number of doubles to increment to get to the next frame */
int32_t partialloc, frmInc;
MEMFIL *atsmemfile;
double timefrmInc;
/* indicates if the data file is byte swapped or not */
int32_t swapped;
} ATSREAD;
typedef struct _atsreadnz {
OPDS h;
MYFLT *kenergy, *ktimpnt, *ifileno, *inzbin; /* outputs (1) and inputs */
int32_t maxFr;
/* a flag used to indicate if we've steped out of the time range */
/* of the data, so we do not print too many warnings */
int32_t prFlg;
double *datastart; /* points to the start of the data */
int32_t nzbandloc, frmInc;
MEMFIL *atsmemfile;
double timefrmInc;
int32_t swapped; /* indicates if the data file is byte swapped or not */
} ATSREADNZ;
typedef struct _atsadd {
OPDS h;
/* audio output and k & i inputs */
MYFLT *aoutput, *ktimpnt, *kfmod, *ifileno, *ifn, *iptls;
/* optional arguments */
MYFLT *iptloffset, *iptlincr, *igatefun;
/* pointer to table with wave to synthesize sound */
FUNC *ftp, *AmpGateFunc;
AUXCH auxch;
MEMFIL *atsmemfile;
double maxFr;
/* a flag used to indicate if we've steped out of the time range */
/* of the data, so we do not print too many warnings */
int32_t prFlg;
double timefrmInc;
double MaxAmp; /* maximum amplitude in anaylsis file */
int32_t firstpartial, partialinc, frmInc;
double *datastart;
double *oscphase; /* oscillator phase */
ATS_DATA_LOC *buf;
int32_t swapped; /* indicates if the data file is byte swapped or not */
MYFLT *oldamps;
} ATSADD;
typedef struct _atsaddnz {
OPDS h;
/* audio output and k & i inputs */
MYFLT *aoutput, *ktimpnt, *ifileno, *ibands;
/* optional arguments */
MYFLT *ibandoffset, *ibandincr;
MEMFIL *atsmemfile; /* a pointer into the ATS file */
double maxFr;
int32_t prFlg;
int32_t frmInc; /* amount to increment frame pointer to get to next frame */
double timefrmInc;
double winsize; /* size of windows in analysis file, used to */
/* compute RMS amplitude from energy in noise band */
double *datastart;
double buf[25]; /* stores band information for passing data */
double phaseinc[25]; /* to create an array of noise */
double oscphase[25]; /* the phase of all the oscilators */
RANDIATS randinoise[25]; /* pointer to the interpolated random noise info */
double nfreq[25];
int32_t firstband;
int32_t swapped; /* indicates if the data file is byte swapped or not */
int32_t bands, bandoffset, bandincr;
ATSSTRUCT atshead;
} ATSADDNZ;
struct _atsbufread {
OPDS h;
MYFLT *ktimpnt, *kfmod, *ifileno, *iptls;
MYFLT *iptloffset, *iptlincr; /* optional arguments */
MEMFIL *mfp;
int32_t maxFr, prFlg;
/* base Frame (in frameData0) and maximum frame on file, ptr to fr, size */
AUXCH auxch;
ATS_DATA_LOC *table; /* store freq and amp info for later use */
ATS_DATA_LOC *utable; /* store freq and amp info for later use (unsorted) */
int32_t frmInc; /* amount to increment frame pointer to get to next frame */
int32_t firstpartial; /* location of first wanted partial in the frame */
int32_t partialinc; /* amount to increment pointer by */
/* to get at the next partial in a frame */
double timefrmInc;
MYFLT MaxAmp; /* maximum amplitude in anaylsis file */
double *datastart; /* pointer to the data (past the header) */
ATSSTRUCT atshead;
int32_t swapped; /* indicates if the data file is byte swapped or not */
};
typedef struct _atscross {
OPDS h;
/* audio output and k & i inputs */
MYFLT *aoutput, *ktimpnt, *kfmod, *ifileno, *ifn;
MYFLT *kmyamp, *katsbufamp, *iptls;
/* optional arguments */
MYFLT *iptloffset, *iptlincr, *igatefun, *kthresh;
/* pointer to table with wave to synthesize sound */
FUNC *ftp, *AmpGateFunc;
AUXCH auxch;
MEMFIL *atsmemfile;
double maxFr;
/* a flag used to indicate if we've steped out of the time range */
/* of the data, so we do not print too many warnings */
int32_t prFlg;
double timefrmInc;
double MaxAmp; /* maximum amplitude in anaylsis file */
int32_t firstpartial, partialinc, frmInc;
double *datastart;
double *oscphase; /* oscillator phase */
ATS_DATA_LOC *buf;
int32_t swapped; /* indicates if the data file is byte swapped or not */
MYFLT *oldamps;
} ATSCROSS; /* modified from atsadd */
typedef struct _atssinnoi {
OPDS h;
/* audio output and k & i inputs */
MYFLT *aoutput, *ktimpnt, *ksinamp, *knzamp, *kfreq, *ifileno, *iptls;
/* optional arguments */
MYFLT *iptloffset, *iptlincr, *igatefun;
MEMFIL *atsmemfile; /* a pointer into the ATS file */
AUXCH auxch;
double maxFr;
int32_t prFlg;
int32_t nzmemsize;
/* double winsize; */ /* size of windows in analysis file, used to */
/* compute RMS amplitude from energy in noise band */
double *datastart;
double *nzdata;
int32_t firstpartial;
int32_t partialinc;
int32_t firstband;
int32_t frmInc; /* amount to increment frame pointer to get to next frame */
double timefrmInc;
int32_t npartials;
ATS_DATA_LOC *oscbuf; /* stores band information for passing data */
double *nzbuf; /* stores band information for passing data */
double *oscphase; /* the phase of all the oscilators */
RANDIATS *randinoise; /* a pointer to the interpolated random noise info */
ATSSTRUCT *atshead;
char *filename;
int32_t swapped; /* indicates if the data file is byte swapped or not */
double noiphase[25];
double phaseinc[25];
} ATSSINNOI;
typedef struct _atspartialtap {
OPDS h;
MYFLT *kfreq, *kamp, *iparnum; /* out: freq, amp, in: partialnumber */
} ATSPARTIALTAP;
typedef struct _atsinterpread {
OPDS h;
MYFLT *kamp, *kfreq; /* output amp, input: frequency */
int32_t overflowflag;
} ATSINTERPREAD;
|