From 34f3aa9e3643ba44bfd2f7f595f6e33bc8e5b04b Mon Sep 17 00:00:00 2001 From: twobit Date: Mon, 6 Aug 2012 15:40:09 +0200 Subject: [PATCH] frequency table --- firmware/freq_table.h | 102 +++++++++++++++++++++++++++++++++++++++ synth/freq_table.h | 1 + synth/make_freq_table.py | 10 ++++ 3 files changed, 113 insertions(+) create mode 100644 firmware/freq_table.h create mode 120000 synth/freq_table.h create mode 100644 synth/make_freq_table.py diff --git a/firmware/freq_table.h b/firmware/freq_table.h new file mode 100644 index 0000000..e938d8a --- /dev/null +++ b/firmware/freq_table.h @@ -0,0 +1,102 @@ +const uint16_t freq_table[] = { +/*0x00*/ 39, +/*0x01*/ 41, +/*0x02*/ 43, +/*0x03*/ 46, +/*0x04*/ 49, +/*0x05*/ 51, +/*0x06*/ 54, +/*0x07*/ 58, +/*0x08*/ 61, +/*0x09*/ 65, +/*0x0a*/ 69, +/*0x0b*/ 73, +/*0x0c*/ 77, +/*0x0d*/ 82, +/*0x0e*/ 87, +/*0x0f*/ 92, +/*0x10*/ 97, +/*0x11*/ 103, +/*0x12*/ 109, +/*0x13*/ 115, +/*0x14*/ 122, +/*0x15*/ 130, +/*0x16*/ 137, +/*0x17*/ 145, +/*0x18*/ 154, +/*0x19*/ 163, +/*0x1a*/ 173, +/*0x1b*/ 183, +/*0x1c*/ 194, +/*0x1d*/ 206, +/*0x1e*/ 218, +/*0x1f*/ 231, +/*0x20*/ 245, +/*0x21*/ 259, +/*0x22*/ 275, +/*0x23*/ 291, +/*0x24*/ 308, +/*0x25*/ 327, +/*0x26*/ 346, +/*0x27*/ 367, +/*0x28*/ 388, +/*0x29*/ 412, +/*0x2a*/ 436, +/*0x2b*/ 462, +/*0x2c*/ 489, +/*0x2d*/ 518, +/*0x2e*/ 549, +/*0x2f*/ 582, +/*0x30*/ 617, +/*0x31*/ 653, +/*0x32*/ 692, +/*0x33*/ 733, +/*0x34*/ 777, +/*0x35*/ 823, +/*0x36*/ 872, +/*0x37*/ 924, +/*0x38*/ 979, +/*0x39*/ 1037, +/*0x3a*/ 1099, +/*0x3b*/ 1164, +/*0x3c*/ 1233, +/*0x3d*/ 1306, +/*0x3e*/ 1384, +/*0x3f*/ 1466, +/*0x40*/ 1554, +/*0x41*/ 1646, +/*0x42*/ 1744, +/*0x43*/ 1848, +/*0x44*/ 1957, +/*0x45*/ 2074, +/*0x46*/ 2197, +/*0x47*/ 2328, +/*0x48*/ 2466, +/*0x49*/ 2613, +/*0x4a*/ 2768, +/*0x4b*/ 2933, +/*0x4c*/ 3107, +/*0x4d*/ 3292, +/*0x4e*/ 3488, +/*0x4f*/ 3695, +/*0x50*/ 3915, +/*0x51*/ 4148, +/*0x52*/ 4394, +/*0x53*/ 4656, +/*0x54*/ 4933, +/*0x55*/ 5226, +/*0x56*/ 5537, +/*0x57*/ 5866, +/*0x58*/ 6215, +/*0x59*/ 6584, +/*0x5a*/ 6976, +/*0x5b*/ 7390, +/*0x5c*/ 7830, +/*0x5d*/ 8295, +/*0x5e*/ 8789, +/*0x5f*/ 9311, +/*0x60*/ 9865, +/*0x61*/ 10452, +/*0x62*/ 11073, +/*0x63*/ 11732, +}; diff --git a/synth/freq_table.h b/synth/freq_table.h new file mode 120000 index 0000000..7dad7c1 --- /dev/null +++ b/synth/freq_table.h @@ -0,0 +1 @@ +../firmware/freq_table.h \ No newline at end of file diff --git a/synth/make_freq_table.py b/synth/make_freq_table.py new file mode 100644 index 0000000..3fe4627 --- /dev/null +++ b/synth/make_freq_table.py @@ -0,0 +1,10 @@ +rate = 8000000 / (3 * 64) +offset = 50 + +print "const uint16_t freq_table[] = {" + +for i in range(100): + n = int(440.0 / rate * 2 ** ((i - offset) / 12.0) * 2 ** 16 + 0.5) + if n < 0x10000 / 2: + print "/*0x%02x*/\t%d," % (i, n) +print "};"