synth_mono + portamento in ms also in synth(pp)_simple

This commit is contained in:
Stefano D'Angelo 2024-02-20 11:33:50 +01:00
parent a80aa87b27
commit a5e56e2dd1
16 changed files with 1158 additions and 875 deletions

View File

@ -0,0 +1,5 @@
{
"android": {
"javaPackageName": "com.orastron.bw_example_synth_mono"
}
}

View File

@ -1,356 +0,0 @@
/*
* Brickworks
*
* Copyright (C) 2022, 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_synth_mono.h"
#include <bw_buf.h>
void bw_example_synth_mono_init(bw_example_synth_mono *instance) {
bw_osc_saw_init(&instance->vco_saw_coeffs);
bw_phase_gen_init(&instance->vco1_phase_gen_coeffs);
bw_osc_pulse_init(&instance->vco1_pulse_coeffs);
bw_osc_tri_init(&instance->vco1_tri_coeffs);
bw_gain_init(&instance->vco1_gain_coeffs);
bw_phase_gen_init(&instance->vco2_phase_gen_coeffs);
bw_osc_pulse_init(&instance->vco2_pulse_coeffs);
bw_osc_tri_init(&instance->vco2_tri_coeffs);
bw_gain_init(&instance->vco2_gain_coeffs);
bw_phase_gen_init(&instance->vco3_phase_gen_coeffs);
bw_osc_pulse_init(&instance->vco3_pulse_coeffs);
bw_osc_tri_init(&instance->vco3_tri_coeffs);
bw_gain_init(&instance->vco3_gain_coeffs);
bw_noise_gen_init(&instance->noise_gen_coeffs, &instance->rand_state);
bw_pink_filt_init(&instance->pink_filt_coeffs);
bw_gain_init(&instance->noise_gain_coeffs);
bw_env_gen_init(&instance->vcf_env_gen_coeffs);
bw_svf_init(&instance->vcf_coeffs);
bw_env_gen_init(&instance->vca_env_gen_coeffs);
bw_phase_gen_init(&instance->a440_phase_gen_coeffs);
bw_gain_init(&instance->gain_coeffs);
bw_ppm_init(&instance->ppm_coeffs);
bw_osc_saw_set_antialiasing(&instance->vco_saw_coeffs, 1);
bw_osc_pulse_set_antialiasing(&instance->vco1_pulse_coeffs, 1);
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_osc_pulse_set_antialiasing(&instance->vco3_pulse_coeffs, 1);
bw_osc_tri_set_antialiasing(&instance->vco3_tri_coeffs, 1);
bw_phase_gen_set_frequency(&instance->a440_phase_gen_coeffs, 440.f);
instance->rand_state = 0xbaddecaf600dfeed;
}
void bw_example_synth_mono_set_sample_rate(bw_example_synth_mono *instance, float sample_rate) {
bw_osc_saw_set_sample_rate(&instance->vco_saw_coeffs, sample_rate);
bw_phase_gen_set_sample_rate(&instance->vco1_phase_gen_coeffs, sample_rate);
bw_osc_pulse_set_sample_rate(&instance->vco1_pulse_coeffs, sample_rate);
bw_osc_tri_set_sample_rate(&instance->vco1_tri_coeffs, sample_rate);
bw_gain_set_sample_rate(&instance->vco1_gain_coeffs, sample_rate);
bw_phase_gen_set_sample_rate(&instance->vco2_phase_gen_coeffs, sample_rate);
bw_osc_pulse_set_sample_rate(&instance->vco2_pulse_coeffs, sample_rate);
bw_osc_tri_set_sample_rate(&instance->vco2_tri_coeffs, sample_rate);
bw_gain_set_sample_rate(&instance->vco2_gain_coeffs, sample_rate);
bw_phase_gen_set_sample_rate(&instance->vco3_phase_gen_coeffs, sample_rate);
bw_osc_pulse_set_sample_rate(&instance->vco3_pulse_coeffs, sample_rate);
bw_osc_tri_set_sample_rate(&instance->vco3_tri_coeffs, sample_rate);
bw_gain_set_sample_rate(&instance->vco3_gain_coeffs, sample_rate);
bw_noise_gen_set_sample_rate(&instance->noise_gen_coeffs, sample_rate);
bw_pink_filt_set_sample_rate(&instance->pink_filt_coeffs, sample_rate);
bw_gain_set_sample_rate(&instance->noise_gain_coeffs, sample_rate);
bw_env_gen_set_sample_rate(&instance->vcf_env_gen_coeffs, sample_rate);
bw_svf_set_sample_rate(&instance->vcf_coeffs, sample_rate);
bw_env_gen_set_sample_rate(&instance->vca_env_gen_coeffs, sample_rate);
bw_phase_gen_set_sample_rate(&instance->a440_phase_gen_coeffs, sample_rate);
bw_gain_set_sample_rate(&instance->gain_coeffs, sample_rate);
bw_ppm_set_sample_rate(&instance->ppm_coeffs, sample_rate);
bw_osc_saw_reset_coeffs(&instance->vco_saw_coeffs);
bw_noise_gen_reset_coeffs(&instance->noise_gen_coeffs);
bw_pink_filt_reset_coeffs(&instance->pink_filt_coeffs);
}
void bw_example_synth_mono_reset(bw_example_synth_mono *instance) {
const float v = instance->params[p_vcf_cutoff];
const float cutoff = 20.f + (20e3f - 20.f) * v * v * v;
bw_svf_set_cutoff(&instance->vcf_coeffs, bw_clipf(cutoff, 20.f, 20e3f));
float p, pi;
bw_phase_gen_reset_coeffs(&instance->vco1_phase_gen_coeffs);
bw_phase_gen_reset_state(&instance->vco1_phase_gen_coeffs, &instance->vco1_phase_gen_state, 0.f, &p, &pi);
bw_osc_pulse_reset_coeffs(&instance->vco1_pulse_coeffs);
bw_osc_tri_reset_coeffs(&instance->vco1_tri_coeffs);
bw_gain_reset_coeffs(&instance->vco1_gain_coeffs);
bw_phase_gen_reset_coeffs(&instance->vco2_phase_gen_coeffs);
bw_phase_gen_reset_state(&instance->vco2_phase_gen_coeffs, &instance->vco2_phase_gen_state, 0.f, &p, &pi);
bw_osc_pulse_reset_coeffs(&instance->vco2_pulse_coeffs);
bw_osc_tri_reset_coeffs(&instance->vco2_tri_coeffs);
bw_gain_reset_coeffs(&instance->vco2_gain_coeffs);
bw_phase_gen_reset_coeffs(&instance->vco3_phase_gen_coeffs);
bw_phase_gen_reset_state(&instance->vco3_phase_gen_coeffs, &instance->vco3_phase_gen_state, 0.f, &p, &pi);
bw_osc_pulse_reset_coeffs(&instance->vco3_pulse_coeffs);
bw_osc_tri_reset_coeffs(&instance->vco3_tri_coeffs);
bw_gain_reset_coeffs(&instance->vco3_gain_coeffs);
bw_osc_filt_reset_state(&instance->osc_filt_state, 0.f);
bw_pink_filt_reset_state(&instance->pink_filt_coeffs, &instance->pink_filt_state, 0.f);
bw_gain_reset_coeffs(&instance->noise_gain_coeffs);
bw_env_gen_reset_coeffs(&instance->vcf_env_gen_coeffs);
bw_env_gen_reset_state(&instance->vcf_env_gen_coeffs, &instance->vcf_env_gen_state, 0);
bw_svf_reset_coeffs(&instance->vcf_coeffs);
float lp, bp, hp;
bw_svf_reset_state(&instance->vcf_coeffs, &instance->vcf_state, 0.f, &lp, &bp, &hp);
bw_env_gen_reset_coeffs(&instance->vca_env_gen_coeffs);
bw_env_gen_reset_state(&instance->vca_env_gen_coeffs, &instance->vca_env_gen_state, 0);
bw_phase_gen_reset_coeffs(&instance->a440_phase_gen_coeffs);
bw_phase_gen_reset_state(&instance->a440_phase_gen_coeffs, &instance->a440_phase_gen_state, 0.f, &p, &pi);
bw_gain_reset_coeffs(&instance->gain_coeffs);
bw_ppm_reset_coeffs(&instance->ppm_coeffs);
bw_ppm_reset_state(&instance->ppm_coeffs, &instance->ppm_state, 0.f);
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_synth_mono_process(bw_example_synth_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;
bw_phase_gen_set_frequency(&instance->vco1_phase_gen_coeffs, 440.f *
bw_pow2f(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)));
bw_phase_gen_set_frequency(&instance->vco2_phase_gen_coeffs, 440.f *
bw_pow2f(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)));
bw_phase_gen_set_frequency(&instance->vco3_phase_gen_coeffs, 440.f *
bw_pow2f(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);
bw_phase_gen_process(&instance->vco3_phase_gen_coeffs, &instance->vco3_phase_gen_state, NULL, out, instance->buf[0], n);
if (instance->params[p_vco3_waveform] >= (1.f / 4.f + 1.f / 2.f)) {
bw_osc_tri_process(&instance->vco3_tri_coeffs, out, instance->buf[0], out, n);
bw_osc_pulse_reset_coeffs(&instance->vco3_pulse_coeffs);
} else if (instance->params[p_vco3_waveform] >= (1.f / 4.f)) {
bw_osc_pulse_process(&instance->vco3_pulse_coeffs, out, instance->buf[0], out, n);
bw_osc_tri_reset_coeffs(&instance->vco3_tri_coeffs);
} else {
bw_osc_saw_process(&instance->vco_saw_coeffs, out, instance->buf[0], out, n);
bw_osc_pulse_reset_coeffs(&instance->vco3_pulse_coeffs);
bw_osc_tri_reset_coeffs(&instance->vco3_tri_coeffs);
}
bw_noise_gen_process(&instance->noise_gen_coeffs, instance->buf[0], n);
if (instance->params[p_noise_color] >= 0.5f)
bw_pink_filt_process(&instance->pink_filt_coeffs, &instance->pink_filt_state, instance->buf[0], instance->buf[0], n);
else
bw_pink_filt_reset_state(&instance->pink_filt_coeffs, &instance->pink_filt_state, 0.f); // FIXME: calling this here is sloppy coding
bw_buf_scale(instance->buf[0], 5.f, instance->buf[0], 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[1], instance->params[p_vco1_mod], instance->buf[2], n);
bw_phase_gen_process(&instance->vco1_phase_gen_coeffs, &instance->vco1_phase_gen_state, instance->buf[2], instance->buf[2], instance->buf[3], n);
if (instance->params[p_vco1_waveform] >= (1.f / 4.f + 1.f / 2.f)) {
bw_osc_tri_process(&instance->vco1_tri_coeffs, instance->buf[2], instance->buf[3], instance->buf[2], n);
bw_osc_pulse_reset_coeffs(&instance->vco1_pulse_coeffs);
} else if (instance->params[p_vco1_waveform] >= (1.f / 4.f)) {
bw_osc_pulse_process(&instance->vco1_pulse_coeffs, instance->buf[2], instance->buf[3], instance->buf[2], n);
bw_osc_tri_reset_coeffs(&instance->vco1_tri_coeffs);
} else {
bw_osc_saw_process(&instance->vco_saw_coeffs, instance->buf[2], instance->buf[3], instance->buf[2], n);
bw_osc_pulse_reset_coeffs(&instance->vco1_pulse_coeffs);
bw_osc_tri_reset_coeffs(&instance->vco1_tri_coeffs);
}
bw_buf_scale(instance->buf[1], instance->params[p_vco2_mod], instance->buf[1], n);
bw_phase_gen_process(&instance->vco2_phase_gen_coeffs, &instance->vco2_phase_gen_state, instance->buf[1], instance->buf[1], instance->buf[3], n);
if (instance->params[p_vco2_waveform] >= (1.f / 4.f + 1.f / 2.f)) {
bw_osc_tri_process(&instance->vco2_tri_coeffs, instance->buf[1], instance->buf[3], instance->buf[1], n);
bw_osc_pulse_reset_coeffs(&instance->vco2_pulse_coeffs);
} else if (instance->params[p_vco2_waveform] >= (1.f / 4.f)) {
bw_osc_pulse_process(&instance->vco2_pulse_coeffs, instance->buf[1], instance->buf[3], instance->buf[1], n);
bw_osc_tri_reset_coeffs(&instance->vco2_tri_coeffs);
} else {
bw_osc_saw_process(&instance->vco_saw_coeffs, instance->buf[1], instance->buf[3], instance->buf[1], n);
bw_osc_pulse_reset_coeffs(&instance->vco2_pulse_coeffs);
bw_osc_tri_reset_coeffs(&instance->vco2_tri_coeffs);
}
bw_gain_process(&instance->vco1_gain_coeffs, instance->buf[2], instance->buf[2], n);
bw_gain_process(&instance->vco2_gain_coeffs, instance->buf[1], instance->buf[1], n);
bw_gain_process(&instance->vco3_gain_coeffs, out, out, n);
bw_gain_process(&instance->noise_gain_coeffs, instance->buf[0], instance->buf[0], n);
bw_buf_mix(out, instance->buf[1], out, n);
bw_buf_mix(out, instance->buf[2], out, n);
bw_osc_filt_process(&instance->osc_filt_state, out, out, n);
const float k = instance->params[p_noise_color] >= 0.5f
? 6.f * bw_noise_gen_get_scaling_k(&instance->noise_gen_coeffs) * bw_pink_filt_get_scaling_k(&instance->pink_filt_coeffs)
: 0.1f * bw_noise_gen_get_scaling_k(&instance->noise_gen_coeffs);
bw_buf_scale(instance->buf[0], k, instance->buf[0], n);
bw_buf_mix(out, instance->buf[0], out, n);
bw_env_gen_process(&instance->vcf_env_gen_coeffs, &instance->vcf_env_gen_state, instance->gate, NULL, n);
float v = instance->params[p_vcf_cutoff] + instance->params[p_vcf_contour] * bw_env_gen_get_y_z1(&instance->vcf_env_gen_state) + 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(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((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((0.629960524947437f * 8.333333333333333e-2f) * (instance->note - 60));
// otherwise no kbd control
bw_svf_set_cutoff(&instance->vcf_coeffs, bw_clipf(cutoff, 20.f, 20e3f));
bw_svf_process(&instance->vcf_coeffs, &instance->vcf_state, out, out, NULL, NULL, n);
bw_env_gen_process(&instance->vca_env_gen_coeffs, &instance->vca_env_gen_state, instance->gate, instance->buf[0], n);
bw_buf_mul(out, instance->buf[0], out, n);
bw_phase_gen_process(&instance->a440_phase_gen_coeffs, &instance->a440_phase_gen_state, NULL, instance->buf[0], NULL, n);
bw_osc_sin_process(instance->buf[0], instance->buf[0], n);
if (instance->params[p_a440] >= 0.5f)
bw_buf_mix(out, instance->buf[0], out, n);
bw_gain_process(&instance->gain_coeffs, out, out, n);
bw_ppm_process(&instance->ppm_coeffs, &instance->ppm_state, out, NULL, n);
}
}
void bw_example_synth_mono_set_parameter(bw_example_synth_mono *instance, int index, float value) {
instance->params[index] = value;
switch (index) {
case p_volume:
bw_gain_set_gain_lin(&instance->gain_coeffs, value * value * value);
break;
case p_portamento:
bw_phase_gen_set_portamento_tau(&instance->vco1_phase_gen_coeffs, value);
bw_phase_gen_set_portamento_tau(&instance->vco2_phase_gen_coeffs, value);
bw_phase_gen_set_portamento_tau(&instance->vco3_phase_gen_coeffs, value);
break;
case p_vco1_pw_slope:
bw_osc_pulse_set_pulse_width(&instance->vco1_pulse_coeffs, value);
bw_osc_tri_set_slope(&instance->vco1_tri_coeffs, bw_clipf(value, 0.001f, 0.999f));
break;
case p_vco1_level:
bw_gain_set_gain_lin(&instance->vco1_gain_coeffs, value * value * value);
break;
case p_vco2_pw_slope:
bw_osc_pulse_set_pulse_width(&instance->vco2_pulse_coeffs, value);
bw_osc_tri_set_slope(&instance->vco2_tri_coeffs, bw_clipf(value, 0.001f, 0.999f));
break;
case p_vco2_level:
bw_gain_set_gain_lin(&instance->vco2_gain_coeffs, value * value * value);
break;
case p_vco3_pw_slope:
bw_osc_pulse_set_pulse_width(&instance->vco3_pulse_coeffs, value);
bw_osc_tri_set_slope(&instance->vco3_tri_coeffs, bw_clipf(value, 0.001f, 0.999f));
break;
case p_vco3_level:
bw_gain_set_gain_lin(&instance->vco3_gain_coeffs, value * value * value);
break;
case p_noise_level:
bw_gain_set_gain_lin(&instance->noise_gain_coeffs, value * value * value);
break;
case p_vcf_Q:
bw_svf_set_Q(&instance->vcf_coeffs, 0.5f + 9.5f * value);
break;
case p_vcf_attack:
bw_env_gen_set_attack(&instance->vcf_env_gen_coeffs, value);
break;
case p_vcf_decay:
bw_env_gen_set_decay(&instance->vcf_env_gen_coeffs, value);
break;
case p_vcf_sustain:
bw_env_gen_set_sustain(&instance->vcf_env_gen_coeffs, value);
break;
case p_vcf_release:
bw_env_gen_set_release(&instance->vcf_env_gen_coeffs, value);
break;
case p_vca_attack:
bw_env_gen_set_attack(&instance->vca_env_gen_coeffs, bw_maxf(0.002f, value));
break;
case p_vca_decay:
bw_env_gen_set_decay(&instance->vca_env_gen_coeffs, value);
break;
case p_vca_sustain:
bw_env_gen_set_sustain(&instance->vca_env_gen_coeffs, value);
break;
case p_vca_release:
bw_env_gen_set_release(&instance->vca_env_gen_coeffs, bw_maxf(0.002f, value));
break;
}
}
float bw_example_synth_mono_get_parameter(bw_example_synth_mono *instance, int index) {
if (index < p_n)
return instance->params[index];
const float v = bw_ppm_get_y_z1(&instance->ppm_state);
return v < -200.f ? 0.f : bw_clipf(0.01666666666666666f * v + 1.f, 0.f, 1.f);
}
static void update_note_gate(bw_example_synth_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_synth_mono_note_on(bw_example_synth_mono *instance, char note, char velocity) {
if (velocity == 0)
bw_example_synth_mono_note_off(instance, note);
else {
instance->notes_pressed[(int)note] = 1;
update_note_gate(instance);
}
}
void bw_example_synth_mono_note_off(bw_example_synth_mono *instance, char note) {
if (instance->notes_pressed[(int)note]) {
instance->notes_pressed[(int)note] = 0;
update_note_gate(instance);
}
}
void bw_example_synth_mono_pitch_bend(bw_example_synth_mono *instance, int value) {
instance->pitch_bend = (value - 0x2000) / (float)0x4000;
}
void bw_example_synth_mono_mod_wheel(bw_example_synth_mono *instance, char value) {
instance->mod_wheel = (float)value / 0x80;
}

View File

@ -1,154 +0,0 @@
/*
* Brickworks
*
* Copyright (C) 2022, 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_SYNTH_MONO_H
#define _BW_EXAMPLE_SYNTH_MONO_H
#include "platform.h"
#include <bw_math.h>
#include <bw_phase_gen.h>
#include <bw_osc_saw.h>
#include <bw_osc_pulse.h>
#include <bw_osc_tri.h>
#include <bw_osc_sin.h>
#include <bw_osc_filt.h>
#include <bw_noise_gen.h>
#include <bw_pink_filt.h>
#include <bw_svf.h>
#include <bw_env_gen.h>
#include <bw_gain.h>
#include <bw_ppm.h>
#ifdef __cplusplus
extern "C" {
#endif
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_synth_mono {
// Sub-components
bw_osc_saw_coeffs vco_saw_coeffs;
bw_phase_gen_coeffs vco1_phase_gen_coeffs;
bw_phase_gen_state vco1_phase_gen_state;
bw_osc_pulse_coeffs vco1_pulse_coeffs;
bw_osc_tri_coeffs vco1_tri_coeffs;
bw_gain_coeffs vco1_gain_coeffs;
bw_phase_gen_coeffs vco2_phase_gen_coeffs;
bw_phase_gen_state vco2_phase_gen_state;
bw_osc_pulse_coeffs vco2_pulse_coeffs;
bw_osc_tri_coeffs vco2_tri_coeffs;
bw_gain_coeffs vco2_gain_coeffs;
bw_phase_gen_coeffs vco3_phase_gen_coeffs;
bw_phase_gen_state vco3_phase_gen_state;
bw_osc_pulse_coeffs vco3_pulse_coeffs;
bw_osc_tri_coeffs vco3_tri_coeffs;
bw_gain_coeffs vco3_gain_coeffs;
bw_osc_filt_state osc_filt_state;
bw_noise_gen_coeffs noise_gen_coeffs;
bw_pink_filt_coeffs pink_filt_coeffs;
bw_pink_filt_state pink_filt_state;
bw_gain_coeffs noise_gain_coeffs;
bw_env_gen_coeffs vcf_env_gen_coeffs;
bw_env_gen_state vcf_env_gen_state;
bw_svf_coeffs vcf_coeffs;
bw_svf_state vcf_state;
bw_env_gen_coeffs vca_env_gen_coeffs;
bw_env_gen_state vca_env_gen_state;
bw_phase_gen_coeffs a440_phase_gen_coeffs;
bw_phase_gen_state a440_phase_gen_state;
bw_gain_coeffs gain_coeffs;
bw_ppm_coeffs ppm_coeffs;
bw_ppm_state ppm_state;
// 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];
};
typedef struct _bw_example_synth_mono bw_example_synth_mono;
void bw_example_synth_mono_init(bw_example_synth_mono *instance);
void bw_example_synth_mono_set_sample_rate(bw_example_synth_mono *instance, float sample_rate);
void bw_example_synth_mono_reset(bw_example_synth_mono *instance);
void bw_example_synth_mono_process(bw_example_synth_mono *instance, const float** x, float** y, int n_samples);
void bw_example_synth_mono_set_parameter(bw_example_synth_mono *instance, int index, float value);
float bw_example_synth_mono_get_parameter(bw_example_synth_mono *instance, int index);
void bw_example_synth_mono_note_on(bw_example_synth_mono *instance, char note, char velocity);
void bw_example_synth_mono_note_off(bw_example_synth_mono *instance, char note);
void bw_example_synth_mono_pitch_bend(bw_example_synth_mono *instance, int value);
void bw_example_synth_mono_mod_wheel(bw_example_synth_mono *instance, char value);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,16 @@
{
"cmd": {
"busIds": [ "midi_in", "output" ],
"parameterIds": [
"volume", "master_tune", "portamento", "mod_mix",
"vco1_mod", "vco1_coarse", "vco1_fine", "vco1_wave", "vco1_pw", "vco1_level",
"vco2_mod", "vco2_coarse", "vco2_fine", "vco2_wave", "vco2_pw", "vco2_level",
"vco3_kbd_ctrl", "vco3_coarse", "vco3_fine", "vco3_wave", "vco3_pw", "vco3_level",
"noise_color", "noise_level",
"vcf_mod", "vcf_kbd_ctrl", "vcf_cutoff", "vcf_resonance", "vcf_contour",
"vcf_attack", "vcf_decay", "vcf_sustain", "vcf_release",
"vca_attack", "vca_decay", "vca_sustain", "vca_release",
"a440", "level"
]
}
}

View File

@ -1,125 +0,0 @@
/*
* Brickworks
*
* Copyright (C) 2022, 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_synth_mono"
#define PLUGIN_VERSION "1.0.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_synth_mono.h"
#define P_TYPE bw_example_synth_mono
#define P_INIT bw_example_synth_mono_init
#define P_SET_SAMPLE_RATE bw_example_synth_mono_set_sample_rate
#define P_RESET bw_example_synth_mono_reset
#define P_PROCESS bw_example_synth_mono_process
#define P_SET_PARAMETER bw_example_synth_mono_set_parameter
#define P_GET_PARAMETER bw_example_synth_mono_get_parameter
#define P_NOTE_ON bw_example_synth_mono_note_on
#define P_NOTE_OFF bw_example_synth_mono_note_off
#define P_PITCH_BEND bw_example_synth_mono_pitch_bend
#define P_MOD_WHEEL bw_example_synth_mono_mod_wheel
#endif

View File

@ -1,234 +0,0 @@
/*
* Brickworks
*
* Copyright (C) 2022 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
*/
var buses = [
{
stereo: false,
output: true
}
];
var parameters = [
{
name: "Volume",
output: false,
defaultValue: 0.5
},
{
name: "Master tune",
output: false,
defaultValue: 0.5
},
{
name: "Portamento",
output: false,
defaultValue: 0.0
},
{
name: "Modulation mix",
output: false,
defaultValue: 0.0
},
{
name: "VCO1 modulation",
output: false,
defaultValue: 0.0
},
{
name: "VCO1 coarse",
output: false,
defaultValue: 0.5,
step: 6
},
{
name: "VCO1 fine",
output: false,
defaultValue: 0.5
},
{
name: "VCO1 waveform",
output: false,
defaultValue: 0.5,
step: 2
},
{
name: "VCO1 pulse width/slope",
output: false,
defaultValue: 0.5
},
{
name: "VCO1 level",
output: false,
defaultValue: 1.0
},
{
name: "VCO2 modulation",
output: false,
defaultValue: 0.0
},
{
name: "VCO2 coarse",
output: false,
defaultValue: 0.5,
step: 6
},
{
name: "VCO2 fine",
output: false,
defaultValue: 0.5
},
{
name: "VCO2 waveform",
output: false,
defaultValue: 0.5,
step: 2
},
{
name: "VCO2 pulse width/slope",
output: false,
defaultValue: 0.5
},
{
name: "VCO2 level",
output: false,
defaultValue: 0.0
},
{
name: "VCO3 keyboard control",
output: false,
defaultValue: 1.0,
step: 1
},
{
name: "VCO3 coarse",
output: false,
defaultValue: 0.5,
step: 6
},
{
name: "VCO3 fine",
output: false,
defaultValue: 0.5
},
{
name: "VCO3 waveform",
output: false,
defaultValue: 0.5,
step: 2
},
{
name: "VCO3 pulse width/slope",
output: false,
defaultValue: 0.5
},
{
name: "VCO3 level",
output: false,
defaultValue: 0.0
},
{
name: "Noise color",
output: false,
defaultValue: 0.0,
step: 1
},
{
name: "Noise level",
output: false,
defaultValue: 0.0
},
{
name: "VCF modulation",
output: false,
defaultValue: 0.0
},
{
name: "VCF keyboard control",
output: false,
defaultValue: 0.0,
step: 3
},
{
name: "VCF cutoff",
output: false,
defaultValue: 1.0
},
{
name: "VCF Q",
output: false,
defaultValue: 0.0
},
{
name: "VCF contour",
output: false,
defaultValue: 0.0
},
{
name: "VCF attack",
output: false,
defaultValue: 0.0
},
{
name: "VCF decay",
output: false,
defaultValue: 0.0
},
{
name: "VCF sustain",
output: false,
defaultValue: 1.0
},
{
name: "VCF release",
output: false,
defaultValue: 0.0
},
{
name: "VCA attack",
output: false,
defaultValue: 0.0
},
{
name: "VCA decay",
output: false,
defaultValue: 0.0
},
{
name: "VCA sustain",
output: false,
defaultValue: 1.0
},
{
name: "VCA release",
output: false,
defaultValue: 0.0
},
{
name: "A440",
output: false,
defaultValue: 0.0,
step: 1
},
{
name: "Level",
output: true,
defaultValue: 0.0
}
];

View File

@ -0,0 +1,26 @@
{
"daisy_seed": {
"parameterPins": [
-1, -1, -1, -1,
-1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1,
-1, -1,
-1, -1, -1, -1, -1,
-1, -1, -1, -1,
-1, -1, -1, -1,
-1, 22
],
"midiCCMaps": [
7, 3, 5, 9,
14, 15, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29,
30, 31, 85, 86, 87, 89,
90, 102,
103, 104, 74, 71, 105,
106, 107, 108, 109,
73, 110, 111, 72,
112, -1
]
}
}

View File

@ -0,0 +1,5 @@
{
"ios": {
"productBundleIdentifier": "com.orastron.bw_example_synth_mono"
}
}

View File

@ -0,0 +1,22 @@
{
"lv2": {
"prefixes": {
"bw_examples": "https://www.orastron.com/brickworks/examples/"
},
"uri": "@bw_examples:synth_mono",
"types": [ "@lv2:InstrumentPlugin" ],
"version": "1.0",
"busSymbols": [ "midi_in", "output" ],
"parameterSymbols": [
"volume", "master_tune", "portamento", "mod_mix",
"vco1_mod", "vco1_coarse", "vco1_fine", "vco1_wave", "vco1_pw", "vco1_level",
"vco2_mod", "vco2_coarse", "vco2_fine", "vco2_wave", "vco2_pw", "vco2_level",
"vco3_mod", "vco3_coarse", "vco3_fine", "vco3_wave", "vco3_pw", "vco3_level",
"noise_color", "noise_level",
"vcf_mod", "vcf_kbd_ctrl", "vcf_cutoff", "vcf_resonance", "vcf_contour",
"vcf_attack", "vcf_decay", "vcf_sustain", "vcf_release",
"vca_attack", "vca_decay", "vca_sustain", "vca_release",
"a440", "level"
]
}
}

View File

@ -0,0 +1,621 @@
#include "common.h"
#include <bw_phase_gen.h>
#include <bw_osc_saw.h>
#include <bw_osc_pulse.h>
#include <bw_osc_tri.h>
#include <bw_osc_sin.h>
#include <bw_osc_filt.h>
#include <bw_noise_gen.h>
#include <bw_pink_filt.h>
#include <bw_svf.h>
#include <bw_env_gen.h>
#include <bw_gain.h>
#include <bw_ppm.h>
#include <bw_buf.h>
#define BUFFER_SIZE 128
#define SYNC_RATE 1e-3f // synchronous control rate, seconds
typedef struct plugin {
bw_osc_saw_coeffs vco_saw_coeffs;
bw_phase_gen_coeffs vco1_phase_gen_coeffs;
bw_phase_gen_state vco1_phase_gen_state;
bw_osc_pulse_coeffs vco1_pulse_coeffs;
bw_osc_tri_coeffs vco1_tri_coeffs;
bw_gain_coeffs vco1_gain_coeffs;
bw_phase_gen_coeffs vco2_phase_gen_coeffs;
bw_phase_gen_state vco2_phase_gen_state;
bw_osc_pulse_coeffs vco2_pulse_coeffs;
bw_osc_tri_coeffs vco2_tri_coeffs;
bw_gain_coeffs vco2_gain_coeffs;
bw_phase_gen_coeffs vco3_phase_gen_coeffs;
bw_phase_gen_state vco3_phase_gen_state;
bw_osc_pulse_coeffs vco3_pulse_coeffs;
bw_osc_tri_coeffs vco3_tri_coeffs;
bw_gain_coeffs vco3_gain_coeffs;
bw_osc_filt_state osc_filt_state;
bw_noise_gen_coeffs noise_gen_coeffs;
bw_pink_filt_coeffs pink_filt_coeffs;
bw_pink_filt_state pink_filt_state;
bw_gain_coeffs noise_gain_coeffs;
bw_env_gen_coeffs vcf_env_gen_coeffs;
bw_env_gen_state vcf_env_gen_state;
bw_svf_coeffs vcf_coeffs;
bw_svf_state vcf_state;
bw_env_gen_coeffs vca_env_gen_coeffs;
bw_env_gen_state vca_env_gen_state;
bw_phase_gen_coeffs a440_phase_gen_coeffs;
bw_phase_gen_state a440_phase_gen_state;
bw_gain_coeffs gain_coeffs;
bw_ppm_coeffs ppm_coeffs;
bw_ppm_state ppm_state;
size_t sync_count;
uint64_t rand_state;
float master_tune;
float modulation_mix;
float vco1_modulation;
int vco1_coarse;
float vco1_fine;
char vco1_waveform;
float vco2_modulation;
int vco2_coarse;
float vco2_fine;
char vco2_waveform;
char vco3_kbd_ctrl;
int vco3_coarse;
float vco3_fine;
char vco3_waveform;
char noise_color;
float vcf_modulation;
char vcf_kbd_ctrl;
float vcf_cutoff;
float vcf_contour;
char a440;
int note;
char gate;
float pitch_bend;
float mod_wheel;
char notes_pressed[128];
size_t sync_left;
char vco3_waveform_cur;
char noise_color_cur;
float mod_k;
char vco1_waveform_cur;
char vco2_waveform_cur;
float vcf_env_k;
float buf[4][BUFFER_SIZE];
} plugin;
static void plugin_init(plugin *instance) {
bw_osc_saw_init(&instance->vco_saw_coeffs);
bw_phase_gen_init(&instance->vco1_phase_gen_coeffs);
bw_osc_pulse_init(&instance->vco1_pulse_coeffs);
bw_osc_tri_init(&instance->vco1_tri_coeffs);
bw_gain_init(&instance->vco1_gain_coeffs);
bw_phase_gen_init(&instance->vco2_phase_gen_coeffs);
bw_osc_pulse_init(&instance->vco2_pulse_coeffs);
bw_osc_tri_init(&instance->vco2_tri_coeffs);
bw_gain_init(&instance->vco2_gain_coeffs);
bw_phase_gen_init(&instance->vco3_phase_gen_coeffs);
bw_osc_pulse_init(&instance->vco3_pulse_coeffs);
bw_osc_tri_init(&instance->vco3_tri_coeffs);
bw_gain_init(&instance->vco3_gain_coeffs);
bw_noise_gen_init(&instance->noise_gen_coeffs, &instance->rand_state);
bw_pink_filt_init(&instance->pink_filt_coeffs);
bw_gain_init(&instance->noise_gain_coeffs);
bw_env_gen_init(&instance->vcf_env_gen_coeffs);
bw_svf_init(&instance->vcf_coeffs);
bw_env_gen_init(&instance->vca_env_gen_coeffs);
bw_phase_gen_init(&instance->a440_phase_gen_coeffs);
bw_gain_init(&instance->gain_coeffs);
bw_ppm_init(&instance->ppm_coeffs);
bw_osc_saw_set_antialiasing(&instance->vco_saw_coeffs, 1);
bw_osc_pulse_set_antialiasing(&instance->vco1_pulse_coeffs, 1);
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_osc_pulse_set_antialiasing(&instance->vco3_pulse_coeffs, 1);
bw_osc_tri_set_antialiasing(&instance->vco3_tri_coeffs, 1);
bw_phase_gen_set_frequency(&instance->a440_phase_gen_coeffs, 440.f);
instance->rand_state = 0xbaddecaf600dfeed;
}
static void plugin_fini(plugin *instance) {
(void)instance;
}
static void plugin_set_sample_rate(plugin *instance, float sample_rate) {
bw_osc_saw_set_sample_rate(&instance->vco_saw_coeffs, sample_rate);
bw_phase_gen_set_sample_rate(&instance->vco1_phase_gen_coeffs, sample_rate);
bw_osc_pulse_set_sample_rate(&instance->vco1_pulse_coeffs, sample_rate);
bw_osc_tri_set_sample_rate(&instance->vco1_tri_coeffs, sample_rate);
bw_gain_set_sample_rate(&instance->vco1_gain_coeffs, sample_rate);
bw_phase_gen_set_sample_rate(&instance->vco2_phase_gen_coeffs, sample_rate);
bw_osc_pulse_set_sample_rate(&instance->vco2_pulse_coeffs, sample_rate);
bw_osc_tri_set_sample_rate(&instance->vco2_tri_coeffs, sample_rate);
bw_gain_set_sample_rate(&instance->vco2_gain_coeffs, sample_rate);
bw_phase_gen_set_sample_rate(&instance->vco3_phase_gen_coeffs, sample_rate);
bw_osc_pulse_set_sample_rate(&instance->vco3_pulse_coeffs, sample_rate);
bw_osc_tri_set_sample_rate(&instance->vco3_tri_coeffs, sample_rate);
bw_gain_set_sample_rate(&instance->vco3_gain_coeffs, sample_rate);
bw_noise_gen_set_sample_rate(&instance->noise_gen_coeffs, sample_rate);
bw_pink_filt_set_sample_rate(&instance->pink_filt_coeffs, sample_rate);
bw_gain_set_sample_rate(&instance->noise_gain_coeffs, sample_rate);
bw_env_gen_set_sample_rate(&instance->vcf_env_gen_coeffs, sample_rate);
bw_svf_set_sample_rate(&instance->vcf_coeffs, sample_rate);
bw_env_gen_set_sample_rate(&instance->vca_env_gen_coeffs, sample_rate);
bw_phase_gen_set_sample_rate(&instance->a440_phase_gen_coeffs, sample_rate);
bw_gain_set_sample_rate(&instance->gain_coeffs, sample_rate);
bw_ppm_set_sample_rate(&instance->ppm_coeffs, sample_rate);
bw_osc_saw_reset_coeffs(&instance->vco_saw_coeffs);
bw_noise_gen_reset_coeffs(&instance->noise_gen_coeffs);
bw_pink_filt_reset_coeffs(&instance->pink_filt_coeffs);
instance->sync_count = (size_t)bw_roundf(sample_rate * SYNC_RATE);
}
static size_t plugin_mem_req(plugin *instance) {
(void)instance;
return 0;
}
static void plugin_mem_set(plugin *instance, void *mem) {
(void)instance;
(void)mem;
}
static void plugin_reset(plugin *instance) {
bw_svf_set_cutoff(&instance->vcf_coeffs, instance->vcf_cutoff);
float p, pi;
bw_phase_gen_reset_coeffs(&instance->vco1_phase_gen_coeffs);
bw_phase_gen_reset_state(&instance->vco1_phase_gen_coeffs, &instance->vco1_phase_gen_state, 0.f, &p, &pi);
bw_osc_pulse_reset_coeffs(&instance->vco1_pulse_coeffs);
bw_osc_tri_reset_coeffs(&instance->vco1_tri_coeffs);
bw_gain_reset_coeffs(&instance->vco1_gain_coeffs);
bw_phase_gen_reset_coeffs(&instance->vco2_phase_gen_coeffs);
bw_phase_gen_reset_state(&instance->vco2_phase_gen_coeffs, &instance->vco2_phase_gen_state, 0.f, &p, &pi);
bw_osc_pulse_reset_coeffs(&instance->vco2_pulse_coeffs);
bw_osc_tri_reset_coeffs(&instance->vco2_tri_coeffs);
bw_gain_reset_coeffs(&instance->vco2_gain_coeffs);
bw_phase_gen_reset_coeffs(&instance->vco3_phase_gen_coeffs);
bw_phase_gen_reset_state(&instance->vco3_phase_gen_coeffs, &instance->vco3_phase_gen_state, 0.f, &p, &pi);
bw_osc_pulse_reset_coeffs(&instance->vco3_pulse_coeffs);
bw_osc_tri_reset_coeffs(&instance->vco3_tri_coeffs);
bw_gain_reset_coeffs(&instance->vco3_gain_coeffs);
bw_osc_filt_reset_state(&instance->osc_filt_state, 0.f);
bw_pink_filt_reset_state(&instance->pink_filt_coeffs, &instance->pink_filt_state, 0.f);
bw_gain_reset_coeffs(&instance->noise_gain_coeffs);
bw_env_gen_reset_coeffs(&instance->vcf_env_gen_coeffs);
bw_env_gen_reset_state(&instance->vcf_env_gen_coeffs, &instance->vcf_env_gen_state, 0);
bw_svf_reset_coeffs(&instance->vcf_coeffs);
float lp, bp, hp;
bw_svf_reset_state(&instance->vcf_coeffs, &instance->vcf_state, 0.f, &lp, &bp, &hp);
bw_env_gen_reset_coeffs(&instance->vca_env_gen_coeffs);
bw_env_gen_reset_state(&instance->vca_env_gen_coeffs, &instance->vca_env_gen_state, 0);
bw_phase_gen_reset_coeffs(&instance->a440_phase_gen_coeffs);
bw_phase_gen_reset_state(&instance->a440_phase_gen_coeffs, &instance->a440_phase_gen_state, 0.f, &p, &pi);
bw_gain_reset_coeffs(&instance->gain_coeffs);
bw_ppm_reset_coeffs(&instance->ppm_coeffs);
bw_ppm_reset_state(&instance->ppm_coeffs, &instance->ppm_state, 0.f);
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;
instance->sync_left = instance->sync_count;
instance->vco3_waveform_cur = instance->vco3_waveform;
instance->noise_color_cur = instance->noise_color;
instance->vco1_waveform_cur = instance->vco1_waveform;
instance->vco2_waveform_cur = instance->vco2_waveform;
}
static void plugin_set_parameter(plugin *instance, size_t index, float value) {
switch (index) {
case 0:
{
const float v = 0.01f * value;
bw_gain_set_gain_lin(&instance->gain_coeffs, v * v * v);
}
break;
case 1:
instance->master_tune = value;
break;
case 2:
{
// using portamento time 0% -> 90%: tau = portamento time / log(10)
const float v = (0.001f * 0.4342944819032517f) * value;
bw_phase_gen_set_portamento_tau(&instance->vco1_phase_gen_coeffs, v);
bw_phase_gen_set_portamento_tau(&instance->vco2_phase_gen_coeffs, v);
bw_phase_gen_set_portamento_tau(&instance->vco3_phase_gen_coeffs, v);
break;
}
case 3:
instance->modulation_mix = 0.01f * value;
break;
case 4:
instance->vco1_modulation = 0.01f * value;
break;
case 5:
instance->vco1_coarse = value;
break;
case 6:
instance->vco1_fine = value;
break;
case 7:
instance->vco1_waveform = value;
break;
case 8:
{
const float v = 0.01f * value;
bw_osc_pulse_set_pulse_width(&instance->vco1_pulse_coeffs, v);
bw_osc_tri_set_slope(&instance->vco1_tri_coeffs, bw_clipf(v, 0.001f, 0.999f));
break;
}
case 9:
{
const float v = 0.01f * value;
bw_gain_set_gain_lin(&instance->vco1_gain_coeffs, v * v * v);
break;
}
case 10:
instance->vco2_modulation = 0.01f * value;
break;
case 11:
instance->vco2_coarse = value;
break;
case 12:
instance->vco2_fine = value;
break;
case 13:
instance->vco2_waveform = value;
break;
case 14:
{
const float v = 0.01f * value;
bw_osc_pulse_set_pulse_width(&instance->vco2_pulse_coeffs, v);
bw_osc_tri_set_slope(&instance->vco2_tri_coeffs, bw_clipf(v, 0.001f, 0.999f));
break;
}
case 15:
{
const float v = 0.01f * value;
bw_gain_set_gain_lin(&instance->vco2_gain_coeffs, v * v * v);
break;
}
case 16:
instance->vco3_kbd_ctrl = value >= 0.5f;
break;
case 17:
instance->vco3_coarse = value;
break;
case 18:
instance->vco3_fine = value;
break;
case 19:
instance->vco3_waveform = value;
break;
case 20:
{
const float v = 0.01f * value;
bw_osc_pulse_set_pulse_width(&instance->vco3_pulse_coeffs, v);
bw_osc_tri_set_slope(&instance->vco3_tri_coeffs, bw_clipf(v, 0.001f, 0.999f));
break;
}
case 21:
{
const float v = 0.01f * value;
bw_gain_set_gain_lin(&instance->vco3_gain_coeffs, v * v * v);
break;
}
case 22:
instance->noise_color = value;
break;
case 23:
{
const float v = 0.01f * value;
bw_gain_set_gain_lin(&instance->noise_gain_coeffs, v * v * v);
break;
}
case 24:
instance->vcf_modulation = 0.01f * value;
break;
case 25:
instance->vcf_kbd_ctrl = value;
break;
case 26:
instance->vcf_cutoff = value;
break;
case 27:
bw_svf_set_Q(&instance->vcf_coeffs, 0.5f + (0.01f * 9.5f) * value);
break;
case 28:
instance->vcf_contour = 0.01f * value;
break;
case 29:
bw_env_gen_set_attack(&instance->vcf_env_gen_coeffs, 0.001f * value);
break;
case 30:
bw_env_gen_set_decay(&instance->vcf_env_gen_coeffs, 0.001f * value);
break;
case 31:
bw_env_gen_set_sustain(&instance->vcf_env_gen_coeffs, 0.01f * value);
break;
case 32:
bw_env_gen_set_release(&instance->vcf_env_gen_coeffs, 0.001f * value);
break;
case 33:
bw_env_gen_set_attack(&instance->vca_env_gen_coeffs, 0.001f * value);
break;
case 34:
bw_env_gen_set_decay(&instance->vca_env_gen_coeffs, 0.001f * value);
break;
case 35:
bw_env_gen_set_sustain(&instance->vca_env_gen_coeffs, 0.01f * value);
break;
case 36:
bw_env_gen_set_release(&instance->vca_env_gen_coeffs, 0.001f * value);
break;
case 37:
instance->a440 = value >= 0.5f;
break;
}
}
static float plugin_get_parameter(plugin *instance, size_t index) {
(void)index;
return bw_clipf(bw_ppm_get_y_z1(&instance->ppm_state), -60.f, 0.f);
}
static void plugin_process(plugin *instance, const float **inputs, float **outputs, size_t n_samples) {
(void)inputs;
// asynchronous control-rate operations
int n = instance->note - 69;
int n3 = instance->vco3_kbd_ctrl >= 0.5f ? instance->note - 69 : -69;
bw_phase_gen_set_frequency(&instance->vco1_phase_gen_coeffs,
instance->master_tune
* bw_pow2f(instance->vco1_coarse + instance->pitch_bend
+ 8.333333333333333e-2f * (n + 0.01f * instance->vco1_fine)));
bw_phase_gen_set_frequency(&instance->vco2_phase_gen_coeffs,
instance->master_tune
* bw_pow2f(instance->vco2_coarse + instance->pitch_bend
+ 8.333333333333333e-2f * (n + 0.01f * instance->vco2_fine)));
bw_phase_gen_set_frequency(&instance->vco3_phase_gen_coeffs,
instance->master_tune
* bw_pow2f(instance->vco3_coarse + instance->pitch_bend
+ 8.333333333333333e-2f * (n3 + 0.01f * instance->vco3_fine)));
if (instance->vco3_waveform_cur != instance->vco3_waveform) {
switch (instance->vco3_waveform) {
case 2:
bw_osc_pulse_reset_coeffs(&instance->vco3_pulse_coeffs);
break;
case 3:
bw_osc_tri_reset_coeffs(&instance->vco3_tri_coeffs);
break;
}
instance->vco3_waveform_cur = instance->vco3_waveform;
}
if (instance->noise_color_cur != instance->noise_color) {
if (instance->noise_color == 2)
bw_pink_filt_reset_state(&instance->pink_filt_coeffs, &instance->pink_filt_state, 0.f);
instance->noise_color_cur = instance->noise_color;
}
if (instance->vco1_waveform_cur != instance->vco1_waveform) {
switch (instance->vco1_waveform) {
case 2:
bw_osc_pulse_reset_coeffs(&instance->vco1_pulse_coeffs);
break;
case 3:
bw_osc_tri_reset_coeffs(&instance->vco1_tri_coeffs);
break;
}
instance->vco1_waveform_cur = instance->vco1_waveform;
}
if (instance->vco2_waveform_cur != instance->vco2_waveform) {
switch (instance->vco2_waveform) {
case 2:
bw_osc_pulse_reset_coeffs(&instance->vco2_pulse_coeffs);
break;
case 3:
bw_osc_tri_reset_coeffs(&instance->vco2_tri_coeffs);
break;
}
instance->vco2_waveform_cur = instance->vco2_waveform;
}
// synchronous control-rate and audio-rate operations
for (size_t i = 0; i < n_samples; ) {
float *out = outputs[0] + i;
int n = bw_minf(bw_minf(n_samples - i, BUFFER_SIZE), instance->sync_left);
const char sync = instance->sync_left == instance->sync_count;
// osc 3
bw_phase_gen_process(&instance->vco3_phase_gen_coeffs, &instance->vco3_phase_gen_state, NULL, out, instance->buf[0], n);
switch (instance->vco3_waveform_cur) {
case 1:
bw_osc_saw_process(&instance->vco_saw_coeffs, out, instance->buf[0], out, n);
break;
case 2:
bw_osc_pulse_process(&instance->vco3_pulse_coeffs, out, instance->buf[0], out, n);
break;
default:
bw_osc_tri_process(&instance->vco3_tri_coeffs, out, instance->buf[0], out, n);
break;
}
// noise generator
bw_noise_gen_process(&instance->noise_gen_coeffs, instance->buf[0], n);
if (instance->noise_color_cur == 2)
bw_pink_filt_process(&instance->pink_filt_coeffs, &instance->pink_filt_state, instance->buf[0], instance->buf[0], n);
bw_buf_scale(instance->buf[0], 5.f, instance->buf[0], n);
// modulation signals
for (int j = 0; j < n; j++)
instance->buf[1][j] = instance->mod_wheel * (out[j] + instance->modulation_mix * (instance->buf[0][j] - out[j]));
if (sync)
instance->mod_k = instance->buf[1][0];
// osc 1
bw_buf_scale(instance->buf[1], instance->vco1_modulation, instance->buf[2], n);
bw_phase_gen_process(&instance->vco1_phase_gen_coeffs, &instance->vco1_phase_gen_state, instance->buf[2], instance->buf[2], instance->buf[3], n);
switch (instance->vco1_waveform_cur) {
case 1:
bw_osc_saw_process(&instance->vco_saw_coeffs, instance->buf[2], instance->buf[3], instance->buf[2], n);
break;
case 2:
bw_osc_pulse_process(&instance->vco1_pulse_coeffs, instance->buf[2], instance->buf[3], instance->buf[2], n);
break;
default:
bw_osc_tri_process(&instance->vco1_tri_coeffs, instance->buf[2], instance->buf[3], instance->buf[2], n);
break;
}
// osc 2
bw_buf_scale(instance->buf[1], instance->vco2_modulation, instance->buf[1], n);
bw_phase_gen_process(&instance->vco2_phase_gen_coeffs, &instance->vco2_phase_gen_state, instance->buf[1], instance->buf[1], instance->buf[3], n);
switch (instance->vco2_waveform_cur) {
case 1:
bw_osc_saw_process(&instance->vco_saw_coeffs, instance->buf[1], instance->buf[3], instance->buf[1], n);
break;
case 2:
bw_osc_pulse_process(&instance->vco2_pulse_coeffs, instance->buf[1], instance->buf[3], instance->buf[1], n);
break;
default:
bw_osc_tri_process(&instance->vco2_tri_coeffs, instance->buf[1], instance->buf[3], instance->buf[1], n);
break;
}
// mixer
bw_gain_process(&instance->vco1_gain_coeffs, instance->buf[2], instance->buf[2], n);
bw_gain_process(&instance->vco2_gain_coeffs, instance->buf[1], instance->buf[1], n);
bw_gain_process(&instance->vco3_gain_coeffs, out, out, n);
bw_gain_process(&instance->noise_gain_coeffs, instance->buf[0], instance->buf[0], n);
bw_buf_mix(out, instance->buf[1], out, n);
bw_buf_mix(out, instance->buf[2], out, n);
bw_osc_filt_process(&instance->osc_filt_state, out, out, n);
const float k = instance->noise_color_cur == 2
? 6.f * bw_noise_gen_get_scaling_k(&instance->noise_gen_coeffs) * bw_pink_filt_get_scaling_k(&instance->pink_filt_coeffs)
: 0.1f * bw_noise_gen_get_scaling_k(&instance->noise_gen_coeffs);
bw_buf_scale(instance->buf[0], k, instance->buf[0], n);
bw_buf_mix(out, instance->buf[0], out, n);
// vcf
bw_env_gen_process(&instance->vcf_env_gen_coeffs, &instance->vcf_env_gen_state, instance->gate, NULL, n);
if (sync)
instance->vcf_env_k = bw_env_gen_get_y_z1(&instance->vcf_env_gen_state);
const float cutoff_unmapped = 0.1447648273010839f * bw_logf(0.05f * instance->vcf_cutoff);
const float cutoff_vpos = cutoff_unmapped + instance->vcf_contour * instance->vcf_env_k + 0.3f * instance->vcf_modulation * instance->mod_k;
float cutoff = 20.f * bw_expf(6.907755278982137 * cutoff_vpos);
switch (instance->vcf_kbd_ctrl) {
case 2: // 1/3
cutoff *= bw_pow2f((0.629960524947437f * 8.333333333333333e-2f) * (instance->note - 60));
break;
case 3: // 2/3
cutoff *= bw_pow2f((0.793700525984100f * 8.333333333333333e-2f) * (instance->note - 60));
break;
case 4: // full
cutoff *= bw_pow2f(8.333333333333333e-2f * (instance->note - 60));
break;
default: // off, do nothing
break;
}
bw_svf_set_cutoff(&instance->vcf_coeffs, bw_clipf(cutoff, 20.f, 20e3f));
bw_svf_process(&instance->vcf_coeffs, &instance->vcf_state, out, out, NULL, NULL, n);
// vca
bw_env_gen_process(&instance->vca_env_gen_coeffs, &instance->vca_env_gen_state, instance->gate, instance->buf[0], n);
bw_buf_mul(out, instance->buf[0], out, n);
// A 440 Hz osc
if (instance->a440) { // nobody will notice or care about phase issues here
bw_phase_gen_process(&instance->a440_phase_gen_coeffs, &instance->a440_phase_gen_state, NULL, instance->buf[0], NULL, n);
bw_osc_sin_process(instance->buf[0], instance->buf[0], n);
bw_buf_mix(out, instance->buf[0], out, n);
}
// output
bw_gain_process(&instance->gain_coeffs, out, out, n);
bw_ppm_process(&instance->ppm_coeffs, &instance->ppm_state, out, NULL, n);
instance->sync_left -= n;
if (instance->sync_left == 0)
instance->sync_left = instance->sync_count;
i += n;
}
}
static void update_note_gate(plugin *instance) {
for (int i = 0; i < 128; i++)
if (instance->notes_pressed[i]) {
instance->note = i;
instance->gate = 1;
return;
}
instance->gate = 0;
}
static void note_on(plugin *instance, char note) {
instance->notes_pressed[(int)note] = 1;
update_note_gate(instance);
}
static void note_off(plugin *instance, char note) {
if (instance->notes_pressed[(int)note]) {
instance->notes_pressed[(int)note] = 0;
update_note_gate(instance);
}
}
static void plugin_midi_msg_in(plugin *instance, size_t index, const uint8_t * data) {
(void)index;
switch (data[0] & 0xf0) {
case 0x90: // note on
if (data[2] == 0) // no, note off actually
note_off(instance, data[1]);
else
note_on(instance, data[1]);
break;
case 0x80: // note off
note_off(instance, data[1]);
break;
case 0xe0: // pitch bend
{
const uint16_t v = (data[2] << 7) | data[1];
instance->pitch_bend = 2.f * bw_maxf((1.f / 16383.f) * (v - 0x2000), -1.f) - 1.f;
break;
}
case 0xb0: // control change
if (data[1] == 1) // mod wheel
instance->mod_wheel = (1.f / 127.f) * data[2];
break;
}
}

View File

@ -0,0 +1,446 @@
{
"product": {
"name": "Brickworks mono synth example",
"version": "1.1.0",
"buildVersion": "1",
"bundleName": "bw_example_synth_mono",
"buses": [
{
"type": "midi",
"direction": "input",
"name": "MIDI input",
"shortName": "MIDI input"
},
{
"type": "audio",
"direction": "output",
"channels": "mono",
"name": "Output",
"shortName": "Output"
}
],
"parameters": [
{
"name": "Volume",
"shortName": "Volume",
"direction": "input",
"defaultValue": 50.0,
"minimum": 0.0,
"maximum": 100.0,
"unit": "pc",
"map": "linear"
},
{
"name": "Master tune",
"shortName": "Master tune",
"direction": "input",
"defaultValue": 440.0,
"minimum": 415.304697579945,
"maximum": 466.1637615180899,
"unit": "hz",
"map": "logarithmic"
},
{
"name": "Portamento",
"shortName": "Portamento",
"direction": "input",
"defaultValue": 0.0,
"minimum": 0.0,
"maximum": 1000.0,
"unit": "ms",
"map": "linear"
},
{
"name": "Modulation mix",
"shortName": "Modulation mix",
"direction": "input",
"defaultValue": 0.0,
"minimum": 0.0,
"maximum": 100.0,
"unit": "pc",
"map": "linear"
},
{
"name": "VCO1 modulation",
"shortName": "VCO1 modulation",
"direction": "input",
"defaultValue": 0.0,
"minimum": 0.0,
"maximum": 100.0,
"unit": "pc",
"map": "linear"
},
{
"name": "VCO1 coarse tuning",
"shortName": "VCO1 coarse",
"direction": "input",
"defaultValue": 0.0,
"minimum": -3.0,
"maximum": 3.0,
"unit": "oct",
"integer": true,
"map": "linear"
},
{
"name": "VCO1 fine tuning",
"shortName": "VCO1 fine",
"direction": "input",
"defaultValue": 0.0,
"minimum": -100.0,
"maximum": 100.0,
"unit": "cent",
"map": "linear"
},
{
"name": "VCO1 waveform",
"shortName": "VCO1 waveform",
"direction": "input",
"defaultValue": 1.0,
"minimum": 1.0,
"maximum": 3.0,
"integer": true,
"scalePoints": {
"Saw": 1.0,
"Pulse": 2.0,
"Triangle": 3.0
},
"list": true,
"map": "linear"
},
{
"name": "VCO1 pulse width/slope",
"shortName": "VCO1 pw/slope",
"direction": "input",
"defaultValue": 50.0,
"minimum": 0.0,
"maximum": 100.0,
"unit": "pc",
"map": "linear"
},
{
"name": "VCO1 level",
"shortName": "VCO1 level",
"direction": "input",
"defaultValue": 100.0,
"minimum": 0.0,
"maximum": 100.0,
"unit": "pc",
"map": "linear"
},
{
"name": "VCO2 modulation",
"shortName": "VCO2 modulation",
"direction": "input",
"defaultValue": 0.0,
"minimum": 0.0,
"maximum": 100.0,
"unit": "pc",
"map": "linear"
},
{
"name": "VCO2 coarse tuning",
"shortName": "VCO2 coarse",
"direction": "input",
"defaultValue": 0.0,
"minimum": -3.0,
"maximum": 3.0,
"unit": "oct",
"integer": true,
"map": "linear"
},
{
"name": "VCO2 fine tuning",
"shortName": "VCO2 fine",
"direction": "input",
"defaultValue": 0.0,
"minimum": -100.0,
"maximum": 100.0,
"unit": "cent",
"map": "linear"
},
{
"name": "VCO2 waveform",
"shortName": "VCO2 waveform",
"direction": "input",
"defaultValue": 1.0,
"minimum": 1.0,
"maximum": 3.0,
"integer": true,
"scalePoints": {
"Saw": 1.0,
"Pulse": 2.0,
"Triangle": 3.0
},
"list": true,
"map": "linear"
},
{
"name": "VCO2 pulse width/slope",
"shortName": "VCO2 pw/slope",
"direction": "input",
"defaultValue": 50.0,
"minimum": 0.0,
"maximum": 100.0,
"unit": "pc",
"map": "linear"
},
{
"name": "VCO2 level",
"shortName": "VCO2 level",
"direction": "input",
"defaultValue": 0.0,
"minimum": 0.0,
"maximum": 100.0,
"unit": "pc",
"map": "linear"
},
{
"name": "VCO3 keyboard control",
"shortName": "VCO3 kbd ctrl",
"direction": "input",
"defaultValue": 1.0,
"minimum": 0.0,
"maximum": 1.0,
"toggled": true
},
{
"name": "VCO3 coarse tuning",
"shortName": "VCO3 coarse",
"direction": "input",
"defaultValue": 0.0,
"minimum": -3.0,
"maximum": 3.0,
"unit": "oct",
"integer": true,
"map": "linear"
},
{
"name": "VCO3 fine tuning",
"shortName": "VCO3 fine",
"direction": "input",
"defaultValue": 0.0,
"minimum": -100.0,
"maximum": 100.0,
"unit": "cent",
"map": "linear"
},
{
"name": "VCO3 waveform",
"shortName": "VCO3 waveform",
"direction": "input",
"defaultValue": 1.0,
"minimum": 1.0,
"maximum": 3.0,
"integer": true,
"scalePoints": {
"Saw": 1.0,
"Pulse": 2.0,
"Triangle": 3.0
},
"list": true,
"map": "linear"
},
{
"name": "VCO3 pulse width/slope",
"shortName": "VCO3 pw/slope",
"direction": "input",
"defaultValue": 50.0,
"minimum": 0.0,
"maximum": 100.0,
"unit": "pc",
"map": "linear"
},
{
"name": "VCO3 level",
"shortName": "VCO3 level",
"direction": "input",
"defaultValue": 0.0,
"minimum": 0.0,
"maximum": 100.0,
"unit": "pc",
"map": "linear"
},
{
"name": "Noise color",
"shortName": "Noise color",
"direction": "input",
"defaultValue": 1.0,
"minimum": 1.0,
"maximum": 2.0,
"integer": true,
"scalePoints": {
"White": 1.0,
"Pink": 2.0
},
"list": true,
"map": "linear"
},
{
"name": "Noise level",
"shortName": "Noise level",
"direction": "input",
"defaultValue": 0.0,
"minimum": 0.0,
"maximum": 100.0,
"unit": "pc",
"map": "linear"
},
{
"name": "VCF modulation",
"shortName": "VCF modulation",
"direction": "input",
"defaultValue": 0.0,
"minimum": 0.0,
"maximum": 100.0,
"unit": "pc",
"map": "linear"
},
{
"name": "VCF keyboard control",
"shortName": "VCF kbd ctrl",
"direction": "input",
"defaultValue": 1.0,
"minimum": 1.0,
"maximum": 4.0,
"integer": true,
"scalePoints": {
"Off": 1.0,
"1/3": 2.0,
"2/3": 3.0,
"Full": 4.0
},
"list": true,
"map": "linear"
},
{
"name": "VCF cutoff",
"shortName": "VCF cutoff",
"direction": "input",
"defaultValue": 20e3,
"minimum": 20.0,
"maximum": 20e3,
"unit": "hz",
"map": "logarithmic"
},
{
"name": "VCF resonance",
"shortName": "VCF resonance",
"direction": "input",
"defaultValue": 0.0,
"minimum": 0.0,
"maximum": 100.0,
"unit": "pc",
"map": "linear"
},
{
"name": "VCF contour",
"shortName": "VCF contour",
"direction": "input",
"defaultValue": 0.0,
"minimum": 0.0,
"maximum": 100.0,
"unit": "pc",
"map": "linear"
},
{
"name": "VCF attack",
"shortName": "VCF attack",
"direction": "input",
"defaultValue": 0.0,
"minimum": 0.0,
"maximum": 1000.0,
"unit": "ms",
"map": "linear"
},
{
"name": "VCF decay",
"shortName": "VCF decay",
"direction": "input",
"defaultValue": 0.0,
"minimum": 0.0,
"maximum": 1000.0,
"unit": "ms",
"map": "linear"
},
{
"name": "VCF sustain",
"shortName": "VCF sustain",
"direction": "input",
"defaultValue": 100.0,
"minimum": 0.0,
"maximum": 100.0,
"unit": "pc",
"map": "linear"
},
{
"name": "VCF release",
"shortName": "VCF release",
"direction": "input",
"defaultValue": 0.0,
"minimum": 0.0,
"maximum": 1000.0,
"unit": "ms",
"map": "linear"
},
{
"name": "VCA attack",
"shortName": "VCA attack",
"direction": "input",
"defaultValue": 2.0,
"minimum": 2.0,
"maximum": 1000.0,
"unit": "ms",
"map": "linear"
},
{
"name": "VCA decay",
"shortName": "VCA decay",
"direction": "input",
"defaultValue": 2.0,
"minimum": 2.0,
"maximum": 1000.0,
"unit": "ms",
"map": "linear"
},
{
"name": "VCA sustain",
"shortName": "VCA sustain",
"direction": "input",
"defaultValue": 100.0,
"minimum": 0.0,
"maximum": 100.0,
"unit": "pc",
"map": "linear"
},
{
"name": "VCA release",
"shortName": "VCA release",
"direction": "input",
"defaultValue": 2.0,
"minimum": 2.0,
"maximum": 1000.0,
"unit": "ms",
"map": "linear"
},
{
"name": "A440",
"shortName": "A440",
"direction": "input",
"defaultValue": 0.0,
"minimum": 0.0,
"maximum": 1.0,
"toggled": true
},
{
"name": "Level",
"shortName": "Level",
"direction": "output",
"defaultValue": -60.0,
"minimum": -60.0,
"maximum": 0.0,
"unit": "db",
"map": "linear"
}
]
}
}

View File

@ -0,0 +1,11 @@
{
"vst3": {
"plugin": {
"cid": "5af9b17295ef439cb10ed6f0b962eef1"
},
"controller": {
"cid": "ed4990b08989421596fc7cda5a56cec9"
},
"subCategory": "Instrument|Synth"
}
}

View File

@ -92,7 +92,7 @@ static void plugin_set_parameter(plugin *instance, size_t index, float value) {
break;
case 2:
// using portamento time 0% -> 90%: tau = portamento time / log(10)
bw_phase_gen_set_portamento_tau(&instance->phase_gen_coeffs, 0.4342944819032517f * value);
bw_phase_gen_set_portamento_tau(&instance->phase_gen_coeffs, (0.001f * 0.4342944819032517f) * value);
break;
case 3:
bw_osc_pulse_set_pulse_width(&instance->osc_pulse_coeffs, 0.01f * value);

View File

@ -46,8 +46,8 @@
"direction": "input",
"defaultValue": 0.0,
"minimum": 0.0,
"maximum": 1.0,
"unit": "s",
"maximum": 1000.0,
"unit": "ms",
"map": "linear"
},
{

View File

@ -80,7 +80,7 @@ void impl_set_parameter(impl handle, size_t index, float value) {
break;
case 2:
// using portamento time 0% -> 90%: tau = portamento time / log(10)
instance->phaseGen.setPortamentoTau(0.4342944819032517f * value);
instance->phaseGen.setPortamentoTau((0.001f * 0.4342944819032517f) * value);
break;
case 3:
instance->oscPulse.setPulseWidth(0.01f * value);

View File

@ -46,8 +46,8 @@
"direction": "input",
"defaultValue": 0.0,
"minimum": 0.0,
"maximum": 1.0,
"unit": "s",
"maximum": 1000.0,
"unit": "ms",
"map": "linear"
},
{