-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainComponent.h
155 lines (113 loc) · 4.85 KB
/
MainComponent.h
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
==============================================================================
This file was auto-generated!
==============================================================================
*/
#pragma once
#include "ObjCInterface.h"
#include "../JuceLibraryCode/JuceHeader.h"
#include "BasicThumbComp.h"
#include "MultiChannelAudioSource.h"
#include "SuperpoweredBandpassFilterBank.h"
#include "SuperpoweredSimple.h"
#include "UploadCSVComp.h"
//==============================================================================
/*
This component lives inside our window, and this is where you should put all
your controls and content.
*/
class MainComponent : public AudioAppComponent,
private Timer,
public OSCReceiver,
public OSCReceiver::Listener<OSCReceiver::MessageLoopCallback>,
private AsyncUpdater,
public ChangeListener
{
public:
//==============================================================================
MainComponent();
~MainComponent();
//==============================================================================
void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override;
void getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill) override;
void releaseResources() override;
void changeListenerCallback (ChangeBroadcaster* source) override;
//==============================================================================
void paint (Graphics& g) override;
void resized() override;
void process(float data, const float input);
void updateLabelText(const String& text, const Label& label, int index = 0 );
void timerCallback() override;
void addMuseLabels();
void oscMessageReceived(const OSCMessage& message) override;
void oscBundleReceived(const OSCBundle& bundle) override;
bool receiveChecker(const OSCMessage& m);
void addOSCBundle (const OSCBundle& bundle, int level = 0);
void addOSCMessageArgument (const OSCArgument& arg , String m);
void handleAsyncUpdate() override
{
}
void showConnectionErrorMessage (const String& messageText);
enum{
fftOrder= 7,
fftSize = 1 << fftOrder
};
//pitch detector (rough version)
void pitchDetector(float data, int index);
//current file multitrack
HashMap<int, File> FileArray;
void openButtonClicked(int index);
void playButtonClicked();
void stopButtonClicked();
private:
double lastSampleRate= 44100;
double audioFFTValue = 0.0;
dsp::FFT audioAnalyser;
float fifo[fftSize];
float fftData[fftSize * 2];
int fftIndex= 0;
int fftSampleIndex = 0;
bool fftReady= false;
float joy, anger, disgust, engage, att, valence;
OwnedArray<Label> affDexLabels;
Array<String> affDexStrings = {"Joy: ", "Anger: ", "Disgust: ", "Engagement: ",
"Attention: ", "Valence: "};
UploadCSVComp upCSV;
Label audioValue, appHeader, noteValue;
String currentNote= "Pitch: ";
const int labelHeight = 40;
//OSC variables for Muse
OwnedArray<Label> museLabels;
Label alphaLabel;
Array<String> museStrings ={"Alpha: ", "Beta: ", "Delta: ", "Gamma: ", "Theta: "};
const String alphaMessage = "/muse/elements/alpha_absolute",
thetaMessage = "/muse/elements/beta_absolute",
gammaMessage = "/muse/elements/delta_absolute",
betaMessage = "/muse/elements/gamma_absolute",
deltaMessage = "/muse/elements/theta_absolute";
String museAlpha, museBeta, museDelta, museTheta, museGamma;
String museText;
//File Uploader Variables and functions
AudioThumbnailCache atCache;
//BasicThumbComp bassThumb, drumThumb, synthThumb, voiceThumb;
OwnedArray<BasicThumbComp> thumbnails;
AudioFormatManager afManager;
Array<String> sectionString = {"Bass", "Drums", "Synth", "Voice"};
OwnedArray<TextButton> openButton;
TextButton playButton;
TextButton stopButton;
//this instantiates the multi-track "stem" format funcitonality for wav files.
MultiChannelAudioSource mixer;
//pitch variables
Array<String> notes ={"A", "A#", "B", "C" ,"C#" , "D", "D#" , "E" , "F","F#", "G", "G#"};
Array<String> midiTable;
int discreteCount = 0;
SuperpoweredBandpassFilterbank *superFB;
float frequencies[8] = { 55, 110, 220, 440, 880, 1760, 3520, 7040 };
float widths[8] = { 1, 1, 1, 1, 1, 1, 1, 1 };
float bands[128][8];
float* peak, *sum;
//==============================================================================
// Your private member variables go here...
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
};