[SCM] calf/master: + Wavetable: add more wavetables and the ability to select them

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:39:25 UTC 2013


The following commit has been merged in the master branch:
commit 3680d427402c5019d2c1bfe64e0379751201214b
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Sun Mar 1 15:59:35 2009 +0000

    + Wavetable: add more wavetables and the ability to select them

diff --git a/src/calf/metadata.h b/src/calf/metadata.h
index c5568dc..99f852c 100644
--- a/src/calf/metadata.h
+++ b/src/calf/metadata.h
@@ -214,6 +214,15 @@ struct fluidsynth_metadata: public plugin_metadata<fluidsynth_metadata>
 /// Wavetable - metadata
 struct wavetable_metadata: public plugin_metadata<wavetable_metadata>
 {
+    enum {
+        wt_fmshiny,
+        wt_fmshiny2,
+        wt_rezo,
+        wt_metal,
+        wt_bell,
+        wt_blah,
+        wt_count
+    };
     enum { 
         par_o1wave, par_o1offset, par_o1transpose, par_o1detune, par_o1level,
         par_o2wave, par_o2offset, par_o2transpose, par_o2detune, par_o2level,
diff --git a/src/calf/wavetable.h b/src/calf/wavetable.h
index 4e6a2c5..a7c6a9e 100644
--- a/src/calf/wavetable.h
+++ b/src/calf/wavetable.h
@@ -88,7 +88,7 @@ public:
     float *ins[in_count]; 
     float *outs[out_count];
     float *params[param_count];
-    int16_t tables[129][256]; // one dummy level for interpolation
+    int16_t tables[wt_count][129][256]; // one dummy level for interpolation
 
 public:
     wavetable_audio_module();
diff --git a/src/modules.cpp b/src/modules.cpp
index f00915b..7b5ee5f 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -504,6 +504,15 @@ CALF_PORT_PROPS(fluidsynth) = {
 
 ////////////////////////////////////////////////////////////////////////////
 
+const char *wavetable_names[] = { 
+    "Shiny1",
+    "Shiny2",
+    "Rezo",
+    "Metal",
+    "Bell",
+    "Blah",
+};
+
 const char *wavetable_init_soundfont = "";
 
 CALF_PORT_NAMES(wavetable) = {
@@ -513,13 +522,13 @@ CALF_PORT_NAMES(wavetable) = {
 CALF_PLUGIN_INFO(wavetable) = { 0x8701, "Wavetable", "Calf Wavetable", "Krzysztof Foltman", calf_plugins::calf_copyright_info, "SynthesizerPlugin" };
 
 CALF_PORT_PROPS(wavetable) = {
-    { 0,       0,  organ_enums::wave_count - 1, 0, PF_ENUM | PF_SCALE_LINEAR | PF_CTL_COMBO, organ_wave_names, "o1wave", "Osc1 Wave" },
+    { 0,       0,  wavetable_metadata::wt_count - 1, 0, PF_ENUM | PF_SCALE_LINEAR | PF_CTL_COMBO, wavetable_names, "o1wave", "Osc1 Wave" },
     { 0.2,     -1,      1,  0, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "o1offset", "Osc1 Ctl"},
     { 0,        -48,   48, 48*2+1, PF_INT   | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_SEMITONES, NULL, "o1trans", "Osc1 Transpose" },
     { 6,       -100,  100,      0, PF_INT   | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "o1detune", "Osc1 Detune" },
     { 0.1,      0,   1,     0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "o1level", "Osc1 Level" },
 
-    { 0,       0,  organ_enums::wave_count - 1, 0, PF_ENUM | PF_SCALE_LINEAR | PF_CTL_COMBO, organ_wave_names, "o2wave", "Osc2 Wave" },
+    { 0,       0,  wavetable_metadata::wt_count - 1, 0, PF_ENUM | PF_SCALE_LINEAR | PF_CTL_COMBO, wavetable_names, "o2wave", "Osc2 Wave" },
     { 0.4,     -1,      1,  0, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "o2offset", "Osc2 Ctl"},
     { 0,        -48,   48, 48*2+1, PF_INT   | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_SEMITONES, NULL, "o2trans", "Osc2 Transpose" },
     { -6,     -100,  100,      0, PF_INT   | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_CENTS, NULL, "o2detune", "Osc2 Detune" },
diff --git a/src/wavetable.cpp b/src/wavetable.cpp
index e5960a7..75a7a8f 100644
--- a/src/wavetable.cpp
+++ b/src/wavetable.cpp
@@ -58,7 +58,6 @@ void wavetable_voice::note_on(int note, int vel)
     velocity = vel / 127.0;
     amp.set(1.0);
     for (int i = 0; i < OscCount; i++) {
-        oscs[i].tables = parent->tables;
         oscs[i].reset();
         oscs[i].set_freq(note_to_hz(note, 0), sample_rate);
     }
@@ -85,8 +84,10 @@ void wavetable_voice::render_block()
     
     int ospc = md::par_o2level - md::par_o1level;
     int espc = md::par_eg2attack - md::par_eg1attack;
-    for (int j = 0; j < OscCount; j++)
+    for (int j = 0; j < OscCount; j++) {
+        oscs[j].tables = parent->tables[(int)*params[md::par_o1wave + j * ospc]];
         oscs[j].set_freq(note_to_hz(note, *params[md::par_o1transpose + j * ospc] * 100+ *params[md::par_o1detune + j * ospc]), sample_rate);
+    }
     float s = 0.001;
     for (int j = 0; j < EnvCount; j++) {
         int o = j*espc;
@@ -117,7 +118,7 @@ void wavetable_voice::render_block()
 wavetable_audio_module::wavetable_audio_module()
 {
     panic_flag = false;
-    for (int i = 0; i < 128; i++)
+    for (int i = 0; i < 129; i++)
     {
         for (int j = 0; j < 256; j++)
         {
@@ -130,7 +131,76 @@ wavetable_audio_module::wavetable_audio_module()
             float rezo2 = sin(floor(peak + 1) * ph);
             float v1 = sin (ph + 2 * ii * sin(2 * ph) + 2 * ii * ii * sin(4 * ph) + ii * ii * rezo1);
             float v2 = sin (ph + 2 * ii2 * sin(2 * ph) + 2 * ii2 * ii2 * sin(4 * ph) + ii2 * ii2 * rezo2);
-            tables[i][j] = 32767 * lerp(v1, v2, (i & 3) / 4.0);
+            tables[0][i][j] = 32767 * lerp(v1, v2, (i & 3) / 4.0);
+        }
+    }
+    for (int i = 0; i < 129; i++)
+    {
+        for (int j = 0; j < 256; j++)
+        {
+            //tables[i][j] = i < j ? -32767 : 32767;
+            float ph = j * 2 * M_PI / 256;
+            float ii = (i & ~3) / 128.0;
+            float ii2 = ((i & ~3) + 4) / 128.0;
+            float peak = (32 * ii);
+            float rezo1 = sin(floor(peak) * ph);
+            float rezo2 = sin(floor(peak + 1) * ph);
+            float v1 = sin (ph + ii * ii * rezo1);
+            float v2 = sin (ph + ii2 * ii2 * rezo2);
+            tables[1][i][j] = 32767 * lerp(v1, v2, (i & 3) / 4.0);
+        }
+    }
+    for (int i = 0; i < 129; i++)
+    {
+        for (int j = 0; j < 256; j++)
+        {
+            //tables[i][j] = i < j ? -32767 : 32767;
+            float ph = j * 2 * M_PI / 256;
+            float ii = (i & ~3) / 128.0;
+            float ii2 = ((i & ~3) + 4) / 128.0;
+            float peak = (32 * ii);
+            float rezo1 = sin(floor(peak) * ph);
+            float rezo2 = sin(floor(peak + 1) * ph);
+            float widener = (0.5 + 0.3 * sin(ph) + 0.2 * sin (3 * ph));
+            float v1 = 0.5 * sin (ph) + 0.5 * ii * ii * rezo1 * widener;
+            float v2 = 0.5 * sin (ph) + 0.5 * ii2 * ii2 * rezo2 * widener;
+            tables[wavetable_metadata::wt_rezo][i][j] = 32767 * lerp(v1, v2, (i & 3) / 4.0);
+        }
+    }
+    for (int i = 0; i < 129; i++)
+    {
+        for (int j = 0; j < 256; j++)
+        {
+            //tables[i][j] = i < j ? -32767 : 32767;
+            float ph = j * 2 * M_PI / 256;
+            float ii = i / 128.0;
+            //float v = (sin(ph) + ii * sin(ph + 2 * ii * sin(ph)) + ii * ii * sin(ph + 3 * ii * ii * sin(3 * ph)) + ii * ii * ii * sin(ph + 5 * ii * ii * ii * sin(5 * ph))) / 4;
+            float v = (sin(ph) + ii * sin(ph + 2 * ii * sin(ph)) + ii * ii * sin(ph + 6 * ii * ii * sin(6 * ph)) + ii * ii * ii * ii * sin(ph + 11 * ii * ii * ii * ii * sin(11 * ph))) / 4;
+            tables[wavetable_metadata::wt_metal][i][j] = 32767 * v;
+        }
+    }
+    for (int i = 0; i < 129; i++)
+    {
+        for (int j = 0; j < 256; j++)
+        {
+            //tables[i][j] = i < j ? -32767 : 32767;
+            float ph = j * 2 * M_PI / 256;
+            float ii = i / 128.0;
+            //float v = (sin(ph) + ii * sin(ph + 2 * ii * sin(ph)) + ii * ii * sin(ph + 3 * ii * ii * sin(3 * ph)) + ii * ii * ii * sin(ph + 5 * ii * ii * ii * sin(5 * ph))) / 4;
+            float v = (sin(ph) + ii * sin(ph - 3 * ii * sin(ph)) + ii * ii * sin(5 * ph - 5 * ii * ii * ii * ii * sin(11 * ph))) / 3;
+            tables[wavetable_metadata::wt_bell][i][j] = 32767 * v;
+        }
+    }
+    for (int i = 0; i < 129; i++)
+    {
+        for (int j = 0; j < 256; j++)
+        {
+            //tables[i][j] = i < j ? -32767 : 32767;
+            float ph = j * 2 * M_PI / 256;
+            float ii = i / 128.0;
+            //float v = (sin(ph) + ii * sin(ph + 2 * ii * sin(ph)) + ii * ii * sin(ph + 3 * ii * ii * sin(3 * ph)) + ii * ii * ii * sin(ph + 5 * ii * ii * ii * sin(5 * ph))) / 4;
+            float v = (sin(ph) + sin(ph - 3 * sin(ii * 5 - 2) * sin(ph)) + sin(ii * 4 - 1.3) * sin(5 * ph + 3 * ii * ii * sin(6 * ph))) / 3;
+            tables[wavetable_metadata::wt_blah][i][j] = 32767 * v;
         }
     }
 }

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list