switching saw works

This commit is contained in:
Gordon JC Pearce 2024-09-03 23:41:01 +01:00
parent cb7445434c
commit 8e9b6adf86
4 changed files with 8 additions and 6 deletions

View File

@ -15,7 +15,7 @@ FILES_DSP = \
include ../dpf/Makefile.plugins.mk
TARGETS += jack
TARGETS += jack lv2
all: $(TARGETS)

View File

@ -33,7 +33,7 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.symbol = "saw";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 127.0f;
parameter.ranges.def = 0.0f;
}
}
@ -121,7 +121,7 @@ void Chassis::run(const float **, float **outputs, uint32_t frames, const MidiEv
// run each synth voice
bzero(outputs[0], sizeof(float) * frames);
for (uint8_t i = 0; i < NUM_VOICES; i++) {
s.voice[i].run(outputs[0], frames);
s.voice[i].run(s, outputs[0], frames);
}
// copy left to right
memmove(outputs[1], outputs[0], sizeof(float) * frames);

View File

@ -54,7 +54,7 @@ void Voice::off() {
target = 0;
}
void Voice::run(float *buffer, uint32_t samples) {
void Voice::run(Synth &s, float *buffer, uint32_t samples) {
float y;
env = ((target - env) * 0.01) + env;
for (uint32_t i = 0; i < samples; i++) {
@ -63,6 +63,6 @@ void Voice::run(float *buffer, uint32_t samples) {
y = (2 * phase) - 1;
y -= blep(phase, omega);
buffer[i] += 0.25 * y * env;
buffer[i] += (0.25 * y * env) * s.p.saw;
}
}

View File

@ -20,6 +20,8 @@
#include <cstdint>
class Synth;
class Patch {
public:
float saw,sqr;
@ -36,7 +38,7 @@ class Voice {
bool isFree();
void run(float *buffer, uint32_t samples);
void run(Synth &s, float *buffer, uint32_t samples);
private:
enum { ATTACK,