[SCM] calf/master: + Mod Matrix: apply mapping to source only, not source * modulator, makes more sense this way
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:39:34 UTC 2013
The following commit has been merged in the master branch:
commit 304a66948df247e315941fddbaaed921df693902
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Sat May 23 23:32:45 2009 +0100
+ Mod Matrix: apply mapping to source only, not source * modulator, makes more sense this way
diff --git a/src/calf/modmatrix.h b/src/calf/modmatrix.h
index fa80654..e43e09f 100644
--- a/src/calf/modmatrix.h
+++ b/src/calf/modmatrix.h
@@ -25,31 +25,42 @@
namespace dsp {
-/// Modulation modes
-enum modulation_mode {
- mod_positive, ///< 0..100%
- mod_bipolar, ///< -100%..100%
- mod_negative, ///< -100%..0%
- mod_squared, ///< x^2
- mod_squared_bipolar, ///< x^2 scaled to -100%..100%
- mod_antisquared, ///< 1-(1-x)^2 scaled to 0..100%
- mod_antisquared_bipolar, ///< 1-(1-x)^2 scaled to -100..100%
- mod_parabola, ///< inverted parabola (peaks at 0.5, then decreases to 0)
- mod_type_count
+/// Mapping modes
+enum mapping_mode {
+ map_positive, ///< 0..100%
+ map_bipolar, ///< -100%..100%
+ map_negative, ///< -100%..0%
+ map_squared, ///< x^2
+ map_squared_bipolar, ///< x^2 scaled to -100%..100%
+ map_antisquared, ///< 1-(1-x)^2 scaled to 0..100%
+ map_antisquared_bipolar, ///< 1-(1-x)^2 scaled to -100..100%
+ map_parabola, ///< inverted parabola (peaks at 0.5, then decreases to 0)
+ map_type_count
};
+/// Single entry in modulation matrix
struct modulation_entry
{
- /// Sources
- int src1, src2;
- modulation_mode mapping;
+ /// Mapped source
+ int src1;
+ /// Source mapping mode
+ mapping_mode mapping;
+ /// Unmapped modulating source
+ int src2;
+ /// Modulation amount
float amount;
+ /// Modulation destination
int dest;
+ modulation_entry() {
+ reset();
+ }
+
+ /// Reset the row to default
void reset() {
src1 = 0;
src2 = 0;
- mapping = mod_positive;
+ mapping = map_positive;
amount = 0.f;
dest = 0;
}
@@ -63,7 +74,7 @@ class mod_matrix: public table_edit_iface
{
protected:
/// Polynomials for different scaling modes (1, x, x^2)
- static const float scaling_coeffs[dsp::mod_type_count][3];
+ static const float scaling_coeffs[dsp::map_type_count][3];
/// Column descriptions for table widget
table_column_info table_columns[6];
@@ -87,11 +98,10 @@ public:
{
dsp::modulation_entry &slot = matrix[i];
if (slot.dest) {
- float value = modsrc[slot.src1] * modsrc[slot.src2];
- value = dsp::clip<float>(value, 0, 1);
+ float value = modsrc[slot.src1];
const float *c = scaling_coeffs[slot.mapping];
value = c[0] + c[1] * value + c[2] * value * value;
- moddest[slot.dest] += value * slot.amount;
+ moddest[slot.dest] += value * modsrc[slot.src2] * slot.amount;
}
}
}
diff --git a/src/modmatrix.cpp b/src/modmatrix.cpp
index 518e57c..cba6ced 100644
--- a/src/modmatrix.cpp
+++ b/src/modmatrix.cpp
@@ -28,7 +28,7 @@ using namespace calf_plugins;
const char *mod_mapping_names[] = { "0..1", "-1..1", "-1..0", "x^2", "2x^2-1", "ASqr", "ASqrBip", "Para", NULL };
-const float mod_matrix::scaling_coeffs[dsp::mod_type_count][3] = {
+const float mod_matrix::scaling_coeffs[dsp::map_type_count][3] = {
{ 0, 1, 0 },
{ -1, 2, 0 },
{ -1, 1, 0 },
@@ -47,8 +47,8 @@ mod_matrix::mod_matrix(modulation_entry *_matrix, unsigned int _rows, const char
{
table_column_info tci[6] = {
{ "Source", TCT_ENUM, 0, 0, 0, mod_src_names },
- { "Modulator", TCT_ENUM, 0, 0, 0, mod_src_names },
{ "Mapping", TCT_ENUM, 0, 0, 0, mod_mapping_names },
+ { "Modulator", TCT_ENUM, 0, 0, 0, mod_src_names },
{ "Amount", TCT_FLOAT, 0, 1, 1, NULL},
{ "Destination", TCT_ENUM, 0, 0, 0, mod_dest_names },
{ NULL }
@@ -76,10 +76,10 @@ std::string mod_matrix::get_cell(int param, int row, int column)
switch(column) {
case 0: // source 1
return mod_src_names[slot.src1];
- case 1: // source 2
- return mod_src_names[slot.src2];
- case 2: // mapping mode
+ case 1: // mapping mode
return mod_mapping_names[slot.mapping];
+ case 2: // source 2
+ return mod_src_names[slot.src2];
case 3: // amount
return calf_utils::f2s(slot.amount);
case 4: // destination
@@ -95,7 +95,7 @@ void mod_matrix::set_cell(int param, int row, int column, const std::string &src
assert(row >= 0 && row < (int)matrix_rows);
modulation_entry &slot = matrix[row];
const char **arr = mod_src_names;
- if (column == 2)
+ if (column == 1)
arr = mod_mapping_names;
if (column == 4)
arr = mod_dest_names;
@@ -112,9 +112,9 @@ void mod_matrix::set_cell(int param, int row, int column, const std::string &src
if (column == 0)
slot.src1 = i;
else if (column == 1)
- slot.src2 = i;
+ slot.mapping = (mapping_mode)i;
else if (column == 2)
- slot.mapping = (modulation_mode)i;
+ slot.src2 = i;
else if (column == 4)
slot.dest = i;
error.clear();
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list