adjustments

multi-mode
Ondřej Hruška 9 years ago
parent 56a0d0c63b
commit d49b10a802
  1. 33
      project/mode_audio.c
  2. 18
      project/mode_life.c

@ -134,14 +134,6 @@ static void audio_capture_done(void* unused)
samp_buf.floats[i] -= mean; samp_buf.floats[i] -= mean;
} }
// if (print_next_fft) {
// printf("--- Raw (adjusted) ---\n");
// for(int i = 0; i < samp_count; i++) {
// printf("%.2f, ", samp_buf.floats[i]);
// }
// printf("\n");
// }
for (int i = samp_count - 1; i >= 0; i--) { for (int i = samp_count - 1; i >= 0; i--) {
bins[i * 2 + 1] = 0; // imaginary bins[i * 2 + 1] = 0; // imaginary
bins[i * 2] = samp_buf.floats[i]; // real bins[i * 2] = samp_buf.floats[i]; // real
@ -153,35 +145,20 @@ static void audio_capture_done(void* unused)
arm_cfft_f32(S, bins, 0, true); // bit reversed FFT arm_cfft_f32(S, bins, 0, true); // bit reversed FFT
arm_cmplx_mag_f32(bins, bins, bin_count); // get magnitude (extract real values) arm_cmplx_mag_f32(bins, bins, bin_count); // get magnitude (extract real values)
// if (print_next_fft) {
// printf("--- Bins ---\n");
// for(int i = 0; i < bin_count; i++) {
// printf("%.2f, ", bins[i]);
// }
// printf("\n");
// }
// normalize // normalize
dmtx_clear(dmtx); dmtx_clear(dmtx);
float factor = (1.0f/bin_count)*0.3f;
for(int i = 0; i < bin_count-1; i+=2) {
bins[i] *= factor;
bins[i+1] *= factor;
//float avg = i==0 ? bins[1] : (bins[i] + bins[i+1])/2; float factor = (1.0f / bin_count) * 0.25f;
float avg = (bins[i] + bins[i+1])/2; for (int i = 0; i < bin_count; i++) {
bins[i] *= factor;
for(int j = 0; j < 1+floorf(avg); j++) { for (int j = 0; j < 1 + floorf(bins[i]); j++) {
//dmtx_toggle(dmtx, i/2, j); dmtx_set(dmtx, i - 1, j, 1); // hide zero 0th bin
dmtx_toggle(dmtx, i/2, j);
//dmtx_toggle(dmtx, j, 15-i/2);
//dmtx_toggle(dmtx, 15- i/2, 15-j);
} }
} }
dmtx_show(dmtx); dmtx_show(dmtx);
// print_next_fft = false;
capture_pending = false; capture_pending = false;
} }

@ -36,8 +36,8 @@ static ms_time_t step_time = 200; // game step time
#define BLINKLEN_ONE 300 // blink on time for '1' #define BLINKLEN_ONE 300 // blink on time for '1'
#define BLINKLEN_ZERO 10 // blink on time for '0' #define BLINKLEN_ZERO 10 // blink on time for '0'
#define MOVE_TIME 100 // mouse move #define MOVE_TIME 80 // mouse move
#define MOVE_START_TIME 700 #define MOVE_START_TIME 600
#define WRAPPING 0 #define WRAPPING 0
@ -322,7 +322,7 @@ void mode_life_btn(char key)
case 'K': case 'K':
// Reset btn // Reset btn
if (modA_down) { if (modB_down) {
// total reset // total reset
dbg("Reset to blank"); dbg("Reset to blank");
memset(board_orig, 0, SIZEOF_BOARD); memset(board_orig, 0, SIZEOF_BOARD);
@ -344,14 +344,14 @@ void mode_life_btn(char key)
if (running) { if (running) {
switch (key) { switch (key) {
case 'X': // slower case 'Y': // slower
if (step_time < 1000) { if (step_time < 1000) {
step_time += 50; step_time += 50;
set_periodic_task_interval(task_gametick, step_time); set_periodic_task_interval(task_gametick, step_time);
} }
break; break;
case 'Y': // faster case 'X': // faster
if (step_time > 50) { if (step_time > 50) {
step_time -= 50; step_time -= 50;
set_periodic_task_interval(task_gametick, step_time); set_periodic_task_interval(task_gametick, step_time);
@ -425,10 +425,10 @@ void mode_life_btn(char key)
// --- Paint BTN --- // --- Paint BTN ---
case 'Y': painting_1 = true; break; case 'X': painting_1 = true; break;
case 'y': painting_1 = false; break; case 'x': painting_1 = false; break;
case 'X': painting_0 = true; break; case 'Y': painting_0 = true; break;
case 'x': painting_0 = false; break; case 'y': painting_0 = false; break;
// --- Control --- // --- Control ---

Loading…
Cancel
Save