From 7a3e960b4c58d8e00be44fe40a4978efaa041e9f Mon Sep 17 00:00:00 2001
From: Pacien TRAN-GIRARD
Date: Sat, 6 Jun 2015 00:01:42 +0200
Subject: Add linear frequency attenuation

---
 museduino/museduino.ino | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

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
 #define PRESCALE_FACTOR 256
 #define DUMMY_SAMPLES 1
 #define WAIT_CYCLES 0
+#define TRANSFORM_FACTOR -0.1
+#define TRANSFORM_ORIGIN 1
 
 // Data bins
 #define BINS 128 // FHT_N /2
@@ -115,6 +117,23 @@ void mag_fht() {
 	#endif
 }
 
+void transform_factor() {
+	#if LOG_OUT == 1
+		uint8_t* data = fht_log_out;
+		uint8_t m = 0;
+	#elif LIN_OUT == 1
+		uint16_t* data = fht_lin_out;
+		uint16_t m = 0;
+	#elif LIN_OUT8 == 1
+		uint8_t* data = fht_lin_out8;
+		uint8_t m = 0;
+	#endif
+	
+	for (int i = 0; i < BINS; i++) {
+		data[i] *= TRANSFORM_FACTOR * i + TRANSFORM_ORIGIN;
+	}
+}
+
 int find_max_index() {
 	#if LOG_OUT == 1
 		uint8_t* data = fht_log_out;
@@ -254,6 +273,7 @@ void loop() {
 		aquire_data();
 		
 		run_fht();
+		transform_factor();
 		mag_fht();
 		
 		int max_index = find_max_index();
-- 
cgit v1.2.3