synthpp_mono + fix bwpp_{noise_gen,osc_tri,pink_filt} and synth*

This commit is contained in:
Stefano D'Angelo 2023-06-28 10:48:08 +02:00
parent 1b8e4c56e3
commit 5245adea14
17 changed files with 719 additions and 25 deletions

1
TODO
View File

@ -63,6 +63,7 @@ code:
* allow nullptr in C++ wrappers where process_multi arg can be NULL
* src post filt?
* bw_env_gen process_multi gate const?
* c++ get coeffs/state? or public?
build system:
* make makefiles handle paths with spaces etc

View File

@ -51,11 +51,8 @@ void bw_example_synth_mono_init(bw_example_synth_mono *instance) {
bw_osc_tri_set_antialiasing(&instance->vco1_tri_coeffs, 1);
bw_osc_pulse_set_antialiasing(&instance->vco2_pulse_coeffs, 1);
bw_osc_tri_set_antialiasing(&instance->vco2_tri_coeffs, 1);
bw_gain_set_gain_lin(&instance->vco2_gain_coeffs, 0.f);
bw_osc_pulse_set_antialiasing(&instance->vco3_pulse_coeffs, 1);
bw_osc_tri_set_antialiasing(&instance->vco3_tri_coeffs, 1);
bw_gain_set_gain_lin(&instance->vco3_gain_coeffs, 0.f);
bw_gain_set_gain_lin(&instance->noise_gain_coeffs, 0.f);
bw_phase_gen_set_frequency(&instance->a440_phase_gen_coeffs, 440.f);
instance->rand_state = 0xbaddecaf600dfeed;
@ -246,8 +243,6 @@ void bw_example_synth_mono_process(bw_example_synth_mono *instance, const float*
}
void bw_example_synth_mono_set_parameter(bw_example_synth_mono *instance, int index, float value) {
if (instance->params[index] == value)
return;
instance->params[index] = value;
switch (index) {
case p_volume:

View File

@ -56,11 +56,8 @@ void bw_example_synth_poly_init(bw_example_synth_poly *instance) {
bw_osc_tri_set_antialiasing(&instance->vco1_tri_coeffs, 1);
bw_osc_pulse_set_antialiasing(&instance->vco2_pulse_coeffs, 1);
bw_osc_tri_set_antialiasing(&instance->vco2_tri_coeffs, 1);
bw_gain_set_gain_lin(&instance->vco2_gain_coeffs, 0.f);
bw_osc_pulse_set_antialiasing(&instance->vco3_pulse_coeffs, 1);
bw_osc_tri_set_antialiasing(&instance->vco3_tri_coeffs, 1);
bw_gain_set_gain_lin(&instance->vco3_gain_coeffs, 0.f);
bw_gain_set_gain_lin(&instance->noise_gain_coeffs, 0.f);
bw_phase_gen_set_frequency(&instance->a440_phase_gen_coeffs, 440.f);
instance->rand_state = 0xbaddecaf600dfeed;
@ -337,8 +334,6 @@ void bw_example_synth_poly_process(bw_example_synth_poly *instance, const float*
}
void bw_example_synth_poly_set_parameter(bw_example_synth_poly *instance, int index, float value) {
if (instance->params[index] == value)
return;
instance->params[index] = value;
switch (index) {
case p_volume:

View File

@ -31,8 +31,6 @@ void bw_example_synth_simple_init(bw_example_synth_simple *instance) {
bw_ppm_init(&instance->ppm_coeffs);
bw_osc_pulse_set_antialiasing(&instance->osc_pulse_coeffs, 1);
instance->rand_state = 0xbaddecaf600dfeed;
}
void bw_example_synth_simple_set_sample_rate(bw_example_synth_simple *instance, float sample_rate) {
@ -82,8 +80,6 @@ void bw_example_synth_simple_process(bw_example_synth_simple *instance, const fl
}
void bw_example_synth_simple_set_parameter(bw_example_synth_simple *instance, int index, float value) {
if (instance->params[index] == value)
return;
instance->params[index] = value;
switch (index) {
case p_volume:

View File

@ -68,7 +68,6 @@ struct _bw_example_synth_simple {
float params[p_n];
// States
uint64_t rand_state;
int note;
// Buffers

View File

@ -0,0 +1,9 @@
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
TARGET = bw_example_synthpp_mono
CPP_SOURCES_EXTRA = ${ROOT_DIR}/../src/bw_example_synthpp_mono.cpp
SYNTH := yes
include ${ROOT_DIR}/../../common/daisy-seed/daisy-seed.mk

View File

@ -0,0 +1,72 @@
/*
* Brickworks
*
* Copyright (C) 2023 Orastron Srl unipersonale
*
* Brickworks 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, version 3 of the License.
*
* Brickworks 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 Brickworks. If not, see <http://www.gnu.org/licenses/>.
*
* File authors: Stefano D'Angelo
*/
#ifndef _CONFIG_DAISY_SEED_H
#define _CONFIG_DAISY_SEED_H
struct config_cc {
int param_index;
unsigned char cc;
};
#define NUM_CCS 38
static struct config_cc config_ccs[NUM_CCS] = {
{ 0, 7 }, // Volume
{ 1, 3 }, // Master tune
{ 2, 5 }, // Portamento
{ 3, 9 }, // Modulation mix
{ 4, 14 }, // VCO1 modulation
{ 5, 15 }, // VCO1 coarse
{ 6, 20 }, // VCO1 fine
{ 7, 21 }, // VCO1 waveform
{ 8, 22 }, // VCO1 pulse width/slope
{ 9, 23 }, // VCO1 level
{ 10, 24 }, // VCO2 modulation
{ 11, 25 }, // VCO2 coarse
{ 12, 26 }, // VCO2 fine
{ 13, 27 }, // VCO2 waveform
{ 14, 28 }, // VCO2 pulse width/slope
{ 15, 29 }, // VCO2 level
{ 16, 30 }, // VCO3 keyboard control
{ 17, 31 }, // VCO3 coarse
{ 18, 85 }, // VCO3 fine
{ 19, 86 }, // VCO3 waveform
{ 20, 87 }, // VCO3 puslse width/slope
{ 21, 89 }, // VCO3 level
{ 22, 90 }, // Noise color
{ 23, 102 }, // Noise level
{ 24, 103 }, // VCF modulation
{ 25, 104 }, // VCF keyboard control
{ 26, 74 }, // VCF cutoff
{ 27, 71 }, // VCF Q
{ 28, 105 }, // VCF contour
{ 29, 106 }, // VCF attack
{ 30, 107 }, // VCF decay
{ 31, 108 }, // VCF sustain
{ 32, 109 }, // VCF release
{ 33, 73 }, // VCA attack
{ 34, 110 }, // VCA decay
{ 35, 111 }, // VCA sustain
{ 36, 72 }, // VCA release
{ 37, 112 } // A440
};
#endif

View File

@ -0,0 +1,321 @@
/*
* Brickworks
*
* Copyright (C) 2023 Orastron Srl unipersonale
*
* Brickworks 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, version 3 of the License.
*
* Brickworks 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 Brickworks. If not, see <http://www.gnu.org/licenses/>.
*
* File author: Stefano D'Angelo
*/
#include "bw_example_synthpp_mono.h"
#include <bw_math.h>
#include <bw_buf.h>
void bw_example_synthpp_mono_init(bw_example_synthpp_mono *instance) {
instance->vco1OscSaw.setAntialiasing(true);
instance->vco1OscPulse.setAntialiasing(true);
instance->vco1OscTri.setAntialiasing(true);
instance->vco2OscSaw.setAntialiasing(true);
instance->vco2OscPulse.setAntialiasing(true);
instance->vco2OscTri.setAntialiasing(true);
instance->vco3OscSaw.setAntialiasing(true);
instance->vco3OscPulse.setAntialiasing(true);
instance->vco3OscTri.setAntialiasing(true);
instance->a440PhaseGen.setFrequency(440.f);
instance->rand_state = 0xbaddecaf600dfeed;
}
void bw_example_synthpp_mono_set_sample_rate(bw_example_synthpp_mono *instance, float sample_rate) {
instance->vco1PhaseGen.setSampleRate(sample_rate);
instance->vco1OscPulse.setSampleRate(sample_rate);
instance->vco1OscTri.setSampleRate(sample_rate);
instance->vco1Gain.setSampleRate(sample_rate);
instance->vco2PhaseGen.setSampleRate(sample_rate);
instance->vco2OscPulse.setSampleRate(sample_rate);
instance->vco2OscTri.setSampleRate(sample_rate);
instance->vco2Gain.setSampleRate(sample_rate);
instance->vco3PhaseGen.setSampleRate(sample_rate);
instance->vco3OscPulse.setSampleRate(sample_rate);
instance->vco3OscTri.setSampleRate(sample_rate);
instance->vco3Gain.setSampleRate(sample_rate);
instance->noiseGen.setSampleRate(sample_rate);
instance->pinkFilt.setSampleRate(sample_rate);
instance->noiseGain.setSampleRate(sample_rate);
instance->vcfEnvGen.setSampleRate(sample_rate);
instance->vcf.setSampleRate(sample_rate);
instance->vcaEnvGen.setSampleRate(sample_rate);
instance->a440PhaseGen.setSampleRate(sample_rate);
instance->gain.setSampleRate(sample_rate);
instance->ppm.setSampleRate(sample_rate);
}
void bw_example_synthpp_mono_reset(bw_example_synthpp_mono *instance) {
const float v = instance->params[p_vcf_cutoff];
const float cutoff = 20.f + (20e3f - 20.f) * v * v * v;
instance->vcf.setCutoff(bw_clipf(cutoff, 20.f, 20e3f));
instance->vco1PhaseGen.reset();
instance->vco1OscPulse.reset();
instance->vco1OscTri.reset();
instance->vco1Gain.reset();
instance->vco2PhaseGen.reset();
instance->vco2OscPulse.reset();
instance->vco2OscTri.reset();
instance->vco2Gain.reset();
instance->vco3PhaseGen.reset();
instance->vco3OscPulse.reset();
instance->vco3OscTri.reset();
instance->vco3Gain.reset();
instance->oscFilt.reset();
instance->pinkFilt.reset();
instance->noiseGain.reset();
instance->vcfEnvGen.reset();
instance->vcf.reset();
instance->vcaEnvGen.reset();
instance->a440PhaseGen.reset();
instance->gain.reset();
instance->ppm.reset();
instance->note = 60;
instance->gate = 0;
instance->pitch_bend = 0.f;
instance->mod_wheel = 0.f;
for (int i = 0; i < 128; i++)
instance->notes_pressed[i] = 0;
}
void bw_example_synthpp_mono_process(bw_example_synthpp_mono *instance, const float** x, float** y, int n_samples) {
// FIXME: control-rate modulations are asynchronous here...
// it's all good as long as hosts gives us buffers whose length is a multiple of 32,
// otherwise it's probably still ok but a bit "swingy"
(void)x;
int n = instance->params[p_vco3_kbd] >= 0.5f ? instance->note : 0;
instance->vco1PhaseGen.setFrequency(440.f *
bw_pow2f_3(6.f * instance->params[p_vco1_coarse] - 3.f
+ 2.f * instance->pitch_bend - 1.f
+ 8.333333333333333e-2f * ((instance->note - 69) + 2.f * (instance->params[p_master_tune] + instance->params[p_vco1_fine]) - 2.f)));
instance->vco2PhaseGen.setFrequency(440.f *
bw_pow2f_3(6.f * instance->params[p_vco2_coarse] - 3.f
+ 2.f * instance->pitch_bend - 1.f
+ 8.333333333333333e-2f * ((instance->note - 69) + 2.f * (instance->params[p_master_tune] + instance->params[p_vco2_fine]) - 2.f)));
instance->vco3PhaseGen.setFrequency(440.f *
bw_pow2f_3(6.f * instance->params[p_vco3_coarse] - 3.f
+ 2.f * instance->pitch_bend - 1.f
+ 8.333333333333333e-2f * ((n - 69) + 2.f * (instance->params[p_master_tune] + instance->params[p_vco3_fine]) - 2.f)));
for (int i = 0; i < n_samples; i += BUFFER_SIZE) {
float *out = y[0] + i;
int n = bw_minf(n_samples - i, BUFFER_SIZE);
instance->vco3PhaseGen.process({nullptr}, {out}, {instance->buf[0]}, n);
if (instance->params[p_vco3_waveform] >= (1.f / 4.f + 1.f / 2.f)) {
instance->vco3OscTri.process({out}, {instance->buf[0]}, {out}, n);
instance->vco3OscPulse.reset();
} else if (instance->params[p_vco3_waveform] >= (1.f / 4.f)) {
instance->vco3OscPulse.process({out}, {instance->buf[0]}, {out}, n);
instance->vco3OscTri.reset();
} else {
instance->vco3OscSaw.process({out}, {instance->buf[0]}, {out}, n);
instance->vco3OscPulse.reset();
instance->vco3OscTri.reset();
}
instance->noiseGen.process({instance->buf[0]}, n);
if (instance->params[p_noise_color] >= 0.5f)
instance->pinkFilt.process({instance->buf[0]}, {instance->buf[0]}, n);
else
instance->pinkFilt.reset(); // FIXME: calling this here is sloppy coding
bw_buf_scale(instance->buf[0], instance->buf[0], 5.f, n);
for (int j = 0; j < n; j++)
instance->buf[1][j] = instance->mod_wheel * (out[j] + instance->params[p_mod_mix] * (instance->buf[0][j] - out[j]));
const float vcf_mod = 0.3f * instance->params[p_vcf_mod] * instance->buf[1][0];
bw_buf_scale(instance->buf[2], instance->buf[1], instance->params[p_vco1_mod], n);
instance->vco1PhaseGen.process({instance->buf[2]}, {instance->buf[2]}, {instance->buf[3]}, n);
if (instance->params[p_vco1_waveform] >= (1.f / 4.f + 1.f / 2.f)) {
instance->vco1OscTri.process({instance->buf[2]}, {instance->buf[3]}, {instance->buf[2]}, n);
instance->vco1OscPulse.reset();
} else if (instance->params[p_vco1_waveform] >= (1.f / 4.f)) {
instance->vco1OscPulse.process({instance->buf[2]}, {instance->buf[3]}, {instance->buf[2]}, n);
instance->vco1OscTri.reset();
} else {
instance->vco1OscSaw.process({instance->buf[2]}, {instance->buf[3]}, {instance->buf[2]}, n);
instance->vco1OscPulse.reset();
instance->vco1OscTri.reset();
}
bw_buf_scale(instance->buf[1], instance->buf[1], instance->params[p_vco1_mod], n);
instance->vco2PhaseGen.process({instance->buf[1]}, {instance->buf[1]}, {instance->buf[3]}, n);
if (instance->params[p_vco2_waveform] >= (1.f / 4.f + 1.f / 2.f)) {
instance->vco2OscTri.process({instance->buf[1]}, {instance->buf[3]}, {instance->buf[1]}, n);
instance->vco2OscPulse.reset();
} else if (instance->params[p_vco2_waveform] >= (1.f / 4.f)) {
instance->vco2OscPulse.process({instance->buf[1]}, {instance->buf[3]}, {instance->buf[1]}, n);
instance->vco2OscTri.reset();
} else {
instance->vco2OscSaw.process({instance->buf[1]}, {instance->buf[3]}, {instance->buf[1]}, n);
instance->vco2OscPulse.reset();
instance->vco2OscTri.reset();
}
instance->vco1Gain.process({instance->buf[2]}, {instance->buf[2]}, n);
instance->vco2Gain.process({instance->buf[1]}, {instance->buf[1]}, n);
instance->vco3Gain.process({out}, {out}, n);
instance->noiseGain.process({instance->buf[0]}, {instance->buf[0]}, n);
bw_buf_mix(out, out, instance->buf[1], n);
bw_buf_mix(out, out, instance->buf[2], n);
instance->oscFilt.process({out}, {out}, n);
const float k = instance->params[p_noise_color] >= 0.5f
? 6.f * instance->noiseGen.getScalingK() * instance->pinkFilt.getScalingK()
: 0.1f * instance->noiseGen.getScalingK();
bw_buf_scale(instance->buf[0], instance->buf[0], k, n);
bw_buf_mix(out, out, instance->buf[0], n);
instance->vcfEnvGen.process({instance->gate}, {nullptr}, n);
float v = instance->params[p_vcf_cutoff] + instance->params[p_vcf_contour] * instance->vcfEnvGen.getYZ1(0) + vcf_mod;
float cutoff = 20.f + (20e3f - 20.f) * v * v * v;
if (instance->params[p_vcf_kbd_ctrl] >= (1.f / 6.f + 2.f / 3.f))
cutoff *= bw_pow2f_3(8.333333333333333e-2f * (instance->note - 60));
else if (instance->params[p_vcf_kbd_ctrl] >= (1.f / 6.f + 1.f / 3.f))
cutoff *= bw_pow2f_3((0.793700525984100f * 8.333333333333333e-2f) * (instance->note - 60));
else if (instance->params[p_vcf_kbd_ctrl] >= (1.f / 6.f + 2.f / 3.f))
cutoff *= bw_pow2f_3((0.629960524947437f * 8.333333333333333e-2f) * (instance->note - 60));
// otherwise no kbd control
instance->vcf.setCutoff(bw_clipf(cutoff, 20.f, 20e3f));
instance->vcf.process({out}, {out}, {nullptr}, {nullptr}, n);
instance->vcaEnvGen.process({instance->gate}, {instance->buf[0]}, n);
bw_buf_mul(out, out, instance->buf[0], n);
instance->a440PhaseGen.process({nullptr}, {instance->buf[0]}, {nullptr}, n);
oscSinProcess<1>({instance->buf[0]}, {instance->buf[0]}, n);
if (instance->params[p_a440] >= 0.5f)
bw_buf_mix(out, out, instance->buf[0], n);
instance->gain.process({out}, {out}, n);
instance->ppm.process({out}, {nullptr}, n);
}
}
void bw_example_synthpp_mono_set_parameter(bw_example_synthpp_mono *instance, int index, float value) {
instance->params[index] = value;
switch (index) {
case p_volume:
instance->gain.setGainLin(value * value * value);
break;
case p_portamento:
instance->vco1PhaseGen.setPortamentoTau(value);
instance->vco2PhaseGen.setPortamentoTau(value);
instance->vco3PhaseGen.setPortamentoTau(value);
break;
case p_vco1_pw_slope:
instance->vco1OscPulse.setPulseWidth(value);
instance->vco1OscTri.setSlope(bw_clipf(value, 0.001f, 0.999f));
break;
case p_vco1_level:
instance->vco1Gain.setGainLin(value * value * value);
break;
case p_vco2_pw_slope:
instance->vco2OscPulse.setPulseWidth(value);
instance->vco2OscTri.setSlope(bw_clipf(value, 0.001f, 0.999f));
break;
case p_vco2_level:
instance->vco2Gain.setGainLin(value * value * value);
break;
case p_vco3_pw_slope:
instance->vco3OscPulse.setPulseWidth(value);
instance->vco3OscTri.setSlope(bw_clipf(value, 0.001f, 0.999f));
break;
case p_vco3_level:
instance->vco3Gain.setGainLin(value * value * value);
break;
case p_noise_level:
instance->noiseGain.setGainLin(value * value * value);
break;
case p_vcf_Q:
instance->vcf.setQ(0.5f + 9.5f * value);
break;
case p_vcf_attack:
instance->vcfEnvGen.setAttack(value);
break;
case p_vcf_decay:
instance->vcfEnvGen.setDecay(value);
break;
case p_vcf_sustain:
instance->vcfEnvGen.setSustain(value);
break;
case p_vcf_release:
instance->vcfEnvGen.setRelease(value);
break;
case p_vca_attack:
instance->vcaEnvGen.setAttack(value);
break;
case p_vca_decay:
instance->vcaEnvGen.setDecay(value);
break;
case p_vca_sustain:
instance->vcaEnvGen.setSustain(value);
break;
case p_vca_release:
instance->vcaEnvGen.setRelease(value);
break;
}
}
float bw_example_synthpp_mono_get_parameter(bw_example_synthpp_mono *instance, int index) {
if (index < p_n)
return instance->params[index];
const float v = instance->ppm.getYZ1(0);
return v < -200.f ? 0.f : bw_clipf(0.01666666666666666f * v + 1.f, 0.f, 1.f);
}
static void update_note_gate(bw_example_synthpp_mono *instance) {
for (int i = 0; i < 128; i++)
if (instance->notes_pressed[i]) {
instance->note = i;
instance->gate = 1;
return;
}
instance->gate = 0;
}
void bw_example_synthpp_mono_note_on(bw_example_synthpp_mono *instance, char note, char velocity) {
if (velocity == 0)
bw_example_synthpp_mono_note_off(instance, note);
else {
instance->notes_pressed[(int)note] = 1;
update_note_gate(instance);
}
}
void bw_example_synthpp_mono_note_off(bw_example_synthpp_mono *instance, char note) {
if (instance->notes_pressed[(int)note]) {
instance->notes_pressed[(int)note] = 0;
update_note_gate(instance);
}
}
void bw_example_synthpp_mono_pitch_bend(bw_example_synthpp_mono *instance, int value) {
instance->pitch_bend = (value - 0x2000) / (float)0x4000;
}
void bw_example_synthpp_mono_mod_wheel(bw_example_synthpp_mono *instance, char value) {
instance->mod_wheel = (float)value / 0x80;
}

View File

@ -0,0 +1,144 @@
/*
* Brickworks
*
* Copyright (C) 2023 Orastron Srl unipersonale
*
* Brickworks 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, version 3 of the License.
*
* Brickworks 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 Brickworks. If not, see <http://www.gnu.org/licenses/>.
*
* File author: Stefano D'Angelo
*/
#ifndef _BW_EXAMPLE_SYNTHPP_MONO_H
#define _BW_EXAMPLE_SYNTHPP_MONO_H
#include <bwpp_phase_gen.h>
#include <bwpp_osc_saw.h>
#include <bwpp_osc_pulse.h>
#include <bwpp_osc_tri.h>
#include <bwpp_osc_sin.h>
#include <bwpp_osc_filt.h>
#include <bwpp_noise_gen.h>
#include <bwpp_pink_filt.h>
#include <bwpp_svf.h>
#include <bwpp_env_gen.h>
#include <bwpp_gain.h>
#include <bwpp_ppm.h>
using namespace Brickworks;
extern "C" {
enum {
p_volume,
p_master_tune,
p_portamento,
p_mod_mix,
p_vco1_mod,
p_vco1_coarse,
p_vco1_fine,
p_vco1_waveform,
p_vco1_pw_slope,
p_vco1_level,
p_vco2_mod,
p_vco2_coarse,
p_vco2_fine,
p_vco2_waveform,
p_vco2_pw_slope,
p_vco2_level,
p_vco3_kbd,
p_vco3_coarse,
p_vco3_fine,
p_vco3_waveform,
p_vco3_pw_slope,
p_vco3_level,
p_noise_color,
p_noise_level,
p_vcf_mod,
p_vcf_kbd_ctrl,
p_vcf_cutoff,
p_vcf_Q,
p_vcf_contour,
p_vcf_attack,
p_vcf_decay,
p_vcf_sustain,
p_vcf_release,
p_vca_attack,
p_vca_decay,
p_vca_sustain,
p_vca_release,
p_a440,
p_n
};
#define BUFFER_SIZE 32
struct _bw_example_synthpp_mono {
// Sub-components
PhaseGen<1> vco1PhaseGen;
OscSaw<1> vco1OscSaw;
OscPulse<1> vco1OscPulse;
OscTri<1> vco1OscTri;
Gain<1> vco1Gain;
PhaseGen<1> vco2PhaseGen;
OscSaw<1> vco2OscSaw;
OscPulse<1> vco2OscPulse;
OscTri<1> vco2OscTri;
Gain<1> vco2Gain;
PhaseGen<1> vco3PhaseGen;
OscSaw<1> vco3OscSaw;
OscPulse<1> vco3OscPulse;
OscTri<1> vco3OscTri;
Gain<1> vco3Gain;
OscFilt<1> oscFilt;
NoiseGen<1> noiseGen;
PinkFilt<1> pinkFilt;
Gain<1> noiseGain;
EnvGen<1> vcfEnvGen;
SVF<1> vcf;
EnvGen<1> vcaEnvGen;
PhaseGen<1> a440PhaseGen;
Gain<1> gain;
PPM<1> ppm;
// Parameters
float params[p_n];
// States
uint64_t rand_state;
int note;
char gate;
float pitch_bend;
float mod_wheel;
char notes_pressed[128];
// Buffers
float buf[4][BUFFER_SIZE];
_bw_example_synthpp_mono() : noiseGen(&rand_state) {}
};
typedef struct _bw_example_synthpp_mono bw_example_synthpp_mono;
void bw_example_synthpp_mono_init(bw_example_synthpp_mono *instance);
void bw_example_synthpp_mono_set_sample_rate(bw_example_synthpp_mono *instance, float sample_rate);
void bw_example_synthpp_mono_reset(bw_example_synthpp_mono *instance);
void bw_example_synthpp_mono_process(bw_example_synthpp_mono *instance, const float** x, float** y, int n_samples);
void bw_example_synthpp_mono_set_parameter(bw_example_synthpp_mono *instance, int index, float value);
float bw_example_synthpp_mono_get_parameter(bw_example_synthpp_mono *instance, int index);
void bw_example_synthpp_mono_note_on(bw_example_synthpp_mono *instance, char note, char velocity);
void bw_example_synthpp_mono_note_off(bw_example_synthpp_mono *instance, char note);
void bw_example_synthpp_mono_pitch_bend(bw_example_synthpp_mono *instance, int value);
void bw_example_synthpp_mono_mod_wheel(bw_example_synthpp_mono *instance, char value);
}
#endif

View File

@ -0,0 +1,125 @@
/*
* Brickworks
*
* Copyright (C) 2023 Orastron Srl unipersonale
*
* Brickworks 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, version 3 of the License.
*
* Brickworks 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 Brickworks. If not, see <http://www.gnu.org/licenses/>.
*
* File authors: Stefano D'Angelo
*/
#ifndef _CONFIG_H
#define _CONFIG_H
// Definitions
#define IO_MONO 1
#define IO_STEREO (1<<1)
struct config_io_bus {
const char *name;
char out;
char aux;
char cv;
char configs;
};
struct config_parameter {
const char *name;
const char *shortName;
const char *units;
char out;
char bypass;
int steps;
float defaultValueUnmapped;
};
// Data
#define COMPANY_NAME "Orastron"
#define COMPANY_WEBSITE "https://www.orastron.com/"
#define COMPANY_MAILTO "mailto:info@orastron.com"
#define PLUGIN_NAME "bw_example_synthpp_mono"
#define PLUGIN_VERSION "0.5.0"
#define NUM_BUSES_IN 0
#define NUM_BUSES_OUT 1
#define NUM_CHANNELS_IN 0
#define NUM_CHANNELS_OUT 1
static struct config_io_bus config_buses_out[NUM_BUSES_OUT] = {
{ "Audio out", 1, 0, 0, IO_MONO }
};
#define NUM_PARAMETERS 39
static struct config_parameter config_parameters[NUM_PARAMETERS] = {
{ "Volume", "Volume", "", 0, 0, 0, 0.5f },
{ "Master tune", "Master tune", "st", 0, 0, 0, 0.5f },
{ "Portamento", "Portamento", "s", 0, 0, 0, 0.f },
{ "Modulation mix", "Mod mix", "%", 0, 0, 0, 0.f },
{ "VCO1 modulation", "VCO1 mod", "%", 0, 0, 0, 0.f },
{ "VCO1 coarse", "VCO1 coarse", "", 0, 0, 6, 0.5f },
{ "VCO1 fine", "VCO1 fine", "st", 0, 0, 0, 0.5f },
{ "VCO1 waveform", "VCO1 wave", "", 0, 0, 2, 0.f },
{ "VCO1 pulse width/slope", "VCO1 pw/slope", "%", 0, 0, 0, 0.5f },
{ "VCO1 level", "VCO1 level", "%", 0, 0, 0, 1.f },
{ "VCO2 modulation", "VCO2 mod", "%", 0, 0, 0, 0.f },
{ "VCO2 coarse", "VCO2 coarse", "", 0, 0, 6, 0.5f },
{ "VCO2 fine", "VCO2 fine", "st", 0, 0, 0, 0.5f },
{ "VCO2 waveform", "VCO2 wave", "", 0, 0, 2, 0.f },
{ "VCO2 pulse width/slope", "VCO2 pw/slope", "%", 0, 0, 0, 0.5f },
{ "VCO2 level", "VCO2 level", "%", 0, 0, 0, 0.f },
{ "VCO3 kyboard control", "VCO3 kbd ctrl", "", 0, 0, 1, 1.f },
{ "VCO3 coarse", "VCO3 coarse", "", 0, 0, 6, 0.5f },
{ "VCO3 fine", "VCO3 fine", "st", 0, 0, 0, 0.5f },
{ "VCO3 waveform", "VCO3 wave", "", 0, 0, 2, 0.f },
{ "VCO3 pulse width/slope", "VCO3 pw/slope", "%", 0, 0, 0, 0.5f },
{ "VCO3 level", "VCO3 level", "%", 0, 0, 0, 0.f },
{ "Noise color", "Noise color", "", 0, 0, 1, 0.f },
{ "Noise level", "Noise level", "%", 0, 0, 0, 0.f },
{ "VCF modulation", "VCF mod", "%", 0, 0, 0, 0.f },
{ "VCF keyboard control", "VCF kbd ctrl", "", 0, 0, 3, 0.f },
{ "VCF cutoff", "VCF cutoff", "Hz", 0, 0, 0, 1.f },
{ "VCF Q", "VCF Q", "", 0, 0, 0, 0.f },
{ "VCF contour", "VCF contour", "%", 0, 0, 0, 0.f },
{ "VCF attack", "VCF attack", "s", 0, 0, 0, 0.f },
{ "VCF decay", "VCF decay", "s", 0, 0, 0, 0.f },
{ "VCF sustain", "VCF sustain", "%", 0, 0, 0, 1.f },
{ "VCF release", "VCF release", "s", 0, 0, 0, 0.f },
{ "VCA attack", "VCA attack", "s", 0, 0, 0, 0.f },
{ "VCA decay", "VCA decay", "s", 0, 0, 0, 0.f },
{ "VCA sustain", "VCA sustain", "%", 0, 0, 0, 1.f },
{ "VCA release", "VCA release", "s", 0, 0, 0, 0.f },
{ "A440", "A440", "", 0, 0, 1, 0.f },
{ "Level", "Level", "", 1, 0, 0, 0.f }
};
// Internal API
#include "bw_example_synthpp_mono.h"
#define P_TYPE bw_example_synthpp_mono
#define P_INIT bw_example_synthpp_mono_init
#define P_SET_SAMPLE_RATE bw_example_synthpp_mono_set_sample_rate
#define P_RESET bw_example_synthpp_mono_reset
#define P_PROCESS bw_example_synthpp_mono_process
#define P_SET_PARAMETER bw_example_synthpp_mono_set_parameter
#define P_GET_PARAMETER bw_example_synthpp_mono_get_parameter
#define P_NOTE_ON bw_example_synthpp_mono_note_on
#define P_NOTE_OFF bw_example_synthpp_mono_note_off
#define P_PITCH_BEND bw_example_synthpp_mono_pitch_bend
#define P_MOD_WHEEL bw_example_synthpp_mono_mod_wheel
#endif

View File

@ -0,0 +1,6 @@
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
NAME := bw_example_synthpp_mono
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_synthpp_mono.cpp
include ${ROOT_DIR}/../../common/vst3/vst3.mk

View File

@ -0,0 +1,36 @@
/*
* Brickworks
*
* Copyright (C) 2023 Orastron Srl unipersonale
*
* Brickworks 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, version 3 of the License.
*
* Brickworks 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 Brickworks. If not, see <http://www.gnu.org/licenses/>.
*
* File authors: Stefano D'Angelo, Paolo Marrone
*/
#ifndef _VST3_CONFIG_H
#define _VST3_CONFIG_H
#define PLUGIN_SUBCATEGORY "Instrument|Synth"
#define PLUGIN_GUID_1 0xcee19b6e
#define PLUGIN_GUID_2 0xa6f7497e
#define PLUGIN_GUID_3 0x96c7f307
#define PLUGIN_GUID_4 0x60ef624f
#define CTRL_GUID_1 0x6aaf5238
#define CTRL_GUID_2 0xa4024120
#define CTRL_GUID_3 0xb7bc3d3b
#define CTRL_GUID_4 0xb64f3a94
#endif

View File

@ -20,11 +20,10 @@
#include "bw_example_synthpp_simple.h"
#include "bw_buf.h"
#include <bw_buf.h>
void bw_example_synthpp_simple_init(bw_example_synthpp_simple *instance) {
instance->oscPulse.setAntialiasing(true);
instance->rand_state = 0xbaddecaf600dfeed;
}
void bw_example_synthpp_simple_set_sample_rate(bw_example_synthpp_simple *instance, float sample_rate) {
@ -70,8 +69,6 @@ void bw_example_synthpp_simple_process(bw_example_synthpp_simple *instance, cons
}
void bw_example_synthpp_simple_set_parameter(bw_example_synthpp_simple *instance, int index, float value) {
if (instance->params[index] == value)
return;
instance->params[index] = value;
switch (index) {
case p_volume:

View File

@ -63,7 +63,6 @@ struct _bw_example_synthpp_simple {
float params[p_n];
// States
uint64_t rand_state;
int note;
// Buffers

View File

@ -67,7 +67,7 @@ namespace Brickworks {
}
template<BW_SIZE_T N_CHANNELS>
float NoiseGen<N_CHANNELS>::getScalingK(float value) {
float NoiseGen<N_CHANNELS>::getScalingK() {
return bw_noise_gen_get_scaling_k(&coeffs);
}
}

View File

@ -75,7 +75,7 @@ namespace Brickworks {
}
template<BW_SIZE_T N_CHANNELS>
void OscTri<N_CHANNELS>::setSlope(bool value) {
void OscTri<N_CHANNELS>::setSlope(float value) {
bw_osc_tri_set_slope(&coeffs, value);
}
}

View File

@ -58,7 +58,6 @@ namespace Brickworks {
template<BW_SIZE_T N_CHANNELS>
void PinkFilt<N_CHANNELS>::reset() {
bw_pink_filt_reset_coeffs(&coeffs);
for (BW_SIZE_T i = 0; i < N_CHANNELS; i++)
bw_pink_filt_reset_state(&coeffs, states + i);
}
@ -69,7 +68,7 @@ namespace Brickworks {
std::array<float *, N_CHANNELS> y,
int nSamples) {
for (BW_SIZE_T i = 0; i < N_CHANNELS; i++)
bw_pink_filt_process(&coeffs, x.data()[i], y.data()[i], nSamples);
bw_pink_filt_process(&coeffs, states + i, x.data()[i], y.data()[i], nSamples);
}
template<BW_SIZE_T N_CHANNELS>
@ -78,7 +77,7 @@ namespace Brickworks {
}
template<BW_SIZE_T N_CHANNELS>
float PinkFilt<N_CHANNELS>::getScalingK(float value) {
float PinkFilt<N_CHANNELS>::getScalingK() {
return bw_pink_filt_get_scaling_k(&coeffs);
}
}