synthpp_simple + fixes in bwpp_{osc_filt,osc_pulse,phase_gen}
This commit is contained in:
parent
d01e558622
commit
1b8e4c56e3
9
examples/synthpp_simple/daisy-seed/Makefile
Normal file
9
examples/synthpp_simple/daisy-seed/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
|
||||
TARGET = bw_example_synthpp_simple
|
||||
|
||||
CPP_SOURCES_EXTRA = ${ROOT_DIR}/../src/bw_example_synthpp_simple.cpp
|
||||
|
||||
SYNTH := yes
|
||||
|
||||
include ${ROOT_DIR}/../../common/daisy-seed/daisy-seed.mk
|
44
examples/synthpp_simple/daisy-seed/config_daisy_seed.h
Normal file
44
examples/synthpp_simple/daisy-seed/config_daisy_seed.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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 10
|
||||
|
||||
static struct config_cc config_ccs[NUM_CCS] = {
|
||||
{ 0, 7 }, // Volume
|
||||
{ 1, 3 }, // Master tune
|
||||
{ 2, 5 }, // Portamento
|
||||
{ 3, 28 }, // Pulse width
|
||||
{ 4, 74 }, // Cutoff
|
||||
{ 5, 71 }, // Q
|
||||
{ 6, 73 }, // Attack
|
||||
{ 7, 109 }, // Decay
|
||||
{ 8, 110 }, // Sustain
|
||||
{ 9, 72 } // Release
|
||||
};
|
||||
|
||||
#endif
|
124
examples/synthpp_simple/src/bw_example_synthpp_simple.cpp
Normal file
124
examples/synthpp_simple/src/bw_example_synthpp_simple.cpp
Normal file
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* 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_simple.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) {
|
||||
instance->phaseGen.setSampleRate(sample_rate);
|
||||
instance->oscPulse.setSampleRate(sample_rate);
|
||||
instance->svf.setSampleRate(sample_rate);
|
||||
instance->envGen.setSampleRate(sample_rate);
|
||||
instance->gain.setSampleRate(sample_rate);
|
||||
instance->ppm.setSampleRate(sample_rate);
|
||||
}
|
||||
|
||||
void bw_example_synthpp_simple_reset(bw_example_synthpp_simple *instance) {
|
||||
instance->phaseGen.reset();
|
||||
instance->oscPulse.reset();
|
||||
instance->oscFilt.reset();
|
||||
instance->svf.reset();
|
||||
instance->envGen.reset();
|
||||
instance->gain.reset();
|
||||
instance->ppm.reset();
|
||||
instance->note = -1;
|
||||
}
|
||||
|
||||
void bw_example_synthpp_simple_process(bw_example_synthpp_simple *instance, const float** x, float** y, int n_samples) {
|
||||
(void)x;
|
||||
|
||||
if (instance->note >= 0)
|
||||
instance->phaseGen.setFrequency(
|
||||
440.f * bw_pow2f_3(8.333333333333333e-2f * ((instance->note - 69) + 2.f * instance->params[p_master_tune] - 1.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->phaseGen.process({nullptr}, {out}, {instance->buf}, n);
|
||||
instance->oscPulse.process({out}, {instance->buf}, {out}, n);
|
||||
instance->oscFilt.process({out}, {out}, n);
|
||||
instance->svf.process({out}, {out}, {nullptr}, {nullptr}, n);
|
||||
instance->envGen.process({instance->note >= 0}, {instance->buf}, n);
|
||||
bw_buf_mul(out, out, instance->buf, n);
|
||||
instance->gain.process({out}, {out}, n);
|
||||
instance->ppm.process({out}, {nullptr}, n);
|
||||
}
|
||||
}
|
||||
|
||||
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:
|
||||
instance->gain.setGainLin(value * value * value);
|
||||
break;
|
||||
case p_portamento:
|
||||
instance->phaseGen.setPortamentoTau(value);
|
||||
break;
|
||||
case p_pulse_width:
|
||||
instance->oscPulse.setPulseWidth(value);
|
||||
break;
|
||||
case p_cutoff:
|
||||
instance->svf.setCutoff(20.f + (20e3f - 20.f) * value * value * value);
|
||||
break;
|
||||
case p_Q:
|
||||
instance->svf.setQ(0.5f + 9.5f * value);
|
||||
break;
|
||||
case p_attack:
|
||||
instance->envGen.setAttack(value);
|
||||
break;
|
||||
case p_decay:
|
||||
instance->envGen.setDecay(value);
|
||||
break;
|
||||
case p_sustain:
|
||||
instance->envGen.setSustain(value);
|
||||
break;
|
||||
case p_release:
|
||||
instance->envGen.setRelease(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float bw_example_synthpp_simple_get_parameter(bw_example_synthpp_simple *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);
|
||||
}
|
||||
|
||||
void bw_example_synthpp_simple_note_on(bw_example_synthpp_simple *instance, char note, char velocity) {
|
||||
if (velocity == 0)
|
||||
bw_example_synthpp_simple_note_off(instance, note);
|
||||
else
|
||||
instance->note = note;
|
||||
}
|
||||
|
||||
void bw_example_synthpp_simple_note_off(bw_example_synthpp_simple *instance, char note) {
|
||||
if (note == instance->note)
|
||||
instance->note = -1;
|
||||
}
|
85
examples/synthpp_simple/src/bw_example_synthpp_simple.h
Normal file
85
examples/synthpp_simple/src/bw_example_synthpp_simple.h
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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_SIMPLE_H
|
||||
#define _BW_EXAMPLE_SYNTHPP_SIMPLE_H
|
||||
|
||||
#include <bwpp_phase_gen.h>
|
||||
#include <bwpp_osc_pulse.h>
|
||||
#include <bwpp_osc_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_pulse_width,
|
||||
p_cutoff,
|
||||
p_Q,
|
||||
p_attack,
|
||||
p_decay,
|
||||
p_sustain,
|
||||
p_release,
|
||||
p_n
|
||||
};
|
||||
|
||||
#define BUFFER_SIZE 32
|
||||
|
||||
struct _bw_example_synthpp_simple {
|
||||
// Sub-components
|
||||
PhaseGen<1> phaseGen;
|
||||
OscPulse<1> oscPulse;
|
||||
OscFilt<1> oscFilt;
|
||||
SVF<1> svf;
|
||||
EnvGen<1> envGen;
|
||||
Gain<1> gain;
|
||||
PPM<1> ppm;
|
||||
|
||||
// Parameters
|
||||
float params[p_n];
|
||||
|
||||
// States
|
||||
uint64_t rand_state;
|
||||
int note;
|
||||
|
||||
// Buffers
|
||||
float buf[BUFFER_SIZE];
|
||||
};
|
||||
typedef struct _bw_example_synthpp_simple bw_example_synthpp_simple;
|
||||
|
||||
void bw_example_synthpp_simple_init(bw_example_synthpp_simple *instance);
|
||||
void bw_example_synthpp_simple_set_sample_rate(bw_example_synthpp_simple *instance, float sample_rate);
|
||||
void bw_example_synthpp_simple_reset(bw_example_synthpp_simple *instance);
|
||||
void bw_example_synthpp_simple_process(bw_example_synthpp_simple *instance, const float** x, float** y, int n_samples);
|
||||
void bw_example_synthpp_simple_set_parameter(bw_example_synthpp_simple *instance, int index, float value);
|
||||
float bw_example_synthpp_simple_get_parameter(bw_example_synthpp_simple *instance, int index);
|
||||
void bw_example_synthpp_simple_note_on(bw_example_synthpp_simple *instance, char note, char velocity);
|
||||
void bw_example_synthpp_simple_note_off(bw_example_synthpp_simple *instance, char note);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
95
examples/synthpp_simple/src/config.h
Normal file
95
examples/synthpp_simple/src/config.h
Normal file
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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_simple"
|
||||
#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 11
|
||||
|
||||
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 },
|
||||
{ "Pulse width", "PW", "%", 0, 0, 0, 0.5f },
|
||||
{ "Cutoff", "Cutoff", "Hz", 0, 0, 0, 1.f },
|
||||
{ "Q", "Q", "", 0, 0, 0, 0.f },
|
||||
{ "Attack", "Attack", "s", 0, 0, 0, 0.f },
|
||||
{ "Decay", "Decay", "s", 0, 0, 0, 0.f },
|
||||
{ "Sustain", "Sustain", "%", 0, 0, 0, 1.f },
|
||||
{ "Release", "Release", "0", 0, 0, 0, 0.f },
|
||||
{ "Level", "Level", "", 1, 0, 0, 0.f }
|
||||
};
|
||||
|
||||
// Internal API
|
||||
|
||||
#include "bw_example_synthpp_simple.h"
|
||||
|
||||
#define P_TYPE bw_example_synthpp_simple
|
||||
#define P_INIT bw_example_synthpp_simple_init
|
||||
#define P_SET_SAMPLE_RATE bw_example_synthpp_simple_set_sample_rate
|
||||
#define P_RESET bw_example_synthpp_simple_reset
|
||||
#define P_PROCESS bw_example_synthpp_simple_process
|
||||
#define P_SET_PARAMETER bw_example_synthpp_simple_set_parameter
|
||||
#define P_GET_PARAMETER bw_example_synthpp_simple_get_parameter
|
||||
#define P_NOTE_ON bw_example_synthpp_simple_note_on
|
||||
#define P_NOTE_OFF bw_example_synthpp_simple_note_off
|
||||
|
||||
#endif
|
6
examples/synthpp_simple/vst3/Makefile
Normal file
6
examples/synthpp_simple/vst3/Makefile
Normal file
@ -0,0 +1,6 @@
|
||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
|
||||
NAME := bw_example_synthpp_simple
|
||||
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_synthpp_simple.cpp
|
||||
|
||||
include ${ROOT_DIR}/../../common/vst3/vst3.mk
|
36
examples/synthpp_simple/vst3/config_vst3.h
Normal file
36
examples/synthpp_simple/vst3/config_vst3.h
Normal 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 0x5008d6f4
|
||||
#define PLUGIN_GUID_2 0x7b104d36
|
||||
#define PLUGIN_GUID_3 0x8163d0a0
|
||||
#define PLUGIN_GUID_4 0x4a599a52
|
||||
|
||||
#define CTRL_GUID_1 0xe6967755
|
||||
#define CTRL_GUID_2 0xdaf84890
|
||||
#define CTRL_GUID_3 0x8858da74
|
||||
#define CTRL_GUID_4 0x887ca242
|
||||
|
||||
#endif
|
@ -50,7 +50,7 @@ namespace Brickworks {
|
||||
std::array<float *, N_CHANNELS> y,
|
||||
int nSamples) {
|
||||
for (BW_SIZE_T i = 0; i < N_CHANNELS; i++)
|
||||
bw_osc_filt_process(states + i, x.data(), y.data(), nSamples);
|
||||
bw_osc_filt_process(states + i, x.data()[i], y.data()[i], nSamples);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ namespace Brickworks {
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
void OscPulse<N_CHANNELS>::setPulseWidth(bool value) {
|
||||
void OscPulse<N_CHANNELS>::setPulseWidth(float value) {
|
||||
bw_osc_pulse_set_pulse_width(&coeffs, value);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace Brickworks {
|
||||
PhaseGen();
|
||||
|
||||
void setSampleRate(float sampleRate);
|
||||
void reset();
|
||||
void reset(float phase_0 = 0.f);
|
||||
void process(
|
||||
std::array<const float *, N_CHANNELS> x_mod,
|
||||
std::array<float *, N_CHANNELS> y,
|
||||
@ -60,10 +60,10 @@ namespace Brickworks {
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
void PhaseGen<N_CHANNELS>::reset() {
|
||||
void PhaseGen<N_CHANNELS>::reset(float phase_0) {
|
||||
bw_phase_gen_reset_coeffs(&coeffs);
|
||||
for (BW_SIZE_T i = 0; i < N_CHANNELS; i++)
|
||||
bw_phase_gen_reset_state(&coeffs, states + i);
|
||||
bw_phase_gen_reset_state(&coeffs, states + i, phase_0);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
|
Loading…
Reference in New Issue
Block a user