Skip to content

Commit 270fc7a

Browse files
authored
Merge pull request #79 from pingdynasty/maximilian
maximilian
2 parents 1ca0035 + f123ed7 commit 270fc7a

11 files changed

Lines changed: 5864 additions & 2 deletions

File tree

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ PATCHNAME ?= $(GEN)
4040
PATCHCLASS ?= GenPatch
4141
PATCHFILE ?= GenPatch.hpp
4242
DEPS += gen
43+
else ifdef MAXIMILIAN
44+
# options for Maximilian compilation
45+
PATCHNAME ?= $(MAXIMILIAN)
46+
PATCHCLASS ?= MaximilianPatch
47+
PATCHFILE ?= MaximilianPatch.hpp
48+
DEPS += maximilian
4349
else ifdef TEST
4450
PATCHNAME ?= $(TEST)
4551
PATCHCLASS ?= $(PATCHNAME)Patch
@@ -124,6 +130,9 @@ heavy: .FORCE
124130
gen: .FORCE
125131
@$(MAKE) -s -f gen.mk gen
126132

133+
maximilian: .FORCE
134+
@$(MAKE) -s -f maximilian.mk maximilian
135+
127136
soul: .FORCE
128137
@$(MAKE) -s -f soul.mk soul
129138

Maximilian/MaximilianPatch.hpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#ifndef __MaximilianPatch_hpp__
2+
#define __MaximilianPatch_hpp__
3+
4+
#include "Patch.h"
5+
#include "maximilian.h"
6+
7+
static maxiParam* maxiParameters[8];
8+
static unsigned int maxiParameterCount = 0;
9+
maxiParam::maxiParam() : value(0.0), minValue(0.0), maxValue(1.0),
10+
name(NULL), pid(maxiParameterCount++){
11+
if(pid < 8)
12+
maxiParameters[pid] = this;
13+
}
14+
15+
void maxiParam::update(double v){
16+
const static double lambda = 0.9; // factor for exponential smoothing
17+
value = value*lambda + scale(v)*(1-lambda);
18+
}
19+
20+
class MaximilianPatch : public Patch {
21+
private:
22+
#include "maximilian-patch.h"
23+
float output[2];
24+
public:
25+
MaximilianPatch(){
26+
maxiSettings::sampleRate = getSampleRate();
27+
maxiSettings::channels = 2;
28+
maxiSettings::bufferSize = getBlockSize();
29+
setup();
30+
char name[] = "A";
31+
maxiParameterCount = std::min(7u, maxiParameterCount);
32+
for(int i=0; i<maxiParameterCount; ++i){
33+
if(maxiParameters[i]->name == NULL){
34+
name[0] = 'A'+maxiParameters[i]->pid;
35+
registerParameter((PatchParameterId)(maxiParameters[i]->pid), name);
36+
}else{
37+
registerParameter((PatchParameterId)(maxiParameters[i]->pid), maxiParameters[i]->name);
38+
}
39+
}
40+
}
41+
void processAudio(AudioBuffer &buffer) {
42+
float* left = buffer.getSamples(LEFT_CHANNEL);
43+
float* right = buffer.getSamples(RIGHT_CHANNEL);
44+
for(int i=0; i<maxiParameterCount; ++i)
45+
maxiParameters[i]->update(getParameterValue((PatchParameterId)(maxiParameters[i]->pid)));
46+
for(int i=0; i<buffer.getSize(); ++i){
47+
play(output);
48+
left[i] = output[0];
49+
right[i] = output[1];
50+
}
51+
}
52+
};
53+
54+
#endif // __MaximilianPatch_hpp__

Maximilian/maximilian.cpp

Lines changed: 1436 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)