From 57b2fa6cbc56e6e6858fe6cc29699328f1c8e6d5 Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Tue, 19 Jun 2018 20:13:22 +0000 Subject: [PATCH] Lots of changes, too long ago to remember --- config.h | 4 +- config.lua | 6 +- flame.lua | 174 ++++++++++++++++++++++++++++++++++++++ flame_diffspeed.lua | 174 ++++++++++++++++++++++++++++++++++++++ lut.c | 32 +++---- main.c | 37 ++++---- pulsar.lua | 174 ++++++++++++++++++++++++++++++++++++++ pulsecircle.lua | 55 +++++++----- pulsecircle_ultrafast.lua | 100 ++++++++++++++++++++++ pulsetunnel.lua | 4 +- pulsetunnel_commonmax.lua | 9 +- pulsetunnel_fast.lua | 143 +++++++++++++++++++++++++++++++ run_mpd.sh | 2 +- run_remote.sh | 2 +- ws2801.c | 16 ++-- 15 files changed, 856 insertions(+), 76 deletions(-) create mode 100644 flame.lua create mode 100644 flame_diffspeed.lua create mode 100644 pulsar.lua create mode 100644 pulsecircle_ultrafast.lua create mode 100644 pulsetunnel_fast.lua diff --git a/config.h b/config.h index 50866b5..7d26fe0 100644 --- a/config.h +++ b/config.h @@ -20,7 +20,7 @@ #define PORT 2703 // FFT transformation parameters -#define FFT_EXPONENT 10 // ATTENTION: when you change this, run gen_lut.py with this value as argument +#define FFT_EXPONENT 8 // ATTENTION: when you change this, run gen_lut.py with this value as argument #define BLOCK_LEN (1 << FFT_EXPONENT) // 2^FFT_EXPONENT #define SAMPLE_RATE 44100 #define DATALEN (BLOCK_LEN / 2) @@ -29,7 +29,7 @@ #define BUFFER_PARTS 2 // update rate for the led strip (in seconds) -#define LED_INTERVAL 0.03 +#define LED_INTERVAL 0.01 // frequency ranges for the base colors #define RED_MIN_FREQ 0 diff --git a/config.lua b/config.lua index bb223d5..d99eede 100644 --- a/config.lua +++ b/config.lua @@ -1,7 +1,7 @@ -WS2801_HOST = "192.168.23.222" +WS2801_HOST = "192.168.2.136" WS2801_PORT = 2703 -NUM_MODULES = 20 -CENTER_MODULE = 10 +NUM_MODULES = 128 +CENTER_MODULE = 64 GAMMA = 2.0 diff --git a/flame.lua b/flame.lua new file mode 100644 index 0000000..2850244 --- /dev/null +++ b/flame.lua @@ -0,0 +1,174 @@ +COOLDOWN_FACTOR = 0.9995 +OVERDRIVE = 1.70 +EXPONENT = 1.5 + +M = 1.7 -- mass +D = 1 -- spring strength +DAMPING = {} -- filled in init() + +num_modules = 128 +center_module = 64 + +num_masses = math.floor(num_modules/2) +excitement_pos = 1 + +-- maximum energy values for each band +maxRedEnergy = 1 +maxGreenEnergy = 1 +maxBlueEnergy = 1 + +-- spring-mass-grid values +pos_r = {} +pos_g = {} +pos_b = {} + +vel_r = {} +vel_g = {} +vel_b = {} + +acc_r = {} +acc_g = {} +acc_b = {} + +-- output color buffers +red = {} +green = {} +blue = {} + +r_tmp = {} +g_tmp = {} +b_tmp = {} + +function limit(val) + if val > 1 then + return 1 + elseif val < 0 then + return 0 + else + return val + end +end + +function periodic() + local redEnergy = get_energy_in_band(0, 400); + local greenEnergy = get_energy_in_band(400, 4000); + local blueEnergy = get_energy_in_band(4000, 22000); + local centerIndex = 2 * center_module + 1; + + maxRedEnergy = maxRedEnergy * COOLDOWN_FACTOR + if redEnergy > maxRedEnergy then + maxRedEnergy = redEnergy + end + + maxGreenEnergy = maxGreenEnergy * COOLDOWN_FACTOR + if greenEnergy > maxGreenEnergy then + maxGreenEnergy = greenEnergy + end + + maxBlueEnergy = maxBlueEnergy * COOLDOWN_FACTOR + if blueEnergy > maxBlueEnergy then + maxBlueEnergy = blueEnergy + end + + -- update the spring-mass string + + -- the outside masses are special, as they are auto-returned to 0 position + -- { spring-mass pendulum } { friction } + --acc_r[1] = (-pos_r[1] + (pos_r[2] - pos_r[1])) * D / M + --acc_g[1] = (-pos_g[1] + (pos_g[2] - pos_g[1])) * D / M + --acc_b[1] = (-pos_b[1] + (pos_b[2] - pos_b[1])) * D / M + + acc_r[num_masses] = (-pos_r[num_masses] + (pos_r[num_masses-1] - pos_r[num_masses])) * D / M + acc_g[num_masses] = (-pos_g[num_masses] + (pos_g[num_masses-1] - pos_g[num_masses])) * D / M + acc_b[num_masses] = (-pos_b[num_masses] + (pos_b[num_masses-1] - pos_b[num_masses])) * D / M + + -- inside masses are only influenced by their neighbors + for i = 2,num_masses-1 do + acc_r[i] = (pos_r[i-1] + pos_r[i+1] - 2 * pos_r[i]) * D / M + acc_g[i] = (pos_g[i-1] + pos_g[i+1] - 2 * pos_g[i]) * D / M + acc_b[i] = (pos_b[i-1] + pos_b[i+1] - 2 * pos_b[i]) * D / M + end + + -- update velocity and position + for i = 1,num_masses do + vel_r[i] = DAMPING[i] * (vel_r[i] + acc_r[i]) + vel_g[i] = DAMPING[i] * (vel_g[i] + acc_g[i]) + vel_b[i] = DAMPING[i] * (vel_b[i] + acc_b[i]) + + pos_r[i] = pos_r[i] + vel_r[i] + pos_g[i] = pos_g[i] + vel_g[i] + pos_b[i] = pos_b[i] + vel_b[i] + end + + -- set the new position for the center module + newRed = redEnergy / maxRedEnergy + pos_r[excitement_pos] = newRed + vel_r[excitement_pos] = 0 + acc_r[excitement_pos] = 0 + + newGreen = greenEnergy / maxGreenEnergy + pos_g[excitement_pos] = newGreen + vel_b[excitement_pos] = 0 + acc_b[excitement_pos] = 0 + + newBlue = blueEnergy / maxBlueEnergy + pos_b[excitement_pos] = newBlue + vel_b[excitement_pos] = 0 + acc_b[excitement_pos] = 0 + + -- map to LED modules + for i = 1,num_masses do + r_tmp[i] = pos_r[i] + g_tmp[i] = pos_g[i] + b_tmp[i] = pos_b[i] + + r_tmp[num_modules-i+1] = pos_r[i] + g_tmp[num_modules-i+1] = pos_g[i] + b_tmp[num_modules-i+1] = pos_b[i] + + --print(i, pos_r[i]) + end + + -- make colors more exciting + for i = 1,num_modules do + red[i] = limit(OVERDRIVE * math.pow(r_tmp[i], EXPONENT)) + green[i] = limit(OVERDRIVE * math.pow(g_tmp[i], EXPONENT)) + blue[i] = limit(OVERDRIVE * math.pow(b_tmp[i], EXPONENT)) + end + + -- return the 3 color arrays + return red, green, blue +end + +function init(nmod, cmod) + num_modules = nmod + center_module = cmod + + num_masses = math.floor(nmod/2) + excitement_pos = 1 + + for i = 1,nmod do + red[i] = 0 + green[i] = 0 + blue[i] = 0 + end + + for i = 1,num_masses do + pos_r[i] = 0 + pos_g[i] = 0 + pos_b[i] = 0 + + vel_r[i] = 0 + vel_g[i] = 0 + vel_b[i] = 0 + + acc_r[i] = 0 + acc_g[i] = 0 + acc_b[i] = 0 + + DAMPING[i] = 1 - 0.08 * math.pow(math.abs((i - excitement_pos) / num_masses), 2) + end + + -- don't use fading + return 0 +end diff --git a/flame_diffspeed.lua b/flame_diffspeed.lua new file mode 100644 index 0000000..4b44305 --- /dev/null +++ b/flame_diffspeed.lua @@ -0,0 +1,174 @@ +COOLDOWN_FACTOR = 0.9995 +OVERDRIVE = 1.70 +EXPONENT = 1.5 + +M = {2.3, 1.3, 1.0} -- mass +D = {1, 1, 1} -- spring strength +DAMPING = {} -- filled in init() + +num_modules = 128 +center_module = 64 + +num_masses = math.floor(num_modules/2) +excitement_pos = 1 + +-- maximum energy values for each band +maxRedEnergy = 1 +maxGreenEnergy = 1 +maxBlueEnergy = 1 + +-- spring-mass-grid values +pos_r = {} +pos_g = {} +pos_b = {} + +vel_r = {} +vel_g = {} +vel_b = {} + +acc_r = {} +acc_g = {} +acc_b = {} + +-- output color buffers +red = {} +green = {} +blue = {} + +r_tmp = {} +g_tmp = {} +b_tmp = {} + +function limit(val) + if val > 1 then + return 1 + elseif val < 0 then + return 0 + else + return val + end +end + +function periodic() + local redEnergy = get_energy_in_band(0, 400); + local greenEnergy = get_energy_in_band(400, 4000); + local blueEnergy = get_energy_in_band(4000, 22000); + local centerIndex = 2 * center_module + 1; + + maxRedEnergy = maxRedEnergy * COOLDOWN_FACTOR + if redEnergy > maxRedEnergy then + maxRedEnergy = redEnergy + end + + maxGreenEnergy = maxGreenEnergy * COOLDOWN_FACTOR + if greenEnergy > maxGreenEnergy then + maxGreenEnergy = greenEnergy + end + + maxBlueEnergy = maxBlueEnergy * COOLDOWN_FACTOR + if blueEnergy > maxBlueEnergy then + maxBlueEnergy = blueEnergy + end + + -- update the spring-mass string + + -- the outside masses are special, as they are auto-returned to 0 position + -- { spring-mass pendulum } { friction } + --acc_r[1] = (-pos_r[1] + (pos_r[2] - pos_r[1])) * D / M + --acc_g[1] = (-pos_g[1] + (pos_g[2] - pos_g[1])) * D / M + --acc_b[1] = (-pos_b[1] + (pos_b[2] - pos_b[1])) * D / M + + acc_r[num_masses] = (-pos_r[num_masses] + (pos_r[num_masses-1] - pos_r[num_masses])) * D[1] / M[1] + acc_g[num_masses] = (-pos_g[num_masses] + (pos_g[num_masses-1] - pos_g[num_masses])) * D[2] / M[2] + acc_b[num_masses] = (-pos_b[num_masses] + (pos_b[num_masses-1] - pos_b[num_masses])) * D[3] / M[3] + + -- inside masses are only influenced by their neighbors + for i = 2,num_masses-1 do + acc_r[i] = (pos_r[i-1] + pos_r[i+1] - 2 * pos_r[i]) * D[1] / M[1] + acc_g[i] = (pos_g[i-1] + pos_g[i+1] - 2 * pos_g[i]) * D[2] / M[2] + acc_b[i] = (pos_b[i-1] + pos_b[i+1] - 2 * pos_b[i]) * D[3] / M[3] + end + + -- update velocity and position + for i = 1,num_masses do + vel_r[i] = DAMPING[i] * (vel_r[i] + acc_r[i]) + vel_g[i] = DAMPING[i] * (vel_g[i] + acc_g[i]) + vel_b[i] = DAMPING[i] * (vel_b[i] + acc_b[i]) + + pos_r[i] = pos_r[i] + vel_r[i] + pos_g[i] = pos_g[i] + vel_g[i] + pos_b[i] = pos_b[i] + vel_b[i] + end + + -- set the new position for the center module + newRed = redEnergy / maxRedEnergy + pos_r[excitement_pos] = newRed + vel_r[excitement_pos] = 0 + acc_r[excitement_pos] = 0 + + newGreen = greenEnergy / maxGreenEnergy + pos_g[excitement_pos] = newGreen + vel_b[excitement_pos] = 0 + acc_b[excitement_pos] = 0 + + newBlue = blueEnergy / maxBlueEnergy + pos_b[excitement_pos] = newBlue + vel_b[excitement_pos] = 0 + acc_b[excitement_pos] = 0 + + -- map to LED modules + for i = 1,num_masses do + r_tmp[i] = pos_r[i] + g_tmp[i] = pos_g[i] + b_tmp[i] = pos_b[i] + + r_tmp[num_modules-i+1] = pos_r[i] + g_tmp[num_modules-i+1] = pos_g[i] + b_tmp[num_modules-i+1] = pos_b[i] + + --print(i, pos_r[i]) + end + + -- make colors more exciting + for i = 1,num_modules do + red[i] = limit(OVERDRIVE * math.pow(r_tmp[i], EXPONENT)) + green[i] = limit(OVERDRIVE * math.pow(g_tmp[i], EXPONENT)) + blue[i] = limit(OVERDRIVE * math.pow(b_tmp[i], EXPONENT)) + end + + -- return the 3 color arrays + return red, green, blue +end + +function init(nmod, cmod) + num_modules = nmod + center_module = cmod + + num_masses = math.floor(nmod/2) + excitement_pos = 1 + + for i = 1,nmod do + red[i] = 0 + green[i] = 0 + blue[i] = 0 + end + + for i = 1,num_masses do + pos_r[i] = 0 + pos_g[i] = 0 + pos_b[i] = 0 + + vel_r[i] = 0 + vel_g[i] = 0 + vel_b[i] = 0 + + acc_r[i] = 0 + acc_g[i] = 0 + acc_b[i] = 0 + + DAMPING[i] = 1 - 0.08 * math.pow(math.abs((i - excitement_pos) / num_masses), 2) + end + + -- don't use fading + return 0 +end diff --git a/lut.c b/lut.c index fd09ea1..d9d96a4 100644 --- a/lut.c +++ b/lut.c @@ -2,6 +2,8 @@ #include "lut.h" +value_type sin_lut0[1] = {0}; + value_type sin_lut1[2] = {0, -1.0000000000}; value_type sin_lut2[4] = {0, -0.7071067812, -1.0000000000, -0.7071067812}; @@ -16,34 +18,24 @@ value_type sin_lut6[64] = {0, -0.0490676743, -0.0980171403, -0.1467304745, -0.19 value_type sin_lut7[128] = {0, -0.0245412285, -0.0490676743, -0.0735645636, -0.0980171403, -0.1224106752, -0.1467304745, -0.1709618888, -0.1950903220, -0.2191012402, -0.2429801799, -0.2667127575, -0.2902846773, -0.3136817404, -0.3368898534, -0.3598950365, -0.3826834324, -0.4052413140, -0.4275550934, -0.4496113297, -0.4713967368, -0.4928981922, -0.5141027442, -0.5349976199, -0.5555702330, -0.5758081914, -0.5956993045, -0.6152315906, -0.6343932842, -0.6531728430, -0.6715589548, -0.6895405447, -0.7071067812, -0.7242470830, -0.7409511254, -0.7572088465, -0.7730104534, -0.7883464276, -0.8032075315, -0.8175848132, -0.8314696123, -0.8448535652, -0.8577286100, -0.8700869911, -0.8819212643, -0.8932243012, -0.9039892931, -0.9142097557, -0.9238795325, -0.9329927988, -0.9415440652, -0.9495281806, -0.9569403357, -0.9637760658, -0.9700312532, -0.9757021300, -0.9807852804, -0.9852776424, -0.9891765100, -0.9924795346, -0.9951847267, -0.9972904567, -0.9987954562, -0.9996988187, -1.0000000000, -0.9996988187, -0.9987954562, -0.9972904567, -0.9951847267, -0.9924795346, -0.9891765100, -0.9852776424, -0.9807852804, -0.9757021300, -0.9700312532, -0.9637760658, -0.9569403357, -0.9495281806, -0.9415440652, -0.9329927988, -0.9238795325, -0.9142097557, -0.9039892931, -0.8932243012, -0.8819212643, -0.8700869911, -0.8577286100, -0.8448535652, -0.8314696123, -0.8175848132, -0.8032075315, -0.7883464276, -0.7730104534, -0.7572088465, -0.7409511254, -0.7242470830, -0.7071067812, -0.6895405447, -0.6715589548, -0.6531728430, -0.6343932842, -0.6152315906, -0.5956993045, -0.5758081914, -0.5555702330, -0.5349976199, -0.5141027442, -0.4928981922, -0.4713967368, -0.4496113297, -0.4275550934, -0.4052413140, -0.3826834324, -0.3598950365, -0.3368898534, -0.3136817404, -0.2902846773, -0.2667127575, -0.2429801799, -0.2191012402, -0.1950903220, -0.1709618888, -0.1467304745, -0.1224106752, -0.0980171403, -0.0735645636, -0.0490676743, -0.0245412285}; -value_type sin_lut8[256] = {0, -0.0122715383, -0.0245412285, -0.0368072229, -0.0490676743, -0.0613207363, -0.0735645636, -0.0857973123, -0.0980171403, -0.1102222073, -0.1224106752, -0.1345807085, -0.1467304745, -0.1588581433, -0.1709618888, -0.1830398880, -0.1950903220, -0.2071113762, -0.2191012402, -0.2310581083, -0.2429801799, -0.2548656596, -0.2667127575, -0.2785196894, -0.2902846773, -0.3020059493, -0.3136817404, -0.3253102922, -0.3368898534, -0.3484186802, -0.3598950365, -0.3713171940, -0.3826834324, -0.3939920401, -0.4052413140, -0.4164295601, -0.4275550934, -0.4386162385, -0.4496113297, -0.4605387110, -0.4713967368, -0.4821837721, -0.4928981922, -0.5035383837, -0.5141027442, -0.5245896827, -0.5349976199, -0.5453249884, -0.5555702330, -0.5657318108, -0.5758081914, -0.5857978575, -0.5956993045, -0.6055110414, -0.6152315906, -0.6248594881, -0.6343932842, -0.6438315429, -0.6531728430, -0.6624157776, -0.6715589548, -0.6806009978, -0.6895405447, -0.6983762494, -0.7071067812, -0.7157308253, -0.7242470830, -0.7326542717, -0.7409511254, -0.7491363945, -0.7572088465, -0.7651672656, -0.7730104534, -0.7807372286, -0.7883464276, -0.7958369046, -0.8032075315, -0.8104571983, -0.8175848132, -0.8245893028, -0.8314696123, -0.8382247056, -0.8448535652, -0.8513551931, -0.8577286100, -0.8639728561, -0.8700869911, -0.8760700942, -0.8819212643, -0.8876396204, -0.8932243012, -0.8986744657, -0.9039892931, -0.9091679831, -0.9142097557, -0.9191138517, -0.9238795325, -0.9285060805, -0.9329927988, -0.9373390119, -0.9415440652, -0.9456073254, -0.9495281806, -0.9533060404, -0.9569403357, -0.9604305194, -0.9637760658, -0.9669764710, -0.9700312532, -0.9729399522, -0.9757021300, -0.9783173707, -0.9807852804, -0.9831054874, -0.9852776424, -0.9873014182, -0.9891765100, -0.9909026354, -0.9924795346, -0.9939069700, -0.9951847267, -0.9963126122, -0.9972904567, -0.9981181129, -0.9987954562, -0.9993223846, -0.9996988187, -0.9999247018, -1.0000000000, -0.9999247018, -0.9996988187, -0.9993223846, -0.9987954562, -0.9981181129, -0.9972904567, -0.9963126122, -0.9951847267, -0.9939069700, -0.9924795346, -0.9909026354, -0.9891765100, -0.9873014182, -0.9852776424, -0.9831054874, -0.9807852804, -0.9783173707, -0.9757021300, -0.9729399522, -0.9700312532, -0.9669764710, -0.9637760658, -0.9604305194, -0.9569403357, -0.9533060404, -0.9495281806, -0.9456073254, -0.9415440652, -0.9373390119, -0.9329927988, -0.9285060805, -0.9238795325, -0.9191138517, -0.9142097557, -0.9091679831, -0.9039892931, -0.8986744657, -0.8932243012, -0.8876396204, -0.8819212643, -0.8760700942, -0.8700869911, -0.8639728561, -0.8577286100, -0.8513551931, -0.8448535652, -0.8382247056, -0.8314696123, -0.8245893028, -0.8175848132, -0.8104571983, -0.8032075315, -0.7958369046, -0.7883464276, -0.7807372286, -0.7730104534, -0.7651672656, -0.7572088465, -0.7491363945, -0.7409511254, -0.7326542717, -0.7242470830, -0.7157308253, -0.7071067812, -0.6983762494, -0.6895405447, -0.6806009978, -0.6715589548, -0.6624157776, -0.6531728430, -0.6438315429, -0.6343932842, -0.6248594881, -0.6152315906, -0.6055110414, -0.5956993045, -0.5857978575, -0.5758081914, -0.5657318108, -0.5555702330, -0.5453249884, -0.5349976199, -0.5245896827, -0.5141027442, -0.5035383837, -0.4928981922, -0.4821837721, -0.4713967368, -0.4605387110, -0.4496113297, -0.4386162385, -0.4275550934, -0.4164295601, -0.4052413140, -0.3939920401, -0.3826834324, -0.3713171940, -0.3598950365, -0.3484186802, -0.3368898534, -0.3253102922, -0.3136817404, -0.3020059493, -0.2902846773, -0.2785196894, -0.2667127575, -0.2548656596, -0.2429801799, -0.2310581083, -0.2191012402, -0.2071113762, -0.1950903220, -0.1830398880, -0.1709618888, -0.1588581433, -0.1467304745, -0.1345807085, -0.1224106752, -0.1102222073, -0.0980171403, -0.0857973123, -0.0735645636, -0.0613207363, -0.0490676743, -0.0368072229, -0.0245412285, -0.0122715383}; +value_type *sin_lut[8] = {sin_lut0, sin_lut1, sin_lut2, sin_lut3, sin_lut4, sin_lut5, sin_lut6, sin_lut7}; +value_type cos_lut0[1] = {1}; -value_type sin_lut9[512] = {0, -0.0061358846, -0.0122715383, -0.0184067299, -0.0245412285, -0.0306748032, -0.0368072229, -0.0429382569, -0.0490676743, -0.0551952443, -0.0613207363, -0.0674439196, -0.0735645636, -0.0796824380, -0.0857973123, -0.0919089565, -0.0980171403, -0.1041216339, -0.1102222073, -0.1163186309, -0.1224106752, -0.1284981108, -0.1345807085, -0.1406582393, -0.1467304745, -0.1527971853, -0.1588581433, -0.1649131205, -0.1709618888, -0.1770042204, -0.1830398880, -0.1890686641, -0.1950903220, -0.2011046348, -0.2071113762, -0.2131103199, -0.2191012402, -0.2250839114, -0.2310581083, -0.2370236060, -0.2429801799, -0.2489276057, -0.2548656596, -0.2607941179, -0.2667127575, -0.2726213554, -0.2785196894, -0.2844075372, -0.2902846773, -0.2961508882, -0.3020059493, -0.3078496400, -0.3136817404, -0.3195020308, -0.3253102922, -0.3311063058, -0.3368898534, -0.3426607173, -0.3484186802, -0.3541635254, -0.3598950365, -0.3656129978, -0.3713171940, -0.3770074102, -0.3826834324, -0.3883450467, -0.3939920401, -0.3996241998, -0.4052413140, -0.4108431711, -0.4164295601, -0.4220002708, -0.4275550934, -0.4330938189, -0.4386162385, -0.4441221446, -0.4496113297, -0.4550835871, -0.4605387110, -0.4659764958, -0.4713967368, -0.4767992301, -0.4821837721, -0.4875501601, -0.4928981922, -0.4982276670, -0.5035383837, -0.5088301425, -0.5141027442, -0.5193559902, -0.5245896827, -0.5298036247, -0.5349976199, -0.5401714727, -0.5453249884, -0.5504579729, -0.5555702330, -0.5606615762, -0.5657318108, -0.5707807459, -0.5758081914, -0.5808139581, -0.5857978575, -0.5907597019, -0.5956993045, -0.6006164794, -0.6055110414, -0.6103828063, -0.6152315906, -0.6200572118, -0.6248594881, -0.6296382389, -0.6343932842, -0.6391244449, -0.6438315429, -0.6485144010, -0.6531728430, -0.6578066933, -0.6624157776, -0.6669999223, -0.6715589548, -0.6760927036, -0.6806009978, -0.6850836678, -0.6895405447, -0.6939714609, -0.6983762494, -0.7027547445, -0.7071067812, -0.7114321957, -0.7157308253, -0.7200025080, -0.7242470830, -0.7284643904, -0.7326542717, -0.7368165689, -0.7409511254, -0.7450577854, -0.7491363945, -0.7531867990, -0.7572088465, -0.7612023855, -0.7651672656, -0.7691033376, -0.7730104534, -0.7768884657, -0.7807372286, -0.7845565972, -0.7883464276, -0.7921065773, -0.7958369046, -0.7995372691, -0.8032075315, -0.8068475535, -0.8104571983, -0.8140363297, -0.8175848132, -0.8211025150, -0.8245893028, -0.8280450453, -0.8314696123, -0.8348628750, -0.8382247056, -0.8415549774, -0.8448535652, -0.8481203448, -0.8513551931, -0.8545579884, -0.8577286100, -0.8608669386, -0.8639728561, -0.8670462455, -0.8700869911, -0.8730949784, -0.8760700942, -0.8790122264, -0.8819212643, -0.8847970984, -0.8876396204, -0.8904487232, -0.8932243012, -0.8959662498, -0.8986744657, -0.9013488470, -0.9039892931, -0.9065957045, -0.9091679831, -0.9117060320, -0.9142097557, -0.9166790599, -0.9191138517, -0.9215140393, -0.9238795325, -0.9262102421, -0.9285060805, -0.9307669611, -0.9329927988, -0.9351835099, -0.9373390119, -0.9394592236, -0.9415440652, -0.9435934582, -0.9456073254, -0.9475855910, -0.9495281806, -0.9514350210, -0.9533060404, -0.9551411683, -0.9569403357, -0.9587034749, -0.9604305194, -0.9621214043, -0.9637760658, -0.9653944417, -0.9669764710, -0.9685220943, -0.9700312532, -0.9715038910, -0.9729399522, -0.9743393828, -0.9757021300, -0.9770281427, -0.9783173707, -0.9795697657, -0.9807852804, -0.9819638691, -0.9831054874, -0.9842100924, -0.9852776424, -0.9863080972, -0.9873014182, -0.9882575677, -0.9891765100, -0.9900582103, -0.9909026354, -0.9917097537, -0.9924795346, -0.9932119492, -0.9939069700, -0.9945645707, -0.9951847267, -0.9957674145, -0.9963126122, -0.9968202993, -0.9972904567, -0.9977230666, -0.9981181129, -0.9984755806, -0.9987954562, -0.9990777278, -0.9993223846, -0.9995294175, -0.9996988187, -0.9998305818, -0.9999247018, -0.9999811753, -1.0000000000, -0.9999811753, -0.9999247018, -0.9998305818, -0.9996988187, -0.9995294175, -0.9993223846, -0.9990777278, -0.9987954562, -0.9984755806, -0.9981181129, -0.9977230666, -0.9972904567, -0.9968202993, -0.9963126122, -0.9957674145, -0.9951847267, -0.9945645707, -0.9939069700, -0.9932119492, -0.9924795346, -0.9917097537, -0.9909026354, -0.9900582103, -0.9891765100, -0.9882575677, -0.9873014182, -0.9863080972, -0.9852776424, -0.9842100924, -0.9831054874, -0.9819638691, -0.9807852804, -0.9795697657, -0.9783173707, -0.9770281427, -0.9757021300, -0.9743393828, -0.9729399522, -0.9715038910, -0.9700312532, -0.9685220943, -0.9669764710, -0.9653944417, -0.9637760658, -0.9621214043, -0.9604305194, -0.9587034749, -0.9569403357, -0.9551411683, -0.9533060404, -0.9514350210, -0.9495281806, -0.9475855910, -0.9456073254, -0.9435934582, -0.9415440652, -0.9394592236, -0.9373390119, -0.9351835099, -0.9329927988, -0.9307669611, -0.9285060805, -0.9262102421, -0.9238795325, -0.9215140393, -0.9191138517, -0.9166790599, -0.9142097557, -0.9117060320, -0.9091679831, -0.9065957045, -0.9039892931, -0.9013488470, -0.8986744657, -0.8959662498, -0.8932243012, -0.8904487232, -0.8876396204, -0.8847970984, -0.8819212643, -0.8790122264, -0.8760700942, -0.8730949784, -0.8700869911, -0.8670462455, -0.8639728561, -0.8608669386, -0.8577286100, -0.8545579884, -0.8513551931, -0.8481203448, -0.8448535652, -0.8415549774, -0.8382247056, -0.8348628750, -0.8314696123, -0.8280450453, -0.8245893028, -0.8211025150, -0.8175848132, -0.8140363297, -0.8104571983, -0.8068475535, -0.8032075315, -0.7995372691, -0.7958369046, -0.7921065773, -0.7883464276, -0.7845565972, -0.7807372286, -0.7768884657, -0.7730104534, -0.7691033376, -0.7651672656, -0.7612023855, -0.7572088465, -0.7531867990, -0.7491363945, -0.7450577854, -0.7409511254, -0.7368165689, -0.7326542717, -0.7284643904, -0.7242470830, -0.7200025080, -0.7157308253, -0.7114321957, -0.7071067812, -0.7027547445, -0.6983762494, -0.6939714609, -0.6895405447, -0.6850836678, -0.6806009978, -0.6760927036, -0.6715589548, -0.6669999223, -0.6624157776, -0.6578066933, -0.6531728430, -0.6485144010, -0.6438315429, -0.6391244449, -0.6343932842, -0.6296382389, -0.6248594881, -0.6200572118, -0.6152315906, -0.6103828063, -0.6055110414, -0.6006164794, -0.5956993045, -0.5907597019, -0.5857978575, -0.5808139581, -0.5758081914, -0.5707807459, -0.5657318108, -0.5606615762, -0.5555702330, -0.5504579729, -0.5453249884, -0.5401714727, -0.5349976199, -0.5298036247, -0.5245896827, -0.5193559902, -0.5141027442, -0.5088301425, -0.5035383837, -0.4982276670, -0.4928981922, -0.4875501601, -0.4821837721, -0.4767992301, -0.4713967368, -0.4659764958, -0.4605387110, -0.4550835871, -0.4496113297, -0.4441221446, -0.4386162385, -0.4330938189, -0.4275550934, -0.4220002708, -0.4164295601, -0.4108431711, -0.4052413140, -0.3996241998, -0.3939920401, -0.3883450467, -0.3826834324, -0.3770074102, -0.3713171940, -0.3656129978, -0.3598950365, -0.3541635254, -0.3484186802, -0.3426607173, -0.3368898534, -0.3311063058, -0.3253102922, -0.3195020308, -0.3136817404, -0.3078496400, -0.3020059493, -0.2961508882, -0.2902846773, -0.2844075372, -0.2785196894, -0.2726213554, -0.2667127575, -0.2607941179, -0.2548656596, -0.2489276057, -0.2429801799, -0.2370236060, -0.2310581083, -0.2250839114, -0.2191012402, -0.2131103199, -0.2071113762, -0.2011046348, -0.1950903220, -0.1890686641, -0.1830398880, -0.1770042204, -0.1709618888, -0.1649131205, -0.1588581433, -0.1527971853, -0.1467304745, -0.1406582393, -0.1345807085, -0.1284981108, -0.1224106752, -0.1163186309, -0.1102222073, -0.1041216339, -0.0980171403, -0.0919089565, -0.0857973123, -0.0796824380, -0.0735645636, -0.0674439196, -0.0613207363, -0.0551952443, -0.0490676743, -0.0429382569, -0.0368072229, -0.0306748032, -0.0245412285, -0.0184067299, -0.0122715383, -0.0061358846}; +value_type cos_lut1[2] = {1, 0.0000000000}; -value_type sin_lut10[1024] = {0, -0.0030679568, -0.0061358846, -0.0092037548, -0.0122715383, -0.0153392063, -0.0184067299, -0.0214740803, -0.0245412285, -0.0276081458, -0.0306748032, -0.0337411719, -0.0368072229, -0.0398729276, -0.0429382569, -0.0460031821, -0.0490676743, -0.0521317047, -0.0551952443, -0.0582582645, -0.0613207363, -0.0643826309, -0.0674439196, -0.0705045734, -0.0735645636, -0.0766238614, -0.0796824380, -0.0827402645, -0.0857973123, -0.0888535526, -0.0919089565, -0.0949634953, -0.0980171403, -0.1010698628, -0.1041216339, -0.1071724250, -0.1102222073, -0.1132709522, -0.1163186309, -0.1193652148, -0.1224106752, -0.1254549834, -0.1284981108, -0.1315400287, -0.1345807085, -0.1376201216, -0.1406582393, -0.1436950332, -0.1467304745, -0.1497645347, -0.1527971853, -0.1558283977, -0.1588581433, -0.1618863938, -0.1649131205, -0.1679382950, -0.1709618888, -0.1739838734, -0.1770042204, -0.1800229014, -0.1830398880, -0.1860551517, -0.1890686641, -0.1920803970, -0.1950903220, -0.1980984107, -0.2011046348, -0.2041089661, -0.2071113762, -0.2101118369, -0.2131103199, -0.2161067971, -0.2191012402, -0.2220936210, -0.2250839114, -0.2280720832, -0.2310581083, -0.2340419586, -0.2370236060, -0.2400030224, -0.2429801799, -0.2459550503, -0.2489276057, -0.2518978182, -0.2548656596, -0.2578311022, -0.2607941179, -0.2637546790, -0.2667127575, -0.2696683256, -0.2726213554, -0.2755718193, -0.2785196894, -0.2814649379, -0.2844075372, -0.2873474595, -0.2902846773, -0.2932191627, -0.2961508882, -0.2990798263, -0.3020059493, -0.3049292297, -0.3078496400, -0.3107671527, -0.3136817404, -0.3165933756, -0.3195020308, -0.3224076788, -0.3253102922, -0.3282098436, -0.3311063058, -0.3339996514, -0.3368898534, -0.3397768844, -0.3426607173, -0.3455413250, -0.3484186802, -0.3512927561, -0.3541635254, -0.3570309612, -0.3598950365, -0.3627557244, -0.3656129978, -0.3684668300, -0.3713171940, -0.3741640630, -0.3770074102, -0.3798472089, -0.3826834324, -0.3855160538, -0.3883450467, -0.3911703843, -0.3939920401, -0.3968099874, -0.3996241998, -0.4024346509, -0.4052413140, -0.4080441629, -0.4108431711, -0.4136383122, -0.4164295601, -0.4192168884, -0.4220002708, -0.4247796812, -0.4275550934, -0.4303264813, -0.4330938189, -0.4358570799, -0.4386162385, -0.4413712687, -0.4441221446, -0.4468688402, -0.4496113297, -0.4523495872, -0.4550835871, -0.4578133036, -0.4605387110, -0.4632597836, -0.4659764958, -0.4686888220, -0.4713967368, -0.4741002147, -0.4767992301, -0.4794937577, -0.4821837721, -0.4848692480, -0.4875501601, -0.4902264833, -0.4928981922, -0.4955652618, -0.4982276670, -0.5008853826, -0.5035383837, -0.5061866453, -0.5088301425, -0.5114688504, -0.5141027442, -0.5167317990, -0.5193559902, -0.5219752929, -0.5245896827, -0.5271991348, -0.5298036247, -0.5324031279, -0.5349976199, -0.5375870763, -0.5401714727, -0.5427507849, -0.5453249884, -0.5478940592, -0.5504579729, -0.5530167056, -0.5555702330, -0.5581185312, -0.5606615762, -0.5631993440, -0.5657318108, -0.5682589527, -0.5707807459, -0.5732971667, -0.5758081914, -0.5783137964, -0.5808139581, -0.5833086529, -0.5857978575, -0.5882815482, -0.5907597019, -0.5932322950, -0.5956993045, -0.5981607070, -0.6006164794, -0.6030665985, -0.6055110414, -0.6079497850, -0.6103828063, -0.6128100824, -0.6152315906, -0.6176473079, -0.6200572118, -0.6224612794, -0.6248594881, -0.6272518155, -0.6296382389, -0.6320187359, -0.6343932842, -0.6367618612, -0.6391244449, -0.6414810128, -0.6438315429, -0.6461760130, -0.6485144010, -0.6508466850, -0.6531728430, -0.6554928530, -0.6578066933, -0.6601143421, -0.6624157776, -0.6647109782, -0.6669999223, -0.6692825883, -0.6715589548, -0.6738290004, -0.6760927036, -0.6783500431, -0.6806009978, -0.6828455464, -0.6850836678, -0.6873153409, -0.6895405447, -0.6917592584, -0.6939714609, -0.6961771315, -0.6983762494, -0.7005687939, -0.7027547445, -0.7049340804, -0.7071067812, -0.7092728264, -0.7114321957, -0.7135848688, -0.7157308253, -0.7178700451, -0.7200025080, -0.7221281939, -0.7242470830, -0.7263591551, -0.7284643904, -0.7305627692, -0.7326542717, -0.7347388781, -0.7368165689, -0.7388873245, -0.7409511254, -0.7430079521, -0.7450577854, -0.7471006060, -0.7491363945, -0.7511651319, -0.7531867990, -0.7552013769, -0.7572088465, -0.7592091890, -0.7612023855, -0.7631884173, -0.7651672656, -0.7671389119, -0.7691033376, -0.7710605243, -0.7730104534, -0.7749531066, -0.7768884657, -0.7788165124, -0.7807372286, -0.7826505962, -0.7845565972, -0.7864552136, -0.7883464276, -0.7902302214, -0.7921065773, -0.7939754776, -0.7958369046, -0.7976908409, -0.7995372691, -0.8013761717, -0.8032075315, -0.8050313311, -0.8068475535, -0.8086561816, -0.8104571983, -0.8122505866, -0.8140363297, -0.8158144108, -0.8175848132, -0.8193475201, -0.8211025150, -0.8228497814, -0.8245893028, -0.8263210628, -0.8280450453, -0.8297612338, -0.8314696123, -0.8331701647, -0.8348628750, -0.8365477272, -0.8382247056, -0.8398937942, -0.8415549774, -0.8432082396, -0.8448535652, -0.8464909388, -0.8481203448, -0.8497417680, -0.8513551931, -0.8529606049, -0.8545579884, -0.8561473284, -0.8577286100, -0.8593018184, -0.8608669386, -0.8624239561, -0.8639728561, -0.8655136241, -0.8670462455, -0.8685707060, -0.8700869911, -0.8715950867, -0.8730949784, -0.8745866523, -0.8760700942, -0.8775452902, -0.8790122264, -0.8804708891, -0.8819212643, -0.8833633387, -0.8847970984, -0.8862225301, -0.8876396204, -0.8890483559, -0.8904487232, -0.8918407094, -0.8932243012, -0.8945994856, -0.8959662498, -0.8973245807, -0.8986744657, -0.9000158920, -0.9013488470, -0.9026733182, -0.9039892931, -0.9052967593, -0.9065957045, -0.9078861165, -0.9091679831, -0.9104412923, -0.9117060320, -0.9129621904, -0.9142097557, -0.9154487161, -0.9166790599, -0.9179007756, -0.9191138517, -0.9203182767, -0.9215140393, -0.9227011283, -0.9238795325, -0.9250492408, -0.9262102421, -0.9273625257, -0.9285060805, -0.9296408958, -0.9307669611, -0.9318842656, -0.9329927988, -0.9340925504, -0.9351835099, -0.9362656672, -0.9373390119, -0.9384035341, -0.9394592236, -0.9405060706, -0.9415440652, -0.9425731976, -0.9435934582, -0.9446048373, -0.9456073254, -0.9466009131, -0.9475855910, -0.9485613499, -0.9495281806, -0.9504860739, -0.9514350210, -0.9523750127, -0.9533060404, -0.9542280951, -0.9551411683, -0.9560452513, -0.9569403357, -0.9578264130, -0.9587034749, -0.9595715131, -0.9604305194, -0.9612804858, -0.9621214043, -0.9629532669, -0.9637760658, -0.9645897933, -0.9653944417, -0.9661900034, -0.9669764710, -0.9677538371, -0.9685220943, -0.9692812354, -0.9700312532, -0.9707721407, -0.9715038910, -0.9722264971, -0.9729399522, -0.9736442497, -0.9743393828, -0.9750253451, -0.9757021300, -0.9763697313, -0.9770281427, -0.9776773578, -0.9783173707, -0.9789481753, -0.9795697657, -0.9801821360, -0.9807852804, -0.9813791933, -0.9819638691, -0.9825393023, -0.9831054874, -0.9836624192, -0.9842100924, -0.9847485018, -0.9852776424, -0.9857975092, -0.9863080972, -0.9868094018, -0.9873014182, -0.9877841416, -0.9882575677, -0.9887216920, -0.9891765100, -0.9896220175, -0.9900582103, -0.9904850843, -0.9909026354, -0.9913108598, -0.9917097537, -0.9920993131, -0.9924795346, -0.9928504145, -0.9932119492, -0.9935641355, -0.9939069700, -0.9942404495, -0.9945645707, -0.9948793308, -0.9951847267, -0.9954807555, -0.9957674145, -0.9960447009, -0.9963126122, -0.9965711458, -0.9968202993, -0.9970600703, -0.9972904567, -0.9975114561, -0.9977230666, -0.9979252862, -0.9981181129, -0.9983015449, -0.9984755806, -0.9986402182, -0.9987954562, -0.9989412932, -0.9990777278, -0.9992047586, -0.9993223846, -0.9994306046, -0.9995294175, -0.9996188225, -0.9996988187, -0.9997694054, -0.9998305818, -0.9998823475, -0.9999247018, -0.9999576446, -0.9999811753, -0.9999952938, -1.0000000000, -0.9999952938, -0.9999811753, -0.9999576446, -0.9999247018, -0.9998823475, -0.9998305818, -0.9997694054, -0.9996988187, -0.9996188225, -0.9995294175, -0.9994306046, -0.9993223846, -0.9992047586, -0.9990777278, -0.9989412932, -0.9987954562, -0.9986402182, -0.9984755806, -0.9983015449, -0.9981181129, -0.9979252862, -0.9977230666, -0.9975114561, -0.9972904567, -0.9970600703, -0.9968202993, -0.9965711458, -0.9963126122, -0.9960447009, -0.9957674145, -0.9954807555, -0.9951847267, -0.9948793308, -0.9945645707, -0.9942404495, -0.9939069700, -0.9935641355, -0.9932119492, -0.9928504145, -0.9924795346, -0.9920993131, -0.9917097537, -0.9913108598, -0.9909026354, -0.9904850843, -0.9900582103, -0.9896220175, -0.9891765100, -0.9887216920, -0.9882575677, -0.9877841416, -0.9873014182, -0.9868094018, -0.9863080972, -0.9857975092, -0.9852776424, -0.9847485018, -0.9842100924, -0.9836624192, -0.9831054874, -0.9825393023, -0.9819638691, -0.9813791933, -0.9807852804, -0.9801821360, -0.9795697657, -0.9789481753, -0.9783173707, -0.9776773578, -0.9770281427, -0.9763697313, -0.9757021300, -0.9750253451, -0.9743393828, -0.9736442497, -0.9729399522, -0.9722264971, -0.9715038910, -0.9707721407, -0.9700312532, -0.9692812354, -0.9685220943, -0.9677538371, -0.9669764710, -0.9661900034, -0.9653944417, -0.9645897933, -0.9637760658, -0.9629532669, -0.9621214043, -0.9612804858, -0.9604305194, -0.9595715131, -0.9587034749, -0.9578264130, -0.9569403357, -0.9560452513, -0.9551411683, -0.9542280951, -0.9533060404, -0.9523750127, -0.9514350210, -0.9504860739, -0.9495281806, -0.9485613499, -0.9475855910, -0.9466009131, -0.9456073254, -0.9446048373, -0.9435934582, -0.9425731976, -0.9415440652, -0.9405060706, -0.9394592236, -0.9384035341, -0.9373390119, -0.9362656672, -0.9351835099, -0.9340925504, -0.9329927988, -0.9318842656, -0.9307669611, -0.9296408958, -0.9285060805, -0.9273625257, -0.9262102421, -0.9250492408, -0.9238795325, -0.9227011283, -0.9215140393, -0.9203182767, -0.9191138517, -0.9179007756, -0.9166790599, -0.9154487161, -0.9142097557, -0.9129621904, -0.9117060320, -0.9104412923, -0.9091679831, -0.9078861165, -0.9065957045, -0.9052967593, -0.9039892931, -0.9026733182, -0.9013488470, -0.9000158920, -0.8986744657, -0.8973245807, -0.8959662498, -0.8945994856, -0.8932243012, -0.8918407094, -0.8904487232, -0.8890483559, -0.8876396204, -0.8862225301, -0.8847970984, -0.8833633387, -0.8819212643, -0.8804708891, -0.8790122264, -0.8775452902, -0.8760700942, -0.8745866523, -0.8730949784, -0.8715950867, -0.8700869911, -0.8685707060, -0.8670462455, -0.8655136241, -0.8639728561, -0.8624239561, -0.8608669386, -0.8593018184, -0.8577286100, -0.8561473284, -0.8545579884, -0.8529606049, -0.8513551931, -0.8497417680, -0.8481203448, -0.8464909388, -0.8448535652, -0.8432082396, -0.8415549774, -0.8398937942, -0.8382247056, -0.8365477272, -0.8348628750, -0.8331701647, -0.8314696123, -0.8297612338, -0.8280450453, -0.8263210628, -0.8245893028, -0.8228497814, -0.8211025150, -0.8193475201, -0.8175848132, -0.8158144108, -0.8140363297, -0.8122505866, -0.8104571983, -0.8086561816, -0.8068475535, -0.8050313311, -0.8032075315, -0.8013761717, -0.7995372691, -0.7976908409, -0.7958369046, -0.7939754776, -0.7921065773, -0.7902302214, -0.7883464276, -0.7864552136, -0.7845565972, -0.7826505962, -0.7807372286, -0.7788165124, -0.7768884657, -0.7749531066, -0.7730104534, -0.7710605243, -0.7691033376, -0.7671389119, -0.7651672656, -0.7631884173, -0.7612023855, -0.7592091890, -0.7572088465, -0.7552013769, -0.7531867990, -0.7511651319, -0.7491363945, -0.7471006060, -0.7450577854, -0.7430079521, -0.7409511254, -0.7388873245, -0.7368165689, -0.7347388781, -0.7326542717, -0.7305627692, -0.7284643904, -0.7263591551, -0.7242470830, -0.7221281939, -0.7200025080, -0.7178700451, -0.7157308253, -0.7135848688, -0.7114321957, -0.7092728264, -0.7071067812, -0.7049340804, -0.7027547445, -0.7005687939, -0.6983762494, -0.6961771315, -0.6939714609, -0.6917592584, -0.6895405447, -0.6873153409, -0.6850836678, -0.6828455464, -0.6806009978, -0.6783500431, -0.6760927036, -0.6738290004, -0.6715589548, -0.6692825883, -0.6669999223, -0.6647109782, -0.6624157776, -0.6601143421, -0.6578066933, -0.6554928530, -0.6531728430, -0.6508466850, -0.6485144010, -0.6461760130, -0.6438315429, -0.6414810128, -0.6391244449, -0.6367618612, -0.6343932842, -0.6320187359, -0.6296382389, -0.6272518155, -0.6248594881, -0.6224612794, -0.6200572118, -0.6176473079, -0.6152315906, -0.6128100824, -0.6103828063, -0.6079497850, -0.6055110414, -0.6030665985, -0.6006164794, -0.5981607070, -0.5956993045, -0.5932322950, -0.5907597019, -0.5882815482, -0.5857978575, -0.5833086529, -0.5808139581, -0.5783137964, -0.5758081914, -0.5732971667, -0.5707807459, -0.5682589527, -0.5657318108, -0.5631993440, -0.5606615762, -0.5581185312, -0.5555702330, -0.5530167056, -0.5504579729, -0.5478940592, -0.5453249884, -0.5427507849, -0.5401714727, -0.5375870763, -0.5349976199, -0.5324031279, -0.5298036247, -0.5271991348, -0.5245896827, -0.5219752929, -0.5193559902, -0.5167317990, -0.5141027442, -0.5114688504, -0.5088301425, -0.5061866453, -0.5035383837, -0.5008853826, -0.4982276670, -0.4955652618, -0.4928981922, -0.4902264833, -0.4875501601, -0.4848692480, -0.4821837721, -0.4794937577, -0.4767992301, -0.4741002147, -0.4713967368, -0.4686888220, -0.4659764958, -0.4632597836, -0.4605387110, -0.4578133036, -0.4550835871, -0.4523495872, -0.4496113297, -0.4468688402, -0.4441221446, -0.4413712687, -0.4386162385, -0.4358570799, -0.4330938189, -0.4303264813, -0.4275550934, -0.4247796812, -0.4220002708, -0.4192168884, -0.4164295601, -0.4136383122, -0.4108431711, -0.4080441629, -0.4052413140, -0.4024346509, -0.3996241998, -0.3968099874, -0.3939920401, -0.3911703843, -0.3883450467, -0.3855160538, -0.3826834324, -0.3798472089, -0.3770074102, -0.3741640630, -0.3713171940, -0.3684668300, -0.3656129978, -0.3627557244, -0.3598950365, -0.3570309612, -0.3541635254, -0.3512927561, -0.3484186802, -0.3455413250, -0.3426607173, -0.3397768844, -0.3368898534, -0.3339996514, -0.3311063058, -0.3282098436, -0.3253102922, -0.3224076788, -0.3195020308, -0.3165933756, -0.3136817404, -0.3107671527, -0.3078496400, -0.3049292297, -0.3020059493, -0.2990798263, -0.2961508882, -0.2932191627, -0.2902846773, -0.2873474595, -0.2844075372, -0.2814649379, -0.2785196894, -0.2755718193, -0.2726213554, -0.2696683256, -0.2667127575, -0.2637546790, -0.2607941179, -0.2578311022, -0.2548656596, -0.2518978182, -0.2489276057, -0.2459550503, -0.2429801799, -0.2400030224, -0.2370236060, -0.2340419586, -0.2310581083, -0.2280720832, -0.2250839114, -0.2220936210, -0.2191012402, -0.2161067971, -0.2131103199, -0.2101118369, -0.2071113762, -0.2041089661, -0.2011046348, -0.1980984107, -0.1950903220, -0.1920803970, -0.1890686641, -0.1860551517, -0.1830398880, -0.1800229014, -0.1770042204, -0.1739838734, -0.1709618888, -0.1679382950, -0.1649131205, -0.1618863938, -0.1588581433, -0.1558283977, -0.1527971853, -0.1497645347, -0.1467304745, -0.1436950332, -0.1406582393, -0.1376201216, -0.1345807085, -0.1315400287, -0.1284981108, -0.1254549834, -0.1224106752, -0.1193652148, -0.1163186309, -0.1132709522, -0.1102222073, -0.1071724250, -0.1041216339, -0.1010698628, -0.0980171403, -0.0949634953, -0.0919089565, -0.0888535526, -0.0857973123, -0.0827402645, -0.0796824380, -0.0766238614, -0.0735645636, -0.0705045734, -0.0674439196, -0.0643826309, -0.0613207363, -0.0582582645, -0.0551952443, -0.0521317047, -0.0490676743, -0.0460031821, -0.0429382569, -0.0398729276, -0.0368072229, -0.0337411719, -0.0306748032, -0.0276081458, -0.0245412285, -0.0214740803, -0.0184067299, -0.0153392063, -0.0122715383, -0.0092037548, -0.0061358846, -0.0030679568}; +value_type cos_lut2[4] = {1, 0.7071067812, 0.0000000000, -0.7071067812}; -value_type *sin_lut[10] = {sin_lut1, sin_lut2, sin_lut3, sin_lut4, sin_lut5, sin_lut6, sin_lut7, sin_lut8, sin_lut9, sin_lut10}; -value_type cos_lut1[2] = {0, 0.0000000000}; +value_type cos_lut3[8] = {1, 0.9238795325, 0.7071067812, 0.3826834324, 0.0000000000, -0.3826834324, -0.7071067812, -0.9238795325}; -value_type cos_lut2[4] = {0, 0.7071067812, 0.0000000000, -0.7071067812}; +value_type cos_lut4[16] = {1, 0.9807852804, 0.9238795325, 0.8314696123, 0.7071067812, 0.5555702330, 0.3826834324, 0.1950903220, 0.0000000000, -0.1950903220, -0.3826834324, -0.5555702330, -0.7071067812, -0.8314696123, -0.9238795325, -0.9807852804}; -value_type cos_lut3[8] = {0, 0.9238795325, 0.7071067812, 0.3826834324, 0.0000000000, -0.3826834324, -0.7071067812, -0.9238795325}; +value_type cos_lut5[32] = {1, 0.9951847267, 0.9807852804, 0.9569403357, 0.9238795325, 0.8819212643, 0.8314696123, 0.7730104534, 0.7071067812, 0.6343932842, 0.5555702330, 0.4713967368, 0.3826834324, 0.2902846773, 0.1950903220, 0.0980171403, 0.0000000000, -0.0980171403, -0.1950903220, -0.2902846773, -0.3826834324, -0.4713967368, -0.5555702330, -0.6343932842, -0.7071067812, -0.7730104534, -0.8314696123, -0.8819212643, -0.9238795325, -0.9569403357, -0.9807852804, -0.9951847267}; -value_type cos_lut4[16] = {0, 0.9807852804, 0.9238795325, 0.8314696123, 0.7071067812, 0.5555702330, 0.3826834324, 0.1950903220, 0.0000000000, -0.1950903220, -0.3826834324, -0.5555702330, -0.7071067812, -0.8314696123, -0.9238795325, -0.9807852804}; +value_type cos_lut6[64] = {1, 0.9987954562, 0.9951847267, 0.9891765100, 0.9807852804, 0.9700312532, 0.9569403357, 0.9415440652, 0.9238795325, 0.9039892931, 0.8819212643, 0.8577286100, 0.8314696123, 0.8032075315, 0.7730104534, 0.7409511254, 0.7071067812, 0.6715589548, 0.6343932842, 0.5956993045, 0.5555702330, 0.5141027442, 0.4713967368, 0.4275550934, 0.3826834324, 0.3368898534, 0.2902846773, 0.2429801799, 0.1950903220, 0.1467304745, 0.0980171403, 0.0490676743, 0.0000000000, -0.0490676743, -0.0980171403, -0.1467304745, -0.1950903220, -0.2429801799, -0.2902846773, -0.3368898534, -0.3826834324, -0.4275550934, -0.4713967368, -0.5141027442, -0.5555702330, -0.5956993045, -0.6343932842, -0.6715589548, -0.7071067812, -0.7409511254, -0.7730104534, -0.8032075315, -0.8314696123, -0.8577286100, -0.8819212643, -0.9039892931, -0.9238795325, -0.9415440652, -0.9569403357, -0.9700312532, -0.9807852804, -0.9891765100, -0.9951847267, -0.9987954562}; -value_type cos_lut5[32] = {0, 0.9951847267, 0.9807852804, 0.9569403357, 0.9238795325, 0.8819212643, 0.8314696123, 0.7730104534, 0.7071067812, 0.6343932842, 0.5555702330, 0.4713967368, 0.3826834324, 0.2902846773, 0.1950903220, 0.0980171403, 0.0000000000, -0.0980171403, -0.1950903220, -0.2902846773, -0.3826834324, -0.4713967368, -0.5555702330, -0.6343932842, -0.7071067812, -0.7730104534, -0.8314696123, -0.8819212643, -0.9238795325, -0.9569403357, -0.9807852804, -0.9951847267}; +value_type cos_lut7[128] = {1, 0.9996988187, 0.9987954562, 0.9972904567, 0.9951847267, 0.9924795346, 0.9891765100, 0.9852776424, 0.9807852804, 0.9757021300, 0.9700312532, 0.9637760658, 0.9569403357, 0.9495281806, 0.9415440652, 0.9329927988, 0.9238795325, 0.9142097557, 0.9039892931, 0.8932243012, 0.8819212643, 0.8700869911, 0.8577286100, 0.8448535652, 0.8314696123, 0.8175848132, 0.8032075315, 0.7883464276, 0.7730104534, 0.7572088465, 0.7409511254, 0.7242470830, 0.7071067812, 0.6895405447, 0.6715589548, 0.6531728430, 0.6343932842, 0.6152315906, 0.5956993045, 0.5758081914, 0.5555702330, 0.5349976199, 0.5141027442, 0.4928981922, 0.4713967368, 0.4496113297, 0.4275550934, 0.4052413140, 0.3826834324, 0.3598950365, 0.3368898534, 0.3136817404, 0.2902846773, 0.2667127575, 0.2429801799, 0.2191012402, 0.1950903220, 0.1709618888, 0.1467304745, 0.1224106752, 0.0980171403, 0.0735645636, 0.0490676743, 0.0245412285, 0.0000000000, -0.0245412285, -0.0490676743, -0.0735645636, -0.0980171403, -0.1224106752, -0.1467304745, -0.1709618888, -0.1950903220, -0.2191012402, -0.2429801799, -0.2667127575, -0.2902846773, -0.3136817404, -0.3368898534, -0.3598950365, -0.3826834324, -0.4052413140, -0.4275550934, -0.4496113297, -0.4713967368, -0.4928981922, -0.5141027442, -0.5349976199, -0.5555702330, -0.5758081914, -0.5956993045, -0.6152315906, -0.6343932842, -0.6531728430, -0.6715589548, -0.6895405447, -0.7071067812, -0.7242470830, -0.7409511254, -0.7572088465, -0.7730104534, -0.7883464276, -0.8032075315, -0.8175848132, -0.8314696123, -0.8448535652, -0.8577286100, -0.8700869911, -0.8819212643, -0.8932243012, -0.9039892931, -0.9142097557, -0.9238795325, -0.9329927988, -0.9415440652, -0.9495281806, -0.9569403357, -0.9637760658, -0.9700312532, -0.9757021300, -0.9807852804, -0.9852776424, -0.9891765100, -0.9924795346, -0.9951847267, -0.9972904567, -0.9987954562, -0.9996988187}; -value_type cos_lut6[64] = {0, 0.9987954562, 0.9951847267, 0.9891765100, 0.9807852804, 0.9700312532, 0.9569403357, 0.9415440652, 0.9238795325, 0.9039892931, 0.8819212643, 0.8577286100, 0.8314696123, 0.8032075315, 0.7730104534, 0.7409511254, 0.7071067812, 0.6715589548, 0.6343932842, 0.5956993045, 0.5555702330, 0.5141027442, 0.4713967368, 0.4275550934, 0.3826834324, 0.3368898534, 0.2902846773, 0.2429801799, 0.1950903220, 0.1467304745, 0.0980171403, 0.0490676743, 0.0000000000, -0.0490676743, -0.0980171403, -0.1467304745, -0.1950903220, -0.2429801799, -0.2902846773, -0.3368898534, -0.3826834324, -0.4275550934, -0.4713967368, -0.5141027442, -0.5555702330, -0.5956993045, -0.6343932842, -0.6715589548, -0.7071067812, -0.7409511254, -0.7730104534, -0.8032075315, -0.8314696123, -0.8577286100, -0.8819212643, -0.9039892931, -0.9238795325, -0.9415440652, -0.9569403357, -0.9700312532, -0.9807852804, -0.9891765100, -0.9951847267, -0.9987954562}; - -value_type cos_lut7[128] = {0, 0.9996988187, 0.9987954562, 0.9972904567, 0.9951847267, 0.9924795346, 0.9891765100, 0.9852776424, 0.9807852804, 0.9757021300, 0.9700312532, 0.9637760658, 0.9569403357, 0.9495281806, 0.9415440652, 0.9329927988, 0.9238795325, 0.9142097557, 0.9039892931, 0.8932243012, 0.8819212643, 0.8700869911, 0.8577286100, 0.8448535652, 0.8314696123, 0.8175848132, 0.8032075315, 0.7883464276, 0.7730104534, 0.7572088465, 0.7409511254, 0.7242470830, 0.7071067812, 0.6895405447, 0.6715589548, 0.6531728430, 0.6343932842, 0.6152315906, 0.5956993045, 0.5758081914, 0.5555702330, 0.5349976199, 0.5141027442, 0.4928981922, 0.4713967368, 0.4496113297, 0.4275550934, 0.4052413140, 0.3826834324, 0.3598950365, 0.3368898534, 0.3136817404, 0.2902846773, 0.2667127575, 0.2429801799, 0.2191012402, 0.1950903220, 0.1709618888, 0.1467304745, 0.1224106752, 0.0980171403, 0.0735645636, 0.0490676743, 0.0245412285, 0.0000000000, -0.0245412285, -0.0490676743, -0.0735645636, -0.0980171403, -0.1224106752, -0.1467304745, -0.1709618888, -0.1950903220, -0.2191012402, -0.2429801799, -0.2667127575, -0.2902846773, -0.3136817404, -0.3368898534, -0.3598950365, -0.3826834324, -0.4052413140, -0.4275550934, -0.4496113297, -0.4713967368, -0.4928981922, -0.5141027442, -0.5349976199, -0.5555702330, -0.5758081914, -0.5956993045, -0.6152315906, -0.6343932842, -0.6531728430, -0.6715589548, -0.6895405447, -0.7071067812, -0.7242470830, -0.7409511254, -0.7572088465, -0.7730104534, -0.7883464276, -0.8032075315, -0.8175848132, -0.8314696123, -0.8448535652, -0.8577286100, -0.8700869911, -0.8819212643, -0.8932243012, -0.9039892931, -0.9142097557, -0.9238795325, -0.9329927988, -0.9415440652, -0.9495281806, -0.9569403357, -0.9637760658, -0.9700312532, -0.9757021300, -0.9807852804, -0.9852776424, -0.9891765100, -0.9924795346, -0.9951847267, -0.9972904567, -0.9987954562, -0.9996988187}; - -value_type cos_lut8[256] = {0, 0.9999247018, 0.9996988187, 0.9993223846, 0.9987954562, 0.9981181129, 0.9972904567, 0.9963126122, 0.9951847267, 0.9939069700, 0.9924795346, 0.9909026354, 0.9891765100, 0.9873014182, 0.9852776424, 0.9831054874, 0.9807852804, 0.9783173707, 0.9757021300, 0.9729399522, 0.9700312532, 0.9669764710, 0.9637760658, 0.9604305194, 0.9569403357, 0.9533060404, 0.9495281806, 0.9456073254, 0.9415440652, 0.9373390119, 0.9329927988, 0.9285060805, 0.9238795325, 0.9191138517, 0.9142097557, 0.9091679831, 0.9039892931, 0.8986744657, 0.8932243012, 0.8876396204, 0.8819212643, 0.8760700942, 0.8700869911, 0.8639728561, 0.8577286100, 0.8513551931, 0.8448535652, 0.8382247056, 0.8314696123, 0.8245893028, 0.8175848132, 0.8104571983, 0.8032075315, 0.7958369046, 0.7883464276, 0.7807372286, 0.7730104534, 0.7651672656, 0.7572088465, 0.7491363945, 0.7409511254, 0.7326542717, 0.7242470830, 0.7157308253, 0.7071067812, 0.6983762494, 0.6895405447, 0.6806009978, 0.6715589548, 0.6624157776, 0.6531728430, 0.6438315429, 0.6343932842, 0.6248594881, 0.6152315906, 0.6055110414, 0.5956993045, 0.5857978575, 0.5758081914, 0.5657318108, 0.5555702330, 0.5453249884, 0.5349976199, 0.5245896827, 0.5141027442, 0.5035383837, 0.4928981922, 0.4821837721, 0.4713967368, 0.4605387110, 0.4496113297, 0.4386162385, 0.4275550934, 0.4164295601, 0.4052413140, 0.3939920401, 0.3826834324, 0.3713171940, 0.3598950365, 0.3484186802, 0.3368898534, 0.3253102922, 0.3136817404, 0.3020059493, 0.2902846773, 0.2785196894, 0.2667127575, 0.2548656596, 0.2429801799, 0.2310581083, 0.2191012402, 0.2071113762, 0.1950903220, 0.1830398880, 0.1709618888, 0.1588581433, 0.1467304745, 0.1345807085, 0.1224106752, 0.1102222073, 0.0980171403, 0.0857973123, 0.0735645636, 0.0613207363, 0.0490676743, 0.0368072229, 0.0245412285, 0.0122715383, 0.0000000000, -0.0122715383, -0.0245412285, -0.0368072229, -0.0490676743, -0.0613207363, -0.0735645636, -0.0857973123, -0.0980171403, -0.1102222073, -0.1224106752, -0.1345807085, -0.1467304745, -0.1588581433, -0.1709618888, -0.1830398880, -0.1950903220, -0.2071113762, -0.2191012402, -0.2310581083, -0.2429801799, -0.2548656596, -0.2667127575, -0.2785196894, -0.2902846773, -0.3020059493, -0.3136817404, -0.3253102922, -0.3368898534, -0.3484186802, -0.3598950365, -0.3713171940, -0.3826834324, -0.3939920401, -0.4052413140, -0.4164295601, -0.4275550934, -0.4386162385, -0.4496113297, -0.4605387110, -0.4713967368, -0.4821837721, -0.4928981922, -0.5035383837, -0.5141027442, -0.5245896827, -0.5349976199, -0.5453249884, -0.5555702330, -0.5657318108, -0.5758081914, -0.5857978575, -0.5956993045, -0.6055110414, -0.6152315906, -0.6248594881, -0.6343932842, -0.6438315429, -0.6531728430, -0.6624157776, -0.6715589548, -0.6806009978, -0.6895405447, -0.6983762494, -0.7071067812, -0.7157308253, -0.7242470830, -0.7326542717, -0.7409511254, -0.7491363945, -0.7572088465, -0.7651672656, -0.7730104534, -0.7807372286, -0.7883464276, -0.7958369046, -0.8032075315, -0.8104571983, -0.8175848132, -0.8245893028, -0.8314696123, -0.8382247056, -0.8448535652, -0.8513551931, -0.8577286100, -0.8639728561, -0.8700869911, -0.8760700942, -0.8819212643, -0.8876396204, -0.8932243012, -0.8986744657, -0.9039892931, -0.9091679831, -0.9142097557, -0.9191138517, -0.9238795325, -0.9285060805, -0.9329927988, -0.9373390119, -0.9415440652, -0.9456073254, -0.9495281806, -0.9533060404, -0.9569403357, -0.9604305194, -0.9637760658, -0.9669764710, -0.9700312532, -0.9729399522, -0.9757021300, -0.9783173707, -0.9807852804, -0.9831054874, -0.9852776424, -0.9873014182, -0.9891765100, -0.9909026354, -0.9924795346, -0.9939069700, -0.9951847267, -0.9963126122, -0.9972904567, -0.9981181129, -0.9987954562, -0.9993223846, -0.9996988187, -0.9999247018}; - -value_type cos_lut9[512] = {0, 0.9999811753, 0.9999247018, 0.9998305818, 0.9996988187, 0.9995294175, 0.9993223846, 0.9990777278, 0.9987954562, 0.9984755806, 0.9981181129, 0.9977230666, 0.9972904567, 0.9968202993, 0.9963126122, 0.9957674145, 0.9951847267, 0.9945645707, 0.9939069700, 0.9932119492, 0.9924795346, 0.9917097537, 0.9909026354, 0.9900582103, 0.9891765100, 0.9882575677, 0.9873014182, 0.9863080972, 0.9852776424, 0.9842100924, 0.9831054874, 0.9819638691, 0.9807852804, 0.9795697657, 0.9783173707, 0.9770281427, 0.9757021300, 0.9743393828, 0.9729399522, 0.9715038910, 0.9700312532, 0.9685220943, 0.9669764710, 0.9653944417, 0.9637760658, 0.9621214043, 0.9604305194, 0.9587034749, 0.9569403357, 0.9551411683, 0.9533060404, 0.9514350210, 0.9495281806, 0.9475855910, 0.9456073254, 0.9435934582, 0.9415440652, 0.9394592236, 0.9373390119, 0.9351835099, 0.9329927988, 0.9307669611, 0.9285060805, 0.9262102421, 0.9238795325, 0.9215140393, 0.9191138517, 0.9166790599, 0.9142097557, 0.9117060320, 0.9091679831, 0.9065957045, 0.9039892931, 0.9013488470, 0.8986744657, 0.8959662498, 0.8932243012, 0.8904487232, 0.8876396204, 0.8847970984, 0.8819212643, 0.8790122264, 0.8760700942, 0.8730949784, 0.8700869911, 0.8670462455, 0.8639728561, 0.8608669386, 0.8577286100, 0.8545579884, 0.8513551931, 0.8481203448, 0.8448535652, 0.8415549774, 0.8382247056, 0.8348628750, 0.8314696123, 0.8280450453, 0.8245893028, 0.8211025150, 0.8175848132, 0.8140363297, 0.8104571983, 0.8068475535, 0.8032075315, 0.7995372691, 0.7958369046, 0.7921065773, 0.7883464276, 0.7845565972, 0.7807372286, 0.7768884657, 0.7730104534, 0.7691033376, 0.7651672656, 0.7612023855, 0.7572088465, 0.7531867990, 0.7491363945, 0.7450577854, 0.7409511254, 0.7368165689, 0.7326542717, 0.7284643904, 0.7242470830, 0.7200025080, 0.7157308253, 0.7114321957, 0.7071067812, 0.7027547445, 0.6983762494, 0.6939714609, 0.6895405447, 0.6850836678, 0.6806009978, 0.6760927036, 0.6715589548, 0.6669999223, 0.6624157776, 0.6578066933, 0.6531728430, 0.6485144010, 0.6438315429, 0.6391244449, 0.6343932842, 0.6296382389, 0.6248594881, 0.6200572118, 0.6152315906, 0.6103828063, 0.6055110414, 0.6006164794, 0.5956993045, 0.5907597019, 0.5857978575, 0.5808139581, 0.5758081914, 0.5707807459, 0.5657318108, 0.5606615762, 0.5555702330, 0.5504579729, 0.5453249884, 0.5401714727, 0.5349976199, 0.5298036247, 0.5245896827, 0.5193559902, 0.5141027442, 0.5088301425, 0.5035383837, 0.4982276670, 0.4928981922, 0.4875501601, 0.4821837721, 0.4767992301, 0.4713967368, 0.4659764958, 0.4605387110, 0.4550835871, 0.4496113297, 0.4441221446, 0.4386162385, 0.4330938189, 0.4275550934, 0.4220002708, 0.4164295601, 0.4108431711, 0.4052413140, 0.3996241998, 0.3939920401, 0.3883450467, 0.3826834324, 0.3770074102, 0.3713171940, 0.3656129978, 0.3598950365, 0.3541635254, 0.3484186802, 0.3426607173, 0.3368898534, 0.3311063058, 0.3253102922, 0.3195020308, 0.3136817404, 0.3078496400, 0.3020059493, 0.2961508882, 0.2902846773, 0.2844075372, 0.2785196894, 0.2726213554, 0.2667127575, 0.2607941179, 0.2548656596, 0.2489276057, 0.2429801799, 0.2370236060, 0.2310581083, 0.2250839114, 0.2191012402, 0.2131103199, 0.2071113762, 0.2011046348, 0.1950903220, 0.1890686641, 0.1830398880, 0.1770042204, 0.1709618888, 0.1649131205, 0.1588581433, 0.1527971853, 0.1467304745, 0.1406582393, 0.1345807085, 0.1284981108, 0.1224106752, 0.1163186309, 0.1102222073, 0.1041216339, 0.0980171403, 0.0919089565, 0.0857973123, 0.0796824380, 0.0735645636, 0.0674439196, 0.0613207363, 0.0551952443, 0.0490676743, 0.0429382569, 0.0368072229, 0.0306748032, 0.0245412285, 0.0184067299, 0.0122715383, 0.0061358846, 0.0000000000, -0.0061358846, -0.0122715383, -0.0184067299, -0.0245412285, -0.0306748032, -0.0368072229, -0.0429382569, -0.0490676743, -0.0551952443, -0.0613207363, -0.0674439196, -0.0735645636, -0.0796824380, -0.0857973123, -0.0919089565, -0.0980171403, -0.1041216339, -0.1102222073, -0.1163186309, -0.1224106752, -0.1284981108, -0.1345807085, -0.1406582393, -0.1467304745, -0.1527971853, -0.1588581433, -0.1649131205, -0.1709618888, -0.1770042204, -0.1830398880, -0.1890686641, -0.1950903220, -0.2011046348, -0.2071113762, -0.2131103199, -0.2191012402, -0.2250839114, -0.2310581083, -0.2370236060, -0.2429801799, -0.2489276057, -0.2548656596, -0.2607941179, -0.2667127575, -0.2726213554, -0.2785196894, -0.2844075372, -0.2902846773, -0.2961508882, -0.3020059493, -0.3078496400, -0.3136817404, -0.3195020308, -0.3253102922, -0.3311063058, -0.3368898534, -0.3426607173, -0.3484186802, -0.3541635254, -0.3598950365, -0.3656129978, -0.3713171940, -0.3770074102, -0.3826834324, -0.3883450467, -0.3939920401, -0.3996241998, -0.4052413140, -0.4108431711, -0.4164295601, -0.4220002708, -0.4275550934, -0.4330938189, -0.4386162385, -0.4441221446, -0.4496113297, -0.4550835871, -0.4605387110, -0.4659764958, -0.4713967368, -0.4767992301, -0.4821837721, -0.4875501601, -0.4928981922, -0.4982276670, -0.5035383837, -0.5088301425, -0.5141027442, -0.5193559902, -0.5245896827, -0.5298036247, -0.5349976199, -0.5401714727, -0.5453249884, -0.5504579729, -0.5555702330, -0.5606615762, -0.5657318108, -0.5707807459, -0.5758081914, -0.5808139581, -0.5857978575, -0.5907597019, -0.5956993045, -0.6006164794, -0.6055110414, -0.6103828063, -0.6152315906, -0.6200572118, -0.6248594881, -0.6296382389, -0.6343932842, -0.6391244449, -0.6438315429, -0.6485144010, -0.6531728430, -0.6578066933, -0.6624157776, -0.6669999223, -0.6715589548, -0.6760927036, -0.6806009978, -0.6850836678, -0.6895405447, -0.6939714609, -0.6983762494, -0.7027547445, -0.7071067812, -0.7114321957, -0.7157308253, -0.7200025080, -0.7242470830, -0.7284643904, -0.7326542717, -0.7368165689, -0.7409511254, -0.7450577854, -0.7491363945, -0.7531867990, -0.7572088465, -0.7612023855, -0.7651672656, -0.7691033376, -0.7730104534, -0.7768884657, -0.7807372286, -0.7845565972, -0.7883464276, -0.7921065773, -0.7958369046, -0.7995372691, -0.8032075315, -0.8068475535, -0.8104571983, -0.8140363297, -0.8175848132, -0.8211025150, -0.8245893028, -0.8280450453, -0.8314696123, -0.8348628750, -0.8382247056, -0.8415549774, -0.8448535652, -0.8481203448, -0.8513551931, -0.8545579884, -0.8577286100, -0.8608669386, -0.8639728561, -0.8670462455, -0.8700869911, -0.8730949784, -0.8760700942, -0.8790122264, -0.8819212643, -0.8847970984, -0.8876396204, -0.8904487232, -0.8932243012, -0.8959662498, -0.8986744657, -0.9013488470, -0.9039892931, -0.9065957045, -0.9091679831, -0.9117060320, -0.9142097557, -0.9166790599, -0.9191138517, -0.9215140393, -0.9238795325, -0.9262102421, -0.9285060805, -0.9307669611, -0.9329927988, -0.9351835099, -0.9373390119, -0.9394592236, -0.9415440652, -0.9435934582, -0.9456073254, -0.9475855910, -0.9495281806, -0.9514350210, -0.9533060404, -0.9551411683, -0.9569403357, -0.9587034749, -0.9604305194, -0.9621214043, -0.9637760658, -0.9653944417, -0.9669764710, -0.9685220943, -0.9700312532, -0.9715038910, -0.9729399522, -0.9743393828, -0.9757021300, -0.9770281427, -0.9783173707, -0.9795697657, -0.9807852804, -0.9819638691, -0.9831054874, -0.9842100924, -0.9852776424, -0.9863080972, -0.9873014182, -0.9882575677, -0.9891765100, -0.9900582103, -0.9909026354, -0.9917097537, -0.9924795346, -0.9932119492, -0.9939069700, -0.9945645707, -0.9951847267, -0.9957674145, -0.9963126122, -0.9968202993, -0.9972904567, -0.9977230666, -0.9981181129, -0.9984755806, -0.9987954562, -0.9990777278, -0.9993223846, -0.9995294175, -0.9996988187, -0.9998305818, -0.9999247018, -0.9999811753}; - -value_type cos_lut10[1024] = {0, 0.9999952938, 0.9999811753, 0.9999576446, 0.9999247018, 0.9998823475, 0.9998305818, 0.9997694054, 0.9996988187, 0.9996188225, 0.9995294175, 0.9994306046, 0.9993223846, 0.9992047586, 0.9990777278, 0.9989412932, 0.9987954562, 0.9986402182, 0.9984755806, 0.9983015449, 0.9981181129, 0.9979252862, 0.9977230666, 0.9975114561, 0.9972904567, 0.9970600703, 0.9968202993, 0.9965711458, 0.9963126122, 0.9960447009, 0.9957674145, 0.9954807555, 0.9951847267, 0.9948793308, 0.9945645707, 0.9942404495, 0.9939069700, 0.9935641355, 0.9932119492, 0.9928504145, 0.9924795346, 0.9920993131, 0.9917097537, 0.9913108598, 0.9909026354, 0.9904850843, 0.9900582103, 0.9896220175, 0.9891765100, 0.9887216920, 0.9882575677, 0.9877841416, 0.9873014182, 0.9868094018, 0.9863080972, 0.9857975092, 0.9852776424, 0.9847485018, 0.9842100924, 0.9836624192, 0.9831054874, 0.9825393023, 0.9819638691, 0.9813791933, 0.9807852804, 0.9801821360, 0.9795697657, 0.9789481753, 0.9783173707, 0.9776773578, 0.9770281427, 0.9763697313, 0.9757021300, 0.9750253451, 0.9743393828, 0.9736442497, 0.9729399522, 0.9722264971, 0.9715038910, 0.9707721407, 0.9700312532, 0.9692812354, 0.9685220943, 0.9677538371, 0.9669764710, 0.9661900034, 0.9653944417, 0.9645897933, 0.9637760658, 0.9629532669, 0.9621214043, 0.9612804858, 0.9604305194, 0.9595715131, 0.9587034749, 0.9578264130, 0.9569403357, 0.9560452513, 0.9551411683, 0.9542280951, 0.9533060404, 0.9523750127, 0.9514350210, 0.9504860739, 0.9495281806, 0.9485613499, 0.9475855910, 0.9466009131, 0.9456073254, 0.9446048373, 0.9435934582, 0.9425731976, 0.9415440652, 0.9405060706, 0.9394592236, 0.9384035341, 0.9373390119, 0.9362656672, 0.9351835099, 0.9340925504, 0.9329927988, 0.9318842656, 0.9307669611, 0.9296408958, 0.9285060805, 0.9273625257, 0.9262102421, 0.9250492408, 0.9238795325, 0.9227011283, 0.9215140393, 0.9203182767, 0.9191138517, 0.9179007756, 0.9166790599, 0.9154487161, 0.9142097557, 0.9129621904, 0.9117060320, 0.9104412923, 0.9091679831, 0.9078861165, 0.9065957045, 0.9052967593, 0.9039892931, 0.9026733182, 0.9013488470, 0.9000158920, 0.8986744657, 0.8973245807, 0.8959662498, 0.8945994856, 0.8932243012, 0.8918407094, 0.8904487232, 0.8890483559, 0.8876396204, 0.8862225301, 0.8847970984, 0.8833633387, 0.8819212643, 0.8804708891, 0.8790122264, 0.8775452902, 0.8760700942, 0.8745866523, 0.8730949784, 0.8715950867, 0.8700869911, 0.8685707060, 0.8670462455, 0.8655136241, 0.8639728561, 0.8624239561, 0.8608669386, 0.8593018184, 0.8577286100, 0.8561473284, 0.8545579884, 0.8529606049, 0.8513551931, 0.8497417680, 0.8481203448, 0.8464909388, 0.8448535652, 0.8432082396, 0.8415549774, 0.8398937942, 0.8382247056, 0.8365477272, 0.8348628750, 0.8331701647, 0.8314696123, 0.8297612338, 0.8280450453, 0.8263210628, 0.8245893028, 0.8228497814, 0.8211025150, 0.8193475201, 0.8175848132, 0.8158144108, 0.8140363297, 0.8122505866, 0.8104571983, 0.8086561816, 0.8068475535, 0.8050313311, 0.8032075315, 0.8013761717, 0.7995372691, 0.7976908409, 0.7958369046, 0.7939754776, 0.7921065773, 0.7902302214, 0.7883464276, 0.7864552136, 0.7845565972, 0.7826505962, 0.7807372286, 0.7788165124, 0.7768884657, 0.7749531066, 0.7730104534, 0.7710605243, 0.7691033376, 0.7671389119, 0.7651672656, 0.7631884173, 0.7612023855, 0.7592091890, 0.7572088465, 0.7552013769, 0.7531867990, 0.7511651319, 0.7491363945, 0.7471006060, 0.7450577854, 0.7430079521, 0.7409511254, 0.7388873245, 0.7368165689, 0.7347388781, 0.7326542717, 0.7305627692, 0.7284643904, 0.7263591551, 0.7242470830, 0.7221281939, 0.7200025080, 0.7178700451, 0.7157308253, 0.7135848688, 0.7114321957, 0.7092728264, 0.7071067812, 0.7049340804, 0.7027547445, 0.7005687939, 0.6983762494, 0.6961771315, 0.6939714609, 0.6917592584, 0.6895405447, 0.6873153409, 0.6850836678, 0.6828455464, 0.6806009978, 0.6783500431, 0.6760927036, 0.6738290004, 0.6715589548, 0.6692825883, 0.6669999223, 0.6647109782, 0.6624157776, 0.6601143421, 0.6578066933, 0.6554928530, 0.6531728430, 0.6508466850, 0.6485144010, 0.6461760130, 0.6438315429, 0.6414810128, 0.6391244449, 0.6367618612, 0.6343932842, 0.6320187359, 0.6296382389, 0.6272518155, 0.6248594881, 0.6224612794, 0.6200572118, 0.6176473079, 0.6152315906, 0.6128100824, 0.6103828063, 0.6079497850, 0.6055110414, 0.6030665985, 0.6006164794, 0.5981607070, 0.5956993045, 0.5932322950, 0.5907597019, 0.5882815482, 0.5857978575, 0.5833086529, 0.5808139581, 0.5783137964, 0.5758081914, 0.5732971667, 0.5707807459, 0.5682589527, 0.5657318108, 0.5631993440, 0.5606615762, 0.5581185312, 0.5555702330, 0.5530167056, 0.5504579729, 0.5478940592, 0.5453249884, 0.5427507849, 0.5401714727, 0.5375870763, 0.5349976199, 0.5324031279, 0.5298036247, 0.5271991348, 0.5245896827, 0.5219752929, 0.5193559902, 0.5167317990, 0.5141027442, 0.5114688504, 0.5088301425, 0.5061866453, 0.5035383837, 0.5008853826, 0.4982276670, 0.4955652618, 0.4928981922, 0.4902264833, 0.4875501601, 0.4848692480, 0.4821837721, 0.4794937577, 0.4767992301, 0.4741002147, 0.4713967368, 0.4686888220, 0.4659764958, 0.4632597836, 0.4605387110, 0.4578133036, 0.4550835871, 0.4523495872, 0.4496113297, 0.4468688402, 0.4441221446, 0.4413712687, 0.4386162385, 0.4358570799, 0.4330938189, 0.4303264813, 0.4275550934, 0.4247796812, 0.4220002708, 0.4192168884, 0.4164295601, 0.4136383122, 0.4108431711, 0.4080441629, 0.4052413140, 0.4024346509, 0.3996241998, 0.3968099874, 0.3939920401, 0.3911703843, 0.3883450467, 0.3855160538, 0.3826834324, 0.3798472089, 0.3770074102, 0.3741640630, 0.3713171940, 0.3684668300, 0.3656129978, 0.3627557244, 0.3598950365, 0.3570309612, 0.3541635254, 0.3512927561, 0.3484186802, 0.3455413250, 0.3426607173, 0.3397768844, 0.3368898534, 0.3339996514, 0.3311063058, 0.3282098436, 0.3253102922, 0.3224076788, 0.3195020308, 0.3165933756, 0.3136817404, 0.3107671527, 0.3078496400, 0.3049292297, 0.3020059493, 0.2990798263, 0.2961508882, 0.2932191627, 0.2902846773, 0.2873474595, 0.2844075372, 0.2814649379, 0.2785196894, 0.2755718193, 0.2726213554, 0.2696683256, 0.2667127575, 0.2637546790, 0.2607941179, 0.2578311022, 0.2548656596, 0.2518978182, 0.2489276057, 0.2459550503, 0.2429801799, 0.2400030224, 0.2370236060, 0.2340419586, 0.2310581083, 0.2280720832, 0.2250839114, 0.2220936210, 0.2191012402, 0.2161067971, 0.2131103199, 0.2101118369, 0.2071113762, 0.2041089661, 0.2011046348, 0.1980984107, 0.1950903220, 0.1920803970, 0.1890686641, 0.1860551517, 0.1830398880, 0.1800229014, 0.1770042204, 0.1739838734, 0.1709618888, 0.1679382950, 0.1649131205, 0.1618863938, 0.1588581433, 0.1558283977, 0.1527971853, 0.1497645347, 0.1467304745, 0.1436950332, 0.1406582393, 0.1376201216, 0.1345807085, 0.1315400287, 0.1284981108, 0.1254549834, 0.1224106752, 0.1193652148, 0.1163186309, 0.1132709522, 0.1102222073, 0.1071724250, 0.1041216339, 0.1010698628, 0.0980171403, 0.0949634953, 0.0919089565, 0.0888535526, 0.0857973123, 0.0827402645, 0.0796824380, 0.0766238614, 0.0735645636, 0.0705045734, 0.0674439196, 0.0643826309, 0.0613207363, 0.0582582645, 0.0551952443, 0.0521317047, 0.0490676743, 0.0460031821, 0.0429382569, 0.0398729276, 0.0368072229, 0.0337411719, 0.0306748032, 0.0276081458, 0.0245412285, 0.0214740803, 0.0184067299, 0.0153392063, 0.0122715383, 0.0092037548, 0.0061358846, 0.0030679568, 0.0000000000, -0.0030679568, -0.0061358846, -0.0092037548, -0.0122715383, -0.0153392063, -0.0184067299, -0.0214740803, -0.0245412285, -0.0276081458, -0.0306748032, -0.0337411719, -0.0368072229, -0.0398729276, -0.0429382569, -0.0460031821, -0.0490676743, -0.0521317047, -0.0551952443, -0.0582582645, -0.0613207363, -0.0643826309, -0.0674439196, -0.0705045734, -0.0735645636, -0.0766238614, -0.0796824380, -0.0827402645, -0.0857973123, -0.0888535526, -0.0919089565, -0.0949634953, -0.0980171403, -0.1010698628, -0.1041216339, -0.1071724250, -0.1102222073, -0.1132709522, -0.1163186309, -0.1193652148, -0.1224106752, -0.1254549834, -0.1284981108, -0.1315400287, -0.1345807085, -0.1376201216, -0.1406582393, -0.1436950332, -0.1467304745, -0.1497645347, -0.1527971853, -0.1558283977, -0.1588581433, -0.1618863938, -0.1649131205, -0.1679382950, -0.1709618888, -0.1739838734, -0.1770042204, -0.1800229014, -0.1830398880, -0.1860551517, -0.1890686641, -0.1920803970, -0.1950903220, -0.1980984107, -0.2011046348, -0.2041089661, -0.2071113762, -0.2101118369, -0.2131103199, -0.2161067971, -0.2191012402, -0.2220936210, -0.2250839114, -0.2280720832, -0.2310581083, -0.2340419586, -0.2370236060, -0.2400030224, -0.2429801799, -0.2459550503, -0.2489276057, -0.2518978182, -0.2548656596, -0.2578311022, -0.2607941179, -0.2637546790, -0.2667127575, -0.2696683256, -0.2726213554, -0.2755718193, -0.2785196894, -0.2814649379, -0.2844075372, -0.2873474595, -0.2902846773, -0.2932191627, -0.2961508882, -0.2990798263, -0.3020059493, -0.3049292297, -0.3078496400, -0.3107671527, -0.3136817404, -0.3165933756, -0.3195020308, -0.3224076788, -0.3253102922, -0.3282098436, -0.3311063058, -0.3339996514, -0.3368898534, -0.3397768844, -0.3426607173, -0.3455413250, -0.3484186802, -0.3512927561, -0.3541635254, -0.3570309612, -0.3598950365, -0.3627557244, -0.3656129978, -0.3684668300, -0.3713171940, -0.3741640630, -0.3770074102, -0.3798472089, -0.3826834324, -0.3855160538, -0.3883450467, -0.3911703843, -0.3939920401, -0.3968099874, -0.3996241998, -0.4024346509, -0.4052413140, -0.4080441629, -0.4108431711, -0.4136383122, -0.4164295601, -0.4192168884, -0.4220002708, -0.4247796812, -0.4275550934, -0.4303264813, -0.4330938189, -0.4358570799, -0.4386162385, -0.4413712687, -0.4441221446, -0.4468688402, -0.4496113297, -0.4523495872, -0.4550835871, -0.4578133036, -0.4605387110, -0.4632597836, -0.4659764958, -0.4686888220, -0.4713967368, -0.4741002147, -0.4767992301, -0.4794937577, -0.4821837721, -0.4848692480, -0.4875501601, -0.4902264833, -0.4928981922, -0.4955652618, -0.4982276670, -0.5008853826, -0.5035383837, -0.5061866453, -0.5088301425, -0.5114688504, -0.5141027442, -0.5167317990, -0.5193559902, -0.5219752929, -0.5245896827, -0.5271991348, -0.5298036247, -0.5324031279, -0.5349976199, -0.5375870763, -0.5401714727, -0.5427507849, -0.5453249884, -0.5478940592, -0.5504579729, -0.5530167056, -0.5555702330, -0.5581185312, -0.5606615762, -0.5631993440, -0.5657318108, -0.5682589527, -0.5707807459, -0.5732971667, -0.5758081914, -0.5783137964, -0.5808139581, -0.5833086529, -0.5857978575, -0.5882815482, -0.5907597019, -0.5932322950, -0.5956993045, -0.5981607070, -0.6006164794, -0.6030665985, -0.6055110414, -0.6079497850, -0.6103828063, -0.6128100824, -0.6152315906, -0.6176473079, -0.6200572118, -0.6224612794, -0.6248594881, -0.6272518155, -0.6296382389, -0.6320187359, -0.6343932842, -0.6367618612, -0.6391244449, -0.6414810128, -0.6438315429, -0.6461760130, -0.6485144010, -0.6508466850, -0.6531728430, -0.6554928530, -0.6578066933, -0.6601143421, -0.6624157776, -0.6647109782, -0.6669999223, -0.6692825883, -0.6715589548, -0.6738290004, -0.6760927036, -0.6783500431, -0.6806009978, -0.6828455464, -0.6850836678, -0.6873153409, -0.6895405447, -0.6917592584, -0.6939714609, -0.6961771315, -0.6983762494, -0.7005687939, -0.7027547445, -0.7049340804, -0.7071067812, -0.7092728264, -0.7114321957, -0.7135848688, -0.7157308253, -0.7178700451, -0.7200025080, -0.7221281939, -0.7242470830, -0.7263591551, -0.7284643904, -0.7305627692, -0.7326542717, -0.7347388781, -0.7368165689, -0.7388873245, -0.7409511254, -0.7430079521, -0.7450577854, -0.7471006060, -0.7491363945, -0.7511651319, -0.7531867990, -0.7552013769, -0.7572088465, -0.7592091890, -0.7612023855, -0.7631884173, -0.7651672656, -0.7671389119, -0.7691033376, -0.7710605243, -0.7730104534, -0.7749531066, -0.7768884657, -0.7788165124, -0.7807372286, -0.7826505962, -0.7845565972, -0.7864552136, -0.7883464276, -0.7902302214, -0.7921065773, -0.7939754776, -0.7958369046, -0.7976908409, -0.7995372691, -0.8013761717, -0.8032075315, -0.8050313311, -0.8068475535, -0.8086561816, -0.8104571983, -0.8122505866, -0.8140363297, -0.8158144108, -0.8175848132, -0.8193475201, -0.8211025150, -0.8228497814, -0.8245893028, -0.8263210628, -0.8280450453, -0.8297612338, -0.8314696123, -0.8331701647, -0.8348628750, -0.8365477272, -0.8382247056, -0.8398937942, -0.8415549774, -0.8432082396, -0.8448535652, -0.8464909388, -0.8481203448, -0.8497417680, -0.8513551931, -0.8529606049, -0.8545579884, -0.8561473284, -0.8577286100, -0.8593018184, -0.8608669386, -0.8624239561, -0.8639728561, -0.8655136241, -0.8670462455, -0.8685707060, -0.8700869911, -0.8715950867, -0.8730949784, -0.8745866523, -0.8760700942, -0.8775452902, -0.8790122264, -0.8804708891, -0.8819212643, -0.8833633387, -0.8847970984, -0.8862225301, -0.8876396204, -0.8890483559, -0.8904487232, -0.8918407094, -0.8932243012, -0.8945994856, -0.8959662498, -0.8973245807, -0.8986744657, -0.9000158920, -0.9013488470, -0.9026733182, -0.9039892931, -0.9052967593, -0.9065957045, -0.9078861165, -0.9091679831, -0.9104412923, -0.9117060320, -0.9129621904, -0.9142097557, -0.9154487161, -0.9166790599, -0.9179007756, -0.9191138517, -0.9203182767, -0.9215140393, -0.9227011283, -0.9238795325, -0.9250492408, -0.9262102421, -0.9273625257, -0.9285060805, -0.9296408958, -0.9307669611, -0.9318842656, -0.9329927988, -0.9340925504, -0.9351835099, -0.9362656672, -0.9373390119, -0.9384035341, -0.9394592236, -0.9405060706, -0.9415440652, -0.9425731976, -0.9435934582, -0.9446048373, -0.9456073254, -0.9466009131, -0.9475855910, -0.9485613499, -0.9495281806, -0.9504860739, -0.9514350210, -0.9523750127, -0.9533060404, -0.9542280951, -0.9551411683, -0.9560452513, -0.9569403357, -0.9578264130, -0.9587034749, -0.9595715131, -0.9604305194, -0.9612804858, -0.9621214043, -0.9629532669, -0.9637760658, -0.9645897933, -0.9653944417, -0.9661900034, -0.9669764710, -0.9677538371, -0.9685220943, -0.9692812354, -0.9700312532, -0.9707721407, -0.9715038910, -0.9722264971, -0.9729399522, -0.9736442497, -0.9743393828, -0.9750253451, -0.9757021300, -0.9763697313, -0.9770281427, -0.9776773578, -0.9783173707, -0.9789481753, -0.9795697657, -0.9801821360, -0.9807852804, -0.9813791933, -0.9819638691, -0.9825393023, -0.9831054874, -0.9836624192, -0.9842100924, -0.9847485018, -0.9852776424, -0.9857975092, -0.9863080972, -0.9868094018, -0.9873014182, -0.9877841416, -0.9882575677, -0.9887216920, -0.9891765100, -0.9896220175, -0.9900582103, -0.9904850843, -0.9909026354, -0.9913108598, -0.9917097537, -0.9920993131, -0.9924795346, -0.9928504145, -0.9932119492, -0.9935641355, -0.9939069700, -0.9942404495, -0.9945645707, -0.9948793308, -0.9951847267, -0.9954807555, -0.9957674145, -0.9960447009, -0.9963126122, -0.9965711458, -0.9968202993, -0.9970600703, -0.9972904567, -0.9975114561, -0.9977230666, -0.9979252862, -0.9981181129, -0.9983015449, -0.9984755806, -0.9986402182, -0.9987954562, -0.9989412932, -0.9990777278, -0.9992047586, -0.9993223846, -0.9994306046, -0.9995294175, -0.9996188225, -0.9996988187, -0.9997694054, -0.9998305818, -0.9998823475, -0.9999247018, -0.9999576446, -0.9999811753, -0.9999952938}; - -value_type *cos_lut[10] = {cos_lut1, cos_lut2, cos_lut3, cos_lut4, cos_lut5, cos_lut6, cos_lut7, cos_lut8, cos_lut9, cos_lut10}; +value_type *cos_lut[8] = {cos_lut0, cos_lut1, cos_lut2, cos_lut3, cos_lut4, cos_lut5, cos_lut6, cos_lut7}; value_type lookup_sin(int layer, int element) { diff --git a/main.c b/main.c index a6a5d7a..1c43f92 100644 --- a/main.c +++ b/main.c @@ -113,7 +113,7 @@ void* fft_thread(void *param) { } nextFrame += 1.000/FPS; - sleep_until(nextFrame); + //sleep_until(nextFrame); } return NULL; @@ -130,6 +130,7 @@ int main(int argc, char **argv) { pthread_t fftThread; int active = 1; + int frame = 0; double *red; double *green; @@ -143,7 +144,7 @@ int main(int argc, char **argv) { } // initialize lua - lua_State *L = lua_open(); + lua_State *L = luaL_newstate(); // load the lua libraries luaL_openlibs(L); @@ -240,22 +241,24 @@ int main(int argc, char **argv) { lua_readdoublearray(L, green, num_modules); lua_readdoublearray(L, red, num_modules); - if(useFading) { - for(i = 0; i < num_modules; i++) { - ws2801_fade_color(i, - 255 * gamma_correct(red[i], gamma), - 255 * gamma_correct(green[i], gamma), - 255 * gamma_correct(blue[i], gamma)); + if((++frame & 1) == 0) { + if(useFading) { + for(i = 0; i < num_modules; i++) { + ws2801_fade_color(i, + 255 * gamma_correct(red[i], gamma), + 255 * gamma_correct(green[i], gamma), + 255 * gamma_correct(blue[i], gamma)); + } + ws2801_commit(); + } else { + for(i = 0; i < num_modules; i++) { + ws2801_set_color(i, + 255 * gamma_correct(red[i], gamma), + 255 * gamma_correct(green[i], gamma), + 255 * gamma_correct(blue[i], gamma)); + } + ws2801_commit(); } - ws2801_commit(); - } else { - for(i = 0; i < num_modules; i++) { - ws2801_set_color(i, - 255 * gamma_correct(red[i], gamma), - 255 * gamma_correct(green[i], gamma), - 255 * gamma_correct(blue[i], gamma)); - } - ws2801_commit(); } if(lastUpdateTime < nextFrame - 1) { diff --git a/pulsar.lua b/pulsar.lua new file mode 100644 index 0000000..9ee54b6 --- /dev/null +++ b/pulsar.lua @@ -0,0 +1,174 @@ +COOLDOWN_FACTOR = 0.9995 +OVERDRIVE = 1.50 +EXPONENT = 1.5 + +M = 1.7 -- mass +D = 1 -- spring strength +DAMPING = {} -- filled in init() + +num_modules = 128 +center_module = 64 + +num_masses = math.floor(num_modules/2) +excitement_pos = math.floor(center_module/2) + +-- maximum energy values for each band +maxRedEnergy = 1 +maxGreenEnergy = 1 +maxBlueEnergy = 1 + +-- spring-mass-grid values +pos_r = {} +pos_g = {} +pos_b = {} + +vel_r = {} +vel_g = {} +vel_b = {} + +acc_r = {} +acc_g = {} +acc_b = {} + +-- output color buffers +red = {} +green = {} +blue = {} + +r_tmp = {} +g_tmp = {} +b_tmp = {} + +function limit(val) + if val > 1 then + return 1 + elseif val < 0 then + return 0 + else + return val + end +end + +function periodic() + local redEnergy = get_energy_in_band(0, 400); + local greenEnergy = get_energy_in_band(400, 4000); + local blueEnergy = get_energy_in_band(4000, 22000); + local centerIndex = 2 * center_module + 1; + + maxRedEnergy = maxRedEnergy * COOLDOWN_FACTOR + if redEnergy > maxRedEnergy then + maxRedEnergy = redEnergy + end + + maxGreenEnergy = maxGreenEnergy * COOLDOWN_FACTOR + if greenEnergy > maxGreenEnergy then + maxGreenEnergy = greenEnergy + end + + maxBlueEnergy = maxBlueEnergy * COOLDOWN_FACTOR + if blueEnergy > maxBlueEnergy then + maxBlueEnergy = blueEnergy + end + + -- update the spring-mass string + + -- the outside masses are special, as they are auto-returned to 0 position + -- { spring-mass pendulum } { friction } + acc_r[1] = (-pos_r[1] + (pos_r[2] - pos_r[1])) * D / M + acc_g[1] = (-pos_g[1] + (pos_g[2] - pos_g[1])) * D / M + acc_b[1] = (-pos_b[1] + (pos_b[2] - pos_b[1])) * D / M + + acc_r[num_masses] = (-pos_r[num_masses] + (pos_r[num_masses-1] - pos_r[num_masses])) * D / M + acc_g[num_masses] = (-pos_g[num_masses] + (pos_g[num_masses-1] - pos_g[num_masses])) * D / M + acc_b[num_masses] = (-pos_b[num_masses] + (pos_b[num_masses-1] - pos_b[num_masses])) * D / M + + -- inside masses are only influenced by their neighbors + for i = 2,num_masses-1 do + acc_r[i] = (pos_r[i-1] + pos_r[i+1] - 2 * pos_r[i]) * D / M + acc_g[i] = (pos_g[i-1] + pos_g[i+1] - 2 * pos_g[i]) * D / M + acc_b[i] = (pos_b[i-1] + pos_b[i+1] - 2 * pos_b[i]) * D / M + end + + -- update velocity and position + for i = 1,num_masses do + vel_r[i] = DAMPING[i] * (vel_r[i] + acc_r[i]) + vel_g[i] = DAMPING[i] * (vel_g[i] + acc_g[i]) + vel_b[i] = DAMPING[i] * (vel_b[i] + acc_b[i]) + + pos_r[i] = pos_r[i] + vel_r[i] + pos_g[i] = pos_g[i] + vel_g[i] + pos_b[i] = pos_b[i] + vel_b[i] + end + + -- set the new position for the center module + newRed = redEnergy / maxRedEnergy + pos_r[excitement_pos] = newRed + vel_r[excitement_pos] = 0 + acc_r[excitement_pos] = 0 + + newGreen = greenEnergy / maxGreenEnergy + pos_g[excitement_pos] = newGreen + vel_b[excitement_pos] = 0 + acc_b[excitement_pos] = 0 + + newBlue = blueEnergy / maxBlueEnergy + pos_b[excitement_pos] = newBlue + vel_b[excitement_pos] = 0 + acc_b[excitement_pos] = 0 + + -- map to LED modules + for i = 1,num_masses do + r_tmp[i] = pos_r[i] + g_tmp[i] = pos_g[i] + b_tmp[i] = pos_b[i] + + r_tmp[num_modules-i+1] = pos_r[i] + g_tmp[num_modules-i+1] = pos_g[i] + b_tmp[num_modules-i+1] = pos_b[i] + + --print(i, pos_r[i]) + end + + -- make colors more exciting + for i = 1,num_modules do + red[i] = limit(OVERDRIVE * math.pow(r_tmp[i], EXPONENT)) + green[i] = limit(OVERDRIVE * math.pow(g_tmp[i], EXPONENT)) + blue[i] = limit(OVERDRIVE * math.pow(b_tmp[i], EXPONENT)) + end + + -- return the 3 color arrays + return red, green, blue +end + +function init(nmod, cmod) + num_modules = nmod + center_module = cmod + + num_masses = math.floor(nmod/2) + excitement_pos = math.floor(cmod/2) + + for i = 1,nmod do + red[i] = 0 + green[i] = 0 + blue[i] = 0 + end + + for i = 1,num_masses do + pos_r[i] = 0 + pos_g[i] = 0 + pos_b[i] = 0 + + vel_r[i] = 0 + vel_g[i] = 0 + vel_b[i] = 0 + + acc_r[i] = 0 + acc_g[i] = 0 + acc_b[i] = 0 + + DAMPING[i] = 1 - 0.5 * math.pow(math.abs((i - excitement_pos) / num_masses), 2) + end + + -- don't use fading + return 0 +end diff --git a/pulsecircle.lua b/pulsecircle.lua index 58b0fbe..24223cf 100644 --- a/pulsecircle.lua +++ b/pulsecircle.lua @@ -1,8 +1,10 @@ COOLDOWN_FACTOR = 0.9998 -FADE_FACTOR = 0.985 +FADE_FACTOR = 1 +OVERDRIVE = 1.30 +EXPONENT = 1.8 -num_modules = 20 -center_module = 10 +num_modules = 160 +center_module = 80 -- maximum energy values for each band maxRedEnergy = 1 @@ -18,6 +20,14 @@ tmpRed = {} tmpGreen = {} tmpBlue = {} +function limit(val) + if val > 1 then + return 1 + else + return val + end +end + function periodic() local redEnergy = get_energy_in_band(0, 400); local greenEnergy = get_energy_in_band(400, 4000); @@ -48,30 +58,33 @@ function periodic() -- set the new value for the center module newRed = redEnergy / maxRedEnergy - if newRed > tmpRed[num_modules] then - tmpRed[1] = newRed - else - tmpRed[1] = tmpRed[num_modules] - end + tmpRed[1] = newRed + --if newRed > tmpRed[num_modules] then + -- tmpRed[1] = newRed + --else + -- tmpRed[1] = tmpRed[num_modules] + --end newGreen = greenEnergy / maxGreenEnergy - if newGreen > tmpGreen[num_modules] then - tmpGreen[1] = newGreen - else - tmpGreen[1] = tmpGreen[num_modules] - end + tmpGreen[1] = newGreen + --if newGreen > tmpGreen[num_modules] then + -- tmpGreen[1] = newGreen + --else + -- tmpGreen[1] = tmpGreen[num_modules] + --end newBlue = blueEnergy / maxBlueEnergy - if newBlue > tmpBlue[num_modules] then - tmpBlue[1] = newBlue - else - tmpBlue[1] = tmpBlue[num_modules] - end + tmpBlue[1] = newBlue + --if newBlue > tmpBlue[num_modules] then + -- tmpBlue[1] = newBlue + --else + -- tmpBlue[1] = tmpBlue[num_modules] + --end for i = 1,num_modules do - red[i] = tmpRed[i] - green[i] = tmpGreen[i] - blue[i] = tmpBlue[i] + red[i] = limit(OVERDRIVE * math.pow(tmpRed[i], EXPONENT)) + green[i] = limit(OVERDRIVE * math.pow(tmpGreen[i], EXPONENT)) + blue[i] = limit(OVERDRIVE * math.pow(tmpBlue[i], EXPONENT)) end -- return the 3 color arrays diff --git a/pulsecircle_ultrafast.lua b/pulsecircle_ultrafast.lua new file mode 100644 index 0000000..c002fcb --- /dev/null +++ b/pulsecircle_ultrafast.lua @@ -0,0 +1,100 @@ +COOLDOWN_FACTOR = 0.9998 +FADE_FACTOR = 1 +OVERDRIVE = 1.30 +EXPONENT = 1.8 + +SHIFT=2 + +num_modules = 20 +center_module = 10 + +-- maximum energy values for each band +maxRedEnergy = 1 +maxGreenEnergy = 1 +maxBlueEnergy = 1 + +-- output color buffers +red = {} +green = {} +blue = {} + +tmpRed = {} +tmpGreen = {} +tmpBlue = {} + +function limit(val) + if val > 1 then + return 1 + else + return val + end +end + +function periodic() + local redEnergy = get_energy_in_band(0, 400); + local greenEnergy = get_energy_in_band(400, 4000); + local blueEnergy = get_energy_in_band(4000, 22000); + local centerIndex = 2 * center_module + 1; + + maxRedEnergy = maxRedEnergy * COOLDOWN_FACTOR + if redEnergy > maxRedEnergy then + maxRedEnergy = redEnergy + end + + maxGreenEnergy = maxGreenEnergy * COOLDOWN_FACTOR + if greenEnergy > maxGreenEnergy then + maxGreenEnergy = greenEnergy + end + + maxBlueEnergy = maxBlueEnergy * COOLDOWN_FACTOR + if blueEnergy > maxBlueEnergy then + maxBlueEnergy = blueEnergy + end + + -- move the color buffers on by one + for i = num_modules-SHIFT,1,-1 do + tmpRed[i+SHIFT] = FADE_FACTOR * tmpRed[i] + tmpGreen[i+SHIFT] = FADE_FACTOR * tmpGreen[i] + tmpBlue[i+SHIFT] = FADE_FACTOR * tmpBlue[i] + end + + -- set the new value for the center module + newRed = redEnergy / maxRedEnergy + newGreen = greenEnergy / maxGreenEnergy + newBlue = blueEnergy / maxBlueEnergy + + for i = 1,SHIFT do + tmpRed[i] = newRed + tmpGreen[i] = newGreen + tmpBlue[i] = newBlue + end + + for i = 1,num_modules do + red[i] = limit(OVERDRIVE * math.pow(tmpRed[i], EXPONENT)) + green[i] = limit(OVERDRIVE * math.pow(tmpGreen[i], EXPONENT)) + blue[i] = limit(OVERDRIVE * math.pow(tmpBlue[i], EXPONENT)) + end + + -- return the 3 color arrays + return red, green, blue +end + +function init(nmod, cmod) + num_modules = nmod + center_module = cmod + + for i = 1,nmod do + red[i] = 0 + green[i] = 0 + blue[i] = 0 + end + + for i = 1,nmod do + tmpRed[i] = 0 + tmpGreen[i] = 0 + tmpBlue[i] = 0 + end + + -- don't use fading + return 0 +end diff --git a/pulsetunnel.lua b/pulsetunnel.lua index 3f629e2..23126e2 100644 --- a/pulsetunnel.lua +++ b/pulsetunnel.lua @@ -1,7 +1,7 @@ COOLDOWN_FACTOR = 0.9998 -num_modules = 20 -center_module = 10 +num_modules = 160 +center_module = 80 -- maximum energy values for each band maxRedEnergy = 1 diff --git a/pulsetunnel_commonmax.lua b/pulsetunnel_commonmax.lua index 65190e0..0434db8 100644 --- a/pulsetunnel_commonmax.lua +++ b/pulsetunnel_commonmax.lua @@ -20,9 +20,9 @@ tmpGreen = {} tmpBlue = {} function weighted_avg(array, centerIndex) - return 0.2 * array[centerIndex - 1] + - 0.6 * array[centerIndex] + - 0.2 * array[centerIndex + 1] + return 0.20 * array[centerIndex - 1] + + 0.60 * array[centerIndex] + + 0.20 * array[centerIndex + 1] end function periodic() @@ -63,6 +63,9 @@ function periodic() tmpBlue[centerIndex] = blueEnergy / maxEnergy for i = 1,num_modules do + --red[i] = tmpRed[i+centerIndex-num_modules/2] + --green[i] = tmpGreen[i+centerIndex-num_modules/2] + --blue[i] = tmpBlue[i+centerIndex-num_modules/2] red[i] = weighted_avg(tmpRed, 2*i) green[i] = weighted_avg(tmpGreen, 2*i) blue[i] = weighted_avg(tmpBlue, 2*i) diff --git a/pulsetunnel_fast.lua b/pulsetunnel_fast.lua new file mode 100644 index 0000000..f151b3c --- /dev/null +++ b/pulsetunnel_fast.lua @@ -0,0 +1,143 @@ +COOLDOWN_FACTOR = 0.9998 +FADE_FACTOR = 1 +OVERDRIVE = 1.30 +EXPONENT = 1.8 + +INTERP_FACTOR = 2 +INTERP_FILTER = {0.5, 1.0, 0.5} + +num_modules = 128 +center_module = 64 + +-- maximum energy values for each band +maxRedEnergy = 1 +maxGreenEnergy = 1 +maxBlueEnergy = 1 + +-- output color buffers +red = {} +green = {} +blue = {} + +tmpRed = {} +tmpGreen = {} +tmpBlue = {} + +tmpRed2 = {} +tmpGreen2 = {} +tmpBlue2 = {} + +tmpRed3 = {} +tmpGreen3 = {} +tmpBlue3 = {} + +function limit(val) + if val > 1 then + return 1 + else + return val + end +end + +function periodic() + local redEnergy = get_energy_in_band(0, 400); + local greenEnergy = get_energy_in_band(400, 4000); + local blueEnergy = get_energy_in_band(4000, 22000); + local centerIndex = 2 * center_module + 1; + + maxRedEnergy = maxRedEnergy * COOLDOWN_FACTOR + if redEnergy > maxRedEnergy then + maxRedEnergy = redEnergy + end + + maxGreenEnergy = maxGreenEnergy * COOLDOWN_FACTOR + if greenEnergy > maxGreenEnergy then + maxGreenEnergy = greenEnergy + end + + maxBlueEnergy = maxBlueEnergy * COOLDOWN_FACTOR + if blueEnergy > maxBlueEnergy then + maxBlueEnergy = blueEnergy + end + + -- move the color buffers on by one + for i = center_module/INTERP_FACTOR,1,-1 do + tmpRed[i+1] = FADE_FACTOR * tmpRed[i] + tmpGreen[i+1] = FADE_FACTOR * tmpGreen[i] + tmpBlue[i+1] = FADE_FACTOR * tmpBlue[i] + end + + for i = center_module/INTERP_FACTOR+1,num_modules/INTERP_FACTOR,1 do + tmpRed[i-1] = FADE_FACTOR * tmpRed[i] + tmpGreen[i-1] = FADE_FACTOR * tmpGreen[i] + tmpBlue[i-1] = FADE_FACTOR * tmpBlue[i] + end + + -- set the new value for the center module + newRed = redEnergy / maxRedEnergy + tmpRed[1] = newRed + tmpRed[num_modules/INTERP_FACTOR] = newRed + + newGreen = greenEnergy / maxGreenEnergy + tmpGreen[1] = newGreen + tmpGreen[num_modules/INTERP_FACTOR] = newGreen + + newBlue = blueEnergy / maxBlueEnergy + tmpBlue[1] = newBlue + tmpBlue[num_modules/INTERP_FACTOR] = newBlue + + for i = INTERP_FACTOR,num_modules,INTERP_FACTOR do + tmpRed2[i] = tmpRed[math.floor(i/INTERP_FACTOR)] + tmpGreen2[i] = tmpGreen[math.floor(i/INTERP_FACTOR)] + tmpBlue2[i] = tmpBlue[math.floor(i/INTERP_FACTOR)] + end + + for i = 1,num_modules do + tmpRed3[i] = 0 + tmpGreen3[i] = 0 + tmpBlue3[i] = 0 + + for j = 1,#INTERP_FILTER do + idx = math.floor(i+j-#INTERP_FILTER/2) + + if idx >= 1 and idx <= num_modules then + tmpRed3[i] = tmpRed3[i] + tmpRed2[idx] * INTERP_FILTER[j] + tmpGreen3[i] = tmpGreen3[i] + tmpGreen2[idx] * INTERP_FILTER[j] + tmpBlue3[i] = tmpBlue3[i] + tmpBlue2[idx] * INTERP_FILTER[j] + end + end + end + + for i = 1,num_modules do + red[i] = limit(OVERDRIVE * math.pow(tmpRed3[i], EXPONENT)) + green[i] = limit(OVERDRIVE * math.pow(tmpGreen3[i], EXPONENT)) + blue[i] = limit(OVERDRIVE * math.pow(tmpBlue3[i], EXPONENT)) + end + + -- return the 3 color arrays + return red, green, blue +end + +function init(nmod, cmod) + num_modules = nmod + center_module = cmod + + for i = 1,nmod do + red[i] = 0 + green[i] = 0 + blue[i] = 0 + end + + for i = 1,nmod do + tmpRed[i] = 0 + tmpGreen[i] = 0 + tmpBlue[i] = 0 + + tmpRed2[i] = 0 + tmpGreen2[i] = 0 + tmpBlue2[i] = 0 + end + + -- don't use fading + return 0 +end diff --git a/run_mpd.sh b/run_mpd.sh index 246cdae..53788bc 100755 --- a/run_mpd.sh +++ b/run_mpd.sh @@ -1,4 +1,4 @@ #!/bin/sh #dd if=/tmp/mpd.fifo bs=1024 | ./musiclight2 -./musiclight2 $* < /tmp/mpd.fifo +./musiclight2 $* < /tmp/musiclight.fifo diff --git a/run_remote.sh b/run_remote.sh index cbc98bc..ab3dc31 100755 --- a/run_remote.sh +++ b/run_remote.sh @@ -1,3 +1,3 @@ #!/bin/sh -nc -l -p 12345 | ./musiclight2 $* +socat UDP4-RECV:12345 STDOUT | ./musiclight2 $* diff --git a/ws2801.c b/ws2801.c index d1cf917..5335143 100644 --- a/ws2801.c +++ b/ws2801.c @@ -24,12 +24,13 @@ #define SET_FADESTEP 3 struct WS2801Packet { - uint8_t metadata; + uint8_t action; + uint8_t module; uint8_t data[3]; }; int ws2801_socket = -1; -struct WS2801Packet packetQueue[50]; +struct WS2801Packet packetQueue[1024]; int queueIndex = 0; // creates the socket needed for steering the LED strip @@ -70,7 +71,8 @@ int ws2801_init(const char *host, unsigned short port) { } void ws2801_set_color(uint8_t module, uint8_t r, uint8_t g, uint8_t b) { - packetQueue[queueIndex].metadata = (SET_COLOR << 6) | (module & 0x3F); + packetQueue[queueIndex].action = SET_COLOR; + packetQueue[queueIndex].module = module; packetQueue[queueIndex].data[0] = r; packetQueue[queueIndex].data[1] = g; packetQueue[queueIndex].data[2] = b; @@ -78,7 +80,8 @@ void ws2801_set_color(uint8_t module, uint8_t r, uint8_t g, uint8_t b) { } void ws2801_fade_color(uint8_t module, uint8_t r, uint8_t g, uint8_t b) { - packetQueue[queueIndex].metadata = (FADE_COLOR << 6) | (module & 0x3F); + packetQueue[queueIndex].action = FADE_COLOR; + packetQueue[queueIndex].module = module; packetQueue[queueIndex].data[0] = r; packetQueue[queueIndex].data[1] = g; packetQueue[queueIndex].data[2] = b; @@ -86,7 +89,8 @@ void ws2801_fade_color(uint8_t module, uint8_t r, uint8_t g, uint8_t b) { } void ws2801_add_color(uint8_t module, uint8_t r, uint8_t g, uint8_t b) { - packetQueue[queueIndex].metadata = (ADD_COLOR << 6) | (module & 0x3F); + packetQueue[queueIndex].action = ADD_COLOR; + packetQueue[queueIndex].module = module; packetQueue[queueIndex].data[0] = r; packetQueue[queueIndex].data[1] = g; packetQueue[queueIndex].data[2] = b; @@ -94,7 +98,7 @@ void ws2801_add_color(uint8_t module, uint8_t r, uint8_t g, uint8_t b) { } void ws2801_set_fadestep(uint8_t fadestep) { - packetQueue[queueIndex].metadata = (SET_FADESTEP << 6); + packetQueue[queueIndex].action = SET_FADESTEP; packetQueue[queueIndex].data[0] = fadestep; queueIndex++; }