1 /* 2 ugrw1.h: 3 4 Copyright (C) 1997 Robin Whittle 5 6 This file is part of Csound. 7 8 The Csound Library is free software; you can redistribute it 9 and/or modify it under the terms of the GNU Lesser General Public 10 License as published by the Free Software Foundation; either 11 version 2.1 of the License, or (at your option) any later version. 12 13 Csound is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with Csound; if not, write to the Free Software 20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 21 02110-1301 USA 22 */ 23 24 /* UGRW1.H */ 25 /* These files are based on Robin Whittle's 26 * ugrw1.c of 27 August 1996 27 * and ugrw1.h of 7 January 1995 28 * 29 * In February 1997, John Fitch reformatted the comments and 30 * cleaned up some code in printksset() - which was working fine 31 * but was inelegantly coded. 32 * 33 * 34 * Copyright notice - Robin Whittle 25 February 1997 35 * 36 * Documentation files, and the original .c and .h files, with more 37 * spaced out comments, are available from http://www.firstpr.com.au 38 * 39 * The code in both ugrw1 and ugrw2 is copyright Robin Whittle. 40 * Permission is granted to use this in whole or in part for any 41 * purpose, provided this copyright notice remains intact and 42 * any alterations to the source code, including comments, are 43 * clearly indicated as such. 44 */ 45 46 #include "csoundCore.h" 47 48 /* 49 * Unit generators by Robin Whittle 6 January 1996 50 * Header file containing data structures for UGRW1.C. 51 */ 52 53 /* TABLEW data structure used by all the tablew subroutines. */ 54 55 typedef struct { 56 OPDS h; 57 MYFLT *xsig; /* Input value to write to table. */ 58 MYFLT *xndx; /* Index into the table where want to write */ 59 MYFLT *xfn; /* Number of table we are writing to. */ 60 MYFLT *ixmode; /* Index mode (optional parm). 61 * 0 --> Use raw xfn and ixoff. 62 * 1 --> Use these with a range of 0 to 1 for 63 * the entire range of the table. */ 64 MYFLT *ixoff; /* Offset (opt). Fixed value to add to ndx*/ 65 MYFLT *iwgmode; /* Wrap and guard point mode (optional) 66 * 0 --> Limit indx to between 0 table len 67 * 1 --> Index wraps around modulo len 68 * 2 --> Write with 0.5 step offset, and 69 * write both 0 and guard with the 70 * same data. */ 71 72 /* Internal variable for previous state of xfn. */ 73 int32 pfn; /* Internal variable for what to multiply 74 * the ndx and ixoff by. Set to 1 or table 75 * length by tblwset() depending on ixmode. 76 */ 77 int32 xbmul; /* Internal variable for iwrap and igmode. */ 78 int iwgm; /* Internal variable for offset. */ 79 MYFLT offset; /* Pointer to data structure used to access 80 * function table. tblwset() writes this, based 81 * on the value of xfn. 82 */ 83 FUNC *ftp; 84 } TABLEW; 85 86 /* TABLENG data structure used by function tableng to return the 87 * length of the table. */ 88 89 typedef struct { 90 OPDS h; 91 MYFLT *kout; /* Output pointer */ 92 MYFLT *xfn; /* Points to the number of the table. */ 93 } TABLENG; 94 95 /* TABLEGPW data structure used by function tablegpw to write the 96 * guard point of a specified table. (No output arguments) */ 97 98 typedef struct { 99 OPDS h; 100 MYFLT *xfn; /* Points to number of table. */ 101 } TABLEGPW; 102 103 /* TABLEMIX data structure used by function tablemix. */ 104 105 typedef struct { 106 OPDS h; 107 MYFLT *dft, *doff, *len, *s1ft, *s1off, *s1g, *s2ft, *s2off, *s2g; 108 109 /* Storage to remember what the table numbers were from a previous k 110 cycle, and to store pointers to their FUNC data structures. */ 111 int pdft; /* Previous destination */ 112 int ps1ft, ps2ft; /* source function table numbers. */ 113 FUNC *funcd, *funcs1, *funcs2; 114 } TABLEMIX; 115 116 /* TABLECOPY data structure used by function tablecopy. */ 117 118 typedef struct { 119 OPDS h; 120 MYFLT *dft; /* Destination function table number. */ 121 MYFLT *sft; /* Source function table number */ 122 123 /* Storage to remember what the table numbers were from a previous k 124 cycle, and to store pointers to their FUNC data structures. */ 125 int pdft; /* Previous destination */ 126 int psft; /* source function table numbers. */ 127 FUNC *funcd, *funcs; 128 } TABLECOPY; 129 130 /* TABLERA data structure used by tablera subroutine. */ 131 132 typedef struct { 133 OPDS h; 134 MYFLT *adest; /* A rate destination */ 135 MYFLT *kfn; /* Number of table read */ 136 MYFLT *kstart; /* Index mode within table */ 137 MYFLT *koff; /* Offset to add to table index */ 138 139 /* Internal variable for previous state of xfn. */ 140 int32 pfn; /* Pointer to function table data structure */ 141 FUNC *ftp; 142 } TABLERA; 143 144 /* TABLEWA data structure used by tablewa subroutine. */ 145 146 typedef struct { 147 OPDS h; 148 MYFLT *kstart; /* Index mode within table we start reading. 149 * Note this is also an input argument. First 150 * we read it to determine where we should start 151 * writing the a rate samples. When we have 152 * finished we write to it the number of the 153 * next location which should be written. */ 154 MYFLT *kfn; /* Number of table we are reading from. */ 155 MYFLT *asig; /* a rate input signal. */ 156 MYFLT *koff; /* Offset to add to table index. */ 157 158 int32 pfn; /* Pointer to function table. */ 159 FUNC *ftp; 160 } TABLEWA; 161 162 /*****************************************************************************/ 163 /*****************************************************************************/ 164 165 /* RDTIME data structure for timek(), times(), instimset(), instimek() 166 and instimes(). */ 167 168 typedef struct { 169 OPDS h; 170 MYFLT *rslt; 171 int32 instartk; 172 } RDTIME; 173 174 /*****************************************************************************/ 175 176 /* PRINTK data structure for printk() and printkset(). */ 177 typedef struct { 178 OPDS h; 179 MYFLT *ptime; /* How much time to leave between each print*/ 180 MYFLT *val; /* Value to print */ 181 MYFLT *space; /* Spaces to insert before printing */ 182 MYFLT *named; 183 MYFLT printat, ctime; /* Time when initialised; initialised */ 184 int32 pspace; /* How many spaces to print */ 185 int initialised; /* Non zero for initialised */ 186 } PRINTK; 187 188 /* PRINTKS data structure for printks() and printksset() */ 189 typedef struct { 190 OPDS h; 191 MYFLT *ifilcod; /* File name */ 192 MYFLT *ptime; /* How much time to leave between each print */ 193 MYFLT *kvals[VARGMAX-2];/* values to print */ 194 MYFLT printat, ctime; /* Time when initialised; Cycle time */ 195 int initialised; 196 char txtstring[8192]; /* Place to store the string printed */ 197 char* old; 198 } PRINTKS; 199 200 /* an i-rate-only prints */ 201 typedef struct { 202 OPDS h; 203 MYFLT *ifilcod; /* File name */ 204 MYFLT *kvals[VARGMAX-1];/* values to print */ 205 } PRINTS; 206 /*****************************************************************************/ 207 208 /* PEAK data structure for peakk() and peaka(). */ 209 typedef struct { 210 OPDS h; 211 MYFLT *kpeakout; /* Pointer to k or a rate input variable. */ 212 MYFLT *xsigin; /* Pointer to k rate input variable which, 213 * if set to no zero, causes the ugen to 214 * clear the accumulator. */ 215 } PEAK; 216 217 typedef struct { 218 OPDS h; 219 MYFLT *val, *space, *named; 220 MYFLT oldvalue; 221 int32_t pspace; 222 } PRINTK2; 223 224 typedef struct { 225 OPDS h; 226 MYFLT *iformat; 227 MYFLT *val; 228 MYFLT oldvalue; 229 char *sarg; 230 } PRINTK3; 231 232 typedef struct { 233 OPDS h; 234 MYFLT *ndx; 235 MYFLT *dummy, dummy1; 236 } IOZ; 237 238 int instimek(CSOUND*,RDTIME *p); 239 int instimes(CSOUND*,RDTIME *p); 240 int instimset(CSOUND*,RDTIME *p); 241 //int itablecopy(CSOUND*,TABLECOPY *p); 242 //int itablegpw(CSOUND*,TABLEGPW *p); 243 //int itablemix(CSOUND*,TABLEMIX *p); 244 //int itableng(CSOUND*,TABLENG *p); 245 //int itablew(CSOUND*,TABLEW *p); 246 //int ktablew(CSOUND*,TABLEW *p); 247 //int ktablewkt(CSOUND*,TABLEW *p); 248 int peaka(CSOUND*,PEAK *p); 249 int peakk(CSOUND*,PEAK *p); 250 int printk(CSOUND*,PRINTK *p); 251 int printk2(CSOUND*,PRINTK2 *p); 252 int printk4(CSOUND*,PRINTK2 *p); 253 int printk2set(CSOUND*,PRINTK2 *p); 254 int printks(CSOUND*,PRINTKS *p); 255 int printkset(CSOUND*,PRINTK *p); 256 int printksset(CSOUND*,PRINTKS *p); 257 int printksset_S(CSOUND*,PRINTKS *p); 258 int printsset(CSOUND*,PRINTS *p); 259 int printsset_S(CSOUND*,PRINTS *p); 260 int printk3(CSOUND*,PRINTK3 *p); 261 int printk3set(CSOUND*,PRINTK3 *p); 262 263 //int tablecopy(CSOUND*,TABLECOPY *p); 264 //int tablecopyset(CSOUND*,TABLECOPY *p); 265 //int tablegpw(CSOUND*,TABLEGPW *p); 266 //int tablemix(CSOUND*,TABLEMIX *p); 267 //int tablemixset(CSOUND*,TABLEMIX *p); 268 //int tableng(CSOUND*,TABLENG *p); 269 //int tablera(CSOUND*,TABLERA *p); 270 //int tableraset(CSOUND*,TABLERA *p); 271 //int tablew(CSOUND*,TABLEW *p); 272 //int tablewa(CSOUND*,TABLEWA *p); 273 //int tablewaset(CSOUND*,TABLEWA *p); 274 //int tablewkt(CSOUND*,TABLEW *p); 275 //int tblsetw(CSOUND*,TABLEW *p); 276 //int tblsetwkt(CSOUND*,TABLEW *p); 277 int timek(CSOUND*,RDTIME *p); 278 int timesr(CSOUND*,RDTIME *p); 279 int inz(CSOUND*,IOZ *p); 280 int outz(CSOUND*,IOZ *p); 281 282