Diferencia entre revisiones de «Mesa musical»
Sin resumen de edición |
|||
| Línea 15: | Línea 15: | ||
const int speaker_pin = 3; | const int speaker_pin = 3; | ||
const float base_duration_ms = 40; | |||
const float base_freq = 100.0; | |||
const float dynamic_pitch_factor = 5.0; | const float dynamic_pitch_factor = 5.0; | ||
const float dynamic_duration_factor = 10.0; | const float dynamic_duration_factor = 10.0; | ||
const float note_interval = 1.059463; | |||
const float detection_threshold = 0.4; | |||
const float note_interval = 1. | |||
const float detection_threshold = 0. | |||
const float sensitivity_factor = 20.0; | const float sensitivity_factor = 20.0; | ||
const float degree_offset = 3.0; | const float degree_offset = 3.0; | ||
const float baseline_iir_filter_coef = 0.6; | const float baseline_iir_filter_coef = 0.6; | ||
const range_t desired_range = ADXL345_RANGE_4_G; | |||
const dataRate_t desired_rate = ADXL345_DATARATE_3200_HZ; | |||
#define NUM_NOTES 33 | #define NUM_NOTES 33 | ||
| Línea 34: | Línea 36: | ||
Serial.begin(115200); | Serial.begin(115200); | ||
while (!accel.begin()) { | while (!accel.begin()) { | ||
Serial.println("accel.begin() failed | Serial.println("accel.begin() failed. We will retry."); | ||
delay(100); | delay(100); | ||
} | } | ||
while (accel.getRange() != desired_range) { | while (accel.getRange() != desired_range) { | ||
Serial.println("setting range"); | Serial.println("setting range"); | ||
| Línea 45: | Línea 46: | ||
} | } | ||
while (accel.getDataRate() != desired_rate) { | while (accel.getDataRate() != desired_rate) { | ||
Serial.println("setting rate"); | Serial.println("setting rate"); | ||
| Línea 78: | Línea 78: | ||
const int first_index = 0; | const int first_index = 0; | ||
const int last_index = | const int last_index = NUM_NOTES - 1; | ||
degree = max(degree, first_index); | degree = max(degree, first_index); | ||
degree = min(degree, last_index); | degree = min(degree, last_index); | ||