haha
This commit is contained in:
commit
21b61658fc
44
essays/oct28a/oct28a.ino
Normal file
44
essays/oct28a/oct28a.ino
Normal file
@ -0,0 +1,44 @@
|
||||
#define MIDI_CHANNEL 1
|
||||
#include <spi4teensy3.h>
|
||||
#include <EEPROM.h>
|
||||
#include <Haarnet.h>
|
||||
|
||||
int min_c = 9999;
|
||||
int max_c = 0;
|
||||
|
||||
float alpha = 0.2;
|
||||
int prev = 0;
|
||||
|
||||
float freq = 125;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(57600);
|
||||
|
||||
Music.init();
|
||||
Music.setFrequency(freq);
|
||||
|
||||
prev = touchRead(A1);
|
||||
}
|
||||
|
||||
int filter(int n) {
|
||||
prev = (int) (alpha * n + (1.0 - alpha) * prev);
|
||||
return prev;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
|
||||
int d = touchRead(A1);
|
||||
int f = filter(d);
|
||||
|
||||
|
||||
|
||||
if(d < min_c) min_c = d;
|
||||
if(d > max_c) max_c = d;
|
||||
int e = map(d, min_c, max_c, 0, 100);
|
||||
Music.setDetune(e);
|
||||
|
||||
Serial.print(d);Serial.print(",");Serial.println(f);
|
||||
delay(100);
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user