[SCM] calf/master: + Organ: new PADsynth waveforms, new preset, disable waveform display in LV2 (it didn't work anyway, would require OSC support, contexts and who-knows-what-else) + LV2: do not call write function from callback functions to avoid recursion (and because it's Just Incorrect) + Rotary Speaker: new LFO, added modulation depth parameter
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:37:14 UTC 2013
The following commit has been merged in the master branch:
commit 88776555529d1a76488de085ef722c8045c6e9d5
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date: Mon May 19 22:23:37 2008 +0000
+ Organ: new PADsynth waveforms, new preset, disable waveform display in LV2 (it didn't work anyway, would require OSC support, contexts and who-knows-what-else)
+ LV2: do not call write function from callback functions to avoid recursion (and because it's Just Incorrect)
+ Rotary Speaker: new LFO, added modulation depth parameter
git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@185 78b06b96-2940-0410-b7fc-879d825d01d8
diff --git a/presets.xml b/presets.xml
index fe157c5..ac9231a 100644
--- a/presets.xml
+++ b/presets.xml
@@ -1735,7 +1735,7 @@
<param name="perc_timbre" value="2" />
<param name="perc_trigger" value="0" />
<param name="filter_chain" value="0" />
- <param name="master" value="1" />
+ <param name="master" value="0.1" />
<param name="f1_cutoff" value="126.191" />
<param name="f1_res" value="1.35441" />
<param name="f1_env1" value="7568" />
@@ -1772,4 +1772,111 @@
<param name="vib_phase" value="180" />
<param name="vib_mode" value="4" />
</preset>
+<preset bank="0" program="0" plugin="organ" name="Monkstown">
+ <param name="l1" value="4.04598" />
+ <param name="l2" value="4.04598" />
+ <param name="l3" value="8" />
+ <param name="l4" value="8" />
+ <param name="l5" value="0" />
+ <param name="l6" value="0" />
+ <param name="l7" value="0" />
+ <param name="l8" value="0" />
+ <param name="l9" value="0" />
+ <param name="f1" value="4" />
+ <param name="f2" value="4" />
+ <param name="f3" value="2" />
+ <param name="f4" value="2" />
+ <param name="f5" value="6" />
+ <param name="f6" value="8" />
+ <param name="f7" value="10" />
+ <param name="f8" value="12" />
+ <param name="f9" value="16" />
+ <param name="w1" value="34" />
+ <param name="w2" value="34" />
+ <param name="w3" value="34" />
+ <param name="w4" value="34" />
+ <param name="w5" value="0" />
+ <param name="w6" value="0" />
+ <param name="w7" value="0" />
+ <param name="w8" value="0" />
+ <param name="w9" value="0" />
+ <param name="detune1" value="-12" />
+ <param name="detune2" value="14" />
+ <param name="detune3" value="-8" />
+ <param name="detune4" value="8" />
+ <param name="detune5" value="0" />
+ <param name="detune6" value="0" />
+ <param name="detune7" value="0" />
+ <param name="detune8" value="0" />
+ <param name="detune9" value="0" />
+ <param name="phase1" value="79.2" />
+ <param name="phase2" value="61.2" />
+ <param name="phase3" value="270" />
+ <param name="phase4" value="147.6" />
+ <param name="phase5" value="0" />
+ <param name="phase6" value="0" />
+ <param name="phase7" value="0" />
+ <param name="phase8" value="0" />
+ <param name="phase9" value="0" />
+ <param name="pan1" value="-1" />
+ <param name="pan2" value="1" />
+ <param name="pan3" value="-1" />
+ <param name="pan4" value="1" />
+ <param name="pan5" value="0" />
+ <param name="pan6" value="0" />
+ <param name="pan7" value="0" />
+ <param name="pan8" value="0" />
+ <param name="pan9" value="0" />
+ <param name="routing1" value="1" />
+ <param name="routing2" value="1" />
+ <param name="routing3" value="1" />
+ <param name="routing4" value="1" />
+ <param name="routing5" value="0" />
+ <param name="routing6" value="0" />
+ <param name="routing7" value="0" />
+ <param name="routing8" value="0" />
+ <param name="routing9" value="0" />
+ <param name="foldnote" value="114" />
+ <param name="perc_decay" value="200" />
+ <param name="perc_level" value="0" />
+ <param name="perc_timbre" value="2" />
+ <param name="perc_trigger" value="0" />
+ <param name="filter_chain" value="0" />
+ <param name="master" value="1" />
+ <param name="f1_cutoff" value="514.079" />
+ <param name="f1_res" value="0.7" />
+ <param name="f1_env1" value="3032" />
+ <param name="f1_env2" value="0" />
+ <param name="f1_env3" value="0" />
+ <param name="f1_keyf" value="1" />
+ <param name="f2_cutoff" value="2000" />
+ <param name="f2_res" value="2" />
+ <param name="f2_env1" value="0" />
+ <param name="f2_env2" value="8000" />
+ <param name="f2_env3" value="0" />
+ <param name="f2_keyf" value="0" />
+ <param name="adsr_a" value="2263.62" />
+ <param name="adsr_d" value="350" />
+ <param name="adsr_s" value="0.96" />
+ <param name="adsr_r" value="614.2" />
+ <param name="adsr_v" value="0" />
+ <param name="eg1_amp_ctl" value="4" />
+ <param name="adsr2_a" value="1" />
+ <param name="adsr2_d" value="350" />
+ <param name="adsr2_s" value="0.5" />
+ <param name="adsr2_r" value="50" />
+ <param name="adsr2_v" value="0" />
+ <param name="eg2_amp_ctl" value="0" />
+ <param name="adsr3_a" value="1" />
+ <param name="adsr3_d" value="350" />
+ <param name="adsr3_s" value="0.5" />
+ <param name="adsr3_r" value="50" />
+ <param name="adsr3_v" value="0" />
+ <param name="eg3_amp_ctl" value="0" />
+ <param name="vib_rate" value="6.6" />
+ <param name="vib_amt" value="0.5" />
+ <param name="vib_wet" value="0.5" />
+ <param name="vib_phase" value="180" />
+ <param name="vib_mode" value="0" />
+</preset>
</presets>
diff --git a/src/calf/modules.h b/src/calf/modules.h
index 11879ec..9db53c9 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -543,21 +543,21 @@ public:
class rotary_speaker_audio_module: public null_audio_module
{
public:
- enum { par_speed, par_spacing, par_shift, param_count };
+ enum { par_speed, par_spacing, par_shift, par_moddepth, param_count };
enum { in_count = 2, out_count = 2, support_midi = true, rt_capable = true };
static const char *port_names[];
float *ins[in_count];
float *outs[out_count];
float *params[param_count];
- double phase_l, dphase_l, phase_h, dphase_h;
- int cos_l, sin_l, cos_h, sin_h;
- dsp::simple_delay<4096, float> delay;
+ unsigned int phase_l, dphase_l, phase_h, dphase_h;
+ dsp::simple_delay<1024, float> delay;
dsp::biquad<float> crossover1l, crossover1r, crossover2l, crossover2r;
dsp::simple_delay<8, float> phaseshift;
uint32_t srate;
int vibrato_mode;
static parameter_properties param_props[];
float mwhl_value, hold_value, aspeed_l, aspeed_h, dspeed;
+ unsigned int dphase2_l, dphase2_h;
rotary_speaker_audio_module()
{
@@ -607,19 +607,17 @@ public:
{
float speed_h = aspeed_h >= 0 ? (48 + (400-48) * aspeed_h) : (48 * (1 + aspeed_h));
float speed_l = aspeed_l >= 0 ? 40 + (342-40) * aspeed_l : (40 * (1 + aspeed_l));
- dphase_h = speed_h / (60 * srate);
- dphase_l = speed_l / (60 * srate);
- cos_h = (int)(16384*16384*cos(dphase_h * 2 * PI));
- sin_h = (int)(16384*16384*sin(dphase_h * 2 * PI));
- cos_l = (int)(16384*16384*cos(dphase_l * 2 * PI));
- sin_l = (int)(16384*16384*sin(dphase_l * 2 * PI));
- }
- static inline void update_euler(long long int &x, long long int &y, int dx, int dy)
+ double fdphase_h = speed_h / (60 * srate);
+ double fdphase_l = speed_l / (60 * srate);
+ dphase_h = (unsigned int)(fdphase_h * (1 << 30)) << 2;
+ dphase_l = (unsigned int)(fdphase_l * (1 << 30)) << 2;
+ }
+ /// map a ramp [int] to a sinusoid-like function [0, 65536]
+ static inline int pseudo_sine_scl(int counter)
{
- long long int nx = (x * dx - y * dy) >> 28;
- long long int ny = (x * dy + y * dx) >> 28;
- x = nx;
- y = ny;
+ // premature optimization is a root of all evil; it can be done with integers only - but later :)
+ double v = counter * (1.0 / (65536.0 * 32768.0));
+ return 32768 + 32768 * (v - v*v*v) * (1.0 / 0.3849);
}
inline bool update_speed(float &aspeed, float delta_decc, float delta_acc)
{
@@ -636,30 +634,21 @@ public:
}
uint32_t process(uint32_t offset, uint32_t nsamples, uint32_t inputs_mask, uint32_t outputs_mask)
{
- long long int xl0 = (int)(10000*16384*cos(phase_l * 2 * PI));
- long long int yl0 = (int)(10000*16384*sin(phase_l * 2 * PI));
- long long int xh0 = (int)(10000*16384*cos(phase_h * 2 * PI));
- long long int yh0 = (int)(10000*16384*sin(phase_h * 2 * PI));
-// int shift = 500000, pdelta = 150000;
int shift = (int)(300000 * (*params[par_shift])), pdelta = (int)(300000 * (*params[par_spacing]));
- // printf("xl=%d yl=%d dx=%d dy=%d\n", (int)(xl0>>14), (int)(yl0 >> 14), cos_l, sin_l);
+ int md = (int)(100 * (*params[par_moddepth]));
for (unsigned int i = 0; i < nsamples; i++) {
float in_l = ins[0][i + offset], in_r = ins[1][i + offset];
float in_mono = 0.5f * (in_l + in_r);
- // int xl = (int)(10000 * cos(phase_l)), yl = (int)(10000 * sin(phase_l));
- //int xh = (int)(10000 * cos(phase_h)), yh = (int)(10000 * sin(phase_h));
- int xl = xl0 >> 14, yl = yl0 >> 14;
- int xh = xh0 >> 14, yh = yh0 >> 14;
- update_euler(xl0, yl0, cos_l, sin_l);
- // printf("xl=%d yl=%d xl'=%f yl'=%f\n", xl, yl, 16384*cos((phase_l + dphase_l * i) * 2 * PI), 16384*sin((phase_l + dphase_l * i) * 2 * PI));
- update_euler(xh0, yh0, cos_h, sin_h);
+ int xl = pseudo_sine_scl(phase_l), yl = pseudo_sine_scl(phase_l + 0x40000000);
+ int xh = pseudo_sine_scl(phase_h), yh = pseudo_sine_scl(phase_h + 0x40000000);
+ // printf("%d %d %d\n", shift, pdelta, shift + pdelta + 20 * xl);
- float out_hi_l = 0.5f * in_mono - delay.get_interp_1616(shift + 20 * xh) + 0.0001 * xh * delay.get_interp_1616(shift + pdelta - 20 * yh) - delay.get_interp_1616(shift + pdelta + pdelta - 20 * xh);
- float out_hi_r = 0.5f * in_mono + delay.get_interp_1616(shift - 20 * yh) - 0.0001 * yh * delay.get_interp_1616(shift + pdelta + 20 * xh) + delay.get_interp_1616(shift + pdelta + pdelta + 20 * yh);
+ float out_hi_l = 0.5f * in_mono - delay.get_interp_1616(shift + md * xh) + 0.0001 * xh * delay.get_interp_1616(shift + md * 65536 + pdelta - md * yh) - delay.get_interp_1616(shift + md * 65536 + pdelta + pdelta - md * xh);
+ float out_hi_r = 0.5f * in_mono + delay.get_interp_1616(shift + md * 65536 - md * yh) - 0.0001 * yh * delay.get_interp_1616(shift + pdelta + md * xh) + delay.get_interp_1616(shift + pdelta + pdelta + md * yh);
- float out_lo_l = 0.5f * in_mono - delay.get_interp_1616(shift + 20 * xl) + delay.get_interp_1616(shift + pdelta - 20 * yl);
- float out_lo_r = 0.5f * in_mono + delay.get_interp_1616(shift - 20 * xl) - delay.get_interp_1616(shift + pdelta + 20 * yl);
+ float out_lo_l = 0.5f * in_mono - delay.get_interp_1616(shift + md * xl) + delay.get_interp_1616(shift + md * 65536 + pdelta - md * yl);
+ float out_lo_r = 0.5f * in_mono + delay.get_interp_1616(shift + md * 65536 - md * xl) - delay.get_interp_1616(shift + pdelta + md * yl);
out_hi_l = crossover2l.process_d2(out_hi_l); // sanitize(out_hi_l);
out_hi_r = crossover2r.process_d2(out_hi_r); // sanitize(out_hi_r);
@@ -675,13 +664,13 @@ public:
outs[0][i + offset] = out_l * 0.5f;
outs[1][i + offset] = out_r * 0.5f;
delay.put(in_mono);
+ phase_l += dphase_l;
+ phase_h += dphase_h;
}
crossover1l.sanitize_d2();
crossover1r.sanitize_d2();
crossover2l.sanitize_d2();
crossover2r.sanitize_d2();
- phase_l = fmod(phase_l + nsamples * dphase_l, 1.0);
- phase_h = fmod(phase_h + nsamples * dphase_h, 1.0);
float delta = nsamples * 1.0 / srate;
bool u1 = update_speed(aspeed_l, delta * 0.2, delta * 0.14);
bool u2 = update_speed(aspeed_h, delta, delta * 0.5);
diff --git a/src/calf/organ.h b/src/calf/organ.h
index 2dfc359..228a5f2 100644
--- a/src/calf/organ.h
+++ b/src/calf/organ.h
@@ -95,6 +95,8 @@ public:
wave_bellpad,
wave_space,
wave_choir,
+ wave_choir2,
+ wave_choir3,
wave_count,
wave_count_big = wave_count - wave_count_small
};
diff --git a/src/calf/utils.h b/src/calf/utils.h
index ae2d663..9babfa6 100644
--- a/src/calf/utils.h
+++ b/src/calf/utils.h
@@ -88,6 +88,22 @@ public:
}
};
+template<class T>
+class scope_assign
+{
+ T &data, old_value;
+public:
+ scope_assign(T &_data, T new_value)
+ : data(_data), old_value(_data)
+ {
+ data = new_value;
+ }
+ ~scope_assign()
+ {
+ data = old_value;
+ }
+};
+
typedef std::map<std::string, std::string> dictionary;
extern std::string encodeMap(const dictionary &data);
diff --git a/src/gui.cpp b/src/gui.cpp
index 966f22a..b6331e6 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -744,7 +744,9 @@ GtkWidget *plugin_gui::create_from_xml(plugin_ctl_iface *_plugin, const char *xm
XML_SetElementHandler(parser, xml_element_start, xml_element_end);
XML_Status status = XML_Parse(parser, xml, strlen(xml), 1);
if (status == XML_STATUS_ERROR)
+ {
g_error("Parse error: %s in XML", XML_ErrorString(XML_GetErrorCode(parser)));
+ }
XML_ParserFree(parser);
return GTK_WIDGET(top_container->container);
diff --git a/src/lv2gui.cpp b/src/lv2gui.cpp
index fecf621..c40b261 100644
--- a/src/lv2gui.cpp
+++ b/src/lv2gui.cpp
@@ -29,10 +29,12 @@
#include <calf/benchmark.h>
#include <calf/lv2_ui.h>
#include <calf/preset_gui.h>
+#include <calf/utils.h>
using namespace std;
using namespace dsp;
using namespace synth;
+using namespace calf_utils;
struct plugin_proxy_base: public plugin_ctl_iface
{
@@ -80,9 +82,8 @@ struct plugin_proxy: public plugin_proxy_base, public line_graph_iface
return;
params[param_no] = value;
if (send) {
- send = false;
+ scope_assign<bool> _a_(send, false);
write_function(controller, param_no + Module::in_count + Module::out_count, sizeof(float), 0, ¶ms[param_no]);
- send = true;
}
}
virtual int get_param_count()
@@ -164,6 +165,7 @@ LV2UI_Handle gui_instantiate(const struct _LV2UI_Descriptor* descriptor,
const LV2_Feature* const* features)
{
plugin_proxy_base *proxy = create_plugin_proxy(plugin_uri + sizeof("http://calf.sourceforge.net/plugins/") - 1);
+ scope_assign<bool> _a_(proxy->send, false);
proxy->setup(write_function, controller);
// dummy window
main_window *main = new main_window;
@@ -194,7 +196,12 @@ void gui_port_event(LV2UI_Handle handle, uint32_t port, uint32_t buffer_size, ui
return;
if (fabs(gui->plugin->get_param_value(port) - v) < 0.00001)
return;
- gui->set_param_value(port, v);
+ plugin_proxy_base *proxy = dynamic_cast<plugin_proxy_base *>(gui->plugin);
+ assert(proxy);
+ {
+ scope_assign<bool> _a_(proxy->send, false);
+ gui->set_param_value(port, v);
+ }
}
const void *gui_extension(const char *uri)
diff --git a/src/modules.cpp b/src/modules.cpp
index eb28664..6f0e1ec 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -166,6 +166,7 @@ parameter_properties rotary_speaker_audio_module::param_props[] = {
{ 2, 0, 4, 1.01, PF_ENUM | PF_CTL_COMBO, rotary_speaker_speed_names, "vib_speed", "Speed Mode" },
{ 0.5, 0, 1, 0, PF_FLOAT | PF_CTL_KNOB | PF_SCALE_PERC, NULL, "spacing", "Tap Spacing" },
{ 0.5, 0, 1, 0, PF_FLOAT | PF_CTL_KNOB | PF_SCALE_PERC, NULL, "shift", "Tap Offset" },
+ { 0.15, 0, 1, 0, PF_FLOAT | PF_CTL_KNOB | PF_SCALE_PERC, NULL, "mod_depth", "Mod Depth" },
};
static synth::ladspa_info rotary_speaker_info = { 0x8483, "RotarySpeaker", "Calf Rotary Speaker", "Krzysztof Foltman", copyright, "SimulationPlugin" };
diff --git a/src/organ.cpp b/src/organ.cpp
index 513ddea..f8b3939 100644
--- a/src/organ.cpp
+++ b/src/organ.cpp
@@ -53,7 +53,9 @@ const char *organ_audio_module::get_gui_xml()
return
"<vbox border=\"10\">"
"<hbox>"
- "<line-graph param=\"master\" refresh=\"1\"/>"
+ "<if cond=\"directlink\">"
+ "<line-graph param=\"master\" refresh=\"1\"/>"
+ "</if>"
"<vbox>"
"<label param=\"foldnote\"/>"
"<align><knob param=\"foldnote\"/></align>"
@@ -350,7 +352,7 @@ const char *organ_wave_names[] = {
"Bell", "Bell2",
"W1", "W2", "W3", "W4", "W5", "W6", "W7", "W8", "W9",
"DSaw", "DSqr", "DPls",
- "P:SynStr","P:WideStr","P:Sine","P:Bell","P:Space","P:Voice"
+ "P:SynStr","P:WideStr","P:Sine","P:Bell","P:Space","P:Voice","P:Hiss","P:Chant",
};
const char *organ_routing_names[] = { "Out", "Flt 1", "Flt 2" };
@@ -526,7 +528,7 @@ static void padsynth(bandlimiter<ORGAN_WAVE_BITS> blSrc, bandlimiter<ORGAN_BIG_W
}
int periods = 64 * ORGAN_BIG_WAVE_SIZE / ORGAN_WAVE_SIZE;
- for (int i = 0; i <= ORGAN_BIG_WAVE_SIZE; i++) {
+ for (int i = 0; i <= ORGAN_BIG_WAVE_SIZE / 2; i++) {
blDest.spectrum[i] = 0;
}
for (int i = 1; i <= ORGAN_WAVE_SIZE / 2; i++) {
@@ -538,7 +540,7 @@ static void padsynth(bandlimiter<ORGAN_WAVE_BITS> blSrc, bandlimiter<ORGAN_BIG_W
for (int j = delta; j <= bw; j+=delta)
{
float p = j * 1.0 / bw;
- sum += exp(-p*p);
+ sum += 2 * exp(-p*p);
}
if (sum < 0.0001)
continue;
@@ -786,28 +788,35 @@ organ_voice_base::organ_voice_base(organ_parameters *_parameters)
bl.compute_spectrum(tmp);
padsynth(bl, blBig, big_waves[wave_space - wave_count_small], 30, 30);
-#if 0
for (int i = 0; i < ORGAN_WAVE_SIZE; i++)
{
float ph = i * 2 * M_PI / ORGAN_WAVE_SIZE;
- float fm = 0.3 * sin(3*ph) + 0.3 * sin(4*ph) + 0.3 * sin(5*ph);
- tmp[i] = sin(ph + fm) + 0.5 * cos(2*ph - fm);
+ float fm = 0.5 * sin(ph) + 0.5 * sin(2*ph) + 0.5 * sin(3*ph);
+ tmp[i] = sin(ph + fm) + 0.5 * cos(7*ph - 2 * fm) + 0.25 * cos(13*ph - 4 * fm);
}
normalize_waveform(tmp, ORGAN_WAVE_SIZE);
bl.compute_spectrum(tmp);
padsynth(bl, blBig, big_waves[wave_choir - wave_count_small], 50, 10);
-#endif
-
+
for (int i = 0; i < ORGAN_WAVE_SIZE; i++)
{
float ph = i * 2 * M_PI / ORGAN_WAVE_SIZE;
- float fm = 0.5 * sin(ph) + 0.5 * sin(2*ph) + 0.5 * sin(3*ph);
- tmp[i] = sin(ph + fm) + 0.5 * cos(7*ph - 2 * fm) + 0.25 * cos(13*ph - 4 * fm);
+ float fm = sin(ph) ;
+ tmp[i] = sin(ph + fm) + 0.25 * cos(11*ph - 2 * fm) + 0.125 * cos(23*ph - 2 * fm) + 0.0625 * cos(49*ph - 2 * fm);
}
normalize_waveform(tmp, ORGAN_WAVE_SIZE);
bl.compute_spectrum(tmp);
- padsynth(bl, blBig, big_waves[wave_choir - wave_count_small], 50, 10);
+ padsynth(bl, blBig, big_waves[wave_choir2 - wave_count_small], 50, 10);
+ for (int i = 0; i < ORGAN_WAVE_SIZE; i++)
+ {
+ float ph = i * 2 * M_PI / ORGAN_WAVE_SIZE;
+ float fm = sin(ph) ;
+ tmp[i] = sin(ph + 4 * fm) + 0.5 * sin(2 * ph + 4 * ph);
+ }
+ normalize_waveform(tmp, ORGAN_WAVE_SIZE);
+ bl.compute_spectrum(tmp);
+ padsynth(bl, blBig, big_waves[wave_choir3 - wave_count_small], 50, 10);
}
}
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list