[SCM] calf/master: + Wavetable: add missing files

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


The following commit has been merged in the master branch:
commit 334505e144e6930bd5cbf7f2792ee29bb8575540
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Sat Feb 28 13:25:43 2009 +0000

    + Wavetable: add missing files

diff --git a/src/calf/wavetable.h b/src/calf/wavetable.h
new file mode 100644
index 0000000..87ad106
--- /dev/null
+++ b/src/calf/wavetable.h
@@ -0,0 +1,98 @@
+#ifndef __CALF_WAVETABLE_H
+#define __CALF_WAVETABLE_H
+
+#include <assert.h>
+#include "biquad.h"
+#include "onepole.h"
+#include "audio_fx.h"
+#include "inertia.h"
+#include "osc.h"
+#include "synth.h"
+#include "envelope.h"
+
+namespace calf_plugins {
+
+#define WAVETABLE_WAVE_BITS 8
+
+class wavetable_voice: public dsp::voice
+{
+public:
+    enum { Channels = 2, BlockSize = 64, EnvCount = 3, OscCount = 1 };
+    float output_buffer[BlockSize][Channels];
+protected:
+    int note;
+    float **params;
+    dsp::decay amp;
+    dsp::simple_oscillator oscs[OscCount];
+    dsp::adsr envs[EnvCount];
+public:
+    void set_params_ptr(float **_params) { params = _params; }
+    void reset();
+    void note_on(int note, int vel);
+    void note_off(int /* vel */);
+    void steal();
+    void render_block();
+    virtual int get_current_note() {
+        return note;
+    }
+    virtual bool get_active() {
+        // printf("note %d getactive %d use_percussion %d pamp active %d\n", note, amp.get_active(), use_percussion(), pamp.get_active());
+        return (note != -1) && (amp.get_active());
+    }
+};    
+
+class wavetable_audio_module: public audio_module<wavetable_metadata>, public dsp::basic_synth
+{
+public:
+    using dsp::basic_synth::note_on;
+    using dsp::basic_synth::note_off;
+    using dsp::basic_synth::control_change;
+    using dsp::basic_synth::pitch_bend;
+    uint32_t srate; // XXXKF hack!
+
+protected:
+    uint32_t crate;
+    bool panic_flag;
+
+public:
+    float *ins[in_count]; 
+    float *outs[out_count];
+    float *params[param_count];
+
+public:
+    wavetable_audio_module()
+    {
+        panic_flag = false;
+    }
+
+    dsp::voice *alloc_voice() {
+        dsp::block_voice<wavetable_voice> *v = new dsp::block_voice<wavetable_voice>();
+        v->set_params_ptr(params);
+        return v;
+    }
+    
+    /// process function copied from Organ (will probably need some adjustments as well as implementing the panic flag elsewhere
+    uint32_t process(uint32_t offset, uint32_t nsamples, uint32_t inputs_mask, uint32_t outputs_mask) {
+        float *o[2] = { outs[0] + offset, outs[1] + offset };
+        if (panic_flag)
+        {
+            control_change(120, 0); // stop all sounds
+            control_change(121, 0); // reset all controllers
+            panic_flag = false;
+        }
+        float buf[4096][2];
+        dsp::zero(&buf[0][0], 2 * nsamples);
+        basic_synth::render_to(buf, nsamples);
+        float gain = 1.0f;
+        for (uint32_t i=0; i<nsamples; i++) {
+            o[0][i] = gain*buf[i][0];
+            o[1][i] = gain*buf[i][1];
+        }
+        return 3;
+    }
+};
+
+    
+};
+
+#endif
diff --git a/src/wavetable.cpp b/src/wavetable.cpp
new file mode 100644
index 0000000..899d644
--- /dev/null
+++ b/src/wavetable.cpp
@@ -0,0 +1,71 @@
+/* Calf DSP Library
+ * Example audio modules - wavetable synthesizer
+ *
+ * Copyright (C) 2009 Krzysztof Foltman
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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.
+ */
+#include <config.h>
+
+#if ENABLE_EXPERIMENTAL
+    
+#include <assert.h>
+#include <memory.h>
+#include <complex>
+#if USE_JACK
+#include <jack/jack.h>
+#endif
+#include <calf/giface.h>
+#include <calf/modules_synths.h>
+#include <iostream>
+
+using namespace dsp;
+using namespace calf_plugins;
+
+void wavetable_voice::reset()
+{
+    note = -1;
+}
+
+void wavetable_voice::note_on(int note, int vel)
+{
+    this->note = note;
+    amp.set(1.0);
+    for (int i = 0; i < OscCount; i++)
+        oscs[i].reset();
+    for (int i = 0; i < EnvCount; i++)
+        envs[i].note_on();
+}
+
+void wavetable_voice::note_off(int /* vel */)
+{
+    for (int i = 0; i < EnvCount; i++)
+        envs[i].note_off();
+}
+
+void wavetable_voice::steal()
+{
+}
+
+void wavetable_voice::render_block()
+{
+    for (int i = 0; i < BlockSize; i++)
+        output_buffer[i][0] = output_buffer[i][1] = oscs[0].get() * envs[0].value;
+    for (int i = 0; i < EnvCount; i++)
+        envs[i].advance();    
+}
+
+#endif

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list