nonfunctional stubs, lots of (void)s, compiles cleanly

This commit is contained in:
Gordon JC Pearce 2023-06-19 21:39:23 +01:00
parent 28b6dcb1ef
commit e14f0ded1a
7 changed files with 169 additions and 279 deletions

View File

@ -66,8 +66,6 @@ DistrhoPluginNekobi::DistrhoPluginNekobi()
fSynth.nugget_remains = 0;
fSynth.note_id = 0;
fSynth.polyphony = XSYNTH_DEFAULT_POLYPHONY;
fSynth.voices = XSYNTH_DEFAULT_POLYPHONY;
fSynth.monophonic = XSYNTH_MONO_MODE_ONCE;
fSynth.glide = 0;
fSynth.last_noteon_pitch = 0.0f;

View File

@ -1,77 +0,0 @@
/* nekobee DSSI software synthesizer plugin
*
* Copyright (C) 2004 Sean Bolton and others.
*
* Portions of this file may have come from Chris Cannam and Steve
* Harris's public domain DSSI example code.
*
* This program 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; either version 2 of
* the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA.
*/
#ifndef _XSYNTH_H
#define _XSYNTH_H
/* ==== debugging ==== */
/* XSYNTH_DEBUG bits */
#define XDB_DSSI 1 /* DSSI interface */
#define XDB_AUDIO 2 /* audio output */
#define XDB_NOTE 4 /* note on/off, voice allocation */
#define XDB_DATA 8 /* plugin patchbank handling */
#define GDB_MAIN 16 /* GUI main program flow */
#define GDB_OSC 32 /* GUI OSC handling */
#define GDB_IO 64 /* GUI patch file input/output */
#define GDB_GUI 128 /* GUI GUI callbacks, updating, etc. */
/* If you want debug information, define XSYNTH_DEBUG to the XDB_* bits you're
* interested in getting debug information about, bitwise-ORed together.
* Otherwise, leave it undefined. */
// #define XSYNTH_DEBUG (1+8+16+32+64)
//#define XSYNTH_DEBUG GDB_GUI + GDB_OSC
// #define XSYNTH_DEBUG XDB_DSSI
#ifdef XSYNTH_DEBUG
#include <stdio.h>
#define XSYNTH_DEBUG_INIT(x)
#define XDB_MESSAGE(type, fmt...) { if (XSYNTH_DEBUG & type) fprintf(stderr, "nekobee-dssi.so" fmt); }
#define GDB_MESSAGE(type, fmt...) { if (XSYNTH_DEBUG & type) fprintf(stderr, "nekobee_gtk" fmt); }
// -FIX-:
// #include "message_buffer.h"
// #define XSYNTH_DEBUG_INIT(x) mb_init(x)
// #define XDB_MESSAGE(type, fmt...) { \-
// if (XSYNTH_DEBUG & type) { \-
// char _m[256]; \-
// snprintf(_m, 255, fmt); \-
// add_message(_m); \-
// } \-
// }
#else /* !XSYNTH_DEBUG */
#define XDB_MESSAGE(type, fmt, ...)
#define GDB_MESSAGE(type, fmt, ...)
#define XSYNTH_DEBUG_INIT(x)
#endif /* XSYNTH_DEBUG */
/* ==== end of debugging ==== */
#define XSYNTH_MAX_POLYPHONY 1
#define XSYNTH_DEFAULT_POLYPHONY 1
#endif /* _XSYNTH_H */

View File

@ -25,13 +25,13 @@
* MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "nekobee.h"
#include "nekobee_synth.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "nekobee_voice.h"
/*
@ -39,19 +39,13 @@
*
* stop processing all notes immediately
*/
void
nekobee_synth_all_voices_off(nekobee_synth_t *synth)
{
void nekobee_synth_all_voices_off(nekobee_synth_t *synth) {
int i;
nekobee_voice_t *voice;
for (i = 0; i < synth->voices; i++) {
//voice = synth->voice[i];
voice = synth->voice;
nekobee_voice_t *voice = synth->voice;
if (_PLAYING(voice)) {
nekobee_voice_off(voice);
}
}
for (i = 0; i < 8; i++) synth->held_keys[i] = -1;
}
@ -60,23 +54,16 @@ nekobee_synth_all_voices_off(nekobee_synth_t *synth)
*
* handle a note off message
*/
void
nekobee_synth_note_off(nekobee_synth_t *synth, unsigned char key, unsigned char rvelocity)
{
int i, count = 0;
nekobee_voice_t *voice;
for (i = 0; i < synth->voices; i++) {
voice = synth->voice;
void nekobee_synth_note_off(nekobee_synth_t *synth, unsigned char key,
unsigned char rvelocity) {
int count = 0;
nekobee_voice_t *voice = synth->voice;
if (_PLAYING(voice)) {
XDB_MESSAGE(XDB_NOTE, " nekobee_synth_note_off: key %d rvel %d voice %d note id %d\n", key, rvelocity, i, voice->note_id);
nekobee_voice_note_off(synth, voice, key, 64);
count++;
}
}
if (!count)
nekobee_voice_remove_held_key(synth, key);
if (!count) nekobee_voice_remove_held_key(synth, key);
return;
(void)rvelocity;
@ -87,34 +74,28 @@ nekobee_synth_note_off(nekobee_synth_t *synth, unsigned char key, unsigned char
*
* put all notes into the released state
*/
void
nekobee_synth_all_notes_off(nekobee_synth_t* synth)
{
int i;
nekobee_voice_t *voice;
void nekobee_synth_all_notes_off(nekobee_synth_t *synth) {
nekobee_voice_t *voice = synth->voice;
/* reset the sustain controller */
synth->cc[MIDI_CTL_SUSTAIN] = 0;
for (i = 0; i < synth->voices; i++) {
//voice = synth->voice[i];
voice = synth->voice;
if (_ON(voice) || _SUSTAINED(voice)) {
nekobee_voice_release_note(synth, voice);
}
}
}
/*
* nekobee_synth_note_on
*/
void
nekobee_synth_note_on(nekobee_synth_t *synth, unsigned char key, unsigned char velocity)
{
nekobee_voice_t* voice;
void nekobee_synth_note_on(nekobee_synth_t *synth, unsigned char key,
unsigned char velocity) {
nekobee_voice_t *voice;
voice = synth->voice;
if (_PLAYING(synth->voice)) {
XDB_MESSAGE(XDB_NOTE, " nekobee_synth_note_on: retriggering mono voice on new key %d\n", key);
// XDB_MESSAGE(XDB_NOTE, " nekobee_synth_note_on: retriggering mono
// voice on new key %d\n", key);
}
voice->note_id = synth->note_id++;
@ -125,26 +106,23 @@ nekobee_synth_note_on(nekobee_synth_t *synth, unsigned char key, unsigned char v
/*
* nekobee_synth_update_volume
*/
void
nekobee_synth_update_volume(nekobee_synth_t* synth)
{
void nekobee_synth_update_volume(nekobee_synth_t *synth) {
synth->cc_volume = (float)(synth->cc[MIDI_CTL_MSB_MAIN_VOLUME] * 128 +
synth->cc[MIDI_CTL_LSB_MAIN_VOLUME]) / 16256.0f;
if (synth->cc_volume > 1.0f)
synth->cc_volume = 1.0f;
/* don't need to check if any playing voices need updating, because it's global */
synth->cc[MIDI_CTL_LSB_MAIN_VOLUME]) /
16256.0f;
if (synth->cc_volume > 1.0f) synth->cc_volume = 1.0f;
/* don't need to check if any playing voices need updating, because it's
* global */
}
/*
* nekobee_synth_control_change
*/
void
nekobee_synth_control_change(nekobee_synth_t *synth, unsigned int param, signed int value)
{
void nekobee_synth_control_change(nekobee_synth_t *synth, unsigned int param,
signed int value) {
synth->cc[param] = value;
switch (param) {
case MIDI_CTL_MSB_MAIN_VOLUME:
case MIDI_CTL_LSB_MAIN_VOLUME:
nekobee_synth_update_volume(synth);
@ -180,9 +158,7 @@ nekobee_synth_control_change(nekobee_synth_t *synth, unsigned int param, signed
/*
* nekobee_synth_init_controls
*/
void
nekobee_synth_init_controls(nekobee_synth_t *synth)
{
void nekobee_synth_init_controls(nekobee_synth_t *synth) {
int i;
for (i = 0; i < 128; i++) {
@ -196,41 +172,45 @@ nekobee_synth_init_controls(nekobee_synth_t *synth)
/*
* nekobee_synth_render_voices
*/
void
nekobee_synth_render_voices(nekobee_synth_t *synth, float *out, unsigned long sample_count,
int do_control_update)
{
void nekobee_synth_render_voices(nekobee_synth_t *synth, float *out,
unsigned long sample_count,
int do_control_update) {
unsigned long i;
float res, wow;
/* clear the buffer */
for (i = 0; i < sample_count; i++)
out[i] = 0.0f;
for (i = 0; i < sample_count; i++) out[i] = 0.0f;
// we can do anything that must be updated all the time here
// this is called even when a voice isn't playing
// approximate a log scale
res = 1-synth->resonance;
wow = res*res;
wow = wow/10.0f;
res = 1 - synth->resonance;
wow = res * res;
wow = wow / 10.0f;
// as the resonance is increased, "wow" slows down the accent attack
if ((synth->voice->velocity>90) && (synth->vcf_accent < synth->voice->vcf_eg)) {
synth->vcf_accent=(0.985-wow)*synth->vcf_accent+(0.015+wow)*synth->voice->vcf_eg;
if ((synth->voice->velocity > 90) &&
(synth->vcf_accent < synth->voice->vcf_eg)) {
synth->vcf_accent = (0.985 - wow) * synth->vcf_accent +
(0.015 + wow) * synth->voice->vcf_eg;
} else {
synth->vcf_accent=(0.985-wow)*synth->vcf_accent; // or just decay
synth->vcf_accent = (0.985 - wow) * synth->vcf_accent; // or just decay
}
if (synth->voice->velocity>90) {
synth->vca_accent=0.95*synth->vca_accent+0.05; // ramp up accent on with a time constant
if (synth->voice->velocity > 90) {
synth->vca_accent = 0.95 * synth->vca_accent +
0.05; // ramp up accent on with a time constant
} else {
synth->vca_accent=0.95*synth->vca_accent; // accent off with time constant
synth->vca_accent =
0.95 * synth->vca_accent; // accent off with time constant
}
#if defined(XSYNTH_DEBUG) && (XSYNTH_DEBUG & XDB_AUDIO)
out[0] += 0.10f; /* add a 'buzz' to output so there's something audible even when quiescent */
out[0] += 0.10f; /* add a 'buzz' to output so there's something audible even
when quiescent */
#endif /* defined(XSYNTH_DEBUG) && (XSYNTH_DEBUG & XDB_AUDIO) */
if (_PLAYING(synth->voice)) {
nekobee_voice_render(synth, synth->voice, out, sample_count, do_control_update);
nekobee_voice_render(synth, out, sample_count);
}
(void)do_control_update;
}

View File

@ -26,7 +26,6 @@
#ifndef _XSYNTH_SYNTH_H
#define _XSYNTH_SYNTH_H
#include "nekobee.h"
#include "nekobee_types.h"
#define XSYNTH_MONO_MODE_OFF 0
@ -51,8 +50,6 @@ struct _nekobee_synth_t {
/* voice tracking and data */
unsigned int note_id; /* incremented for every new note, used for voice-stealing prioritization */
int polyphony; /* requested polyphony, must be <= XSYNTH_MAX_POLYPHONY */
int voices; /* current polyphony, either requested polyphony above or 1 while in monophonic mode */
int monophonic; /* true if operating in monophonic mode */
int glide; /* current glide mode */
float last_noteon_pitch; /* glide start pitch for non-legato modes */
@ -60,7 +57,6 @@ struct _nekobee_synth_t {
float vcf_accent; /* used to emulate the circuit that sweeps the vcf at full resonance */
float vca_accent; /* used to smooth the accent pulse, removing the click */
//nekobee_voice_t *voice[XSYNTH_MAX_POLYPHONY];
nekobee_voice_t *voice;
/* current non-paramter-mapped controller values */

View File

@ -30,7 +30,6 @@
#include <stdlib.h>
#include "nekobee_types.h"
#include "nekobee.h"
#include "nekobee_synth.h"
#include "nekobee_voice.h"
@ -57,7 +56,6 @@ nekobee_voice_note_on(nekobee_synth_t *synth, nekobee_voice_t *voice,
unsigned char key, unsigned char velocity)
{
int i;
voice->key = key;
voice->velocity = velocity;
@ -65,7 +63,6 @@ nekobee_voice_note_on(nekobee_synth_t *synth, nekobee_voice_t *voice,
if (!synth->monophonic || !(_ON(voice) || _SUSTAINED(voice))) {
// brand-new voice, or monophonic voice in release phase; set everything up
XDB_MESSAGE(XDB_NOTE, " nekobee_voice_note_on in polyphonic/new section: key %d, mono %d, old status %d\n", key, synth->monophonic, voice->status);
voice->target_pitch = nekobee_pitch[key];
@ -97,7 +94,6 @@ nekobee_voice_note_on(nekobee_synth_t *synth, nekobee_voice_t *voice,
} else {
/* synth is monophonic, and we're modifying a playing voice */
XDB_MESSAGE(XDB_NOTE, " nekobee_voice_note_on in monophonic section: old key %d => new key %d\n", synth->held_keys[0], key);
/* set new pitch */
voice->target_pitch = nekobee_pitch[key];
@ -184,8 +180,6 @@ nekobee_voice_note_off(nekobee_synth_t *synth, nekobee_voice_t *voice,
{
unsigned char previous_top_key;
XDB_MESSAGE(XDB_NOTE, " nekobee_set_note_off: called for voice %p, key %d\n", voice, key);
/* save release velocity */
voice->velocity = rvelocity;
@ -202,7 +196,6 @@ nekobee_voice_note_off(nekobee_synth_t *synth, nekobee_voice_t *voice,
/* most-recently-played key has changed */
voice->key = synth->held_keys[0];
XDB_MESSAGE(XDB_NOTE, " note-off in monophonic section: changing pitch to %d\n", voice->key);
voice->target_pitch = nekobee_pitch[voice->key];
if (synth->glide == XSYNTH_GLIDE_MODE_INITIAL ||
synth->glide == XSYNTH_GLIDE_MODE_OFF)
@ -221,14 +214,12 @@ nekobee_voice_note_off(nekobee_synth_t *synth, nekobee_voice_t *voice,
if (XSYNTH_SYNTH_SUSTAINED(synth)) {
/* no more keys in list, but we're sustained */
XDB_MESSAGE(XDB_NOTE, " note-off in monophonic section: sustained with no held keys\n");
if (!_RELEASED(voice))
voice->status = XSYNTH_VOICE_SUSTAINED;
} else { /* not sustained */
/* no more keys in list, so turn off note */
XDB_MESSAGE(XDB_NOTE, " note-off in monophonic section: turning off voice %p\n", voice);
nekobee_voice_set_release_phase(voice);
voice->status = XSYNTH_VOICE_RELEASED;
@ -243,7 +234,6 @@ nekobee_voice_note_off(nekobee_synth_t *synth, nekobee_voice_t *voice,
void
nekobee_voice_release_note(nekobee_synth_t *synth, nekobee_voice_t *voice)
{
XDB_MESSAGE(XDB_NOTE, " nekobee_voice_release_note: turning off voice %p\n", voice);
if (_ON(voice)) {
/* dummy up a release velocity */
voice->rvelocity = 64;

View File

@ -27,6 +27,7 @@
#define _XSYNTH_VOICE_H
#include <string.h>
#include <stdint.h>
#include "nekobee_types.h"
@ -50,8 +51,7 @@
/* delay between start of DD pulse and the discontinuity, in samples: */
#define DD_SAMPLE_DELAY 4
struct _nekobee_patch_t
{
struct _nekobee_patch_t {
float tuning;
unsigned char waveform;
float cutoff;
@ -62,16 +62,16 @@ struct _nekobee_patch_t
float volume;
};
enum nekobee_voice_status
{
enum nekobee_voice_status {
XSYNTH_VOICE_OFF, /* silent: is not processed by render loop */
XSYNTH_VOICE_ON, /* has not received a note off event */
XSYNTH_VOICE_SUSTAINED, /* has received note off, but sustain controller is on */
XSYNTH_VOICE_RELEASED /* had note off, not sustained, in final decay phase of envelopes */
XSYNTH_VOICE_SUSTAINED, /* has received note off, but sustain controller is
on */
XSYNTH_VOICE_RELEASED /* had note off, not sustained, in final decay phase
of envelopes */
};
struct blosc
{
struct blosc {
int last_waveform, /* persistent */
waveform, /* comes from LADSPA port each cycle */
bp_high; /* persistent */
@ -82,8 +82,7 @@ struct blosc
/*
* nekobee_voice_t
*/
struct _nekobee_voice_t
{
struct _nekobee_voice_t {
unsigned int note_id;
unsigned char status;
@ -95,20 +94,10 @@ struct _nekobee_voice_t
float pressure; /* filter resonance multiplier, off = 1.0, full on = 0.0 */
/* persistent voice state */
float prev_pitch,
target_pitch,
lfo_pos;
float prev_pitch, target_pitch, lfo_pos;
struct blosc osc1;
float vca_eg,
vcf_eg,
accent_slug,
delay1,
delay2,
delay3,
delay4,
c5;
unsigned char vca_eg_phase,
vcf_eg_phase;
float vca_eg, vcf_eg, accent_slug, delay1, delay2, delay3, delay4, c5;
unsigned char vca_eg_phase, vcf_eg_phase;
int osc_index; /* shared index into osc_audio */
float osc_audio[MINBLEP_BUFFER_LENGTH];
float freqcut_buf[XSYNTH_NUGGET_SIZE];
@ -123,35 +112,29 @@ struct _nekobee_voice_t
extern float nekobee_pitch[128];
typedef struct { float value, delta; } float_value_delta;
typedef struct {
float value, delta;
} float_value_delta;
extern float_value_delta step_dd_table[];
extern float slope_dd_table[];
/* nekobee_voice.c */
nekobee_voice_t *nekobee_voice_new();
void nekobee_voice_note_on(nekobee_synth_t *synth,
nekobee_voice_t *voice,
unsigned char key,
unsigned char velocity);
void nekobee_voice_remove_held_key(nekobee_synth_t *synth,
unsigned char key);
void nekobee_voice_note_off(nekobee_synth_t *synth,
nekobee_voice_t *voice,
unsigned char key,
unsigned char rvelocity);
void nekobee_voice_release_note(nekobee_synth_t *synth,
nekobee_voice_t *voice);
void nekobee_voice_set_ports(nekobee_synth_t *synth,
nekobee_patch_t *patch);
void nekobee_voice_note_on(nekobee_synth_t *synth, nekobee_voice_t *voice,
unsigned char key, unsigned char velocity);
void nekobee_voice_remove_held_key(nekobee_synth_t *synth, unsigned char key);
void nekobee_voice_note_off(nekobee_synth_t *synth, nekobee_voice_t *voice,
unsigned char key, unsigned char rvelocity);
void nekobee_voice_release_note(nekobee_synth_t *synth, nekobee_voice_t *voice);
void nekobee_voice_set_ports(nekobee_synth_t *synth, nekobee_patch_t *patch);
void nekobee_voice_update_pressure_mod(nekobee_synth_t *synth,
nekobee_voice_t *voice);
/* nekobee_voice_render.c */
void nekobee_init_tables(void);
void nekobee_voice_render(nekobee_synth_t *synth, nekobee_voice_t *voice,
float *out, unsigned long sample_count,
int do_control_update);
void nekobee_voice_render(nekobee_synth_t *synth, float *out,
uint32_t count);
/* inline functions */
@ -161,9 +144,7 @@ void nekobee_voice_render(nekobee_synth_t *synth, nekobee_voice_t *voice,
* Purpose: Turns off a voice immediately, meaning that it is not processed
* anymore by the render loop.
*/
static inline void
nekobee_voice_off(nekobee_voice_t* voice)
{
static inline void nekobee_voice_off(nekobee_voice_t *voice) {
voice->status = XSYNTH_VOICE_OFF;
/* silence the oscillator buffer for the next use */
memset(voice->osc_audio, 0, MINBLEP_BUFFER_LENGTH * sizeof(float));
@ -173,9 +154,7 @@ nekobee_voice_off(nekobee_voice_t* voice)
/*
* nekobee_voice_start_voice
*/
static inline void
nekobee_voice_start_voice(nekobee_voice_t *voice)
{
static inline void nekobee_voice_start_voice(nekobee_voice_t *voice) {
voice->status = XSYNTH_VOICE_ON;
/* -FIX- increment active voice count? */
}

View File

@ -18,3 +18,27 @@
* MA 02111-1307, USA.
*/
// complete rewrite of the voice engine
#include <stdint.h>
#include <math.h>
#include "nekobee_synth.h"
float nekobee_pitch[128];
void nekobee_init_tables(void) {
return;
}
void nekobee_voice_render(nekobee_synth_t *synth, float *out, uint32_t count) {
// generate "count" samples into the buffer at out
return;
(void)synth;
(void)out;
(void)count;
}