LMMS
Loading...
Searching...
No Matches
nekobee_voice.h
Go to the documentation of this file.
1/* nekobee DSSI software synthesizer plugin
2 *
3 * Copyright (C) 2004 Sean Bolton and others.
4 *
5 * Portions of this file may have come from Steve Brookes'
6 * nekobee, copyright (C) 1999 S. J. Brookes.
7 * Portions of this file may have come from Peter Hanappe's
8 * Fluidsynth, copyright (C) 2003 Peter Hanappe and others.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be
16 * useful, but WITHOUT ANY WARRANTY; without even the implied
17 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18 * PURPOSE. See the GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public
21 * License along with this program; if not, write to the Free
22 * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307, USA.
24 */
25
26#ifndef _XSYNTH_VOICE_H
27#define _XSYNTH_VOICE_H
28
29#include <string.h>
30
31#include "nekobee_types.h"
32
33/* maximum size of a rendering burst */
34#define XSYNTH_NUGGET_SIZE 64
35
36/* minBLEP constants */
37/* minBLEP table oversampling factor (must be a power of two): */
38#define MINBLEP_PHASES 64
39/* MINBLEP_PHASES minus one: */
40#define MINBLEP_PHASE_MASK 63
41/* length in samples of (truncated) step discontinuity delta: */
42#define STEP_DD_PULSE_LENGTH 72
43/* length in samples of (truncated) slope discontinuity delta: */
44#define SLOPE_DD_PULSE_LENGTH 71
45/* the longer of the two above: */
46#define LONGEST_DD_PULSE_LENGTH STEP_DD_PULSE_LENGTH
47/* MINBLEP_BUFFER_LENGTH must be at least XSYNTH_NUGGET_SIZE plus
48 * LONGEST_DD_PULSE_LENGTH, and not less than twice LONGEST_DD_PULSE_LENGTH: */
49#define MINBLEP_BUFFER_LENGTH 512
50/* delay between start of DD pulse and the discontinuity, in samples: */
51#define DD_SAMPLE_DELAY 4
52
54{
55 float tuning;
56 unsigned char waveform;
57 float cutoff;
58 float resonance;
59 float envmod;
60 float decay;
61 float accent;
62 float volume;
63};
64
66{
67 XSYNTH_VOICE_OFF, /* silent: is not processed by render loop */
68 XSYNTH_VOICE_ON, /* has not received a note off event */
69 XSYNTH_VOICE_SUSTAINED, /* has received note off, but sustain controller is on */
70 XSYNTH_VOICE_RELEASED /* had note off, not sustained, in final decay phase of envelopes */
71};
72
73struct blosc
74{
75 int last_waveform, /* persistent */
76 waveform, /* comes from LADSPA port each cycle */
77 bp_high; /* persistent */
78 float pos, /* persistent */
79 pw; /* comes from LADSPA port each cycle */
80};
81
82/*
83 * nekobee_voice_t
84 */
86{
87 unsigned int note_id;
88
89 unsigned char status;
90 unsigned char key;
91 unsigned char velocity;
92 unsigned char rvelocity; /* the note-off velocity */
93
94 /* translated controller values */
95 float pressure; /* filter resonance multiplier, off = 1.0, full on = 0.0 */
96
97 /* persistent voice state */
101 struct blosc osc1;
102 float vca_eg,
110 unsigned char vca_eg_phase,
112 int osc_index; /* shared index into osc_audio */
116};
117
118#define _PLAYING(voice) ((voice)->status != XSYNTH_VOICE_OFF)
119#define _ON(voice) ((voice)->status == XSYNTH_VOICE_ON)
120#define _SUSTAINED(voice) ((voice)->status == XSYNTH_VOICE_SUSTAINED)
121#define _RELEASED(voice) ((voice)->status == XSYNTH_VOICE_RELEASED)
122#define _AVAILABLE(voice) ((voice)->status == XSYNTH_VOICE_OFF)
123
124extern float nekobee_pitch[128];
125
126typedef struct { float value, delta; } float_value_delta;
128
129extern float slope_dd_table[];
130
131/* nekobee_voice.c */
134 nekobee_voice_t *voice,
135 unsigned char key,
136 unsigned char velocity);
138 unsigned char key);
140 nekobee_voice_t *voice,
141 unsigned char key,
142 unsigned char rvelocity);
144 nekobee_voice_t *voice);
146 nekobee_patch_t *patch);
148 nekobee_voice_t *voice);
149
150/* nekobee_voice_render.c */
151void nekobee_init_tables(void);
153 float *out, unsigned long sample_count,
154 int do_control_update);
155
156/* inline functions */
157
158/*
159 * nekobee_voice_off
160 *
161 * Purpose: Turns off a voice immediately, meaning that it is not processed
162 * anymore by the render loop.
163 */
164static inline void
166{
167 voice->status = XSYNTH_VOICE_OFF;
168 /* silence the oscillator buffer for the next use */
169 memset(voice->osc_audio, 0, MINBLEP_BUFFER_LENGTH * sizeof(float));
170 /* -FIX- decrement active voice count? */
171}
172
173/*
174 * nekobee_voice_start_voice
175 */
176static inline void
178{
179 voice->status = XSYNTH_VOICE_ON;
180 /* -FIX- increment active voice count? */
181}
182
183#endif /* _XSYNTH_VOICE_H */
SYNTH_T * synth
Definition LocalZynAddSubFx.cpp:47
float out
Definition lilv_test.c:1461
float_value_delta step_dd_table[MINBLEP_PHASES *STEP_DD_PULSE_LENGTH+1]
Definition minblep_tables.c:49
float slope_dd_table[MINBLEP_PHASES *SLOPE_DD_PULSE_LENGTH+1]
Definition minblep_tables.c:1207
struct _nekobee_patch_t nekobee_patch_t
Definition nekobee_types.h:28
struct _nekobee_synth_t nekobee_synth_t
Definition nekobee_types.h:26
struct _nekobee_voice_t nekobee_voice_t
Definition nekobee_types.h:27
nekobee_voice_status
Definition nekobee_voice.h:66
@ XSYNTH_VOICE_RELEASED
Definition nekobee_voice.h:70
@ XSYNTH_VOICE_SUSTAINED
Definition nekobee_voice.h:69
@ XSYNTH_VOICE_ON
Definition nekobee_voice.h:68
@ XSYNTH_VOICE_OFF
Definition nekobee_voice.h:67
nekobee_voice_t * nekobee_voice_new()
Definition nekobee_voice.c:41
#define MINBLEP_BUFFER_LENGTH
Definition nekobee_voice.h:49
void nekobee_voice_render(nekobee_synth_t *synth, nekobee_voice_t *voice, float *out, unsigned long sample_count, int do_control_update)
Definition nekobee_voice_render.c:273
void nekobee_voice_release_note(nekobee_synth_t *synth, nekobee_voice_t *voice)
Definition nekobee_voice.c:244
void nekobee_voice_update_pressure_mod(nekobee_synth_t *synth, nekobee_voice_t *voice)
void nekobee_voice_note_on(nekobee_synth_t *synth, nekobee_voice_t *voice, unsigned char key, unsigned char velocity)
Definition nekobee_voice.c:56
static void nekobee_voice_off(nekobee_voice_t *voice)
Definition nekobee_voice.h:165
float nekobee_pitch[128]
Definition nekobee_voice_render.c:25
#define XSYNTH_NUGGET_SIZE
Definition nekobee_voice.h:34
void nekobee_init_tables(void)
Definition nekobee_voice_render.c:38
void nekobee_voice_set_ports(nekobee_synth_t *synth, nekobee_patch_t *patch)
void nekobee_voice_note_off(nekobee_synth_t *synth, nekobee_voice_t *voice, unsigned char key, unsigned char rvelocity)
Definition nekobee_voice.c:182
void nekobee_voice_remove_held_key(nekobee_synth_t *synth, unsigned char key)
Definition nekobee_voice.c:160
static void nekobee_voice_start_voice(nekobee_voice_t *voice)
Definition nekobee_voice.h:177
Definition nekobee_voice.h:54
float cutoff
Definition nekobee_voice.h:57
float resonance
Definition nekobee_voice.h:58
float envmod
Definition nekobee_voice.h:59
float accent
Definition nekobee_voice.h:61
float decay
Definition nekobee_voice.h:60
float tuning
Definition nekobee_voice.h:55
unsigned char waveform
Definition nekobee_voice.h:56
float volume
Definition nekobee_voice.h:62
Definition nekobee_voice.h:86
float prev_pitch
Definition nekobee_voice.h:98
float delay3
Definition nekobee_voice.h:107
unsigned char status
Definition nekobee_voice.h:89
unsigned char key
Definition nekobee_voice.h:90
float vcf_eg
Definition nekobee_voice.h:103
struct blosc osc1
Definition nekobee_voice.h:101
float delay1
Definition nekobee_voice.h:105
unsigned char vca_eg_phase
Definition nekobee_voice.h:110
unsigned char vcf_eg_phase
Definition nekobee_voice.h:111
float accent_slug
Definition nekobee_voice.h:104
unsigned char rvelocity
Definition nekobee_voice.h:92
float c5
Definition nekobee_voice.h:109
float freqcut_buf[XSYNTH_NUGGET_SIZE]
Definition nekobee_voice.h:114
float delay2
Definition nekobee_voice.h:106
int osc_index
Definition nekobee_voice.h:112
float vca_buf[XSYNTH_NUGGET_SIZE]
Definition nekobee_voice.h:115
float target_pitch
Definition nekobee_voice.h:99
unsigned char velocity
Definition nekobee_voice.h:91
float vca_eg
Definition nekobee_voice.h:102
float delay4
Definition nekobee_voice.h:108
float pressure
Definition nekobee_voice.h:95
float osc_audio[MINBLEP_BUFFER_LENGTH]
Definition nekobee_voice.h:113
float lfo_pos
Definition nekobee_voice.h:100
unsigned int note_id
Definition nekobee_voice.h:87
Definition nekobee_voice.h:74
int bp_high
Definition nekobee_voice.h:77
float pw
Definition nekobee_voice.h:79
float pos
Definition nekobee_voice.h:78
int waveform
Definition nekobee_voice.h:76
int last_waveform
Definition nekobee_voice.h:75
Definition nekobee_voice.h:126
float value
Definition nekobee_voice.h:126
float delta
Definition nekobee_voice.h:126
ZCONST char * key
Definition crypt.c:587