-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBeatDetectionTeensy_ModedForAction.ino
112 lines (81 loc) · 3.16 KB
/
BeatDetectionTeensy_ModedForAction.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// based off of PassThroughStereo example
#include "Beat.h"
#include <QuickStats.h>
//w/outbiquad
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
/*
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=125,180
AudioMixer4 mixer; //xy=305,179
AudioAnalyzePeak analyzer; //xy=620,116
AudioOutputI2S i2s2; //xy=669,274
AudioConnection patchCord1(i2s1, 0, mixer, 0);
AudioConnection patchCord2(i2s1, 1, mixer, 1);
AudioConnection patchCord3(mixer, 0, i2s2, 0);
AudioConnection patchCord4(mixer, analyzer);
AudioConnection patchCord5(mixer, 0, i2s2, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=606,364
// GUItool: end automatically generated code
*/
//with biquad
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=55,177
AudioMixer4 mixer; //xy=234,177
AudioFilterBiquad biquad1; //xy=379,161
AudioAnalyzePeak analyzer; //xy=550,113
AudioOutputI2S i2s2; //xy=599,271
AudioConnection patchCord1(i2s1, 0, mixer, 0);
AudioConnection patchCord2(i2s1, 1, mixer, 1);
AudioConnection patchCord3(mixer, biquad1);
AudioConnection patchCord4(mixer, 0, i2s2, 0);
AudioConnection patchCord5(biquad1, analyzer);
AudioConnection patchCord6(biquad1, 0, i2s2, 1);
//AudioControlSGTL5000 925f15f6.77ab18; //xy=454,579
AudioControlSGTL5000 sgtl5000_1; //xy=536,361
// GUItool: end automatically generated code
BeatAnalyzer beatAnalyzer(&analyzer);
const int myInput = AUDIO_INPUT_LINEIN;
//const int myInput = AUDIO_INPUT_MIC;
void setup() {
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(12);
// Enable the audio shield, select input, and enable output
sgtl5000_1.enable();
sgtl5000_1.inputSelect(myInput);
sgtl5000_1.volume(0.5);
//option 0 capturing value as is
//option 1 averaging bpms and playing with them
//Eqy=ualizer?
sgtl5000_1.audioPreProcessorEnable();
//sgtl5000_1.eqBands(0.5,0.5);
//sgtl5000_1.eqBand(4,-1);
sgtl5000_1.eqBands(0,-1,-1,0,0);
//option 5 notch the middle
//biquad1.setHighpass(0,3500,0.054);
//biquad1.setNotch(0,1300,0.054); //good at 1300
//biquad1.setHighpass(1,1500,0.54);
//biquad1.setHighShelf(1, 2000,10,0.05);//this detects bass as a signal, otherwise zero
//biquad1.setNotch(0,1300,0.054); //good at 1300
//option 3 bass response... doesn't pick up any snare, and picks up so much bassy noise sometimes but still most accurate
biquad1.setLowpass(0, 200, 0.5);
//biquad1.setHighpass(1, 100, 0.54);
//biquad1.setLowShelf(1, 100, 10,0.3);//this detects bass as a signal, otherwise zero
Serial.begin(9600);
// turn on onboard led to signal successful completion of setup //
digitalWrite(13, HIGH);
}
elapsedMillis volmsec=0;
void loop() {
beatAnalyzer.update();
//Serial.println(peak);
}