SHOW:
|
|
- or go back to the newest paste.
1 | using UnityEngine; | |
2 | using System.Collections; | |
3 | ||
4 | // put together by @S0phieH http://pastebin.com/epcCxrAE | |
5 | // pitch frequencies from: | |
6 | // http://www.phy.mtu.edu/~suits/notefreqs.html | |
7 | ||
8 | public class Pitches { | |
9 | public static double GetPitch(Notes note){ | |
10 | switch (note){ | |
11 | case Notes.C0: | |
12 | return 16.35; | |
13 | case Notes.CSHARP0: | |
14 | return 17.32; | |
15 | case Notes.D0: | |
16 | return 18.35; | |
17 | case Notes.DSHARP0: | |
18 | return 19.45; | |
19 | case Notes.E0: | |
20 | return 20.60; | |
21 | case Notes.F0: | |
22 | return 21.83; | |
23 | case Notes.FSHARP0: | |
24 | return 23.12; | |
25 | case Notes.G0: | |
26 | return 24.50; | |
27 | case Notes.GSHARP0: | |
28 | return 25.96; | |
29 | case Notes.A0: | |
30 | return 27.50; | |
31 | case Notes.ASHARP0: | |
32 | return 29.14; | |
33 | case Notes.B0: | |
34 | return 30.87; | |
35 | ||
36 | ||
37 | case Notes.C1: | |
38 | return 32.70; | |
39 | case Notes.CSHARP1: | |
40 | return 34.65; | |
41 | case Notes.D1: | |
42 | return 36.71; | |
43 | case Notes.DSHARP1: | |
44 | return 38.89; | |
45 | case Notes.E1: | |
46 | return 41.20; | |
47 | case Notes.F1: | |
48 | return 43.65; | |
49 | case Notes.FSHARP1: | |
50 | return 46.25; | |
51 | case Notes.G1: | |
52 | return 49.00; | |
53 | case Notes.GSHARP1: | |
54 | return 51.91; | |
55 | case Notes.A1: | |
56 | return 55.00; | |
57 | case Notes.ASHARP1: | |
58 | return 58.27; | |
59 | case Notes.B1: | |
60 | return 61.74; | |
61 | ||
62 | ||
63 | case Notes.C2: | |
64 | return 65.41; | |
65 | case Notes.CSHARP2: | |
66 | return 69.30; | |
67 | case Notes.D2: | |
68 | return 73.42; | |
69 | case Notes.DSHARP2: | |
70 | return 77.78; | |
71 | case Notes.E2: | |
72 | return 82.41; | |
73 | case Notes.F2: | |
74 | return 87.31; | |
75 | case Notes.FSHARP2: | |
76 | return 92.50; | |
77 | case Notes.G2: | |
78 | return 98.00; | |
79 | case Notes.GSHARP2: | |
80 | return 103.83; | |
81 | case Notes.A2: | |
82 | return 110.00; | |
83 | case Notes.ASHARP2: | |
84 | return 116.54; | |
85 | case Notes.B2: | |
86 | return 123.47; | |
87 | ||
88 | ||
89 | case Notes.C3: | |
90 | return 130.81; | |
91 | case Notes.CSHARP3: | |
92 | return 138.59; | |
93 | case Notes.D3: | |
94 | return 146.83; | |
95 | case Notes.DSHARP3: | |
96 | return 155.56; | |
97 | case Notes.E3: | |
98 | return 164.81; | |
99 | case Notes.F3: | |
100 | return 174.61; | |
101 | case Notes.FSHARP3: | |
102 | return 185.00; | |
103 | case Notes.G3: | |
104 | return 196.00; | |
105 | case Notes.GSHARP3: | |
106 | return 207.65; | |
107 | case Notes.A3: | |
108 | return 220.00; | |
109 | case Notes.ASHARP3: | |
110 | return 233.08; | |
111 | case Notes.B3: | |
112 | return 246.94; | |
113 | ||
114 | ||
115 | case Notes.C4: | |
116 | return 261.63; | |
117 | case Notes.CSHARP4: | |
118 | return 277.18; | |
119 | case Notes.D4: | |
120 | return 293.66; | |
121 | case Notes.DSHARP4: | |
122 | return 311.13; | |
123 | case Notes.E4: | |
124 | return 329.63; | |
125 | case Notes.F4: | |
126 | return 349.23; | |
127 | case Notes.FSHARP4: | |
128 | return 369.99; | |
129 | case Notes.G4: | |
130 | return 392.00; | |
131 | case Notes.GSHARP4: | |
132 | return 415.30; | |
133 | case Notes.A4: | |
134 | return 440.00; | |
135 | case Notes.ASHARP4: | |
136 | return 466.16; | |
137 | case Notes.B4: | |
138 | return 493.88; | |
139 | ||
140 | ||
141 | case Notes.C5: | |
142 | return 523.25; | |
143 | case Notes.CSHARP5: | |
144 | return 554.37; | |
145 | case Notes.D5: | |
146 | return 587.33; | |
147 | case Notes.DSHARP5: | |
148 | return 622.25; | |
149 | case Notes.E5: | |
150 | return 659.25; | |
151 | case Notes.F5: | |
152 | return 698.46; | |
153 | case Notes.FSHARP5: | |
154 | return 739.99; | |
155 | case Notes.G5: | |
156 | return 783.99; | |
157 | case Notes.GSHARP5: | |
158 | return 830.61; | |
159 | case Notes.A5: | |
160 | return 880.00; | |
161 | case Notes.ASHARP5: | |
162 | return 932.33; | |
163 | case Notes.B5: | |
164 | return 987.77; | |
165 | ||
166 | ||
167 | case Notes.C6: | |
168 | return 1046.50; | |
169 | case Notes.CSHARP6: | |
170 | return 1108.73; | |
171 | case Notes.D6: | |
172 | return 1174.66; | |
173 | case Notes.DSHARP6: | |
174 | return 1244.51; | |
175 | case Notes.E6: | |
176 | return 1318.51; | |
177 | case Notes.F6: | |
178 | return 1396.91; | |
179 | case Notes.FSHARP6: | |
180 | return 1479.98; | |
181 | case Notes.G6: | |
182 | return 1567.98; | |
183 | case Notes.GSHARP6: | |
184 | return 1661.22; | |
185 | case Notes.A6: | |
186 | return 1760.00; | |
187 | case Notes.ASHARP6: | |
188 | return 1864.66; | |
189 | case Notes.B6: | |
190 | return 1975.53; | |
191 | ||
192 | ||
193 | case Notes.C7: | |
194 | return 2093.00; | |
195 | case Notes.CSHARP7: | |
196 | return 2217.46; | |
197 | case Notes.D7: | |
198 | return 2349.32; | |
199 | case Notes.DSHARP7: | |
200 | return 2489.02; | |
201 | case Notes.E7: | |
202 | return 2637.02; | |
203 | case Notes.F7: | |
204 | return 2793.83; | |
205 | case Notes.FSHARP7: | |
206 | return 2959.96; | |
207 | case Notes.G7: | |
208 | return 3135.96; | |
209 | case Notes.GSHARP7: | |
210 | return 3322.44; | |
211 | case Notes.A7: | |
212 | return 3520.00; | |
213 | case Notes.ASHARP7: | |
214 | return 3729.31; | |
215 | case Notes.B7: | |
216 | return 3951.07; | |
217 | ||
218 | ||
219 | case Notes.C8: | |
220 | return 4186.01; | |
221 | case Notes.CSHARP8: | |
222 | return 4434.92; | |
223 | case Notes.D8: | |
224 | return 4698.63; | |
225 | case Notes.DSHARP8: | |
226 | return 4978.03; | |
227 | case Notes.E8: | |
228 | return 5274.04; | |
229 | case Notes.F8: | |
230 | return 5587.65; | |
231 | case Notes.FSHARP8: | |
232 | return 5919.91; | |
233 | case Notes.G8: | |
234 | return 6271.93; | |
235 | case Notes.GSHARP8: | |
236 | return 6644.88; | |
237 | case Notes.A8: | |
238 | return 7040.00; | |
239 | case Notes.ASHARP8: | |
240 | return 7458.62; | |
241 | case Notes.B8: | |
242 | return 7902.13; | |
243 | } | |
244 | return 440.00; //A | |
245 | } | |
246 | ||
247 | } | |
248 | public enum Notes{ | |
249 | C0 = 0, | |
250 | CSHARP0 = 1, | |
251 | DFLAT0 = 1, | |
252 | D0 = 2, | |
253 | DSHARP0 = 3, | |
254 | EFLAT0 = 3, | |
255 | E0 = 4, | |
256 | F0 = 5, | |
257 | FSHARP0 = 6, | |
258 | GFLAT0 = 6, | |
259 | G0 = 7, | |
260 | GSHARP0 = 8, | |
261 | AFLAT0 = 8, | |
262 | A0 = 9, | |
263 | ASHARP0 = 10, | |
264 | BFLAT0 = 10, | |
265 | B0 = 11, | |
266 | ||
267 | C1 = 12, | |
268 | CSHARP1 = 13, | |
269 | DFLAT1 = 13, | |
270 | D1 = 14, | |
271 | DSHARP1 = 15, | |
272 | EFLAT1 = 15, | |
273 | E1 = 16, | |
274 | F1 = 17, | |
275 | FSHARP1 = 18, | |
276 | GFLAT1 = 18, | |
277 | G1 = 19, | |
278 | GSHARP1 = 20, | |
279 | AFLAT1 = 20, | |
280 | A1 = 21, | |
281 | ASHARP1 = 22, | |
282 | BFLAT1 = 22, | |
283 | B1 = 23, | |
284 | ||
285 | C2 = 24, | |
286 | CSHARP2 = 25, | |
287 | DFLAT2 = 25, | |
288 | D2 = 26, | |
289 | DSHARP2 = 27, | |
290 | EFLAT2 = 27, | |
291 | E2 = 28, | |
292 | F2 = 29, | |
293 | FSHARP2 = 30, | |
294 | GFLAT2 = 30, | |
295 | G2 = 31, | |
296 | GSHARP2 = 32, | |
297 | AFLAT2 = 32, | |
298 | A2 = 33, | |
299 | ASHARP2 = 34, | |
300 | BFLAT2 = 34, | |
301 | B2 = 35, | |
302 | ||
303 | C3 = 36, | |
304 | CSHARP3 = 37, | |
305 | DFLAT3 = 37, | |
306 | D3 = 38, | |
307 | DSHARP3 = 39, | |
308 | EFLAT3 = 39, | |
309 | E3 = 40, | |
310 | F3 = 41, | |
311 | FSHARP3 = 42, | |
312 | GFLAT3 = 42, | |
313 | G3 = 43, | |
314 | GSHARP3 = 44, | |
315 | AFLAT3 = 44, | |
316 | A3 = 45, | |
317 | ASHARP3 = 46, | |
318 | BFLAT3 = 46, | |
319 | B3 = 47, | |
320 | ||
321 | C4 = 48, | |
322 | CSHARP4 = 49, | |
323 | DFLAT4 = 49, | |
324 | D4 = 50, | |
325 | DSHARP4 = 51, | |
326 | EFLAT4 = 51, | |
327 | E4 = 52, | |
328 | F4 = 53, | |
329 | FSHARP4 = 54, | |
330 | GFLAT4 = 54, | |
331 | G4 = 55, | |
332 | GSHARP4 = 56, | |
333 | AFLAT4 = 56, | |
334 | A4 = 57, | |
335 | ASHARP4 = 58, | |
336 | BFLAT4 = 58, | |
337 | B4 = 59, | |
338 | ||
339 | C5 = 60, | |
340 | CSHARP5 = 61, | |
341 | DFLAT5 = 61, | |
342 | D5 = 62, | |
343 | DSHARP5 = 63, | |
344 | EFLAT5 = 63, | |
345 | E5 = 64, | |
346 | F5 = 65, | |
347 | FSHARP5 = 66, | |
348 | GFLAT5 = 66, | |
349 | G5 = 67, | |
350 | GSHARP5 = 68, | |
351 | AFLAT5 = 68, | |
352 | A5 = 69, | |
353 | ASHARP5 = 70, | |
354 | BFLAT5 = 70, | |
355 | B5 = 71, | |
356 | ||
357 | C6 = 72, | |
358 | CSHARP6 = 73, | |
359 | DFLAT6 = 73, | |
360 | D6 = 74, | |
361 | DSHARP6 = 75, | |
362 | EFLAT6 = 75, | |
363 | E6 = 76, | |
364 | F6 = 77, | |
365 | FSHARP6 = 78, | |
366 | GFLAT6 = 78, | |
367 | G6 = 79, | |
368 | GSHARP6 = 80, | |
369 | AFLAT6 = 80, | |
370 | A6 = 81, | |
371 | ASHARP6 = 82, | |
372 | BFLAT6 = 82, | |
373 | B6 = 83, | |
374 | ||
375 | C7 = 84, | |
376 | CSHARP7 = 85, | |
377 | DFLAT7 = 85, | |
378 | D7 = 86, | |
379 | DSHARP7 = 87, | |
380 | EFLAT7 = 87, | |
381 | E7 = 88, | |
382 | F7 = 89, | |
383 | FSHARP7 = 90, | |
384 | GFLAT7 = 90, | |
385 | G7 = 91, | |
386 | GSHARP7 = 92, | |
387 | AFLAT7 = 92, | |
388 | A7 = 93, | |
389 | ASHARP7 = 94, | |
390 | BFLAT7 = 94, | |
391 | B7 = 95, | |
392 | ||
393 | C8 = 96, | |
394 | CSHARP8 = 97, | |
395 | DFLAT8 = 97, | |
396 | D8 = 98, | |
397 | DSHARP8 = 99, | |
398 | EFLAT8 = 99, | |
399 | E8 = 100, | |
400 | F8 = 101, | |
401 | FSHARP8 = 102, | |
402 | GFLAT8 = 102, | |
403 | G8 = 103, | |
404 | GSHARP8 = 104, | |
405 | AFLAT8 = 104, | |
406 | A8 = 105, | |
407 | ASHARP8 = 106, | |
408 | BFLAT8 = 106, | |
409 | B8 = 107, | |
410 | } |