Skip to content

Commit

Permalink
Improve tuning even further
Browse files Browse the repository at this point in the history
Signed-off-by: Petr Horacek <[email protected]>
  • Loading branch information
phoracek committed Nov 24, 2024
1 parent e095f39 commit b51c3f2
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 130 deletions.
5 changes: 3 additions & 2 deletions eurorack/src/system/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ use daisy::audio::{self, Block, Interface};

// pub const SAMPLE_RATE: u32 = audio::FS.to_Hz();
// NOTE: The SAMPLE_RATE needs to be adjusted. Probably because the clock on
// STM32 is unable to exactly match the speed.
pub const SAMPLE_RATE: u32 = 47_810;
// STM32 is unable to exactly match the speed. With this value, it is perfectly
// in tune on A4.
pub const SAMPLE_RATE: u32 = 47_793;
pub const BLOCK_LENGTH: usize = audio::BLOCK_LENGTH;

static mut BUFFER: [(f32, f32); BLOCK_LENGTH] = [(0.0, 0.0); BLOCK_LENGTH];
Expand Down
261 changes: 133 additions & 128 deletions lib/src/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,136 +131,141 @@ pub enum Note {
G9 = 127,
}

// NOTE: Generated with Python:
// ```python
// for i in range(128):
// print("{},".format(440 * 2.0 ** ((i - 12 * 6 + 3) / 12)))
// ```
#[allow(clippy::excessive_precision)]
const FREQUENCIES: [f32; 128] = [
8.175798650097969,
8.661956936691345,
9.177023699353972,
9.722717925526148,
10.30086081896052,
10.913381877820335,
11.56232533420019,
12.249856976560608,
12.9782713778457,
13.749999553407081,
14.567617074291595,
15.433852662970274,
16.351597300195937,
17.323913873382683,
18.354047398707948,
19.445435851052295,
20.601721637921035,
21.826763755640677,
23.12465066840038,
24.49971395312121,
25.95654275569141,
27.499999106814162,
29.135234148583184,
30.86770532594056,
32.703194600391875,
34.647827746765365,
36.708094797415896,
38.89087170210459,
41.20344327584207,
43.653527511281354,
46.24930133680076,
48.99942790624242,
51.91308551138282,
54.999998213628324,
58.27046829716637,
61.73541065188112,
65.40638920078375,
69.29565549353073,
73.41618959483179,
77.78174340420918,
82.40688655168414,
87.30705502256271,
92.49860267360152,
97.99885581248483,
103.82617102276564,
109.99999642725665,
116.54093659433273,
123.47082130376224,
130.8127784015675,
138.59131098706146,
146.83237918966358,
155.56348680841836,
164.81377310336828,
174.61411004512541,
184.99720534720305,
195.99771162496967,
207.65234204553127,
219.9999928545133,
233.08187318866547,
246.94164260752447,
261.625556803135,
277.1826219741231,
293.664758379327,
311.1269736168367,
329.6275462067368,
349.22822009025066,
369.9944106944061,
391.99542324993956,
415.30468409106226,
439.9999857090266,
466.1637463773312,
493.88328521504866,
523.25111360627,
554.3652439482462,
587.329516758654,
622.2539472336734,
659.2550924134736,
698.4564401805013,
739.9888213888122,
783.9908464998791,
830.6093681821245,
879.9999714180532,
932.3274927546624,
987.7665704300973,
1046.50222721254,
1108.7304878964924,
1174.659033517308,
1244.507894467347,
1318.5101848269471,
1396.9128803610026,
1479.9776427776244,
1567.9816929997583,
1661.218736364249,
1759.9999428361064,
1864.654985509325,
1975.5331408601946,
2093.00445442508,
2217.4609757929848,
2349.318067034616,
2489.015788934694,
2637.0203696538942,
2793.8257607220053,
2959.955285555249,
3135.9633859995165,
3322.437472728498,
3519.9998856722127,
3729.30997101865,
3951.0662817203893,
4186.00890885016,
4434.9219515859695,
4698.636134069232,
4978.031577869388,
5274.0407393077885,
5587.6515214440105,
5919.910571110498,
6271.926771999033,
6644.874945456996,
7039.999771344425,
7458.6199420373,
7902.1325634407785,
8372.01781770032,
8869.843903171939,
9397.272268138464,
9956.063155738775,
10548.081478615577,
11175.303042888021,
11839.821142220995,
12543.853543998066,
8.175798915643707,
8.661957218027252,
9.177023997418988,
9.722718241315029,
10.300861153527183,
10.913382232281373,
11.562325709738575,
12.249857374429663,
12.978271799373287,
13.75,
14.567617547440307,
15.433853164253883,
16.351597831287414,
17.323914436054505,
18.354047994837977,
19.445436482630058,
20.601722307054366,
21.826764464562746,
23.12465141947715,
24.499714748859326,
25.956543598746574,
27.5,
29.13523509488062,
30.86770632850775,
32.70319566257483,
34.64782887210901,
36.70809598967594,
38.890872965260115,
41.20344461410875,
43.653528929125486,
46.2493028389543,
48.999429497718666,
51.91308719749314,
55.0,
58.27047018976124,
61.7354126570155,
65.40639132514966,
69.29565774421802,
73.41619197935188,
77.78174593052023,
82.4068892282175,
87.30705785825097,
92.4986056779086,
97.99885899543733,
103.82617439498628,
110.0,
116.54094037952248,
123.47082531403103,
130.8127826502993,
138.59131548843604,
146.8323839587038,
155.56349186104046,
164.81377845643496,
174.61411571650194,
184.9972113558172,
195.99771799087463,
207.65234878997256,
220.0,
233.08188075904496,
246.94165062806206,
261.6255653005986,
277.1826309768721,
293.6647679174076,
311.1269837220809,
329.6275569128699,
349.2282314330039,
369.9944227116344,
391.99543598174927,
415.3046975799451,
440.0,
466.1637615180899,
493.8833012561241,
523.2511306011972,
554.3652619537442,
587.3295358348151,
622.2539674441618,
659.2551138257398,
698.4564628660078,
739.9888454232688,
783.9908719634985,
830.6093951598903,
880.0,
932.3275230361799,
987.7666025122483,
1046.5022612023945,
1108.7305239074883,
1174.6590716696303,
1244.5079348883237,
1318.5102276514797,
1396.9129257320155,
1479.9776908465376,
1567.981743926997,
1661.2187903197805,
1760.0,
1864.6550460723597,
1975.533205024496,
2093.004522404789,
2217.4610478149766,
2349.31814333926,
2489.0158697766474,
2637.02045530296,
2793.825851464031,
2959.955381693075,
3135.9634878539946,
3322.437580639561,
3520.0,
3729.3100921447194,
3951.066410048992,
4186.009044809578,
4434.922095629953,
4698.63628667852,
4978.031739553295,
5274.04091060592,
5587.651702928062,
5919.91076338615,
6271.926975707989,
6644.875161279122,
7040.0,
7458.620184289437,
7902.132820097988,
8372.018089619156,
8869.844191259906,
9397.272573357044,
9956.06347910659,
10548.081821211836,
11175.303405856126,
11839.8215267723,
12543.853951415975,
];

#[allow(non_upper_case_globals)]
Expand Down

0 comments on commit b51c3f2

Please sign in to comment.