| 1 |
/* |
| 2 |
scot.h: |
| 3 |
|
| 4 |
Copyright (C) 1991 Alan deLespinasse |
| 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 |
/* SCOT.H */ |
| 25 |
/* aldel Jul 91 */ |
| 26 |
|
| 27 |
#include <stdio.h> |
| 28 |
#include <string.h> |
| 29 |
#include <ctype.h> |
| 30 |
|
| 31 |
#ifndef TRUE |
| 32 |
#define TRUE 1 |
| 33 |
#define FALSE 0 |
| 34 |
#endif |
| 35 |
#define PITCHCLASSES 7 |
| 36 |
#define NOTESPEROCT 12 |
| 37 |
#define MAXLINE 300 |
| 38 |
#define NEXTP "!&" |
| 39 |
|
| 40 |
typedef struct |
| 41 |
{ |
| 42 |
unsigned long num,denom; |
| 43 |
} Rat; |
| 44 |
|
| 45 |
typedef struct strlist /* used for p-fields */ |
| 46 |
{ |
| 47 |
struct strlist *next; |
| 48 |
char str[32]; |
| 49 |
} Strlist; |
| 50 |
|
| 51 |
typedef struct note |
| 52 |
{ |
| 53 |
struct note *next; |
| 54 |
double instrum; |
| 55 |
Rat start, /* when note starts */ |
| 56 |
dur, /* length of note (mul by grpmul) */ |
| 57 |
lastdur; /* duration to carry to next note */ |
| 58 |
int octave, /* 8=middle c-b */ |
| 59 |
pitchclass, /* c=0, d=1, e=2... */ |
| 60 |
accid, /* -1=flat, +1=sharp, etc. */ |
| 61 |
accmod, /* TRUE if note had #,-,n modifiers */ |
| 62 |
slur, /* 0,1,2,3 */ |
| 63 |
tie, /* TRUE if note has __ after it */ |
| 64 |
written; /* TRUE when written to score */ |
| 65 |
Strlist *p, /* pfields local to this note */ |
| 66 |
*carryp; /* pfields to carry to next note */ |
| 67 |
} Note; |
| 68 |
|
| 69 |
typedef struct nextp /* keeps track of !next keywords */ |
| 70 |
{ |
| 71 |
struct nextp *next; |
| 72 |
int src,dst; /* !next psrc "pdst" */ |
| 73 |
} Nextp; |
| 74 |
|
| 75 |
typedef struct macro |
| 76 |
{ |
| 77 |
struct macro *next; |
| 78 |
char name[33],text[128]; /* [name="text..."] */ |
| 79 |
} Macro; |
| 80 |
|
| 81 |
typedef struct inst |
| 82 |
{ |
| 83 |
struct inst *next; |
| 84 |
char *name; |
| 85 |
unsigned number; |
| 86 |
Macro *lmac; /* local macros */ |
| 87 |
} Inst; |
| 88 |
|
| 89 |
typedef struct tempo |
| 90 |
{ |
| 91 |
struct tempo *next; |
| 92 |
Rat time; |
| 93 |
int val; |
| 94 |
} Tempo; |
| 95 |
|
| 96 |
#include <stdlib.h> |
| 97 |
|
| 98 |
static void readinstsec(Inst *,Nextp **, |
| 99 |
Rat *,Rat *,Rat *,Rat *,Rat *, |
| 100 |
Note **,Note **,Tempo **, |
| 101 |
int *,int *,int *,int *,int *,int*, |
| 102 |
char *); |
| 103 |
static void addparam(int,char *,Strlist **); |
| 104 |
static char *findparam(int,Strlist **); |
| 105 |
static char *readparams(Inst *); |
| 106 |
static int applymacs(char **,Inst *); |
| 107 |
static char *macval(char *,Inst *); |
| 108 |
static void initnote(Note *); |
| 109 |
static void readorch(Inst **); |
| 110 |
static void readmacros(Macro **); |
| 111 |
static void readfunctions(void); |
| 112 |
static void readscore(Inst *); |
| 113 |
static int expectchar(int); |
| 114 |
static int findint(int *); |
| 115 |
static int findchar(int *); |
| 116 |
static int findonoff(int *); |
| 117 |
static int findword(char *); |
| 118 |
static void efindword(char *); |
| 119 |
static int letterval(int); |
| 120 |
static double pitchval(int,int,int,int); |
| 121 |
static void writenote(Note *); |
| 122 |
static void freenote(Note *); |
| 123 |
static void freeps(Strlist *); |
| 124 |
static void strlistcopy(Strlist **,Strlist **); |
| 125 |
static int getccom(void); |
| 126 |
static double ratval(Rat *); |
| 127 |
static void ratreduce(Rat *); |
| 128 |
static void ratadd(Rat *,Rat *,Rat *); |
| 129 |
static void ratmul(Rat *,Rat *,Rat *); |
| 130 |
static void ratdiv(Rat *,Rat *,Rat *); |
| 131 |
static int ratcmp(Rat *,Rat *); |
| 132 |
static void ratass(Rat *,Rat *); |
| 133 |
static void scoterror(char *); |
| 134 |
static void scotferror(char *); |
| 135 |
static void initf(FILE *,FILE *,char *); |
| 136 |
static int scotgetc(void); |
| 137 |
static void scotungetc(void); |
| 138 |
static void reporterrcount(void); |
| 139 |
|