summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2015-06-06 00:01:42 +0200
committerPacien TRAN-GIRARD2015-06-06 00:01:42 +0200
commit7a3e960b4c58d8e00be44fe40a4978efaa041e9f (patch)
treefa14241f9d26f942132226db07e3335cecc98c0d
parent5a698df30a425d8d7c3bfdc889ea5ca605781d6f (diff)
downloadmuseduino-master.tar.gz
Add linear frequency attenuationHEADmaster
-rw-r--r--museduino/museduino.ino20
1 files changed, 20 insertions, 0 deletions
diff --git a/museduino/museduino.ino b/museduino/museduino.ino
index b20e4ab..cd8c93d 100644
--- a/museduino/museduino.ino
+++ b/museduino/museduino.ino
@@ -32,6 +32,8 @@ NICOLE RĂ©mi
32#define PRESCALE_FACTOR 256 32#define PRESCALE_FACTOR 256
33#define DUMMY_SAMPLES 1 33#define DUMMY_SAMPLES 1
34#define WAIT_CYCLES 0 34#define WAIT_CYCLES 0
35#define TRANSFORM_FACTOR -0.1
36#define TRANSFORM_ORIGIN 1
35 37
36// Data bins 38// Data bins
37#define BINS 128 // FHT_N /2 39#define BINS 128 // FHT_N /2
@@ -115,6 +117,23 @@ void mag_fht() {
115 #endif 117 #endif
116} 118}
117 119
120void transform_factor() {
121 #if LOG_OUT == 1
122 uint8_t* data = fht_log_out;
123 uint8_t m = 0;
124 #elif LIN_OUT == 1
125 uint16_t* data = fht_lin_out;
126 uint16_t m = 0;
127 #elif LIN_OUT8 == 1
128 uint8_t* data = fht_lin_out8;
129 uint8_t m = 0;
130 #endif
131
132 for (int i = 0; i < BINS; i++) {
133 data[i] *= TRANSFORM_FACTOR * i + TRANSFORM_ORIGIN;
134 }
135}
136
118int find_max_index() { 137int find_max_index() {
119 #if LOG_OUT == 1 138 #if LOG_OUT == 1
120 uint8_t* data = fht_log_out; 139 uint8_t* data = fht_log_out;
@@ -254,6 +273,7 @@ void loop() {
254 aquire_data(); 273 aquire_data();
255 274
256 run_fht(); 275 run_fht();
276 transform_factor();
257 mag_fht(); 277 mag_fht();
258 278
259 int max_index = find_max_index(); 279 int max_index = find_max_index();