More work on loading and playing midi files.
[orgux.git] / instruments.h
blobff676cd89265c04ad6f0099cb74a0c642758a2d9
1 /*
2 orgux - a just-for-fun real time synth
3 Copyright (C) 2009 Evan Rinehart
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 /* configuration of instruments
22 you may combine the first eight harmonics in whatever proportions you wish
23 to make a carrier for your instrument. magnitudes are proportional, so
24 2,1,0,0,0... means two parts harmonic zero plus one part harmonic one, for
25 a total of three parts or 0.666*f_0 + 0.333*f_1. Actually the coefficients are
26 squared to compensate for lack of dynamic range (0-255).
28 you may choose sine, square, saw, triangle or noise as the basis function or
29 choose any previously defined instrument. choosing a future instrument will
30 result in an undefined instrument.
32 you may choose a frequency modulation signal the same way as you choose a basis.
33 FM_OFF is a special value to choose no FM signal. the value after the FM signal
34 is the frequency of the FM signal. The frequency is determined logarithmically
35 via F = 2^(value/8).
37 The next two values determine cutoff frequencies for the instruments low pass
38 and high pass filter. 0 deactivates the filter, otherwise F = 2^(value/8).
40 At this the the last four numbers are useless.
45 const unsigned char instr_config[128][16] = {
46 /*harmonics
47 0 1 2 3 4 5 6 7| basis FM FM_f LP HP*/
48 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},/*0*/
49 {2,1,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
50 {4,2,1,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
51 {8,4,2,1,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
53 {1,0,0,0,0,0,0,0, SQUARE_BASE, FM_OFF, 0, 0, 0,0,0,0},
54 {1,0,0,0,0,0,0,0, TRIANGLE_BASE, FM_OFF, 0, 0, 0,0,0,0},
55 {1,0,0,0,0,0,0,0, SAW_BASE, FM_OFF, 0, 0, 0,0,0,0},
56 {1,0,0,0,0,0,0,0, NOISE_BASE, FM_OFF, 0, 0, 0,0,0,0},
58 {1,0,0,0,0,0,0,0, SQUARE_BASE, FM_OFF, 0, 0, 0,0,0,0},/*8*/
59 {2,1,0,0,0,0,0,0, SQUARE_BASE, FM_OFF, 0, 0, 0,0,0,0},
60 {4,2,1,0,0,0,0,0, SQUARE_BASE, FM_OFF, 0, 0, 0,0,0,0},
61 {8,4,2,1,0,0,0,0, SQUARE_BASE, FM_OFF, 0, 0, 0,0,0,0},
63 {2,1,0,0,0,0,0,0, TRIANGLE_BASE, FM_OFF, 0, 0, 0,0,0,0},
64 {2,0,1,0,0,0,0,0, TRIANGLE_BASE, FM_OFF, 0, 0, 0,0,0,0},
65 {2,1,1,0,0,0,0,0, TRIANGLE_BASE, FM_OFF, 0, 0, 0,0,0,0},
66 {3,1,1,0,0,0,0,0, TRIANGLE_BASE, FM_OFF, 0, 0, 0,0,0,0},
68 {2,1,0,0,0,0,0,0, SAW_BASE, FM_OFF, 0, 0, 0,0,0,0},/*16*/
69 {4,0,1,0,0,0,0,0, SAW_BASE, FM_OFF, 0, 0, 0,0,0,0},
70 {4,2,1,0,0,0,0,0, SAW_BASE, FM_OFF, 0, 0, 0,0,0,0},
71 {8,2,1,0,0,0,0,0, SAW_BASE, FM_OFF, 0, 0, 0,0,0,0},
73 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
74 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
75 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
76 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
78 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},/*24*/
79 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
80 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
81 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
83 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
84 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
85 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
86 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
88 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},/*32*/
89 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
90 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
91 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
93 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
94 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
95 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
96 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
98 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},/*40*/
99 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
100 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
101 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
103 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
104 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
105 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
106 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
108 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},/*48*/
109 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
110 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
111 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
113 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
114 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
115 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
116 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
118 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},/*56*/
119 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
120 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
121 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
123 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
124 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
125 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
126 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
128 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},/*64*/
129 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
130 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
131 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
133 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
134 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
135 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
136 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
138 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},/*72*/
139 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
140 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
141 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
143 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
144 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
145 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
146 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
148 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},/*80*/
149 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
150 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
151 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
153 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
154 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
155 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
156 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
158 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},/*88*/
159 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
160 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
161 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
163 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
164 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
165 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
166 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
168 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},/*96*/
169 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
170 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
171 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
173 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
174 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
175 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
176 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
178 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},/*104*/
179 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
180 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
181 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
183 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
184 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
185 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
186 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
188 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},/*112*/
189 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
190 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
191 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
193 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
194 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
195 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
196 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
198 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},/*120*/
199 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
200 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
201 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
203 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
204 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
205 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0},
206 {1,0,0,0,0,0,0,0, SINE_BASE, FM_OFF, 0, 0, 0,0,0,0}