Skip to content

Commit f57e86d

Browse files
committed
first commit of proof of concept with CV control of pitch
1 parent f5a2590 commit f57e86d

10 files changed

+1294
-0
lines changed

generate_frequency_table.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/python3
2+
3+
# A440 = midi note 69
4+
5+
MIDI_BASE_NOTE = 69 - 12
6+
7+
BASEFREQ = 440 # This is the Hz for the standard A note.
8+
NOTE = 0 # This is the note relative to the standard A. 0 = standard A itself, -1 = G# etc.
9+
STEPS_PER_OCTAVE = 12 #Normally we use 12 notes per octave.
10+
11+
PAL_PHI = 985248
12+
NTSC_PHI = 1022727 #//This is for machines with 6567R8 VIC. 6567R56A is slightly different.
13+
14+
#CONSTANT = round(pow(256,3) / NTSC_PHI,2) # //Select the constant appropriate for your machine (PAL vs NTSC).
15+
CONSTANT = pow(256,3) / PAL_PHI # //Select the constant appropriate for your machine (PAL vs NTSC).
16+
17+
print("// MIDI_BASE_NOTE of %s" % MIDI_BASE_NOTE)
18+
print("// BASEFREQ of %s" % BASEFREQ)
19+
print("// using PAL_PHI of %s" % 985248)
20+
print("// constant is %s" % CONSTANT)
21+
22+
print("double sidinote[] = {")
23+
24+
for i in range(0,127):
25+
#print("// for midi note %s" % i, end='\t')
26+
27+
# ok so first midi note is MIDI_BASE_NOTE - 69
28+
# so when i = 0 note should be -69
29+
# when i = 1 note should be -68
30+
31+
note = i - MIDI_BASE_NOTE
32+
33+
FREQ_HZ = BASEFREQ * pow(2,note/STEPS_PER_OCTAVE)
34+
35+
#print("// freq_hz is %s" % FREQ_HZ, end='\t')
36+
37+
"""SID_FREQ = round(CONSTANT * FREQ_HZ) # //Calculate SID freq for a certain note (specified in Hz).
38+
39+
if (SID_FREQ > pow(2,16)):
40+
break
41+
#print("// so SID value is %s" % SID_FREQ)
42+
print ("\t%s, // note %s freq %s" % (SID_FREQ, i, FREQ_HZ))"""
43+
44+
print ("\t%s, // note %s freq %s" % (FREQ_HZ, i, FREQ_HZ))
45+
46+
print("};")

include/README

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
This directory is intended for project header files.
3+
4+
A header file is a file containing C declarations and macro definitions
5+
to be shared between several project source files. You request the use of a
6+
header file in your project source file (C, C++, etc) located in `src` folder
7+
by including it, with the C preprocessing directive `#include'.
8+
9+
```src/main.c
10+
11+
#include "header.h"
12+
13+
int main (void)
14+
{
15+
...
16+
}
17+
```
18+
19+
Including a header file produces the same results as copying the header file
20+
into each source file that needs it. Such copying would be time-consuming
21+
and error-prone. With a header file, the related declarations appear
22+
in only one place. If they need to be changed, they can be changed in one
23+
place, and programs that include the header file will automatically use the
24+
new version when next recompiled. The header file eliminates the labor of
25+
finding and changing all the copies as well as the risk that a failure to
26+
find one copy will result in inconsistencies within a program.
27+
28+
In C, the usual convention is to give header files names that end with `.h'.
29+
It is most portable to use only letters, digits, dashes, and underscores in
30+
header file names, and at most one dot.
31+
32+
Read more about using header files in official GCC documentation:
33+
34+
* Include Syntax
35+
* Include Operation
36+
* Once-Only Headers
37+
* Computed Includes
38+
39+
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

include/ads.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "ADS1X15.h"
2+
3+
extern ADS1115 ADS;
4+
5+
void setup_ads();
6+
7+
int read_value(int channel);
8+
float read_voltage(int channel);
9+
double get_frequency_for_pitch(int pitch);
10+
int get_midi_pitch_for_voltage(float voltageFromAdc, int pitch_offset = 24);
11+
double get_frequency_for_voltage(float voltageFromAdc, int pitch_offset = 24);

include/myfreqs.h

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
// MIDI_BASE_NOTE of 57
2+
// BASEFREQ of 440
3+
// using PAL_PHI of 985248
4+
// constant is 17.02841924063789
5+
double sidinote[] = {
6+
16.351597831287414, // note 0 freq 16.351597831287414
7+
17.323914436054505, // note 1 freq 17.323914436054505
8+
18.354047994837977, // note 2 freq 18.354047994837977
9+
19.445436482630058, // note 3 freq 19.445436482630058
10+
20.601722307054366, // note 4 freq 20.601722307054366
11+
21.826764464562746, // note 5 freq 21.826764464562746
12+
23.12465141947715, // note 6 freq 23.12465141947715
13+
24.499714748859326, // note 7 freq 24.499714748859326
14+
25.956543598746574, // note 8 freq 25.956543598746574
15+
27.5, // note 9 freq 27.5
16+
29.13523509488062, // note 10 freq 29.13523509488062
17+
30.86770632850775, // note 11 freq 30.86770632850775
18+
32.70319566257483, // note 12 freq 32.70319566257483
19+
34.64782887210901, // note 13 freq 34.64782887210901
20+
36.70809598967594, // note 14 freq 36.70809598967594
21+
38.890872965260115, // note 15 freq 38.890872965260115
22+
41.20344461410875, // note 16 freq 41.20344461410875
23+
43.653528929125486, // note 17 freq 43.653528929125486
24+
46.2493028389543, // note 18 freq 46.2493028389543
25+
48.999429497718666, // note 19 freq 48.999429497718666
26+
51.91308719749314, // note 20 freq 51.91308719749314
27+
55.0, // note 21 freq 55.0
28+
58.27047018976124, // note 22 freq 58.27047018976124
29+
61.7354126570155, // note 23 freq 61.7354126570155
30+
65.40639132514966, // note 24 freq 65.40639132514966
31+
69.29565774421802, // note 25 freq 69.29565774421802
32+
73.41619197935188, // note 26 freq 73.41619197935188
33+
77.78174593052023, // note 27 freq 77.78174593052023
34+
82.4068892282175, // note 28 freq 82.4068892282175
35+
87.30705785825097, // note 29 freq 87.30705785825097
36+
92.4986056779086, // note 30 freq 92.4986056779086
37+
97.99885899543733, // note 31 freq 97.99885899543733
38+
103.82617439498628, // note 32 freq 103.82617439498628
39+
110.0, // note 33 freq 110.0
40+
116.54094037952248, // note 34 freq 116.54094037952248
41+
123.47082531403103, // note 35 freq 123.47082531403103
42+
130.8127826502993, // note 36 freq 130.8127826502993
43+
138.59131548843604, // note 37 freq 138.59131548843604
44+
146.8323839587038, // note 38 freq 146.8323839587038
45+
155.56349186104046, // note 39 freq 155.56349186104046
46+
164.81377845643496, // note 40 freq 164.81377845643496
47+
174.61411571650194, // note 41 freq 174.61411571650194
48+
184.9972113558172, // note 42 freq 184.9972113558172
49+
195.99771799087463, // note 43 freq 195.99771799087463
50+
207.65234878997256, // note 44 freq 207.65234878997256
51+
220.0, // note 45 freq 220.0
52+
233.08188075904496, // note 46 freq 233.08188075904496
53+
246.94165062806206, // note 47 freq 246.94165062806206
54+
261.6255653005986, // note 48 freq 261.6255653005986
55+
277.1826309768721, // note 49 freq 277.1826309768721
56+
293.6647679174076, // note 50 freq 293.6647679174076
57+
311.1269837220809, // note 51 freq 311.1269837220809
58+
329.6275569128699, // note 52 freq 329.6275569128699
59+
349.2282314330039, // note 53 freq 349.2282314330039
60+
369.9944227116344, // note 54 freq 369.9944227116344
61+
391.99543598174927, // note 55 freq 391.99543598174927
62+
415.3046975799451, // note 56 freq 415.3046975799451
63+
440.0, // note 57 freq 440.0
64+
466.1637615180899, // note 58 freq 466.1637615180899
65+
493.8833012561241, // note 59 freq 493.8833012561241
66+
523.2511306011972, // note 60 freq 523.2511306011972
67+
554.3652619537442, // note 61 freq 554.3652619537442
68+
587.3295358348151, // note 62 freq 587.3295358348151
69+
622.2539674441618, // note 63 freq 622.2539674441618
70+
659.2551138257398, // note 64 freq 659.2551138257398
71+
698.4564628660078, // note 65 freq 698.4564628660078
72+
739.9888454232688, // note 66 freq 739.9888454232688
73+
783.9908719634985, // note 67 freq 783.9908719634985
74+
830.6093951598903, // note 68 freq 830.6093951598903
75+
880.0, // note 69 freq 880.0
76+
932.3275230361799, // note 70 freq 932.3275230361799
77+
987.7666025122483, // note 71 freq 987.7666025122483
78+
1046.5022612023945, // note 72 freq 1046.5022612023945
79+
1108.7305239074883, // note 73 freq 1108.7305239074883
80+
1174.6590716696303, // note 74 freq 1174.6590716696303
81+
1244.5079348883237, // note 75 freq 1244.5079348883237
82+
1318.5102276514797, // note 76 freq 1318.5102276514797
83+
1396.9129257320155, // note 77 freq 1396.9129257320155
84+
1479.9776908465376, // note 78 freq 1479.9776908465376
85+
1567.981743926997, // note 79 freq 1567.981743926997
86+
1661.2187903197805, // note 80 freq 1661.2187903197805
87+
1760.0, // note 81 freq 1760.0
88+
1864.6550460723597, // note 82 freq 1864.6550460723597
89+
1975.533205024496, // note 83 freq 1975.533205024496
90+
2093.004522404789, // note 84 freq 2093.004522404789
91+
2217.4610478149766, // note 85 freq 2217.4610478149766
92+
2349.31814333926, // note 86 freq 2349.31814333926
93+
2489.0158697766474, // note 87 freq 2489.0158697766474
94+
2637.02045530296, // note 88 freq 2637.02045530296
95+
2793.825851464031, // note 89 freq 2793.825851464031
96+
2959.955381693075, // note 90 freq 2959.955381693075
97+
3135.9634878539946, // note 91 freq 3135.9634878539946
98+
3322.437580639561, // note 92 freq 3322.437580639561
99+
3520.0, // note 93 freq 3520.0
100+
3729.3100921447194, // note 94 freq 3729.3100921447194
101+
3951.066410048992, // note 95 freq 3951.066410048992
102+
4186.009044809578, // note 96 freq 4186.009044809578
103+
4434.922095629953, // note 97 freq 4434.922095629953
104+
4698.63628667852, // note 98 freq 4698.63628667852
105+
4978.031739553295, // note 99 freq 4978.031739553295
106+
5274.04091060592, // note 100 freq 5274.04091060592
107+
5587.651702928062, // note 101 freq 5587.651702928062
108+
5919.91076338615, // note 102 freq 5919.91076338615
109+
6271.926975707989, // note 103 freq 6271.926975707989
110+
6644.875161279122, // note 104 freq 6644.875161279122
111+
7040.0, // note 105 freq 7040.0
112+
7458.620184289437, // note 106 freq 7458.620184289437
113+
7902.132820097988, // note 107 freq 7902.132820097988
114+
8372.018089619156, // note 108 freq 8372.018089619156
115+
8869.844191259906, // note 109 freq 8869.844191259906
116+
9397.272573357044, // note 110 freq 9397.272573357044
117+
9956.06347910659, // note 111 freq 9956.06347910659
118+
10548.081821211836, // note 112 freq 10548.081821211836
119+
11175.303405856126, // note 113 freq 11175.303405856126
120+
11839.8215267723, // note 114 freq 11839.8215267723
121+
12543.853951415975, // note 115 freq 12543.853951415975
122+
13289.750322558246, // note 116 freq 13289.750322558246
123+
14080.0, // note 117 freq 14080.0
124+
14917.240368578874, // note 118 freq 14917.240368578874
125+
15804.265640195976, // note 119 freq 15804.265640195976
126+
16744.036179238312, // note 120 freq 16744.036179238312
127+
17739.688382519813, // note 121 freq 17739.688382519813
128+
18794.54514671409, // note 122 freq 18794.54514671409
129+
19912.12695821318, // note 123 freq 19912.12695821318
130+
21096.16364242367, // note 124 freq 21096.16364242367
131+
22350.606811712252, // note 125 freq 22350.606811712252
132+
23679.6430535446, // note 126 freq 23679.6430535446
133+
};

include/pitch_voltage_mapping.h

Whitespace-only changes.

0 commit comments

Comments
 (0)