[SCM] calf/master: + Wavetable: actually start making any noise (trivial saw only for now)
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 ae289c5f4a8b588717fe8e02272c4aaed89da240
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Sat Feb 28 15:37:25 2009 +0000
+ Wavetable: actually start making any noise (trivial saw only for now)
diff --git a/src/calf/wavetable.h b/src/calf/wavetable.h
index 87ad106..1d405ad 100644
--- a/src/calf/wavetable.h
+++ b/src/calf/wavetable.h
@@ -26,7 +26,8 @@ protected:
dsp::simple_oscillator oscs[OscCount];
dsp::adsr envs[EnvCount];
public:
- void set_params_ptr(float **_params) { params = _params; }
+ wavetable_voice();
+ void set_params_ptr(float **_params, int _srate) { params = _params; sample_rate = _srate; }
void reset();
void note_on(int note, int vel);
void note_off(int /* vel */);
@@ -48,7 +49,6 @@ public:
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;
@@ -67,7 +67,7 @@ public:
dsp::voice *alloc_voice() {
dsp::block_voice<wavetable_voice> *v = new dsp::block_voice<wavetable_voice>();
- v->set_params_ptr(params);
+ v->set_params_ptr(params, sample_rate);
return v;
}
@@ -90,6 +90,11 @@ public:
}
return 3;
}
+
+ void set_sample_rate(uint32_t sr) {
+ setup(sr);
+ crate = sample_rate / wavetable_voice::BlockSize;
+ }
};
diff --git a/src/wavetable.cpp b/src/wavetable.cpp
index 899d644..0e26c40 100644
--- a/src/wavetable.cpp
+++ b/src/wavetable.cpp
@@ -35,6 +35,11 @@
using namespace dsp;
using namespace calf_plugins;
+wavetable_voice::wavetable_voice()
+{
+ sample_rate = -1;
+}
+
void wavetable_voice::reset()
{
note = -1;
@@ -44,13 +49,18 @@ void wavetable_voice::note_on(int note, int vel)
{
this->note = note;
amp.set(1.0);
- for (int i = 0; i < OscCount; i++)
+ for (int i = 0; i < OscCount; i++) {
oscs[i].reset();
- for (int i = 0; i < EnvCount; i++)
+ oscs[i].set_freq(note_to_hz(note, 0), sample_rate);
+ }
+ int cr = sample_rate / BlockSize;
+ for (int i = 0; i < EnvCount; i++) {
+ envs[i].set(0.01, 0.1, 0.5, 1, cr);
envs[i].note_on();
+ }
}
-void wavetable_voice::note_off(int /* vel */)
+void wavetable_voice::note_off(int vel)
{
for (int i = 0; i < EnvCount; i++)
envs[i].note_off();
@@ -63,7 +73,7 @@ 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;
+ output_buffer[i][0] = output_buffer[i][1] = oscs[0].get() * envs[0].value * envs[0].value;
for (int i = 0; i < EnvCount; i++)
envs[i].advance();
}
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list