diff --git a/arduino_zauberstab/arduino_zauberstab.ino b/arduino_zauberstab/arduino_zauberstab.ino index 41f3001..40c6a30 100644 --- a/arduino_zauberstab/arduino_zauberstab.ino +++ b/arduino_zauberstab/arduino_zauberstab.ino @@ -65,7 +65,7 @@ int rounds = 0; void setup() { - Serial.begin(115200); + Serial.begin(250000); FastLED.addLeds(leds, NUM_LEDS); FastLED.setMaxPowerInVoltsAndMilliamps(5, 300); diff --git a/firmware/temp/beat_detect.cpp b/firmware/src/beat_detect.cpp similarity index 87% rename from firmware/temp/beat_detect.cpp rename to firmware/src/beat_detect.cpp index a4f75ec..ec7c64b 100644 --- a/firmware/temp/beat_detect.cpp +++ b/firmware/src/beat_detect.cpp @@ -1,6 +1,9 @@ #include "zauberstab.h" #include +#undef NUM_LEDS +#define NUM_LEDS 45 + #define SAMPLING_FREQUENCY_BP 40 // number of energy chunks per second #define SAMPLING_FREQUENCY_CONTROL 1 // check number of times per second if the current band pass is the best one #define Q 20. // quality factor of band pass filters @@ -34,8 +37,6 @@ static float u1[n_BP]; static float u2[n_BP]; static float y[n_BP]; static float y_fil[n_BP]; -static float y_fil_avg; -static float transience = 0; static float angle; static float angle2; @@ -45,14 +46,16 @@ static float angle2; static float pos_target = NUM_LEDS / 2; static float pos_target_filtered = NUM_LEDS / 2; -static float microphone_offset = 675; +static float microphone_offset = 1900; static long initial_time; static int active = 15; static int candidate = 15; static int rounds = 0; -static float get_value(int pos, float pos0) +static int n_samples = 0; + +static int get_value(int pos, float pos0) { if (abs(pos0 - pos) > 5) { @@ -83,23 +86,27 @@ static void set_filter() void setup() { zauberstab_init(); - Serial.begin(115200); + Serial.begin(250000); set_filter(); initial_time = micros(); + } void loop() { int sample = int(analogRead(MIC_PIN) - microphone_offset); energy += abs(sample) * abs(sample); + n_samples++; if (micros() - last_us_bp > sampling_period_bp) { - Serial.println(sample); + Serial.println(n_samples); + n_samples = 0; + microphone_offset += (analogRead(MIC_PIN) - microphone_offset) * 0.001; last_us_bp += sampling_period_bp; //energy_fil += (energy - energy_fil) * 0.01; - y_fil_avg = 0; + for (int i = 0; i < n_BP; i++) { y[i] = (b0[i] / a0[i]) * energy + 0. + (b2[i] / a0[i]) * u2[i] - (a1[i] / a0[i]) * yy1[i] - (a2[i] / a0[i]) * yy2[i]; @@ -112,9 +119,8 @@ void loop() yy2[i] = yy1[i]; yy1[i] = y[i]; y_fil[i] += (abs(y[i]) - y_fil[i]) * 0.005; //linie der scheitelpunkte - y_fil_avg += y_fil[i]; + } - y_fil_avg /= n_BP; float delays = constrain(SAMPLING_FREQUENCY_BP * 0.25 / (1.75 + active * (2.4 - 1.75) / n_BP), 4., 6.); @@ -152,15 +158,12 @@ void loop() energy = 0; - transience += ((y_fil[active]/y_fil_avg-1.6) - transience)*0.02; - transience = max(transience, 0.0f); - transience = min(transience, 1.0f); - for (int i = 0; i < NUM_LEDS; i++) { - leds[i].g = int(get_value(i, pos_target_filtered)*transience); - leds[i].r = int(get_value(i, pos_target_filtered+2)*transience); - leds[i].b = int(get_value(i, pos_target_filtered-2)*transience); + leds[i].g = get_value(i, pos_target_filtered); + leds[i].r = get_value(i, pos_target_filtered+2); + leds[i].b = get_value(i, pos_target_filtered-2); + //leds[i].setRGB(brightness_red, brightness_green, brightness_blue); //leds[i].setHSV(160, (rounds == 6) ? 0xFF : 0, brightness); diff --git a/firmware/src/vumeter.cpp b/firmware/temp/vumeter.cpp similarity index 100% rename from firmware/src/vumeter.cpp rename to firmware/temp/vumeter.cpp diff --git a/inventor/OldVersions/vase_v2._tom.0017.ipt b/inventor/OldVersions/vase_v2._tom.0017.ipt deleted file mode 100644 index 4ad37d5..0000000 Binary files a/inventor/OldVersions/vase_v2._tom.0017.ipt and /dev/null differ diff --git a/inventor/vase_v2._tom.ipt b/inventor/vase_v2._tom.ipt index 8ac530c..b764492 100644 Binary files a/inventor/vase_v2._tom.ipt and b/inventor/vase_v2._tom.ipt differ