new synth_simple + cosmetics in fx_balance
This commit is contained in:
parent
df5f3837ea
commit
f9e1f5eb73
@ -56,7 +56,7 @@ static float plugin_get_parameter(plugin *instance, size_t index) {
|
||||
v = bw_ppm_get_y_z1(&instance->ppm_r_state);
|
||||
break;
|
||||
}
|
||||
return v < -60.f ? -60.f : (v > 0.f ? 0.f : v);
|
||||
return bw_clipf(v, -60.f, 0.f);
|
||||
}
|
||||
|
||||
static void plugin_process(plugin *instance, const float **inputs, float **outputs, size_t n_samples) {
|
||||
|
@ -1,7 +0,0 @@
|
||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
|
||||
NAME := bw_example_synth_simple
|
||||
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_synth_simple.c
|
||||
SYNTH := yes
|
||||
|
||||
include ${ROOT_DIR}/../../common/android/android.mk
|
@ -1,9 +0,0 @@
|
||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
|
||||
TARGET = bw_example_synth_simple
|
||||
|
||||
C_SOURCES += ${ROOT_DIR}/../src/bw_example_synth_simple.c
|
||||
|
||||
SYNTH := yes
|
||||
|
||||
include ${ROOT_DIR}/../../common/daisy-seed/daisy-seed.mk
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* 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
|
@ -1,6 +0,0 @@
|
||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
|
||||
NAME := bw_example_synth_simple
|
||||
SOURCE := ${NAME}.c
|
||||
|
||||
include ${ROOT_DIR}/../../common/ios/ios.mk
|
5
examples/synth_simple/src/android.json
Normal file
5
examples/synth_simple/src/android.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"android": {
|
||||
"javaPackageName": "com.orastron.bw_example_synth_simple"
|
||||
}
|
||||
}
|
@ -1,134 +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_simple.h"
|
||||
|
||||
#include <bw_buf.h>
|
||||
|
||||
void bw_example_synth_simple_init(bw_example_synth_simple *instance) {
|
||||
bw_phase_gen_init(&instance->phase_gen_coeffs);
|
||||
bw_osc_pulse_init(&instance->osc_pulse_coeffs);
|
||||
bw_svf_init(&instance->svf_coeffs);
|
||||
bw_env_gen_init(&instance->env_gen_coeffs);
|
||||
bw_gain_init(&instance->gain_coeffs);
|
||||
bw_ppm_init(&instance->ppm_coeffs);
|
||||
|
||||
bw_osc_pulse_set_antialiasing(&instance->osc_pulse_coeffs, 1);
|
||||
}
|
||||
|
||||
void bw_example_synth_simple_set_sample_rate(bw_example_synth_simple *instance, float sample_rate) {
|
||||
bw_phase_gen_set_sample_rate(&instance->phase_gen_coeffs, sample_rate);
|
||||
bw_osc_pulse_set_sample_rate(&instance->osc_pulse_coeffs, sample_rate);
|
||||
bw_svf_set_sample_rate(&instance->svf_coeffs, sample_rate);
|
||||
bw_env_gen_set_sample_rate(&instance->env_gen_coeffs, sample_rate);
|
||||
bw_gain_set_sample_rate(&instance->gain_coeffs, sample_rate);
|
||||
bw_ppm_set_sample_rate(&instance->ppm_coeffs, sample_rate);
|
||||
}
|
||||
|
||||
void bw_example_synth_simple_reset(bw_example_synth_simple *instance) {
|
||||
bw_phase_gen_reset_coeffs(&instance->phase_gen_coeffs);
|
||||
float p, inc;
|
||||
bw_phase_gen_reset_state(&instance->phase_gen_coeffs, &instance->phase_gen_state, 0.f, &p, &inc);
|
||||
bw_osc_pulse_reset_coeffs(&instance->osc_pulse_coeffs);
|
||||
bw_osc_filt_reset_state(&instance->osc_filt_state, 0.f);
|
||||
bw_svf_reset_coeffs(&instance->svf_coeffs);
|
||||
float lp, bp, hp;
|
||||
bw_svf_reset_state(&instance->svf_coeffs, &instance->svf_state, 0.f, &lp, &bp, &hp);
|
||||
bw_env_gen_reset_coeffs(&instance->env_gen_coeffs);
|
||||
bw_env_gen_reset_state(&instance->env_gen_coeffs, &instance->env_gen_state, 0);
|
||||
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 = -1;
|
||||
}
|
||||
|
||||
void bw_example_synth_simple_process(bw_example_synth_simple *instance, const float** x, float** y, int n_samples) {
|
||||
(void)x;
|
||||
|
||||
if (instance->note >= 0)
|
||||
bw_phase_gen_set_frequency(&instance->phase_gen_coeffs,
|
||||
440.f * bw_pow2f(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);
|
||||
|
||||
bw_phase_gen_process(&instance->phase_gen_coeffs, &instance->phase_gen_state, NULL, out, instance->buf, n);
|
||||
bw_osc_pulse_process(&instance->osc_pulse_coeffs, out, instance->buf, out, n);
|
||||
bw_osc_filt_process(&instance->osc_filt_state, out, out, n);
|
||||
bw_svf_process(&instance->svf_coeffs, &instance->svf_state, out, out, NULL, NULL, n);
|
||||
bw_env_gen_process(&instance->env_gen_coeffs, &instance->env_gen_state, instance->note >= 0, instance->buf, n);
|
||||
bw_buf_mul(out, instance->buf, 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_simple_set_parameter(bw_example_synth_simple *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->phase_gen_coeffs, value);
|
||||
break;
|
||||
case p_pulse_width:
|
||||
bw_osc_pulse_set_pulse_width(&instance->osc_pulse_coeffs, value);
|
||||
break;
|
||||
case p_cutoff:
|
||||
bw_svf_set_cutoff(&instance->svf_coeffs, 20.f + (20e3f - 20.f) * value * value * value);
|
||||
break;
|
||||
case p_Q:
|
||||
bw_svf_set_Q(&instance->svf_coeffs, 0.5f + 9.5f * value);
|
||||
break;
|
||||
case p_attack:
|
||||
bw_env_gen_set_attack(&instance->env_gen_coeffs, bw_maxf(0.002f, value));
|
||||
break;
|
||||
case p_decay:
|
||||
bw_env_gen_set_decay(&instance->env_gen_coeffs, value);
|
||||
break;
|
||||
case p_sustain:
|
||||
bw_env_gen_set_sustain(&instance->env_gen_coeffs, value);
|
||||
break;
|
||||
case p_release:
|
||||
bw_env_gen_set_release(&instance->env_gen_coeffs, bw_maxf(0.002f, value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float bw_example_synth_simple_get_parameter(bw_example_synth_simple *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);
|
||||
}
|
||||
|
||||
void bw_example_synth_simple_note_on(bw_example_synth_simple *instance, char note, char velocity) {
|
||||
if (velocity == 0)
|
||||
bw_example_synth_simple_note_off(instance, note);
|
||||
else
|
||||
instance->note = note;
|
||||
}
|
||||
|
||||
void bw_example_synth_simple_note_off(bw_example_synth_simple *instance, char note) {
|
||||
if (note == instance->note)
|
||||
instance->note = -1;
|
||||
}
|
@ -1,93 +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_SIMPLE_H
|
||||
#define _BW_EXAMPLE_SYNTH_SIMPLE_H
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include <bw_math.h>
|
||||
#include <bw_phase_gen.h>
|
||||
#include <bw_osc_pulse.h>
|
||||
#include <bw_osc_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_pulse_width,
|
||||
p_cutoff,
|
||||
p_Q,
|
||||
p_attack,
|
||||
p_decay,
|
||||
p_sustain,
|
||||
p_release,
|
||||
p_n
|
||||
};
|
||||
|
||||
#define BUFFER_SIZE 128
|
||||
|
||||
struct _bw_example_synth_simple {
|
||||
// Sub-components
|
||||
bw_phase_gen_coeffs phase_gen_coeffs;
|
||||
bw_phase_gen_state phase_gen_state;
|
||||
bw_osc_pulse_coeffs osc_pulse_coeffs;
|
||||
bw_osc_filt_state osc_filt_state;
|
||||
bw_svf_coeffs svf_coeffs;
|
||||
bw_svf_state svf_state;
|
||||
bw_env_gen_coeffs env_gen_coeffs;
|
||||
bw_env_gen_state env_gen_state;
|
||||
bw_gain_coeffs gain_coeffs;
|
||||
bw_ppm_coeffs ppm_coeffs;
|
||||
bw_ppm_state ppm_state;
|
||||
|
||||
// Parameters
|
||||
float params[p_n];
|
||||
|
||||
// States
|
||||
int note;
|
||||
|
||||
// Buffers
|
||||
float buf[BUFFER_SIZE];
|
||||
};
|
||||
typedef struct _bw_example_synth_simple bw_example_synth_simple;
|
||||
|
||||
void bw_example_synth_simple_init(bw_example_synth_simple *instance);
|
||||
void bw_example_synth_simple_set_sample_rate(bw_example_synth_simple *instance, float sample_rate);
|
||||
void bw_example_synth_simple_reset(bw_example_synth_simple *instance);
|
||||
void bw_example_synth_simple_process(bw_example_synth_simple *instance, const float** x, float** y, int n_samples);
|
||||
void bw_example_synth_simple_set_parameter(bw_example_synth_simple *instance, int index, float value);
|
||||
float bw_example_synth_simple_get_parameter(bw_example_synth_simple *instance, int index);
|
||||
void bw_example_synth_simple_note_on(bw_example_synth_simple *instance, char note, char velocity);
|
||||
void bw_example_synth_simple_note_off(bw_example_synth_simple *instance, char note);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
6
examples/synth_simple/src/cmd.json
Normal file
6
examples/synth_simple/src/cmd.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"cmd": {
|
||||
"busIds": [ "midi_in", "output" ],
|
||||
"parameterIds": [ "volume", "master_tune", "portamento", "pulse_width", "cutoff", "resonance", "attack", "decay", "sustain", "release", "level" ]
|
||||
}
|
||||
}
|
@ -1,95 +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_simple"
|
||||
#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 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_synth_simple.h"
|
||||
|
||||
#define P_TYPE bw_example_synth_simple
|
||||
#define P_INIT bw_example_synth_simple_init
|
||||
#define P_SET_SAMPLE_RATE bw_example_synth_simple_set_sample_rate
|
||||
#define P_RESET bw_example_synth_simple_reset
|
||||
#define P_PROCESS bw_example_synth_simple_process
|
||||
#define P_SET_PARAMETER bw_example_synth_simple_set_parameter
|
||||
#define P_GET_PARAMETER bw_example_synth_simple_get_parameter
|
||||
#define P_NOTE_ON bw_example_synth_simple_note_on
|
||||
#define P_NOTE_OFF bw_example_synth_simple_note_off
|
||||
|
||||
#endif
|
@ -1,84 +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: "Pulse width",
|
||||
output: false,
|
||||
defaultValue: 0.5
|
||||
},
|
||||
{
|
||||
name: "Cutoff",
|
||||
output: false,
|
||||
defaultValue: 1.0
|
||||
},
|
||||
{
|
||||
name: "Q",
|
||||
output: false,
|
||||
defaultValue: 0.0
|
||||
},
|
||||
{
|
||||
name: "Attack",
|
||||
output: false,
|
||||
defaultValue: 0.0
|
||||
},
|
||||
{
|
||||
name: "Decay",
|
||||
output: false,
|
||||
defaultValue: 0.0
|
||||
},
|
||||
{
|
||||
name: "Sustain",
|
||||
output: false,
|
||||
defaultValue: 1.0
|
||||
},
|
||||
{
|
||||
name: "Release",
|
||||
output: false,
|
||||
defaultValue: 0.0
|
||||
},
|
||||
{
|
||||
name: "Level",
|
||||
output: true,
|
||||
defaultValue: 0.0
|
||||
}
|
||||
];
|
6
examples/synth_simple/src/daisy-seed.json
Normal file
6
examples/synth_simple/src/daisy-seed.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"daisy_seed": {
|
||||
"parameterPins": [ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 22 ],
|
||||
"midiCCMaps": [ 7, 3, 5, 28, 74, 71, 73, 109, 110, 72, -1 ]
|
||||
}
|
||||
}
|
5
examples/synth_simple/src/ios.json
Normal file
5
examples/synth_simple/src/ios.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"ios": {
|
||||
"productBundleIdentifier": "com.orastron.bw_example_synth_simple"
|
||||
}
|
||||
}
|
12
examples/synth_simple/src/lv2.json
Normal file
12
examples/synth_simple/src/lv2.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"lv2": {
|
||||
"prefixes": {
|
||||
"bw_examples": "https://www.orastron.com/brickworks/examples/"
|
||||
},
|
||||
"uri": "@bw_examples:synth_simple",
|
||||
"types": [ "@lv2:InstrumentPlugin" ],
|
||||
"version": "1.0",
|
||||
"busSymbols": [ "midi_in", "output" ],
|
||||
"parameterSymbols": [ "volume", "master_tune", "portamento", "pulse_width", "cutoff", "resonance", "attack", "decay", "sustain", "release", "level" ]
|
||||
}
|
||||
}
|
166
examples/synth_simple/src/plugin.h
Normal file
166
examples/synth_simple/src/plugin.h
Normal file
@ -0,0 +1,166 @@
|
||||
#include "common.h"
|
||||
#include <bw_phase_gen.h>
|
||||
#include <bw_osc_pulse.h>
|
||||
#include <bw_osc_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
|
||||
|
||||
typedef struct plugin {
|
||||
bw_phase_gen_coeffs phase_gen_coeffs;
|
||||
bw_phase_gen_state phase_gen_state;
|
||||
bw_osc_pulse_coeffs osc_pulse_coeffs;
|
||||
bw_osc_filt_state osc_filt_state;
|
||||
bw_svf_coeffs svf_coeffs;
|
||||
bw_svf_state svf_state;
|
||||
bw_env_gen_coeffs env_gen_coeffs;
|
||||
bw_env_gen_state env_gen_state;
|
||||
bw_gain_coeffs gain_coeffs;
|
||||
bw_ppm_coeffs ppm_coeffs;
|
||||
bw_ppm_state ppm_state;
|
||||
|
||||
float master_tune;
|
||||
int note;
|
||||
|
||||
float buf[BUFFER_SIZE];
|
||||
} plugin;
|
||||
|
||||
static void plugin_init(plugin *instance) {
|
||||
bw_phase_gen_init(&instance->phase_gen_coeffs);
|
||||
bw_osc_pulse_init(&instance->osc_pulse_coeffs);
|
||||
bw_svf_init(&instance->svf_coeffs);
|
||||
bw_env_gen_init(&instance->env_gen_coeffs);
|
||||
bw_gain_init(&instance->gain_coeffs);
|
||||
bw_ppm_init(&instance->ppm_coeffs);
|
||||
|
||||
bw_osc_pulse_set_antialiasing(&instance->osc_pulse_coeffs, 1);
|
||||
|
||||
instance->master_tune = 440.f;
|
||||
}
|
||||
|
||||
static void plugin_fini(plugin *instance) {
|
||||
(void)instance;
|
||||
}
|
||||
|
||||
static void plugin_set_sample_rate(plugin *instance, float sample_rate) {
|
||||
bw_phase_gen_set_sample_rate(&instance->phase_gen_coeffs, sample_rate);
|
||||
bw_osc_pulse_set_sample_rate(&instance->osc_pulse_coeffs, sample_rate);
|
||||
bw_svf_set_sample_rate(&instance->svf_coeffs, sample_rate);
|
||||
bw_env_gen_set_sample_rate(&instance->env_gen_coeffs, sample_rate);
|
||||
bw_gain_set_sample_rate(&instance->gain_coeffs, sample_rate);
|
||||
bw_ppm_set_sample_rate(&instance->ppm_coeffs, sample_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_phase_gen_reset_coeffs(&instance->phase_gen_coeffs);
|
||||
float p, inc;
|
||||
bw_phase_gen_reset_state(&instance->phase_gen_coeffs, &instance->phase_gen_state, 0.f, &p, &inc);
|
||||
bw_osc_pulse_reset_coeffs(&instance->osc_pulse_coeffs);
|
||||
bw_osc_filt_reset_state(&instance->osc_filt_state, 0.f);
|
||||
bw_svf_reset_coeffs(&instance->svf_coeffs);
|
||||
float lp, bp, hp;
|
||||
bw_svf_reset_state(&instance->svf_coeffs, &instance->svf_state, 0.f, &lp, &bp, &hp);
|
||||
bw_env_gen_reset_coeffs(&instance->env_gen_coeffs);
|
||||
bw_env_gen_reset_state(&instance->env_gen_coeffs, &instance->env_gen_state, 0);
|
||||
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 = -1;
|
||||
}
|
||||
|
||||
static void plugin_set_parameter(plugin *instance, size_t index, float value) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
{
|
||||
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)
|
||||
bw_phase_gen_set_portamento_tau(&instance->phase_gen_coeffs, 0.4342944819032517f * value);
|
||||
break;
|
||||
case 3:
|
||||
bw_osc_pulse_set_pulse_width(&instance->osc_pulse_coeffs, 0.01f * value);
|
||||
break;
|
||||
case 4:
|
||||
bw_svf_set_cutoff(&instance->svf_coeffs, value);
|
||||
break;
|
||||
case 5:
|
||||
bw_svf_set_Q(&instance->svf_coeffs, 0.5f + (9.5f * 0.01f) * value);
|
||||
break;
|
||||
case 6:
|
||||
bw_env_gen_set_attack(&instance->env_gen_coeffs, 0.001f * value);
|
||||
break;
|
||||
case 7:
|
||||
bw_env_gen_set_decay(&instance->env_gen_coeffs, 0.001f * value);
|
||||
break;
|
||||
case 8:
|
||||
bw_env_gen_set_sustain(&instance->env_gen_coeffs, 0.01f * value);
|
||||
break;
|
||||
case 9:
|
||||
bw_env_gen_set_release(&instance->env_gen_coeffs, 0.001f * value);
|
||||
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;
|
||||
|
||||
if (instance->note >= 0)
|
||||
bw_phase_gen_set_frequency(&instance->phase_gen_coeffs,
|
||||
instance->master_tune * bw_pow2f(8.333333333333333e-2f * ((instance->note - 69))));
|
||||
|
||||
for (size_t i = 0; i < n_samples; i += BUFFER_SIZE) {
|
||||
float *out = outputs[0] + i;
|
||||
int n = bw_minf(n_samples - i, BUFFER_SIZE);
|
||||
|
||||
bw_phase_gen_process(&instance->phase_gen_coeffs, &instance->phase_gen_state, NULL, out, instance->buf, n);
|
||||
bw_osc_pulse_process(&instance->osc_pulse_coeffs, out, instance->buf, out, n);
|
||||
bw_osc_filt_process(&instance->osc_filt_state, out, out, n);
|
||||
bw_svf_process(&instance->svf_coeffs, &instance->svf_state, out, out, NULL, NULL, n);
|
||||
bw_env_gen_process(&instance->env_gen_coeffs, &instance->env_gen_state, instance->note >= 0, instance->buf, n);
|
||||
bw_buf_mul(out, instance->buf, out, n);
|
||||
bw_gain_process(&instance->gain_coeffs, out, out, n);
|
||||
bw_ppm_process(&instance->ppm_coeffs, &instance->ppm_state, out, NULL, n);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
if (data[1] == instance->note)
|
||||
instance->note = -1;
|
||||
} else
|
||||
instance->note = data[1];
|
||||
break;
|
||||
case 0x80: // note off
|
||||
if (data[1] == instance->note)
|
||||
instance->note = -1;
|
||||
break;
|
||||
}
|
||||
}
|
135
examples/synth_simple/src/product.json
Normal file
135
examples/synth_simple/src/product.json
Normal file
@ -0,0 +1,135 @@
|
||||
{
|
||||
"product": {
|
||||
"name": "Brickworks simple synth example",
|
||||
"version": "1.1.0",
|
||||
"buildVersion": "1",
|
||||
"bundleName": "bw_example_synth_simple",
|
||||
"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": 1.0,
|
||||
"unit": "s",
|
||||
"map": "linear"
|
||||
},
|
||||
{
|
||||
"name": "Pulse width",
|
||||
"shortName": "Pulse width",
|
||||
"direction": "input",
|
||||
"defaultValue": 50.0,
|
||||
"minimum": 0.0,
|
||||
"maximum": 100.0,
|
||||
"unit": "pc",
|
||||
"map": "linear"
|
||||
},
|
||||
{
|
||||
"name": "Cutoff",
|
||||
"shortName": "Cutoff",
|
||||
"direction": "input",
|
||||
"defaultValue": 20e3,
|
||||
"minimum": 20.0,
|
||||
"maximum": 20e3,
|
||||
"unit": "hz",
|
||||
"map": "logarithmic"
|
||||
},
|
||||
{
|
||||
"name": "Resonance",
|
||||
"shortName": "Resonance",
|
||||
"direction": "input",
|
||||
"defaultValue": 0.0,
|
||||
"minimum": 0.0,
|
||||
"maximum": 100.0,
|
||||
"unit": "pc",
|
||||
"map": "linear"
|
||||
},
|
||||
{
|
||||
"name": "Attack",
|
||||
"shortName": "Attack",
|
||||
"direction": "input",
|
||||
"defaultValue": 2.0,
|
||||
"minimum": 2.0,
|
||||
"maximum": 1000.0,
|
||||
"unit": "ms",
|
||||
"map": "linear"
|
||||
},
|
||||
{
|
||||
"name": "Decay",
|
||||
"shortName": "Decay",
|
||||
"direction": "input",
|
||||
"defaultValue": 2.0,
|
||||
"minimum": 2.0,
|
||||
"maximum": 1000.0,
|
||||
"unit": "ms",
|
||||
"map": "linear"
|
||||
},
|
||||
{
|
||||
"name": "Sustain",
|
||||
"shortName": "Sustain",
|
||||
"direction": "input",
|
||||
"defaultValue": 100.0,
|
||||
"minimum": 0.0,
|
||||
"maximum": 100.0,
|
||||
"unit": "pc",
|
||||
"map": "linear"
|
||||
},
|
||||
{
|
||||
"name": "Release",
|
||||
"shortName": "Release",
|
||||
"direction": "input",
|
||||
"defaultValue": 2.0,
|
||||
"minimum": 2.0,
|
||||
"maximum": 1000.0,
|
||||
"unit": "ms",
|
||||
"map": "linear"
|
||||
},
|
||||
{
|
||||
"name": "Level",
|
||||
"shortName": "Level",
|
||||
"direction": "output",
|
||||
"defaultValue": -60.0,
|
||||
"minimum": -60.0,
|
||||
"maximum": 0.0,
|
||||
"unit": "db",
|
||||
"map": "linear"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
11
examples/synth_simple/src/vst3.json
Normal file
11
examples/synth_simple/src/vst3.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"vst3": {
|
||||
"plugin": {
|
||||
"cid": "78a77ca9ab3d46558840a96151f2a6f9"
|
||||
},
|
||||
"controller": {
|
||||
"cid": "e44829aab0e046ae9e9195a083867d48"
|
||||
},
|
||||
"subCategory": "Instrument|Synth"
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
|
||||
NAME := bw_example_synth_simple
|
||||
SOURCE := bw_example_synth_simple.c
|
||||
|
||||
include ${ROOT_DIR}/../../common/vst3/vst3.mk
|
||||
|
||||
CXXFLAGS += -DRELEASE=1 -DNDEBUG -DBW_NO_DEBUG
|
||||
#CXXFLAGS += -DDEVELOPMENT=1 -DBW_DEBUG_DEEP
|
@ -1,36 +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 authors: Stefano D'Angelo, Paolo Marrone
|
||||
*/
|
||||
|
||||
#ifndef _VST3_CONFIG_H
|
||||
#define _VST3_CONFIG_H
|
||||
|
||||
#define PLUGIN_SUBCATEGORY "Instrument|Synth"
|
||||
|
||||
#define PLUGIN_GUID_1 0x78a77ca9
|
||||
#define PLUGIN_GUID_2 0xab3d4655
|
||||
#define PLUGIN_GUID_3 0x8840a961
|
||||
#define PLUGIN_GUID_4 0x51f2a6f9
|
||||
|
||||
#define CTRL_GUID_1 0xe44829aa
|
||||
#define CTRL_GUID_2 0xb0e046ae
|
||||
#define CTRL_GUID_3 0x9e9195a0
|
||||
#define CTRL_GUID_4 0x83867d48
|
||||
|
||||
#endif
|
@ -1,5 +0,0 @@
|
||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_synth_simple.c
|
||||
SYNTH := yes
|
||||
|
||||
include ${ROOT_DIR}/../../common/web/web.mk
|
@ -4,7 +4,7 @@ echo Removing common files
|
||||
|
||||
rm -fr common/cmd common/web common/daisy-seed common/lv2 common/vst3 common/android common/ios
|
||||
|
||||
dirs="fx_ap1 fx_ap2 fx_balance fx_bitcrush fx_cab fx_comp fxpp_ap1 fxpp_ap2 fxpp_balance fxpp_bitcrush fxpp_cab fxpp_comp"
|
||||
dirs="fx_ap1 fx_ap2 fx_balance fx_bitcrush fx_cab fx_comp synth_simple fxpp_ap1 fxpp_ap2 fxpp_balance fxpp_bitcrush fxpp_cab fxpp_comp"
|
||||
|
||||
for d in $dirs; do
|
||||
echo Removing data files for $d
|
||||
|
@ -26,7 +26,7 @@ cd common && $TIBIA_DIR/tibia --common $TIBIA_DIR/templates/android-make android
|
||||
cd common && $TIBIA_DIR/tibia --common $TIBIA_DIR/templates/ios ios && cd ..
|
||||
cd common && $TIBIA_DIR/tibia --common $TIBIA_DIR/templates/ios-make ios && cd ..
|
||||
|
||||
dirs="fx_ap1 fx_ap2 fx_balance fx_bitcrush fx_cab fx_comp fxpp_ap1 fxpp_ap2 fxpp_balance fxpp_bitcrush fxpp_cab fxpp_comp"
|
||||
dirs="fx_ap1 fx_ap2 fx_balance fx_bitcrush fx_cab fx_comp synth_simple fxpp_ap1 fxpp_ap2 fxpp_balance fxpp_bitcrush fxpp_cab fxpp_comp"
|
||||
|
||||
for d in $dirs; do
|
||||
echo Generating data files for $d
|
||||
|
Loading…
Reference in New Issue
Block a user