Browse Source

zverb working

faust
Alexandros Theodotou 3 years ago
parent
commit
8f93d8706d
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 25
      plugins/chordz/chordz.c
  2. 107
      plugins/chordz/chordz_common.h
  3. 171
      plugins/chordz/common.h
  4. 89
      plugins/common.h
  5. 22
      plugins/compressor/compressor.c
  6. 72
      plugins/compressor/compressor_common.h
  7. 2
      plugins/compressor/ttl.h
  8. 4
      plugins/meson.build
  9. 41
      plugins/saw/saw.c
  10. 107
      plugins/saw/saw_common.h
  11. 134
      plugins/verb/common.h
  12. 148
      plugins/verb/ttl.h
  13. 141
      plugins/verb/verb.c
  14. 93
      plugins/verb/verb_common.h

25
plugins/chordz/chordz.c

@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
* along with ZPlugins. If not, see <https://www.gnu.org/licenses/>.
*/
#include PLUGIN_CONFIG
#include <float.h>
#include <math.h>
#include <stdlib.h>
@ -26,7 +28,7 @@ @@ -26,7 +28,7 @@
#include <sys/time.h>
#include "../math.h"
#include "common.h"
#include PLUGIN_COMMON
#include "soundpipe.h"
@ -78,7 +80,9 @@ instantiate ( @@ -78,7 +80,9 @@ instantiate (
{
Chordz * self = calloc (1, sizeof (Chordz));
self->common.samplerate = rate;
SET_SAMPLERATE (self, rate);
PluginCommon * pl_common = &self->common.pl_common;
#define HAVE_FEATURE(x) \
(!strcmp(features[i]->URI, x))
@ -87,34 +91,34 @@ instantiate ( @@ -87,34 +91,34 @@ instantiate (
{
if (HAVE_FEATURE (LV2_URID__map))
{
self->common.map =
pl_common->map =
(LV2_URID_Map*) features[i]->data;
}
else if (HAVE_FEATURE (LV2_LOG__log))
{
self->common.log =
pl_common->log =
(LV2_Log_Log *) features[i]->data;
}
}
#undef HAVE_FEATURE
if (!self->common.map)
if (!pl_common->map)
{
lv2_log_error (
&self->common.logger, "Missing feature urid:map\n");
&pl_common->logger, "Missing feature urid:map\n");
goto fail;
}
/* map uris */
map_uris (self->common.map, &self->common.uris);
map_uris (pl_common->map, &self->common);
/* init atom forge */
lv2_atom_forge_init (
&self->common.forge, self->common.map);
&pl_common->forge, pl_common->map);
/* init logger */
lv2_log_logger_init (
&self->common.logger, self->common.map, self->common.log);
&pl_common->logger, pl_common->map, pl_common->log);
return (LV2_Handle) self;
@ -681,8 +685,7 @@ run ( @@ -681,8 +685,7 @@ run (
LV2_ATOM_SEQUENCE_FOREACH (
self->control, ev)
{
if (ev->body.type ==
self->common.uris.midi_MidiEvent)
if (ev->body.type == PL_URIS(self)->midi_MidiEvent)
{
const uint8_t * const msg =
(const uint8_t *) (ev + 1);

107
plugins/chordz/chordz_common.h

@ -0,0 +1,107 @@ @@ -0,0 +1,107 @@
/*
* Copyright (C) 2018, 2020 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of ZPlugins
*
* ZPlugins is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* ZPlugins 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU General Affero Public License
* along with ZPlugins. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file
*
* Common code for both the DSP and the UI.
*/
#ifndef __Z_CHORDZ_COMMON_H__
#define __Z_CHORDZ_COMMON_H__
#include PLUGIN_CONFIG
#include "../common.h"
typedef struct ChordzUris
{
} ChordzUris;
typedef enum PortIndex
{
/** GUI to plugin communication. */
CHORDZ_CONTROL,
/** Plugin to UI communication. */
CHORDZ_NOTIFY,
CHORDZ_SCALE,
CHORDZ_MAJOR,
CHORDZ_BASS,
CHORDZ_FIRST,
CHORDZ_THIRD,
CHORDZ_FIFTH,
CHORDZ_SEVENTH,
CHORDZ_OCTAVE,
CHORDZ_NINTH,
CHORDZ_ELEVENTH,
CHORDZ_THIRTEENTH,
/** Outputs. */
CHORDZ_MIDI_OUT,
NUM_PORTS,
} PortIndex;
typedef enum ChordzScales
{
SCALE_C,
SCALE_CS,
SCALE_D,
SCALE_DS,
SCALE_E,
SCALE_F,
SCALE_FS,
SCALE_G,
SCALE_GS,
SCALE_A,
SCALE_AS,
SCALE_B
} ChordzScales;
/**
* Group of variables needed by both the DSP and
* the UI.
*/
typedef struct ChordzCommon
{
/** Custom URIs. */
ChordzUris uris;
PluginCommon pl_common;
} ChordzCommon;
static inline void
map_uris (
LV2_URID_Map* urid_map,
ChordzCommon * chordz_common)
{
map_common_uris (
urid_map, &chordz_common->pl_common.uris);
#define MAP(x,uri) \
chordz_common->uris.x = \
urid_map->map (urid_map->handle, uri)
/* custom URIs */
#undef MAP
}
#endif

171
plugins/chordz/common.h

@ -1,171 +0,0 @@ @@ -1,171 +0,0 @@
/*
* Copyright (C) 2018, 2020 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of ZPlugins
*
* ZPlugins is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* ZPlugins 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU General Affero Public License
* along with ZPlugins. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file
*
* Common code for both the DSP and the UI.
*/
#ifndef __Z_CHORDZ_COMMON_H__
#define __Z_CHORDZ_COMMON_H__
#include PLUGIN_CONFIG
#include <string.h>
#include "lv2/atom/atom.h"
#include "lv2/atom/forge.h"
#include "lv2/core/lv2.h"
#include "lv2/log/log.h"
#include "lv2/log/logger.h"
#include "lv2/midi/midi.h"
#include "lv2/urid/urid.h"
#include "lv2/time/time.h"
#include "lv2/worker/worker.h"
typedef struct ChordzUris
{
LV2_URID atom_eventTransfer;
LV2_URID atom_Blank;
LV2_URID atom_Object;
LV2_URID atom_Float;
LV2_URID atom_Double;
LV2_URID atom_Int;
LV2_URID atom_Long;
LV2_URID log_Entry;
LV2_URID log_Error;
LV2_URID log_Note;
LV2_URID log_Trace;
LV2_URID log_Warning;
LV2_URID midi_MidiEvent;
LV2_URID time_Position;
LV2_URID time_bar;
LV2_URID time_barBeat;
LV2_URID time_beatsPerMinute;
LV2_URID time_beatUnit;
LV2_URID time_frame;
LV2_URID time_speed;
} ChordzUris;
typedef enum PortIndex
{
/** GUI to plugin communication. */
CHORDZ_CONTROL,
/** Plugin to UI communication. */
CHORDZ_NOTIFY,
CHORDZ_SCALE,
CHORDZ_MAJOR,
CHORDZ_BASS,
CHORDZ_FIRST,
CHORDZ_THIRD,
CHORDZ_FIFTH,
CHORDZ_SEVENTH,
CHORDZ_OCTAVE,
CHORDZ_NINTH,
CHORDZ_ELEVENTH,
CHORDZ_THIRTEENTH,
/** Outputs. */
CHORDZ_MIDI_OUT,
NUM_PORTS,
} PortIndex;
typedef enum ChordzScales
{
SCALE_C,
SCALE_CS,
SCALE_D,
SCALE_DS,
SCALE_E,
SCALE_F,
SCALE_FS,
SCALE_G,
SCALE_GS,
SCALE_A,
SCALE_AS,
SCALE_B
} ChordzScales;
/**
* Group of variables needed by both the DSP and
* the UI.
*/
typedef struct ChordzCommon
{
/** Log feature. */
LV2_Log_Log * log;
/** Map feature. */
LV2_URID_Map * map;
/** Logger convenience API. */
LV2_Log_Logger logger;
/** Atom forge. */
LV2_Atom_Forge forge;
/** URIs. */
ChordzUris uris;
/** Plugin samplerate. */
double samplerate;
} ChordzCommon;
static inline void
map_uris (
LV2_URID_Map* map,
ChordzUris* uris)
{
#define MAP(x,uri) \
uris->x = map->map (map->handle, uri)
/* official URIs */
MAP (atom_Blank, LV2_ATOM__Blank);
MAP (atom_Object, LV2_ATOM__Object);
MAP (atom_Float, LV2_ATOM__Float);
MAP (atom_Double, LV2_ATOM__Double);
MAP (atom_Int, LV2_ATOM__Int);
MAP (atom_Long, LV2_ATOM__Long);
MAP (atom_eventTransfer, LV2_ATOM__eventTransfer);
MAP (log_Entry, LV2_LOG__Entry);
MAP (log_Error, LV2_LOG__Error);
MAP (log_Note, LV2_LOG__Note);
MAP (log_Trace, LV2_LOG__Trace);
MAP (log_Warning, LV2_LOG__Warning);
MAP (midi_MidiEvent, LV2_MIDI__MidiEvent);
MAP (time_Position, LV2_TIME__Position);
MAP (time_bar, LV2_TIME__bar);
MAP (time_barBeat, LV2_TIME__barBeat);
MAP (
time_beatsPerMinute, LV2_TIME__beatsPerMinute);
MAP (time_beatUnit, LV2_TIME__beatUnit);
MAP (time_frame, LV2_TIME__frame);
MAP (time_speed, LV2_TIME__speed);
/* custom URIs */
//MAP (saw_freeValues, PLUGIN_URI "#freeValues");
//MAP (saw_calcValues, PLUGIN_URI "#calcValues");
}
#endif

89
plugins/saw/common.h → plugins/common.h

@ -23,10 +23,8 @@ @@ -23,10 +23,8 @@
* Common code for both the DSP and the UI.
*/
#ifndef __Z_SUPERSAW_COMMON_H__
#define __Z_SUPERSAW_COMMON_H__
#include PLUGIN_CONFIG
#ifndef __Z_COMMON_H__
#define __Z_COMMON_H__
#include <string.h>
@ -40,7 +38,7 @@ @@ -40,7 +38,7 @@
#include "lv2/time/time.h"
#include "lv2/worker/worker.h"
typedef struct SawUris
typedef struct PluginUris
{
LV2_URID atom_eventTransfer;
LV2_URID atom_Blank;
@ -63,51 +61,13 @@ typedef struct SawUris @@ -63,51 +61,13 @@ typedef struct SawUris
LV2_URID time_frame;
LV2_URID time_speed;
/* custom URIs for communication */
LV2_URID saw_calcValues;
LV2_URID saw_freeValues;
} SawUris;
typedef enum PortIndex
{
/** GUI to plugin communication. */
SUPERSAW_CONTROL,
/** Plugin to UI communication. */
SUPERSAW_NOTIFY,
/** Amount for reverb + detune + number
* of saws. */
SUPERSAW_AMOUNT,
#if 0
/** Spacing of voices. */
SUPERSAW_WIDTH,
/** Voice blend. */
SUPERSAW_BLEND,
/** ADSR. */
SUPERSAW_ATTACK,
SUPERSAW_DECAY,
SUPERSAW_SUSTAIN,
SUPERSAW_RELEASE,
SUPERSAW_REVERB,
SUPERSAW_DISTORTION,
#endif
/** Outputs. */
SUPERSAW_STEREO_OUT_L,
SUPERSAW_STEREO_OUT_R,
NUM_PORTS,
} PortIndex;
} PluginUris;
/**
* Group of variables needed by both the DSP and
* the UI.
* Group of variables needed by all plugins and their
* UIs.
*/
typedef struct SawCommon
typedef struct PluginCommon
{
/** Log feature. */
LV2_Log_Log * log;
@ -125,17 +85,17 @@ typedef struct SawCommon @@ -125,17 +85,17 @@ typedef struct SawCommon
LV2_Atom_Forge forge;
/** URIs. */
SawUris uris;
PluginUris uris;
/** Plugin samplerate. */
double samplerate;
} SawCommon;
} PluginCommon;
static inline void
map_uris (
map_common_uris (
LV2_URID_Map* map,
SawUris* uris)
PluginUris* uris)
{
#define MAP(x,uri) \
uris->x = map->map (map->handle, uri)
@ -157,15 +117,32 @@ map_uris ( @@ -157,15 +117,32 @@ map_uris (
MAP (time_Position, LV2_TIME__Position);
MAP (time_bar, LV2_TIME__bar);
MAP (time_barBeat, LV2_TIME__barBeat);
MAP (
time_beatsPerMinute, LV2_TIME__beatsPerMinute);
MAP (time_beatsPerMinute, LV2_TIME__beatsPerMinute);
MAP (time_beatUnit, LV2_TIME__beatUnit);
MAP (time_frame, LV2_TIME__frame);
MAP (time_speed, LV2_TIME__speed);
/* custom URIs */
MAP (saw_freeValues, PLUGIN_URI "#freeValues");
MAP (saw_calcValues, PLUGIN_URI "#calcValues");
#undef MAP
}
/** Gets the samplerate form a plugin or UI. */
#define GET_SAMPLERATE(_x) \
((_x)->common.pl_common.samplerate)
/** Gets the samplerate form a plugin or UI. */
#define SET_SAMPLERATE(_x,rate) \
((_x)->common.pl_common.samplerate = rate)
#define PL_URIS(_x) \
(&(_x)->common.pl_common.uris)
#define URIS(_x) \
(&(_x)->common.uris)
#define SCHEDULE(_x) \
((_x)->common.pl_common.schedule)
#define FORGE(_x) \
(&(_x)->common.pl_common.forge)
#endif

22
plugins/compressor/compressor.c

@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
* along with ZPlugins. If not, see <https://www.gnu.org/licenses/>.
*/
#include PLUGIN_CONFIG
#include <float.h>
#include <math.h>
#include <stdlib.h>
@ -26,7 +28,7 @@ @@ -26,7 +28,7 @@
#include <sys/time.h>
#include "../math.h"
#include "common.h"
#include PLUGIN_COMMON
#include "soundpipe.h"
@ -62,7 +64,9 @@ instantiate ( @@ -62,7 +64,9 @@ instantiate (
{
Compressor * self = calloc (1, sizeof (Compressor));
self->common.samplerate = rate;
SET_SAMPLERATE (self, rate);
PluginCommon * pl_common = &self->common.pl_common;
#define HAVE_FEATURE(x) \
(!strcmp(features[i]->URI, x))
@ -71,34 +75,34 @@ instantiate ( @@ -71,34 +75,34 @@ instantiate (
{
if (HAVE_FEATURE (LV2_URID__map))
{
self->common.map =
pl_common->map =
(LV2_URID_Map*) features[i]->data;
}
else if (HAVE_FEATURE (LV2_LOG__log))
{
self->common.log =
pl_common->log =
(LV2_Log_Log *) features[i]->data;
}
}
#undef HAVE_FEATURE
if (!self->common.map)
if (!pl_common->map)
{
lv2_log_error (
&self->common.logger, "Missing feature urid:map\n");
&pl_common->logger, "Missing feature urid:map\n");
goto fail;
}
/* map uris */
map_uris (self->common.map, &self->common.uris);
map_uris (pl_common->map, &self->common);
/* init atom forge */
lv2_atom_forge_init (
&self->common.forge, self->common.map);
&pl_common->forge, pl_common->map);
/* init logger */
lv2_log_logger_init (
&self->common.logger, self->common.map, self->common.log);
&pl_common->logger, pl_common->map, pl_common->log);
return (LV2_Handle) self;

72
plugins/compressor/common.h → plugins/compressor/compressor_common.h

@ -23,38 +23,15 @@ @@ -23,38 +23,15 @@
* Common code for both the DSP and the UI.
*/
#ifndef __Z_COMMON_H__
#define __Z_COMMON_H__
#ifndef __Z_COMPRESSOR_COMMON_H__
#define __Z_COMPRESSOR_COMMON_H__
#include PLUGIN_CONFIG
#include <string.h>
#include "lv2/atom/atom.h"
#include "lv2/atom/forge.h"
#include "lv2/core/lv2.h"
#include "lv2/log/log.h"
#include "lv2/log/logger.h"
#include "lv2/midi/midi.h"
#include "lv2/urid/urid.h"
#include "lv2/time/time.h"
#include "lv2/worker/worker.h"
#include "../common.h"
typedef struct CompressorUris
{
LV2_URID atom_eventTransfer;
LV2_URID atom_Blank;
LV2_URID atom_Object;
LV2_URID atom_Float;
LV2_URID atom_Double;
LV2_URID atom_Int;
LV2_URID atom_Long;
LV2_URID log_Entry;
LV2_URID log_Error;
LV2_URID log_Note;
LV2_URID log_Trace;
LV2_URID log_Warning;
} CompressorUris;
typedef enum PortIndex
@ -84,51 +61,28 @@ typedef enum PortIndex @@ -84,51 +61,28 @@ typedef enum PortIndex
*/
typedef struct CompressorCommon
{
/** Log feature. */
LV2_Log_Log * log;
/** Map feature. */
LV2_URID_Map * map;
/** Logger convenience API. */
LV2_Log_Logger logger;
/** Atom forge. */
LV2_Atom_Forge forge;
/** URIs. */
CompressorUris uris;
/** Plugin samplerate. */
double samplerate;
PluginCommon pl_common;
} CompressorCommon;
static inline void
map_uris (
LV2_URID_Map* map,
CompressorUris* uris)
LV2_URID_Map* urid_map,
CompressorCommon * compressor_common)
{
map_common_uris (
urid_map, &compressor_common->pl_common.uris);
#define MAP(x,uri) \
uris->x = map->map (map->handle, uri)
/* official URIs */
MAP (atom_Blank, LV2_ATOM__Blank);
MAP (atom_Object, LV2_ATOM__Object);
MAP (atom_Float, LV2_ATOM__Float);
MAP (atom_Double, LV2_ATOM__Double);
MAP (atom_Int, LV2_ATOM__Int);
MAP (atom_Long, LV2_ATOM__Long);
MAP (atom_eventTransfer, LV2_ATOM__eventTransfer);
MAP (log_Entry, LV2_LOG__Entry);
MAP (log_Error, LV2_LOG__Error);
MAP (log_Note, LV2_LOG__Note);
MAP (log_Trace, LV2_LOG__Trace);
MAP (log_Warning, LV2_LOG__Warning);
compressor_common->uris.x = \
urid_map->map (urid_map->handle, uri)
/* custom URIs */
//MAP (saw_freeValues, PLUGIN_URI "#freeValues");
//MAP (saw_calcValues, PLUGIN_URI "#calcValues");
#undef MAP
}
#endif

2
plugins/compressor/ttl.h

@ -75,7 +75,7 @@ print_ttl (FILE * f) @@ -75,7 +75,7 @@ print_ttl (FILE * f)
lv2:AudioPort ;\n\
lv2:index 3 ;\n\
lv2:symbol \"stereo_in_r\" ;\n\
lv2:name \"Stereo In L\" ;\n\
lv2:name \"Stereo In R\" ;\n\
] , [\n\
a lv2:InputPort ,\n\
lv2:ControlPort ;\n\

4
plugins/meson.build

@ -70,7 +70,9 @@ foreach pl : plugins @@ -70,7 +70,9 @@ foreach pl : plugins
config_h_data.set_quoted (
'PLUGIN_TYPE', pl_type)
config_h_data.set_quoted (
'PLUGIN_COMMON', join_paths (pl_lowercase, 'common.h'))
'PLUGIN_COMMON',
join_paths (
pl_lowercase, pl_lowercase + '_common.h'))
config_h_data.set_quoted (
'PLUGIN_TTL_H', join_paths (pl_lowercase, 'ttl.h'))
config_h_data.set_quoted (

41
plugins/saw/saw.c

@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
* along with ZSaw. If not, see <https://www.gnu.org/licenses/>.
*/
#include PLUGIN_CONFIG
#include <float.h>
#include <math.h>
#include <stdlib.h>
@ -26,7 +28,7 @@ @@ -26,7 +28,7 @@
#include <sys/time.h>
#include "../math.h"
#include "common.h"
#include PLUGIN_COMMON
#include "soundpipe.h"
@ -276,8 +278,8 @@ work_response ( @@ -276,8 +278,8 @@ work_response (
self->common.uris.saw_freeValues },
values };
self->common.schedule->schedule_work (
self->common.schedule->handle,
SCHEDULE (self)->schedule_work (
SCHEDULE (self)->handle,
sizeof (msg), &msg);
/*lv2_log_note (*/
/*&self->common.logger, "inside work response\n");*/
@ -294,7 +296,9 @@ instantiate ( @@ -294,7 +296,9 @@ instantiate (
{
Saw * self = calloc (1, sizeof (Saw));
self->common.samplerate = rate;
SET_SAMPLERATE (self, rate);
PluginCommon * pl_common = &self->common.pl_common;
#define HAVE_FEATURE(x) \
(!strcmp(features[i]->URI, x))
@ -303,46 +307,46 @@ instantiate ( @@ -303,46 +307,46 @@ instantiate (
{
if (HAVE_FEATURE (LV2_URID__map))
{
self->common.map =
pl_common->map =
(LV2_URID_Map*) features[i]->data;
}
else if (HAVE_FEATURE (LV2_WORKER__schedule))
{
self->common.schedule =
pl_common->schedule =
(LV2_Worker_Schedule *) features[i]->data;
}
else if (HAVE_FEATURE (LV2_LOG__log))
{
self->common.log =
pl_common->log =
(LV2_Log_Log *) features[i]->data;
}
}
#undef HAVE_FEATURE
if (!self->common.map)
if (!pl_common->map)
{
lv2_log_error (
&self->common.logger, "Missing feature urid:map\n");
&pl_common->logger, "Missing feature urid:map\n");
goto fail;
}
else if (!self->common.schedule)
else if (!pl_common->schedule)
{
lv2_log_error (
&self->common.logger,
&pl_common->logger,
"Missing feature work:schedule\n");
goto fail;
}
/* map uris */
map_uris (self->common.map, &self->common.uris);
map_uris (pl_common->map, &self->common);
/* init atom forge */
lv2_atom_forge_init (
&self->common.forge, self->common.map);
&pl_common->forge, pl_common->map);
/* init logger */
lv2_log_logger_init (
&self->common.logger, self->common.map, self->common.log);
&pl_common->logger, pl_common->map, pl_common->log);
/* create synth */
srand (time (NULL));
@ -612,8 +616,8 @@ run ( @@ -612,8 +616,8 @@ run (
self->common.uris.saw_calcValues }
};
self->common.schedule->schedule_work (
self->common.schedule->handle,
SCHEDULE (self)->schedule_work (
SCHEDULE (self)->handle,
sizeof (msg), &msg);
/*lv2_log_note (*/
/*&self->common.logger, "scheduled to recalculate\n");*/
@ -623,8 +627,7 @@ run ( @@ -623,8 +627,7 @@ run (
LV2_ATOM_SEQUENCE_FOREACH (
self->control, ev)
{
if (ev->body.type ==
self->common.uris.midi_MidiEvent)
if (ev->body.type == PL_URIS (self)->midi_MidiEvent)
{
const uint8_t * const msg =
(const uint8_t *) (ev + 1);
@ -665,7 +668,7 @@ run ( @@ -665,7 +668,7 @@ run (
}
}
if (lv2_atom_forge_is_object_type (
&self->common.forge, ev->body.type))
FORGE (self), ev->body.type))
{
const LV2_Atom_Object * obj =
(const LV2_Atom_Object*)&ev->body;

107
plugins/saw/saw_common.h

@ -0,0 +1,107 @@ @@ -0,0 +1,107 @@
/*
* Copyright (C) 2020 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of ZPlugins
*
* ZPlugins is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* ZPlugins 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU General Affero Public License
* along with ZPlugins. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file
*
* Common code for both the DSP and the UI.
*/
#ifndef __Z_SAW_COMMON_H__
#define __Z_SAW_COMMON_H__
#include PLUGIN_CONFIG
#include <string.h>
#include "../common.h"
typedef struct SawUris
{
/* custom URIs for communication */
LV2_URID saw_calcValues;
LV2_URID saw_freeValues;
} SawUris;
typedef enum PortIndex
{
/** GUI to plugin communication. */
SUPERSAW_CONTROL,
/** Plugin to UI communication. */
SUPERSAW_NOTIFY,
/** Amount for reverb + detune + number
* of saws. */
SUPERSAW_AMOUNT,
#if 0
/** Spacing of voices. */
SUPERSAW_WIDTH,
/** Voice blend. */
SUPERSAW_BLEND,
/** ADSR. */
SUPERSAW_ATTACK,
SUPERSAW_DECAY,
SUPERSAW_SUSTAIN,
SUPERSAW_RELEASE,
SUPERSAW_REVERB,
SUPERSAW_DISTORTION,
#endif
/** Outputs. */
SUPERSAW_STEREO_OUT_L,
SUPERSAW_STEREO_OUT_R,
NUM_PORTS,
} PortIndex;
/**
* Group of variables needed by both the DSP and
* the UI.
*/
typedef struct SawCommon
{
/** URIs. */
SawUris uris;
PluginCommon pl_common;
} SawCommon;
static inline void
map_uris (
LV2_URID_Map* urid_map,
SawCommon * saw_common)
{
map_common_uris (
urid_map, &saw_common->pl_common.uris);
#define MAP(x,uri) \
saw_common->uris.x = \
urid_map->map (urid_map->handle, uri)
/* custom URIs */
MAP (saw_freeValues, PLUGIN_URI "#freeValues");
MAP (saw_calcValues, PLUGIN_URI "#calcValues");
#undef MAP
}
#endif

134
plugins/verb/common.h

@ -1,134 +0,0 @@ @@ -1,134 +0,0 @@
/*
* Copyright (C) 2020 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of ZPlugins
*
* ZPlugins is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* ZPlugins 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU General Affero Public License
* along with ZPlugins. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file
*
* Common code for both the DSP and the UI.
*/
#ifndef __Z_COMMON_H__
#define __Z_COMMON_H__
#include PLUGIN_CONFIG
#include <string.h>
#include "lv2/atom/atom.h"
#include "lv2/atom/forge.h"
#include "lv2/core/lv2.h"
#include "lv2/log/log.h"
#include "lv2/log/logger.h"
#include "lv2/midi/midi.h"
#include "lv2/urid/urid.h"
#include "lv2/time/time.h"
#include "lv2/worker/worker.h"
typedef struct CompressorUris
{
LV2_URID atom_eventTransfer;
LV2_URID atom_Blank;
LV2_URID atom_Object;
LV2_URID atom_Float;
LV2_URID atom_Double;
LV2_URID atom_Int;
LV2_URID atom_Long;
LV2_URID log_Entry;
LV2_URID log_Error;
LV2_URID log_Note;
LV2_URID log_Trace;
LV2_URID log_Warning;
} CompressorUris;
typedef enum PortIndex
{
/** GUI to plugin communication. */
COMPRESSOR_CONTROL,
/** Plugin to UI communication. */
COMPRESSOR_NOTIFY,
COMPRESSOR_STEREO_IN_L,
COMPRESSOR_STEREO_IN_R,
COMPRESSOR_ATTACK,
COMPRESSOR_RELEASE,
COMPRESSOR_RATIO,
COMPRESSOR_THRESHOLD,
/** Outputs. */
COMPRESSOR_STEREO_OUT_L,
COMPRESSOR_STEREO_OUT_R,
NUM_PORTS,
} PortIndex;
/**
* Group of variables needed by both the DSP and
* the UI.
*/
typedef struct CompressorCommon
{
/** Log feature. */
LV2_Log_Log * log;
/** Map feature. */
LV2_URID_Map * map;
/** Logger convenience API. */
LV2_Log_Logger logger;
/** Atom forge. */
LV2_Atom_Forge forge;
/** URIs. */
CompressorUris uris;
/** Plugin samplerate. */
double samplerate;
} CompressorCommon;
static inline void
map_uris (
LV2_URID_Map* map,
CompressorUris* uris)
{
#define MAP(x,uri) \
uris->x = map->map (map->handle, uri)
/* official URIs */
MAP (atom_Blank, LV2_ATOM__Blank);
MAP (atom_Object, LV2_ATOM__Object);
MAP (atom_Float, LV2_ATOM__Float);
MAP (atom_Double, LV2_ATOM__Double);
MAP (atom_Int, LV2_ATOM__Int);
MAP (atom_Long, LV2_ATOM__Long);
MAP (atom_eventTransfer, LV2_ATOM__eventTransfer);
MAP (log_Entry, LV2_LOG__Entry);
MAP (log_Error, LV2_LOG__Error);
MAP (log_Note, LV2_LOG__Note);
MAP (log_Trace, LV2_LOG__Trace);
MAP (log_Warning, LV2_LOG__Warning);
/* custom URIs */
//MAP (saw_freeValues, PLUGIN_URI "#freeValues");
//MAP (saw_calcValues, PLUGIN_URI "#calcValues");
}
#endif

148
plugins/verb/ttl.h

@ -75,69 +75,167 @@ print_ttl (FILE * f) @@ -75,69 +75,167 @@ print_ttl (FILE * f)
lv2:AudioPort ;\n\
lv2:index 3 ;\n\
lv2:symbol \"stereo_in_r\" ;\n\
lv2:name \"Stereo In L\" ;\n\
] , [\n\
lv2:name \"Stereo In R\" ;\n\
] , [\n");
fprintf (f, "\
a lv2:InputPort ,\n\
lv2:ControlPort ;\n\
lv2:index 4 ;\n\
lv2:symbol \"attack\" ;\n\
lv2:name \"Attack\" ;\n\
lv2:symbol \"in_delay\" ;\n\
lv2:name \"Pre-delay\" ;\n\
lv2:default %f ;\n\
lv2:minimum %f ;\n\
lv2:maximum %f ;\n\
lv2:portProperty pprop:logarithmic; \n\
rdfs:comment \"Compressor attack\" ;\n\
units:unit units:ms ;\n\
rdfs:comment \"Delay in ms before reverberation begins\" ;\n\
] , [\n\
a lv2:InputPort ,\n\
lv2:ControlPort ;\n\
lv2:index 5 ;\n\
lv2:symbol \"release\" ;\n\
lv2:name \"Release\" ;\n\
lv2:symbol \"lf_x\" ;\n\
lv2:name \"Low freq crossover\" ;\n\
lv2:default %f ;\n\
lv2:minimum %f ;\n\
lv2:maximum %f ;\n\
lv2:portProperty pprop:logarithmic; \n\
rdfs:comment \"Compressor release\" ;\n\
units:unit units:hz ;\n\
rdfs:comment \"Crossover frequency separating low and middle frequencies\" ;\n\
] , [\n\
a lv2:InputPort ,\n\
lv2:ControlPort ;\n\
lv2:index 6 ;\n\
lv2:symbol \"ratio\" ;\n\
lv2:name \"Ratio\" ;\n\
lv2:symbol \"rt60_low\" ;\n\
lv2:name \"Low freq decay\" ;\n\
lv2:default %f ;\n\
lv2:minimum %f ;\n\
lv2:maximum %f ;\n\
rdfs:comment \"Ratio to compress with. A value > 1 will compress\" ;\n\
units:unit units:s ;\n\
rdfs:comment \"Time to decay 60db in low-frequency band\" ;\n\
] , [\n\
a lv2:InputPort ,\n\
lv2:ControlPort ;\n\
lv2:index 7 ;\n\
lv2:symbol \"threshold\" ;\n\
lv2:name \"Threshold\" ;\n\
lv2:symbol \"rt60_mid\" ;\n\
lv2:name \"Mid freq decay\" ;\n\
lv2:default %f ;\n\
lv2:minimum %f ;\n\
lv2:maximum %f ;\n\
units:unit units:s ;\n\
rdfs:comment \"Time to decay 60db in mid-frequency band\" ;\n\
] , [\n\
a lv2:InputPort ,\n\
lv2:ControlPort ;\n\
lv2:index 8 ;\n\
lv2:symbol \"hf_damping\" ;\n\
lv2:name \"High freq damping\" ;\n\
lv2:default %f ;\n\
lv2:minimum %f ;\n\
lv2:maximum %f ;\n\
lv2:portProperty pprop:logarithmic; \n\
units:unit units:hz ;\n\
rdfs:comment \"Frequency at which the high-frequency T60 is half the middle-band's T60\" ;\n\
] , [\n\
a lv2:InputPort ,\n\
lv2:ControlPort ;\n\
lv2:index 9 ;\n\
lv2:symbol \"eq1_freq\" ;\n\
lv2:name \"EQ1 freq\" ;\n\
lv2:default %f ;\n\
lv2:minimum %f ;\n\
lv2:maximum %f ;\n\
lv2:portProperty pprop:logarithmic; \n\
units:unit units:hz ;\n\
rdfs:comment \"Center frequency of second-order Regalia Mitra peaking equalizer section 1\" ;\n\
] , [\n\
a lv2:InputPort ,\n\
lv2:ControlPort ;\n\
lv2:index 10 ;\n\
lv2:symbol \"eq1_level\" ;\n\
lv2:name \"EQ1 level\" ;\n\
lv2:default %f ;\n\
lv2:minimum %f ;\n\
lv2:maximum %f ;\n\
units:unit units:db ;\n\
rdfs:comment \"Threshold (in dB) 0 = max\" ;\n\
rdfs:comment \"Peak level of second-order Regalia-Mitra peaking equalizer section 1\" ;\n\
] , [\n\
a lv2:InputPort ,\n\
lv2:ControlPort ;\n\
lv2:index 11 ;\n\
lv2:symbol \"eq2_freq\" ;\n\
lv2:name \"EQ2 freq\" ;\n\
lv2:default %f ;\n\
lv2:minimum %f ;\n\
lv2:maximum %f ;\n\
lv2:portProperty pprop:logarithmic; \n\
units:unit units:hz ;\n\
rdfs:comment \"Center frequency of second-order Regalia Mitra peaking equalizer section 2\" ;\n\
] , [\n\
a lv2:InputPort ,\n\
lv2:ControlPort ;\n\
lv2:index 12 ;\n\
lv2:symbol \"eq2_level\" ;\n\
lv2:name \"EQ2 level\" ;\n\
lv2:default %f ;\n\
lv2:minimum %f ;\n\
lv2:maximum %f ;\n\
units:unit units:db ;\n\
rdfs:comment \"Peak level of second-order Regalia-Mitra peaking equalizer section 2\" ;\n\
] , [\n\
a lv2:InputPort ,\n\
lv2:ControlPort ;\n\
lv2:index 13 ;\n\
lv2:symbol \"wet\" ;\n\
lv2:name \"Wet\" ;\n\
lv2:default %f ;\n\
lv2:minimum %f ;\n\
lv2:maximum %f ;\n\
rdfs:comment \"0 = all dry, 1 = all wet\" ;\n\
] , [\n\
a lv2:InputPort ,\n\
lv2:ControlPort ;\n\
lv2:index 14 ;\n\
lv2:symbol \"level\" ;\n\
lv2:name \"Level\" ;\n\
lv2:default %f ;\n\
lv2:minimum %f ;\n\
lv2:maximum %f ;\n\
units:unit units:db ;\n\
rdfs:comment \"Output scale factor\" ;\n\
] , [\n\
a lv2:OutputPort ,\n\
lv2:AudioPort ;\n\
lv2:index 8 ;\n\
lv2:index 15 ;\n\
lv2:symbol \"stereo_out_l\" ;\n\
lv2:name \"Stereo Out L\" ;\n\
] , [\n\
a lv2:OutputPort ,\n\
lv2:AudioPort ;\n\
lv2:index 9 ;\n\
lv2:index 16 ;\n\
lv2:symbol \"stereo_out_r\" ;\n\
lv2:name \"Stereo Out R\" ;\n\
] .\n",
/* attack */
0.1, 0.000001, 10.0,
/* release */
0.1, 0.000001, 10.0,
/* ratio */
1.0, 1.0, 40.0,
/* threshold */
0.0, -80.0, 0.0);
/* predelay */
40.0, 10.0, 100.0,
/* low freq crossover */
200.0, 50.0, 1000.0,
/* decay low */
3.0, 1.0, 8.0,
/* decay mid */
2.0, 1.0, 8.0,
/* hf damping */
6000.0, 1500.0, 47040.0,
/* eq1 freq */
315.0, 40.0, 2500.0,
/* eq1 level */
0.0, -15.0, 15.0,
/* eq2 freq */
1500.0, 160.0, 12000.0,
/* eq2 level */
0.0, -15.0, 15.0,
/* wet */
1.0, 0.0, 1.0,
/* level */
-20.0, -70.0, 20.0
);
}

141
plugins/verb/verb.c

@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
* along with ZPlugins. If not, see <https://www.gnu.org/licenses/>.
*/
#include PLUGIN_CONFIG
#include <float.h>
#include <math.h>
#include <stdlib.h>
@ -26,32 +28,39 @@ @@ -26,32 +28,39 @@
#include <sys/time.h>
#include "../math.h"
#include "common.h"
#include PLUGIN_COMMON
#include "soundpipe.h"
typedef struct Compressor
typedef struct Verb
{
/** Plugin ports. */
const LV2_Atom_Sequence* control;
LV2_Atom_Sequence* notify;
const float * stereo_in_l;
const float * stereo_in_r;
const float * attack;
const float * release;
const float * ratio;
const float * threshold;
const float * predelay;
const float * low_freq_x;
const float * decay_60_low;
const float * decay_60_mid;
const float * hf_damping;
const float * eq1_freq;
const float * eq1_level;
const float * eq2_freq;
const float * eq2_level;
const float * wet;
const float * level;
/* outputs */
float * stereo_out_l;
float * stereo_out_r;
CompressorCommon common;
VerbCommon common;
sp_data * sp;
sp_compressor * compressor;
sp_zitarev * rev;
} Compressor;
} Verb;
static LV2_Handle
instantiate (
@ -60,9 +69,11 @@ instantiate ( @@ -60,9 +69,11 @@ instantiate (
const char* bundle_path,
const LV2_Feature* const* features)
{
Compressor * self = calloc (1, sizeof (Compressor));
Verb * self = calloc (1, sizeof (Verb));
SET_SAMPLERATE (self, rate);
self->common.samplerate = rate;
PluginCommon * pl_common = &self->common.pl_common;
#define HAVE_FEATURE(x) \
(!strcmp(features[i]->URI, x))
@ -71,34 +82,34 @@ instantiate ( @@ -71,34 +82,34 @@ instantiate (
{
if (HAVE_FEATURE (LV2_URID__map))
{
self->common.map =
pl_common->map =
(LV2_URID_Map*) features[i]->data;
}
else if (HAVE_FEATURE (LV2_LOG__log))
{
self->common.log =
pl_common->log =
(LV2_Log_Log *) features[i]->data;
}
}
#undef HAVE_FEATURE
if (!self->common.map)
if (!pl_common->map)
{
lv2_log_error (
&self->common.logger, "Missing feature urid:map\n");
&pl_common->logger, "Missing feature urid:map\n");
goto fail;
}
/* map uris */
map_uris (self->common.map, &self->common.uris);
map_uris (pl_common->map, &self->common);
/* init atom forge */
lv2_atom_forge_init (
&self->common.forge, self->common.map);
&pl_common->forge, pl_common->map);
/* init logger */
lv2_log_logger_init (
&self->common.logger, self->common.map, self->common.log);
&pl_common->logger, pl_common->map, pl_common->log);
return (LV2_Handle) self;
@ -113,40 +124,40 @@ connect_port ( @@ -113,40 +124,40 @@ connect_port (
uint32_t port,
void * data)
{
Compressor * self = (Compressor *) instance;
Verb * self = (Verb *) instance;
#define SET_FLOAT_INPUT(caps,sc) \
case VERB_##caps: \
self->sc = (const float *) data; \
break
switch ((PortIndex) port)
{
case COMPRESSOR_CONTROL:
case VERB_CONTROL:
self->control =
(const LV2_Atom_Sequence *) data;
break;
case COMPRESSOR_NOTIFY:
case VERB_NOTIFY:
self->notify =
(LV2_Atom_Sequence *) data;
break;
case COMPRESSOR_STEREO_IN_L:
self->stereo_in_l = (const float *) data;
break;
case COMPRESSOR_STEREO_IN_R:
self->stereo_in_r = (const float *) data;
break;
case COMPRESSOR_ATTACK:
self->attack = (const float *) data;
break;
case COMPRESSOR_RELEASE:
self->release = (const float *) data;
break;
case COMPRESSOR_RATIO:
self->ratio = (const float *) data;
break;
case COMPRESSOR_THRESHOLD:
self->threshold = (const float *) data;
break;
case COMPRESSOR_STEREO_OUT_L:
SET_FLOAT_INPUT (STEREO_IN_L, stereo_in_l);
SET_FLOAT_INPUT (STEREO_IN_R, stereo_in_r);
SET_FLOAT_INPUT (PREDELAY, predelay);
SET_FLOAT_INPUT (LOW_FREQ_CROSSOVER, low_freq_x);
SET_FLOAT_INPUT (DECAY_60_LOW, decay_60_low);
SET_FLOAT_INPUT (DECAY_60_MID, decay_60_mid);
SET_FLOAT_INPUT (HF_DAMPING, hf_damping);
SET_FLOAT_INPUT (EQ1_FREQ, eq1_freq);
SET_FLOAT_INPUT (EQ1_LEVEL, eq1_level);
SET_FLOAT_INPUT (EQ2_FREQ, eq2_freq);
SET_FLOAT_INPUT (EQ2_LEVEL, eq2_level);
SET_FLOAT_INPUT (WET, wet);
SET_FLOAT_INPUT (LEVEL, level);
case VERB_STEREO_OUT_L:
self->stereo_out_l = (float *) data;
break;
case COMPRESSOR_STEREO_OUT_R:
case VERB_STEREO_OUT_R:
self->stereo_out_r = (float *) data;
break;
default:
@ -158,11 +169,11 @@ static void @@ -158,11 +1