Browse Source

Update Makefile, refactor other code

tags/v0.4.0
Andrew Belt 7 years ago
parent
commit
2a3de43d9e
4 changed files with 80 additions and 43 deletions
  1. +3
    -26
      Makefile
  2. +2
    -2
      src/EvenVCO.cpp
  3. +63
    -3
      src/Rampage.cpp
  4. +12
    -12
      src/SlewLimiter.cpp

+ 3
- 26
Makefile View File

@@ -1,29 +1,6 @@
ARCH ?= lin
FLAGS = -fPIC -g -Wall -O3 -msse -mfpmath=sse -ffast-math \
-I../../include -I./pffft -DPFFFT_SIMD_DISABLE
LDFLAGS =


SOURCES = $(wildcard src/*.cpp) pffft/pffft.c


ifeq ($(ARCH), lin)
LDFLAGS += -shared
TARGET = plugin.so
endif

ifeq ($(ARCH), mac)
LDFLAGS += -shared -undefined dynamic_lookup
TARGET = plugin.dylib
endif
FLAGS = -I./pffft -DPFFFT_SIMD_DISABLE


ifeq ($(ARCH), win)
LDFLAGS += -shared -L../../ -lRack
TARGET = plugin.dll
endif

all: $(TARGET)

clean:
rm -rfv build $(TARGET)
SOURCES = $(wildcard src/*.cpp) pffft/pffft.c


include ../../Makefile.inc
include ../../plugin.mk

+ 2
- 2
src/EvenVCO.cpp View File

@@ -78,7 +78,7 @@ void EvenVCO::step() {
// Pulse width // Pulse width
float pw = params[PWM_PARAM] + getf(inputs[PWM_INPUT]) / 5.0; float pw = params[PWM_PARAM] + getf(inputs[PWM_INPUT]) / 5.0;
const float minPw = 0.05; const float minPw = 0.05;
pw = mapf(clampf(pw, -1.0, 1.0), -1.0, 1.0, minPw, 1.0-minPw);
pw = rescalef(clampf(pw, -1.0, 1.0), -1.0, 1.0, minPw, 1.0-minPw);


// Advance phase // Advance phase
float deltaPhase = clampf(freq / gSampleRate, 1e-6, 0.5); float deltaPhase = clampf(freq / gSampleRate, 1e-6, 0.5);
@@ -151,7 +151,7 @@ EvenVCOWidget::EvenVCOWidget() {
addChild(createScrew<ScrewBlack>(Vec(15*6, 0))); addChild(createScrew<ScrewBlack>(Vec(15*6, 0)));
addChild(createScrew<ScrewBlack>(Vec(15*6, 365))); addChild(createScrew<ScrewBlack>(Vec(15*6, 365)));


addParam(createParam<BefacoBigKnob>(Vec(24-4+2, 35-4+1), module, EvenVCO::OCTAVE_PARAM, -5.0, 4.0, 0.0));
addParam(createParam<BefacoBigSnapKnob>(Vec(24-4+2, 35-4+1), module, EvenVCO::OCTAVE_PARAM, -5.0, 4.0, 0.0));
addParam(createParam<BefacoTinyKnob>(Vec(72, 131), module, EvenVCO::TUNE_PARAM, -7.0, 7.0, 0.0)); addParam(createParam<BefacoTinyKnob>(Vec(72, 131), module, EvenVCO::TUNE_PARAM, -7.0, 7.0, 0.0));
addParam(createParam<Davies1900hRedKnob>(Vec(16, 230), module, EvenVCO::PWM_PARAM, -1.0, 1.0, 0.0)); addParam(createParam<Davies1900hRedKnob>(Vec(16, 230), module, EvenVCO::PWM_PARAM, -1.0, 1.0, 0.0));




+ 63
- 3
src/Rampage.cpp View File

@@ -48,6 +48,19 @@ struct Rampage : Module {
NUM_OUTPUTS, NUM_OUTPUTS,
}; };


float lastOutA = 0.0;
float lastOutB = 0.0;

float comparatorLight = 0.0;
float minLight = 0.0;
float maxLight = 0.0;
float outALight = 0.0;
float outBLight = 0.0;
float risingALight = 0.0;
float fallingALight = 0.0;
float risingBLight = 0.0;
float fallingBLight = 0.0;

Rampage(); Rampage();
void step(); void step();
}; };
@@ -60,6 +73,43 @@ Rampage::Rampage() {
} }


void Rampage::step() { void Rampage::step() {
// TEMP
float outA = getf(inputs[IN_A_INPUT]);
float outB = getf(inputs[IN_B_INPUT]);
setf(outputs[OUT_A_OUTPUT], outA);
setf(outputs[OUT_B_OUTPUT], outB);
outALight = outA / 10.0;
outBLight = outB / 10.0;

// Slope detector
const float slopeThreshold = 1.0; // volts per second
#define SLOPE(out, lastOut, rising, falling, risingLight, fallingLight) { \
float slope = (out - lastOut) / gSampleRate; \
lastOut = out; \
float rising = slope > slopeThreshold ? 10.0 : 0.0; \
float falling = slope < -slopeThreshold ? 10.0 : 0.0; \
setf(outputs[rising], rising); \
setf(outputs[falling], falling); \
risingLight = rising / 10.0; \
fallingLight = falling / 10.0; \
}
SLOPE(outA, lastOutA, RISING_A_OUTPUT, FALLING_A_OUTPUT, risingALight, fallingALight)
SLOPE(outB, lastOutB, RISING_B_OUTPUT, FALLING_B_OUTPUT, risingBLight, fallingBLight)

// Analog logic processor
float balance = params[BALANCE_PARAM];
const float balancePower = 0.5;
outA *= powf(1.0 - balance, balancePower);
outB *= powf(balance, balancePower);
float max = fmaxf(outA, outB);
float min = fminf(outA, outB);
float comparator = outB > outA ? 10.0 : 0.0;
setf(outputs[MAX_OUTPUT], max);
setf(outputs[MIN_OUTPUT], min);
setf(outputs[COMPARATOR_OUTPUT], comparator);
maxLight = max / 10.0;
minLight = min / 10.0;
comparatorLight = comparator / 20.0;
} }




@@ -94,18 +144,18 @@ RampageWidget::RampageWidget() {
addInput(createInput<PJ3410Port>(Vec(142-3, 290-3), module, Rampage::CYCLE_B_INPUT)); addInput(createInput<PJ3410Port>(Vec(142-3, 290-3), module, Rampage::CYCLE_B_INPUT));


addParam(createParam<BefacoSwitch>(Vec(96-2, 35-3), module, Rampage::RANGE_A_PARAM, 0.0, 2.0, 0.0)); addParam(createParam<BefacoSwitch>(Vec(96-2, 35-3), module, Rampage::RANGE_A_PARAM, 0.0, 2.0, 0.0));
addParam(createParam<BefacoTinyKnob>(Vec(27, 90), module, Rampage::SHAPE_A_PARAM, 0.0, 1.0, 0.0));
addParam(createParam<BefacoTinyKnob>(Vec(27, 90), module, Rampage::SHAPE_A_PARAM, -1.0, 1.0, 0.0));
addParam(createParam<BefacoPush>(Vec(72, 82), module, Rampage::TRIGG_A_PARAM, 0.0, 1.0, 0.0)); addParam(createParam<BefacoPush>(Vec(72, 82), module, Rampage::TRIGG_A_PARAM, 0.0, 1.0, 0.0));
addParam(createParam<BefacoSlidePot>(Vec(21-5, 140-5), module, Rampage::RISE_A_PARAM, 0.0, 1.0, 0.0)); addParam(createParam<BefacoSlidePot>(Vec(21-5, 140-5), module, Rampage::RISE_A_PARAM, 0.0, 1.0, 0.0));
addParam(createParam<BefacoSlidePot>(Vec(62-5, 140-5), module, Rampage::FALL_A_PARAM, 0.0, 1.0, 0.0)); addParam(createParam<BefacoSlidePot>(Vec(62-5, 140-5), module, Rampage::FALL_A_PARAM, 0.0, 1.0, 0.0));
addParam(createParam<BefacoSwitch>(Vec(101, 240-2), module, Rampage::CYCLE_A_PARAM, 0.0, 1.0, 0.0)); addParam(createParam<BefacoSwitch>(Vec(101, 240-2), module, Rampage::CYCLE_A_PARAM, 0.0, 1.0, 0.0));
addParam(createParam<BefacoSwitch>(Vec(149-2, 35-3), module, Rampage::RANGE_B_PARAM, 0.0, 2.0, 0.0)); addParam(createParam<BefacoSwitch>(Vec(149-2, 35-3), module, Rampage::RANGE_B_PARAM, 0.0, 2.0, 0.0));
addParam(createParam<BefacoTinyKnob>(Vec(217, 90), module, Rampage::SHAPE_B_PARAM, 0.0, 1.0, 0.0));
addParam(createParam<BefacoTinyKnob>(Vec(217, 90), module, Rampage::SHAPE_B_PARAM, -1.0, 1.0, 0.0));
addParam(createParam<BefacoPush>(Vec(170, 82), module, Rampage::TRIGG_B_PARAM, 0.0, 1.0, 0.0)); addParam(createParam<BefacoPush>(Vec(170, 82), module, Rampage::TRIGG_B_PARAM, 0.0, 1.0, 0.0));
addParam(createParam<BefacoSlidePot>(Vec(202-5, 140-5), module, Rampage::RISE_B_PARAM, 0.0, 1.0, 0.0)); addParam(createParam<BefacoSlidePot>(Vec(202-5, 140-5), module, Rampage::RISE_B_PARAM, 0.0, 1.0, 0.0));
addParam(createParam<BefacoSlidePot>(Vec(243-5, 140-5), module, Rampage::FALL_B_PARAM, 0.0, 1.0, 0.0)); addParam(createParam<BefacoSlidePot>(Vec(243-5, 140-5), module, Rampage::FALL_B_PARAM, 0.0, 1.0, 0.0));
addParam(createParam<BefacoSwitch>(Vec(141, 240-2), module, Rampage::CYCLE_B_PARAM, 0.0, 1.0, 0.0)); addParam(createParam<BefacoSwitch>(Vec(141, 240-2), module, Rampage::CYCLE_B_PARAM, 0.0, 1.0, 0.0));
addParam(createParam<Davies1900hWhiteKnob>(Vec(117, 76), module, Rampage::BALANCE_PARAM, 0.0, 1.0, 0.0));
addParam(createParam<Davies1900hWhiteKnob>(Vec(117, 76), module, Rampage::BALANCE_PARAM, 0.0, 1.0, 0.5));


addOutput(createOutput<PJ3410Port>(Vec(8-3, 326-3), module, Rampage::RISING_A_OUTPUT)); addOutput(createOutput<PJ3410Port>(Vec(8-3, 326-3), module, Rampage::RISING_A_OUTPUT));
addOutput(createOutput<PJ3410Port>(Vec(67-3, 326-3), module, Rampage::FALLING_A_OUTPUT)); addOutput(createOutput<PJ3410Port>(Vec(67-3, 326-3), module, Rampage::FALLING_A_OUTPUT));
@@ -118,4 +168,14 @@ RampageWidget::RampageWidget() {
addOutput(createOutput<PJ3410Port>(Vec(122-3, 133-3), module, Rampage::COMPARATOR_OUTPUT)); addOutput(createOutput<PJ3410Port>(Vec(122-3, 133-3), module, Rampage::COMPARATOR_OUTPUT));
addOutput(createOutput<PJ3410Port>(Vec(89-3, 156-3), module, Rampage::MIN_OUTPUT)); addOutput(createOutput<PJ3410Port>(Vec(89-3, 156-3), module, Rampage::MIN_OUTPUT));
addOutput(createOutput<PJ3410Port>(Vec(155-3, 156-3), module, Rampage::MAX_OUTPUT)); addOutput(createOutput<PJ3410Port>(Vec(155-3, 156-3), module, Rampage::MAX_OUTPUT));

addChild(createValueLight<SmallLight<RedValueLight>>(Vec(131, 167), &module->comparatorLight));
addChild(createValueLight<SmallLight<RedValueLight>>(Vec(122, 174), &module->minLight));
addChild(createValueLight<SmallLight<RedValueLight>>(Vec(140, 174), &module->maxLight));
addChild(createValueLight<SmallLight<RedValueLight>>(Vec(125, 185), &module->outALight));
addChild(createValueLight<SmallLight<RedValueLight>>(Vec(137, 185), &module->outBLight));
addChild(createValueLight<SmallLight<RedValueLight>>(Vec(17, 312), &module->risingALight));
addChild(createValueLight<SmallLight<RedValueLight>>(Vec(77, 312), &module->fallingALight));
addChild(createValueLight<SmallLight<RedValueLight>>(Vec(186, 312), &module->risingBLight));
addChild(createValueLight<SmallLight<RedValueLight>>(Vec(245, 312), &module->fallingBLight));
} }

+ 12
- 12
src/SlewLimiter.cpp View File

@@ -19,7 +19,7 @@ struct SlewLimiter : Module {
NUM_OUTPUTS NUM_OUTPUTS
}; };


float output = 0.0;
float out = 0.0;


SlewLimiter(); SlewLimiter();
void step(); void step();
@@ -33,33 +33,33 @@ struct SlewLimiter : Module {
} }


void ::SlewLimiter::step() { void ::SlewLimiter::step() {
float input = getf(inputs[IN_INPUT]);
float in = getf(inputs[IN_INPUT]);
float shape = params[SHAPE_PARAM]; float shape = params[SHAPE_PARAM];


// minimum and maximum slopes in volts per second // minimum and maximum slopes in volts per second
const float slewMin = 0.1; const float slewMin = 0.1;
const float slewMax = 40000.0;
const float slewMax = 10000.0;
// Amount of extra slew per voltage difference // Amount of extra slew per voltage difference
const float shapeScale = 1/10.0; const float shapeScale = 1/10.0;


// Rise // Rise
if (input > output) {
if (in > out) {
float rise = getf(inputs[RISE_INPUT]) + params[RISE_PARAM]; float rise = getf(inputs[RISE_INPUT]) + params[RISE_PARAM];
float slew = slewMax * powf(slewMin / slewMax, rise); float slew = slewMax * powf(slewMin / slewMax, rise);
output += slew * crossf(1.0, shapeScale * (input - output), shape) / gSampleRate;
if (output > input)
output = input;
out += slew * crossf(1.0, shapeScale * (in - out), shape) / gSampleRate;
if (out > in)
out = in;
} }
// Fall // Fall
else if (input < output) {
else if (in < out) {
float fall = getf(inputs[FALL_INPUT]) + params[FALL_PARAM]; float fall = getf(inputs[FALL_INPUT]) + params[FALL_PARAM];
float slew = slewMax * powf(slewMin / slewMax, fall); float slew = slewMax * powf(slewMin / slewMax, fall);
output -= slew * crossf(1.0, shapeScale * (output - input), shape) / gSampleRate;
if (output < input)
output = input;
out -= slew * crossf(1.0, shapeScale * (out - in), shape) / gSampleRate;
if (out < in)
out = in;
} }


setf(outputs[OUT_OUTPUT], output);
setf(outputs[OUT_OUTPUT], out);
} }






Loading…
Cancel
Save