LMMS
Loading...
Searching...
No Matches
modules_synths.h
Go to the documentation of this file.
1/* Calf DSP Library
2 * Audio modules - synthesizers
3 *
4 * Copyright (C) 2001-2007 Krzysztof Foltman
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General
17 * Public License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02111-1307, USA.
20 */
21#ifndef __CALF_MODULES_SYNTHS_H
22#define __CALF_MODULES_SYNTHS_H
23
24#include "biquad.h"
25#include "onepole.h"
26#include "audio_fx.h"
27#include "inertia.h"
28#include "osc.h"
29#include "synth.h"
30#include "envelope.h"
31#include "modmatrix.h"
32#include "metadata.h"
33#include "giface.h"
34
35namespace calf_plugins {
36
37#define MONOSYNTH_WAVE_BITS 12
38
41class monosynth_audio_module: public audio_module<monosynth_metadata>, public line_graph_iface, public mod_matrix_impl
42{
43public:
51 bool running;
55 bool gate;
60
66 int wave1;
68 int wave2;
83 float lfo_clock;
95 float queue_vel;
99 int legato;
118 float velocity;
125
127 void set_sample_rate(uint32_t sr);
128 void delayed_note_on();
130 void end_note();
133 void note_on(int channel, int note, int vel);
135 void note_off(int channel, int note, int vel);
137 void channel_pressure(int channel, int value);
139 inline void pitch_bend(int /*channel*/, int value)
140 {
141 inertia_pitchbend.set_inertia(pow(2.0, (value * *params[par_pwhlrange]) / (1200.0 * 8192.0)));
142 }
143
144 void set_frequency();
146 void control_change(int channel, int controller, int value);
148 void params_changed();
149 void activate();
150 void deactivate();
155
156 void lookup_waveforms();
158 void calculate_buffer_oscs(float lfo);
166 bool get_graph(int index, int subindex, int phase, float *data, int points, cairo_iface *context, int *mode) const;
167 bool get_layers(int index, int generation, unsigned int &layers) const { layers = LG_REALTIME_GRAPH; return true; }
170 bool is_cv(int param_no) const { return false; }
172 bool is_noisy(int param_no) const { return param_no != par_cutoff; }
174 uint32_t process(uint32_t offset, uint32_t nsamples, uint32_t inputs_mask, uint32_t outputs_mask);
177 virtual char *configure(const char *key, const char *value) { return mod_matrix_impl::configure(key, value); }
178private:
179 void reset();
180 float get_lfo(dsp::triangle_lfo &lfo, int param);
182 void apply_fadeout();
184 void calculate_step();
186 inline bool is_stereo_filter() const
187 {
189 }
190 static void precalculate_waves(progress_report_iface *reporter);
191};
192
193};
194
195#if ENABLE_EXPERIMENTAL
196
197#include "wavetable.h"
198
199#endif
200
201#endif
Controller controller
Definition main.C:5
float * params[monosynth_metadata::param_count]
Definition giface.h:527
progress_report_iface * progress_report
Definition giface.h:531
mod_matrix_impl(dsp::modulation_entry *_matrix, calf_plugins::mod_matrix_metadata *_metadata)
Definition modmatrix.cpp:31
char * configure(const char *key, const char *value)
Definition modmatrix.cpp:125
void send_configures(send_configure_iface *)
Definition modmatrix.cpp:113
float detune
Definition modules_synths.h:78
int32_t last_pwshift2
Last value of phase shift for pulse width emulation for OSC2.
Definition modules_synths.h:87
bool gate
A key is kept pressed.
Definition modules_synths.h:55
float ampctl
Definition modules_synths.h:78
float xpose2
Definition modules_synths.h:78
float target_freq
Definition modules_synths.h:77
int wave1
Waveform number - OSC1.
Definition modules_synths.h:66
float modwheel_value
Modulation wheel position (0.f-1.f).
Definition modules_synths.h:81
float velocity
Currently used velocity.
Definition modules_synths.h:118
void deactivate()
LADSPA-esque deactivate function.
Definition monosynth.cpp:761
float odcr
Definition modules_synths.h:79
void apply_fadeout()
Apply anti-click'n'pop fadeout (used at the end of the sound).
Definition monosynth.cpp:645
virtual char * configure(const char *key, const char *value)
DSSI configure call.
Definition modules_synths.h:177
void delayed_note_on()
Definition monosynth.cpp:404
uint32_t process(uint32_t offset, uint32_t nsamples, uint32_t inputs_mask, uint32_t outputs_mask)
Main processing function.
Definition monosynth.cpp:808
bool queue_note_on_and_off
Whether the queued note has been already released.
Definition modules_synths.h:93
float last_unison
Last value of unison amount.
Definition modules_synths.h:122
float buffer[step_size]
Output buffers, used to ensure updates are done every step_size regardless of process buffer size.
Definition modules_synths.h:62
void activate()
LADSPA-esque activate function, except it is called after ports are connected, not before.
Definition monosynth.cpp:72
bool get_graph(int index, int subindex, int phase, float *data, int points, cairo_iface *context, int *mode) const
Retrieve filter graph (which is 'live' so it cannot be generated by get_static_graph),...
Definition monosynth.cpp:209
int filter_type
Filter type.
Definition modules_synths.h:74
int32_t last_stretch1
Last value of stretch for osc sync emulation for OSC1.
Definition modules_synths.h:89
bool is_noisy(int param_no) const
Practically all the stuff here is noisy.
Definition modules_synths.h:172
monosynth_audio_module()
Definition monosynth.cpp:32
float porta_time
Definition modules_synths.h:79
dsp::biquad_d1_lerp filter2
Definition modules_synths.h:49
float last_xfade
Last value of oscillator mix ratio.
Definition modules_synths.h:120
void calculate_buffer_oscs(float lfo)
Run oscillators.
Definition monosynth.cpp:277
dsp::triangle_lfo lfo1
Definition modules_synths.h:47
dsp::simple_oscillator unison_osc
Definition modules_synths.h:48
float queue_vel
Velocity of the next note to play.
Definition modules_synths.h:95
dsp::triangle_lfo lfo2
Definition modules_synths.h:47
dsp::waveform_oscillator< MONOSYNTH_WAVE_BITS > detosc
Definition modules_synths.h:46
float xpose1
Definition modules_synths.h:78
float lfo_bend
Definition modules_synths.h:79
int last_filter_type
Filter type on the last calculate_step.
Definition modules_synths.h:76
virtual void send_configures(send_configure_iface *sci)
Send all configure variables set within a plugin to given destination (which may be limited to only t...
Definition modules_synths.h:176
bool is_stereo_filter() const
Definition modules_synths.h:186
float start_freq
Definition modules_synths.h:77
void note_off(int channel, int note, int vel)
Handle MIDI Note Off message.
Definition monosynth.cpp:691
void lookup_waveforms()
Set waveform addresses for oscillators.
Definition monosynth.cpp:394
void end_note()
Release a note (physically), called from note-off handler or when note-off has been scheduled after n...
Definition monosynth.cpp:706
int queue_note_on
Next note to play on the next calculate_step.
Definition modules_synths.h:91
dsp::inertia< dsp::exponential_ramp > inertia_cutoff
Smoothed cutoff value.
Definition modules_synths.h:110
dsp::fadeout fadeout2
Fadeout for buffer 2.
Definition modules_synths.h:108
float moddest[moddest_count]
Current calculated mod matrix outputs.
Definition modules_synths.h:124
int last_key
Last triggered note.
Definition modules_synths.h:59
dsp::adsr envelope2
Definition modules_synths.h:101
void channel_pressure(int channel, int value)
Handle MIDI Channel Pressure.
Definition monosynth.cpp:729
dsp::fadeout fadeout
Fadeout for buffer 1.
Definition modules_synths.h:106
static dsp::waveform_family< MONOSYNTH_WAVE_BITS > * waves
Definition modules_synths.h:45
dsp::gain_smoothing master
Smoothing for master volume.
Definition modules_synths.h:104
int32_t last_pwshift1
Last value of phase shift for pulse width emulation for OSC1.
Definition modules_synths.h:85
int prev_wave1
Last used waveform number - OSC1.
Definition modules_synths.h:70
void calculate_buffer_ser()
Run two filters in series to produce mono output samples.
Definition monosynth.cpp:355
int prev_wave2
Last used waveform number - OSC2.
Definition modules_synths.h:72
void post_instantiate(uint32_t)
Called after instantiating (after all the feature pointers are set - including interfaces like progre...
Definition modules_synths.h:151
bool running
The step code is producing non-zero values.
Definition modules_synths.h:51
uint32_t output_pos
Read position within the buffers, on each '0' the buffers are being filled with new data by calculate...
Definition modules_synths.h:64
float cutoff
Definition modules_synths.h:77
uint32_t crate
Definition modules_synths.h:44
float freq
Definition modules_synths.h:77
dsp::biquad_d1_lerp filter
Definition modules_synths.h:49
void reset()
Definition monosynth.cpp:40
dsp::inertia< dsp::exponential_ramp > inertia_pitchbend
Smoothed pitch bend value.
Definition modules_synths.h:112
bool force_fadeout
All notes off fadeout.
Definition modules_synths.h:57
dsp::modulation_entry mod_matrix_data[mod_matrix_slots]
Rows of the modulation matrix.
Definition modules_synths.h:116
float buffer2[step_size]
Definition modules_synths.h:62
float lfo_clock
Delay counter for LFOs.
Definition modules_synths.h:83
void control_change(int channel, int controller, int value)
Handle control change messages.
Definition monosynth.cpp:735
void note_on(int channel, int note, int vel)
Definition monosynth.cpp:681
dsp::keystack stack
Definition modules_synths.h:102
int modwheel_value_int
Integer value for modwheel (0-16383, read from CC1 - MSBs and CC33 - LSBs).
Definition modules_synths.h:97
float separation
Definition modules_synths.h:77
bool get_layers(int index, int generation, unsigned int &layers) const
Definition modules_synths.h:167
dsp::inertia< dsp::linear_ramp > inertia_pressure
Smoothed channel pressure value.
Definition modules_synths.h:114
void pitch_bend(int, int value)
Handle pitch bend message.
Definition modules_synths.h:139
void params_changed()
Update variables from control ports.
Definition monosynth.cpp:786
float fgain
Definition modules_synths.h:77
void calculate_buffer_stereo()
Run two filters (one per channel) to produce stereo output samples.
Definition monosynth.cpp:381
bool is_cv(int param_no) const
Definition modules_synths.h:170
void set_sample_rate(uint32_t sr)
Set sample rate for the plugin.
Definition monosynth.cpp:482
void calculate_step()
Calculate control signals and produce step_size samples of output.
Definition monosynth.cpp:501
float fltctl
Definition modules_synths.h:78
int legato
Legato mode (bitmask).
Definition modules_synths.h:99
dsp::waveform_oscillator< MONOSYNTH_WAVE_BITS > osc2
Definition modules_synths.h:46
int wave2
Waveform number - OSC2.
Definition modules_synths.h:68
float xfade
Definition modules_synths.h:78
dsp::adsr envelope1
Envelope Generators.
Definition modules_synths.h:101
void calculate_buffer_single()
Run one filter to produce mono output samples.
Definition monosynth.cpp:369
dsp::waveform_oscillator< MONOSYNTH_WAVE_BITS > osc1
Definition modules_synths.h:46
static void precalculate_waves(progress_report_iface *reporter)
Definition monosynth.cpp:79
bool stopping
This is the last non-zero buffer (set on calculate_step after fadeout is complete,...
Definition modules_synths.h:53
uint32_t srate
Definition modules_synths.h:44
void set_frequency()
Update oscillator frequency based on base frequency, detune amount, pitch bend scaling factor and sam...
Definition monosynth.cpp:771
float fgain_delta
Definition modules_synths.h:77
float get_lfo(dsp::triangle_lfo &lfo, int param)
Definition monosynth.cpp:493
Definition envelope.h:33
Definition inertia.h:242
Definition inertia.h:108
Definition synth.h:38
static PuglViewHint int value
Definition pugl.h:1708
JSAMPIMAGE data
Definition jpeglib.h:945
int int32_t
Definition mid.cpp:97
unsigned int uint32_t
Definition mid.cpp:100
Definition benchmark.cpp:53
@ LG_REALTIME_GRAPH
Definition giface.h:181
png_structrp int mode
Definition png.h:1139
Definition giface.h:160
'provides live line graph values' interface
Definition giface.h:198
@ step_size
Definition metadata.h:203
@ moddest_count
Definition metadata.h:229
@ flt_2bp6
Definition metadata.h:188
@ flt_2lp12
Definition metadata.h:188
@ par_pwhlrange
Definition metadata.h:191
@ par_cutoff
Definition metadata.h:189
@ mod_matrix_slots
Definition metadata.h:204
'may receive configure variables' interface
Definition giface.h:291
Definition biquad.h:494
Simple linear fade out for note tails.
Definition envelope.h:212
Single entry in modulation matrix.
Definition modmatrix.h:31
Definition osc.h:36
Definition osc.h:303
Set of bandlimited wavetables.
Definition osc.h:164
Definition osc.h:249
ZCONST char * key
Definition crypt.c:587