-
Notifications
You must be signed in to change notification settings - Fork 30
/
StereoMixerPatch.hpp
60 lines (46 loc) · 1.84 KB
/
StereoMixerPatch.hpp
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
////////////////////////////////////////////////////////////////////////////////////////////////////
/*
LICENSE:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* created by the OWL team 2013 */
////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef __StereoMixerPatch_h__
#define __StereoMixerPatch_h__
#include "StompBox.h"
class StereoMixerPatch : public Patch {
public:
StereoMixerPatch(){
registerParameter(PARAMETER_A, "LL");
registerParameter(PARAMETER_B, "LR");
registerParameter(PARAMETER_C, "RL");
registerParameter(PARAMETER_D, "RR");
}
void processAudio(AudioBuffer &buffer){
// assert_param(buffer.getChannels() > 1);
float gainLL = getParameterValue(PARAMETER_A);
float gainLR = getParameterValue(PARAMETER_B);
float gainRL = getParameterValue(PARAMETER_C);
float gainRR = getParameterValue(PARAMETER_D);
int size = buffer.getSize();
float* left = buffer.getSamples(0);
float* right = buffer.getChannels() > 1 ? buffer.getSamples(1) : left;
float l, r;
for(int i=0; i<size; ++i){
l = gainLL*left[i] + gainLR*right[i];
r = gainRL*left[i] + gainRR*right[i];
left[i] = l;
right[i] = r;
}
}
};
#endif // __StereoMixerPatch_h__