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.nugget_remains = 0;
fSynth.note_id = 0; fSynth.note_id = 0;
fSynth.polyphony = XSYNTH_DEFAULT_POLYPHONY;
fSynth.voices = XSYNTH_DEFAULT_POLYPHONY;
fSynth.monophonic = XSYNTH_MONO_MODE_ONCE; fSynth.monophonic = XSYNTH_MONO_MODE_ONCE;
fSynth.glide = 0; fSynth.glide = 0;
fSynth.last_noteon_pitch = 0.0f; 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. * MA 02111-1307, USA.
*/ */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "nekobee.h"
#include "nekobee_synth.h" #include "nekobee_synth.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "nekobee_voice.h" #include "nekobee_voice.h"
/* /*
@ -39,19 +39,13 @@
* *
* stop processing all notes immediately * stop processing all notes immediately
*/ */
void void nekobee_synth_all_voices_off(nekobee_synth_t *synth) {
nekobee_synth_all_voices_off(nekobee_synth_t *synth)
{
int i; int i;
nekobee_voice_t *voice; nekobee_voice_t *voice = synth->voice;
if (_PLAYING(voice)) {
for (i = 0; i < synth->voices; i++) { nekobee_voice_off(voice);
//voice = synth->voice[i];
voice = synth->voice;
if (_PLAYING(voice)) {
nekobee_voice_off(voice);
}
} }
for (i = 0; i < 8; i++) synth->held_keys[i] = -1; 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 * handle a note off message
*/ */
void void nekobee_synth_note_off(nekobee_synth_t *synth, unsigned char key,
nekobee_synth_note_off(nekobee_synth_t *synth, unsigned char key, unsigned char rvelocity) unsigned char rvelocity) {
{ int count = 0;
int i, count = 0; nekobee_voice_t *voice = synth->voice;
nekobee_voice_t *voice; if (_PLAYING(voice)) {
nekobee_voice_note_off(synth, voice, key, 64);
for (i = 0; i < synth->voices; i++) { count++;
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) if (!count) nekobee_voice_remove_held_key(synth, key);
nekobee_voice_remove_held_key(synth, key);
return; return;
(void)rvelocity; (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 * put all notes into the released state
*/ */
void void nekobee_synth_all_notes_off(nekobee_synth_t *synth) {
nekobee_synth_all_notes_off(nekobee_synth_t* synth) nekobee_voice_t *voice = synth->voice;
{
int i;
nekobee_voice_t *voice;
/* reset the sustain controller */ /* reset the sustain controller */
synth->cc[MIDI_CTL_SUSTAIN] = 0; synth->cc[MIDI_CTL_SUSTAIN] = 0;
for (i = 0; i < synth->voices; i++) {
//voice = synth->voice[i]; if (_ON(voice) || _SUSTAINED(voice)) {
voice = synth->voice; nekobee_voice_release_note(synth, voice);
if (_ON(voice) || _SUSTAINED(voice)) {
nekobee_voice_release_note(synth, voice);
}
} }
} }
/* /*
* nekobee_synth_note_on * nekobee_synth_note_on
*/ */
void void nekobee_synth_note_on(nekobee_synth_t *synth, unsigned char key,
nekobee_synth_note_on(nekobee_synth_t *synth, unsigned char key, unsigned char velocity) unsigned char velocity) {
{ nekobee_voice_t *voice;
nekobee_voice_t* voice;
voice = synth->voice; voice = synth->voice;
if (_PLAYING(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++; voice->note_id = synth->note_id++;
@ -125,112 +106,111 @@ nekobee_synth_note_on(nekobee_synth_t *synth, unsigned char key, unsigned char v
/* /*
* nekobee_synth_update_volume * nekobee_synth_update_volume
*/ */
void void nekobee_synth_update_volume(nekobee_synth_t *synth) {
nekobee_synth_update_volume(nekobee_synth_t* synth)
{
synth->cc_volume = (float)(synth->cc[MIDI_CTL_MSB_MAIN_VOLUME] * 128 + synth->cc_volume = (float)(synth->cc[MIDI_CTL_MSB_MAIN_VOLUME] * 128 +
synth->cc[MIDI_CTL_LSB_MAIN_VOLUME]) / 16256.0f; synth->cc[MIDI_CTL_LSB_MAIN_VOLUME]) /
if (synth->cc_volume > 1.0f) 16256.0f;
synth->cc_volume = 1.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 */ /* don't need to check if any playing voices need updating, because it's
* global */
} }
/* /*
* nekobee_synth_control_change * nekobee_synth_control_change
*/ */
void void nekobee_synth_control_change(nekobee_synth_t *synth, unsigned int param,
nekobee_synth_control_change(nekobee_synth_t *synth, unsigned int param, signed int value) signed int value) {
{
synth->cc[param] = value; synth->cc[param] = value;
switch (param) { switch (param) {
case MIDI_CTL_MSB_MAIN_VOLUME:
case MIDI_CTL_LSB_MAIN_VOLUME:
nekobee_synth_update_volume(synth);
break;
case MIDI_CTL_MSB_MAIN_VOLUME: case MIDI_CTL_ALL_SOUNDS_OFF:
case MIDI_CTL_LSB_MAIN_VOLUME: nekobee_synth_all_voices_off(synth);
nekobee_synth_update_volume(synth); break;
break;
case MIDI_CTL_ALL_SOUNDS_OFF: case MIDI_CTL_RESET_CONTROLLERS:
nekobee_synth_all_voices_off(synth); nekobee_synth_init_controls(synth);
break; break;
case MIDI_CTL_RESET_CONTROLLERS: case MIDI_CTL_ALL_NOTES_OFF:
nekobee_synth_init_controls(synth); nekobee_synth_all_notes_off(synth);
break; break;
case MIDI_CTL_ALL_NOTES_OFF: /* what others should we respond to? */
nekobee_synth_all_notes_off(synth);
break;
/* what others should we respond to? */ /* these we ignore (let the host handle):
* BANK_SELECT_MSB
/* these we ignore (let the host handle): * BANK_SELECT_LSB
* BANK_SELECT_MSB * DATA_ENTRY_MSB
* BANK_SELECT_LSB * NRPN_MSB
* DATA_ENTRY_MSB * NRPN_LSB
* NRPN_MSB * RPN_MSB
* NRPN_LSB * RPN_LSB
* RPN_MSB * -FIX- no! we need RPN (0, 0) Pitch Bend Sensitivity!
* RPN_LSB */
* -FIX- no! we need RPN (0, 0) Pitch Bend Sensitivity!
*/
} }
} }
/* /*
* nekobee_synth_init_controls * nekobee_synth_init_controls
*/ */
void void nekobee_synth_init_controls(nekobee_synth_t *synth) {
nekobee_synth_init_controls(nekobee_synth_t *synth)
{
int i; int i;
for (i = 0; i < 128; i++) { for (i = 0; i < 128; i++) {
synth->cc[i] = 0; synth->cc[i] = 0;
} }
synth->cc[7] = 127; /* full volume */ synth->cc[7] = 127; /* full volume */
nekobee_synth_update_volume(synth); nekobee_synth_update_volume(synth);
} }
/* /*
* nekobee_synth_render_voices * nekobee_synth_render_voices
*/ */
void void nekobee_synth_render_voices(nekobee_synth_t *synth, float *out,
nekobee_synth_render_voices(nekobee_synth_t *synth, float *out, unsigned long sample_count, unsigned long sample_count,
int do_control_update) int do_control_update) {
{
unsigned long i; unsigned long i;
float res, wow; float res, wow;
/* clear the buffer */ /* clear the buffer */
for (i = 0; i < sample_count; i++) for (i = 0; i < sample_count; i++) out[i] = 0.0f;
out[i] = 0.0f;
// we can do anything that must be updated all the time here // we can do anything that must be updated all the time here
// this is called even when a voice isn't playing // this is called even when a voice isn't playing
// approximate a log scale // approximate a log scale
res = 1-synth->resonance; res = 1 - synth->resonance;
wow = res*res; wow = res * res;
wow = wow/10.0f; wow = wow / 10.0f;
// as the resonance is increased, "wow" slows down the accent attack // as the resonance is increased, "wow" slows down the accent attack
if ((synth->voice->velocity>90) && (synth->vcf_accent < synth->voice->vcf_eg)) { if ((synth->voice->velocity > 90) &&
synth->vcf_accent=(0.985-wow)*synth->vcf_accent+(0.015+wow)*synth->voice->vcf_eg; (synth->vcf_accent < synth->voice->vcf_eg)) {
synth->vcf_accent = (0.985 - wow) * synth->vcf_accent +
(0.015 + wow) * synth->voice->vcf_eg;
} else { } 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) { if (synth->voice->velocity > 90) {
synth->vca_accent=0.95*synth->vca_accent+0.05; // ramp up accent on with a time constant synth->vca_accent = 0.95 * synth->vca_accent +
0.05; // ramp up accent on with a time constant
} else { } 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) #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
#endif /* defined(XSYNTH_DEBUG) && (XSYNTH_DEBUG & XDB_AUDIO) */ when quiescent */
#endif /* defined(XSYNTH_DEBUG) && (XSYNTH_DEBUG & XDB_AUDIO) */
if (_PLAYING(synth->voice)) { 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 #ifndef _XSYNTH_SYNTH_H
#define _XSYNTH_SYNTH_H #define _XSYNTH_SYNTH_H
#include "nekobee.h"
#include "nekobee_types.h" #include "nekobee_types.h"
#define XSYNTH_MONO_MODE_OFF 0 #define XSYNTH_MONO_MODE_OFF 0
@ -51,8 +50,6 @@ struct _nekobee_synth_t {
/* voice tracking and data */ /* voice tracking and data */
unsigned int note_id; /* incremented for every new note, used for voice-stealing prioritization */ 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 monophonic; /* true if operating in monophonic mode */
int glide; /* current glide mode */ int glide; /* current glide mode */
float last_noteon_pitch; /* glide start pitch for non-legato modes */ 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 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 */ float vca_accent; /* used to smooth the accent pulse, removing the click */
//nekobee_voice_t *voice[XSYNTH_MAX_POLYPHONY];
nekobee_voice_t *voice; nekobee_voice_t *voice;
/* current non-paramter-mapped controller values */ /* current non-paramter-mapped controller values */

View File

@ -30,7 +30,6 @@
#include <stdlib.h> #include <stdlib.h>
#include "nekobee_types.h" #include "nekobee_types.h"
#include "nekobee.h"
#include "nekobee_synth.h" #include "nekobee_synth.h"
#include "nekobee_voice.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) unsigned char key, unsigned char velocity)
{ {
int i; int i;
voice->key = key; voice->key = key;
voice->velocity = velocity; 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))) { if (!synth->monophonic || !(_ON(voice) || _SUSTAINED(voice))) {
// brand-new voice, or monophonic voice in release phase; set everything up // 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]; voice->target_pitch = nekobee_pitch[key];
@ -97,7 +94,6 @@ nekobee_voice_note_on(nekobee_synth_t *synth, nekobee_voice_t *voice,
} else { } else {
/* synth is monophonic, and we're modifying a playing voice */ /* 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 */ /* set new pitch */
voice->target_pitch = nekobee_pitch[key]; 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; 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 */ /* save release velocity */
voice->velocity = rvelocity; 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 */ /* most-recently-played key has changed */
voice->key = synth->held_keys[0]; 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]; voice->target_pitch = nekobee_pitch[voice->key];
if (synth->glide == XSYNTH_GLIDE_MODE_INITIAL || if (synth->glide == XSYNTH_GLIDE_MODE_INITIAL ||
synth->glide == XSYNTH_GLIDE_MODE_OFF) 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)) { if (XSYNTH_SYNTH_SUSTAINED(synth)) {
/* no more keys in list, but we're sustained */ /* 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)) if (!_RELEASED(voice))
voice->status = XSYNTH_VOICE_SUSTAINED; voice->status = XSYNTH_VOICE_SUSTAINED;
} else { /* not sustained */ } else { /* not sustained */
/* no more keys in list, so turn off note */ /* 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); nekobee_voice_set_release_phase(voice);
voice->status = XSYNTH_VOICE_RELEASED; voice->status = XSYNTH_VOICE_RELEASED;
@ -243,7 +234,6 @@ nekobee_voice_note_off(nekobee_synth_t *synth, nekobee_voice_t *voice,
void void
nekobee_voice_release_note(nekobee_synth_t *synth, nekobee_voice_t *voice) 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)) { if (_ON(voice)) {
/* dummy up a release velocity */ /* dummy up a release velocity */
voice->rvelocity = 64; voice->rvelocity = 64;

View File

@ -27,131 +27,114 @@
#define _XSYNTH_VOICE_H #define _XSYNTH_VOICE_H
#include <string.h> #include <string.h>
#include <stdint.h>
#include "nekobee_types.h" #include "nekobee_types.h"
/* maximum size of a rendering burst */ /* maximum size of a rendering burst */
#define XSYNTH_NUGGET_SIZE 64 #define XSYNTH_NUGGET_SIZE 64
/* minBLEP constants */ /* minBLEP constants */
/* minBLEP table oversampling factor (must be a power of two): */ /* minBLEP table oversampling factor (must be a power of two): */
#define MINBLEP_PHASES 64 #define MINBLEP_PHASES 64
/* MINBLEP_PHASES minus one: */ /* MINBLEP_PHASES minus one: */
#define MINBLEP_PHASE_MASK 63 #define MINBLEP_PHASE_MASK 63
/* length in samples of (truncated) step discontinuity delta: */ /* length in samples of (truncated) step discontinuity delta: */
#define STEP_DD_PULSE_LENGTH 72 #define STEP_DD_PULSE_LENGTH 72
/* length in samples of (truncated) slope discontinuity delta: */ /* length in samples of (truncated) slope discontinuity delta: */
#define SLOPE_DD_PULSE_LENGTH 71 #define SLOPE_DD_PULSE_LENGTH 71
/* the longer of the two above: */ /* the longer of the two above: */
#define LONGEST_DD_PULSE_LENGTH STEP_DD_PULSE_LENGTH #define LONGEST_DD_PULSE_LENGTH STEP_DD_PULSE_LENGTH
/* MINBLEP_BUFFER_LENGTH must be at least XSYNTH_NUGGET_SIZE plus /* MINBLEP_BUFFER_LENGTH must be at least XSYNTH_NUGGET_SIZE plus
* LONGEST_DD_PULSE_LENGTH, and not less than twice LONGEST_DD_PULSE_LENGTH: */ * LONGEST_DD_PULSE_LENGTH, and not less than twice LONGEST_DD_PULSE_LENGTH: */
#define MINBLEP_BUFFER_LENGTH 512 #define MINBLEP_BUFFER_LENGTH 512
/* delay between start of DD pulse and the discontinuity, in samples: */ /* delay between start of DD pulse and the discontinuity, in samples: */
#define DD_SAMPLE_DELAY 4 #define DD_SAMPLE_DELAY 4
struct _nekobee_patch_t struct _nekobee_patch_t {
{ float tuning;
float tuning;
unsigned char waveform; unsigned char waveform;
float cutoff; float cutoff;
float resonance; float resonance;
float envmod; float envmod;
float decay; float decay;
float accent; float accent;
float volume; float volume;
}; };
enum nekobee_voice_status enum nekobee_voice_status {
{
XSYNTH_VOICE_OFF, /* silent: is not processed by render loop */ XSYNTH_VOICE_OFF, /* silent: is not processed by render loop */
XSYNTH_VOICE_ON, /* has not received a note off event */ XSYNTH_VOICE_ON, /* has not received a note off event */
XSYNTH_VOICE_SUSTAINED, /* has received note off, but sustain controller is on */ XSYNTH_VOICE_SUSTAINED, /* has received note off, but sustain controller is
XSYNTH_VOICE_RELEASED /* had note off, not sustained, in final decay phase of envelopes */ on */
XSYNTH_VOICE_RELEASED /* had note off, not sustained, in final decay phase
of envelopes */
}; };
struct blosc struct blosc {
{ int last_waveform, /* persistent */
int last_waveform, /* persistent */ waveform, /* comes from LADSPA port each cycle */
waveform, /* comes from LADSPA port each cycle */ bp_high; /* persistent */
bp_high; /* persistent */ float pos, /* persistent */
float pos, /* persistent */ pw; /* comes from LADSPA port each cycle */
pw; /* comes from LADSPA port each cycle */
}; };
/* /*
* nekobee_voice_t * nekobee_voice_t
*/ */
struct _nekobee_voice_t struct _nekobee_voice_t {
{ unsigned int note_id;
unsigned int note_id;
unsigned char status; unsigned char status;
unsigned char key; unsigned char key;
unsigned char velocity; unsigned char velocity;
unsigned char rvelocity; /* the note-off velocity */ unsigned char rvelocity; /* the note-off velocity */
/* translated controller values */ /* translated controller values */
float pressure; /* filter resonance multiplier, off = 1.0, full on = 0.0 */ float pressure; /* filter resonance multiplier, off = 1.0, full on = 0.0 */
/* persistent voice state */ /* persistent voice state */
float prev_pitch, float prev_pitch, target_pitch, lfo_pos;
target_pitch, struct blosc osc1;
lfo_pos; float vca_eg, vcf_eg, accent_slug, delay1, delay2, delay3, delay4, c5;
struct blosc osc1; unsigned char vca_eg_phase, vcf_eg_phase;
float vca_eg, int osc_index; /* shared index into osc_audio */
vcf_eg, float osc_audio[MINBLEP_BUFFER_LENGTH];
accent_slug, float freqcut_buf[XSYNTH_NUGGET_SIZE];
delay1, float vca_buf[XSYNTH_NUGGET_SIZE];
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];
float vca_buf[XSYNTH_NUGGET_SIZE];
}; };
#define _PLAYING(voice) ((voice)->status != XSYNTH_VOICE_OFF) #define _PLAYING(voice) ((voice)->status != XSYNTH_VOICE_OFF)
#define _ON(voice) ((voice)->status == XSYNTH_VOICE_ON) #define _ON(voice) ((voice)->status == XSYNTH_VOICE_ON)
#define _SUSTAINED(voice) ((voice)->status == XSYNTH_VOICE_SUSTAINED) #define _SUSTAINED(voice) ((voice)->status == XSYNTH_VOICE_SUSTAINED)
#define _RELEASED(voice) ((voice)->status == XSYNTH_VOICE_RELEASED) #define _RELEASED(voice) ((voice)->status == XSYNTH_VOICE_RELEASED)
#define _AVAILABLE(voice) ((voice)->status == XSYNTH_VOICE_OFF) #define _AVAILABLE(voice) ((voice)->status == XSYNTH_VOICE_OFF)
extern float nekobee_pitch[128]; 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_value_delta step_dd_table[];
extern float slope_dd_table[]; extern float slope_dd_table[];
/* nekobee_voice.c */ /* nekobee_voice.c */
nekobee_voice_t *nekobee_voice_new(); nekobee_voice_t *nekobee_voice_new();
void nekobee_voice_note_on(nekobee_synth_t *synth, void nekobee_voice_note_on(nekobee_synth_t *synth, nekobee_voice_t *voice,
nekobee_voice_t *voice, unsigned char key, unsigned char velocity);
unsigned char key, void nekobee_voice_remove_held_key(nekobee_synth_t *synth, unsigned char key);
unsigned char velocity); void nekobee_voice_note_off(nekobee_synth_t *synth, nekobee_voice_t *voice,
void nekobee_voice_remove_held_key(nekobee_synth_t *synth, unsigned char key, unsigned char rvelocity);
unsigned char key); void nekobee_voice_release_note(nekobee_synth_t *synth, nekobee_voice_t *voice);
void nekobee_voice_note_off(nekobee_synth_t *synth, void nekobee_voice_set_ports(nekobee_synth_t *synth, nekobee_patch_t *patch);
nekobee_voice_t *voice, void nekobee_voice_update_pressure_mod(nekobee_synth_t *synth,
unsigned char key, nekobee_voice_t *voice);
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 */ /* nekobee_voice_render.c */
void nekobee_init_tables(void); void nekobee_init_tables(void);
void nekobee_voice_render(nekobee_synth_t *synth, nekobee_voice_t *voice, void nekobee_voice_render(nekobee_synth_t *synth, float *out,
float *out, unsigned long sample_count, uint32_t count);
int do_control_update);
/* inline functions */ /* 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 * Purpose: Turns off a voice immediately, meaning that it is not processed
* anymore by the render loop. * anymore by the render loop.
*/ */
static inline void static inline void nekobee_voice_off(nekobee_voice_t *voice) {
nekobee_voice_off(nekobee_voice_t* voice)
{
voice->status = XSYNTH_VOICE_OFF; voice->status = XSYNTH_VOICE_OFF;
/* silence the oscillator buffer for the next use */ /* silence the oscillator buffer for the next use */
memset(voice->osc_audio, 0, MINBLEP_BUFFER_LENGTH * sizeof(float)); 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 * nekobee_voice_start_voice
*/ */
static inline void static inline void nekobee_voice_start_voice(nekobee_voice_t *voice) {
nekobee_voice_start_voice(nekobee_voice_t *voice)
{
voice->status = XSYNTH_VOICE_ON; voice->status = XSYNTH_VOICE_ON;
/* -FIX- increment active voice count? */ /* -FIX- increment active voice count? */
} }

View File

@ -18,3 +18,27 @@
* MA 02111-1307, USA. * 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;
}