bwpp_pan + fxpp_pan + use process_multi in fx_balance, fx_pan

This commit is contained in:
Stefano D'Angelo 2023-06-27 15:55:37 +02:00
parent 8c83345f25
commit 768aa6d81e
11 changed files with 381 additions and 12 deletions

1
TODO
View File

@ -58,6 +58,7 @@ code:
* float -> double, etc. ?
* sr_reduce reset_coeffs? update_coeffs? process_multi?
* src(_int) process_multi?
* fix definitions leading to X ** -> const X ** error https://isocpp.org/wiki/faq/const-correctness#constptrptr-conversion, fix fx_balance, fx_pan, synth_poly
build system:
* make makefiles handle paths with spaces etc

View File

@ -39,12 +39,8 @@ void bw_example_fx_balance_reset(bw_example_fx_balance *instance) {
void bw_example_fx_balance_process(bw_example_fx_balance *instance, const float** x, float** y, int n_samples) {
bw_balance_process(&instance->balance_coeffs, x[0], x[1], y[0], y[1], n_samples);
bw_ppm_update_coeffs_ctrl(&instance->ppm_coeffs);
for (int i = 0; i < n_samples; i++) {
bw_ppm_update_coeffs_audio(&instance->ppm_coeffs);
bw_ppm_process1(&instance->ppm_coeffs, &instance->ppm_l_state, y[0][i]);
bw_ppm_process1(&instance->ppm_coeffs, &instance->ppm_r_state, y[1][i]);
}
bw_ppm_state *ppm_states[2] = { &instance->ppm_l_state, &instance->ppm_r_state };
bw_ppm_process_multi(&instance->ppm_coeffs, ppm_states, (const float **)y, NULL, 2, n_samples);
}
void bw_example_fx_balance_set_parameter(bw_example_fx_balance *instance, int index, float value) {

View File

@ -39,12 +39,8 @@ void bw_example_fx_pan_reset(bw_example_fx_pan *instance) {
void bw_example_fx_pan_process(bw_example_fx_pan *instance, const float** x, float** y, int n_samples) {
bw_pan_process(&instance->pan_coeffs, x[0], y[0], y[1], n_samples);
bw_ppm_update_coeffs_ctrl(&instance->ppm_coeffs);
for (int i = 0; i < n_samples; i++) {
bw_ppm_update_coeffs_audio(&instance->ppm_coeffs);
bw_ppm_process1(&instance->ppm_coeffs, &instance->ppm_l_state, y[0][i]);
bw_ppm_process1(&instance->ppm_coeffs, &instance->ppm_r_state, y[1][i]);
}
bw_ppm_state *ppm_states[2] = { &instance->ppm_l_state, &instance->ppm_r_state };
bw_ppm_process_multi(&instance->ppm_coeffs, ppm_states, (const float **)y, NULL, 2, n_samples);
}
void bw_example_fx_pan_set_parameter(bw_example_fx_pan *instance, int index, float value) {

View File

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

View File

@ -0,0 +1,35 @@
/*
* 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_pin {
int param_index;
int pin;
};
#define NUM_PINS 1
static struct config_pin config_pins[NUM_PINS] = {
{ 0, 15 }
};
#endif

View File

@ -0,0 +1,71 @@
/*
* 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_fxpp_pan.h"
void bw_example_fxpp_pan_init(bw_example_fxpp_pan *instance) {
(void)instance;
}
void bw_example_fxpp_pan_set_sample_rate(bw_example_fxpp_pan *instance, float sample_rate) {
instance->pan.setSampleRate(sample_rate);
instance->ppm.setSampleRate(sample_rate);
}
void bw_example_fxpp_pan_reset(bw_example_fxpp_pan *instance) {
instance->pan.reset();
instance->ppm.reset();
}
void bw_example_fxpp_pan_process(bw_example_fxpp_pan *instance, const float** x, float** y, int n_samples) {
instance->pan.process({x[0]}, {y[0]}, {y[1]}, n_samples);
instance->ppm.process({y[0], y[1]}, {nullptr, nullptr}, n_samples);
}
void bw_example_fxpp_pan_set_parameter(bw_example_fxpp_pan *instance, int index, float value) {
instance->params[index] = value;
switch (index) {
case p_pan:
instance->pan.setPan(value + value - 1.f);
break;
}
}
float bw_example_fxpp_pan_get_parameter(bw_example_fxpp_pan *instance, int index) {
float r = 0.f;
switch (index) {
case p_pan:
r = instance->params[p_pan];
break;
case p_pan + 1:
{
const float v = instance->ppm.getYZ1(0);
r = v < -200.f ? 0.f : bw_clipf(0.01666666666666667f * v + 1.f, 0.f, 1.f);
break;
}
case p_pan + 2:
{
const float v = instance->ppm.getYZ1(1);
r = v < -200.f ? 0.f : bw_clipf(0.01666666666666667f * v + 1.f, 0.f, 1.f);
break;
}
}
return r;
}

View File

@ -0,0 +1,55 @@
/*
* 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_FXPP_PAN_H
#define _BW_EXAMPLE_FXPP_PAN_H
#include <bwpp_pan.h>
#include <bwpp_ppm.h>
using namespace Brickworks;
extern "C" {
enum {
p_pan,
p_n
};
struct _bw_example_fxpp_pan {
// Sub-components
Pan<1> pan;
PPM<2> ppm;
// Parameters
float params[p_n];
};
typedef struct _bw_example_fxpp_pan bw_example_fxpp_pan;
void bw_example_fxpp_pan_init(bw_example_fxpp_pan *instance);
void bw_example_fxpp_pan_set_sample_rate(bw_example_fxpp_pan *instance, float sample_rate);
void bw_example_fxpp_pan_reset(bw_example_fxpp_pan *instance);
void bw_example_fxpp_pan_process(bw_example_fxpp_pan *instance, const float** x, float** y, int n_samples);
void bw_example_fxpp_pan_set_parameter(bw_example_fxpp_pan *instance, int index, float value);
float bw_example_fxpp_pan_get_parameter(bw_example_fxpp_pan *instance, int index);
}
#endif

View File

@ -0,0 +1,89 @@
/*
* 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_fxpp_pan"
#define PLUGIN_VERSION "0.5.0"
#define NUM_BUSES_IN 1
#define NUM_BUSES_OUT 1
#define NUM_CHANNELS_IN 1
#define NUM_CHANNELS_OUT 2
static struct config_io_bus config_buses_in[NUM_BUSES_IN] = {
{ "Audio in", 0, 0, 0, IO_STEREO }
};
static struct config_io_bus config_buses_out[NUM_BUSES_OUT] = {
{ "Audio out", 1, 0, 0, IO_STEREO }
};
#define NUM_PARAMETERS 3
static struct config_parameter config_parameters[NUM_PARAMETERS] = {
{ "Pan", "Pan", "", 0, 0, 0, 0.5f },
{ "Left level", "L Level", "", 1, 0, 0, 0.f },
{ "Right level", "R Level", "", 1, 0, 0, 0.f }
};
// Internal API
#include "bw_example_fxpp_pan.h"
#define P_TYPE bw_example_fxpp_pan
#define P_INIT bw_example_fxpp_pan_init
#define P_SET_SAMPLE_RATE bw_example_fxpp_pan_set_sample_rate
#define P_RESET bw_example_fxpp_pan_reset
#define P_PROCESS bw_example_fxpp_pan_process
#define P_SET_PARAMETER bw_example_fxpp_pan_set_parameter
#define P_GET_PARAMETER bw_example_fxpp_pan_get_parameter
#endif

View File

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

View File

@ -0,0 +1,36 @@
/*
* Brickworks
*
* Copyright (C) 2023 Orastron Srl unipersonale
*
* Brickworks is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* Brickworks is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Brickworks. If not, see <http://www.gnu.org/licenses/>.
*
* File authors: Stefano D'Angelo, Paolo Marrone
*/
#ifndef _VST3_CONFIG_H
#define _VST3_CONFIG_H
#define PLUGIN_SUBCATEGORY "Fx|Spatial"
#define PLUGIN_GUID_1 0x47d6ebcd
#define PLUGIN_GUID_2 0x744540f2
#define PLUGIN_GUID_3 0x8ea345d6
#define PLUGIN_GUID_4 0x89a2a236
#define CTRL_GUID_1 0x646c6d37
#define CTRL_GUID_2 0xfbe846af
#define CTRL_GUID_3 0xa5e16bd7
#define CTRL_GUID_4 0x6d1676c6
#endif

77
include/bwpp_pan.h Normal file
View File

@ -0,0 +1,77 @@
/*
* 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 BWPP_PAN_H
#define BWPP_PAN_H
#include <bw_pan.h>
#include <array>
namespace Brickworks {
template<BW_SIZE_T N_CHANNELS>
class Pan {
public:
Pan();
void setSampleRate(float sampleRate);
void reset();
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y_l,
std::array<float *, N_CHANNELS> y_r,
int nSamples);
void setPan(float value);
private:
bw_pan_coeffs coeffs;
};
template<BW_SIZE_T N_CHANNELS>
Pan<N_CHANNELS>::Pan() {
bw_pan_init(&coeffs);
}
template<BW_SIZE_T N_CHANNELS>
void Pan<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_pan_set_sample_rate(&coeffs, sampleRate);
}
template<BW_SIZE_T N_CHANNELS>
void Pan<N_CHANNELS>::reset() {
bw_pan_reset_coeffs(&coeffs);
}
template<BW_SIZE_T N_CHANNELS>
void Pan<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y_l,
std::array<float *, N_CHANNELS> y_r,
int nSamples) {
bw_pan_process_multi(&coeffs, x.data(), y_l.data(), y_r.data(), N_CHANNELS, nSamples);
}
template<BW_SIZE_T N_CHANNELS>
void Pan<N_CHANNELS>::setPan(float value) {
bw_pan_set_pan(&coeffs, value);
}
}
#endif