2 * Modulation matrix boilerplate code.
4 * Copyright (C) 2001-2007 Krzysztof Foltman
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General
17 * Public License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301 USA
23 #include <calf/modmatrix.h>
27 using namespace calf_plugins
;
29 const char *mod_mapping_names
[] = { "0..1", "-1..1", "-1..0", "x^2", "2x^2-1", "ASqr", "ASqrBip", "Para", NULL
};
31 const float mod_matrix::scaling_coeffs
[dsp::map_type_count
][3] = {
42 mod_matrix::mod_matrix(modulation_entry
*_matrix
, unsigned int _rows
, const char **_src_names
, const char **_dest_names
)
45 , mod_src_names(_src_names
)
46 , mod_dest_names(_dest_names
)
48 table_column_info tci
[6] = {
49 { "Source", TCT_ENUM
, 0, 0, 0, mod_src_names
},
50 { "Mapping", TCT_ENUM
, 0, 0, 0, mod_mapping_names
},
51 { "Modulator", TCT_ENUM
, 0, 0, 0, mod_src_names
},
52 { "Amount", TCT_FLOAT
, 0, 1, 1, NULL
},
53 { "Destination", TCT_ENUM
, 0, 0, 0, mod_dest_names
},
56 assert(sizeof(table_columns
) == sizeof(tci
));
57 memcpy(table_columns
, tci
, sizeof(table_columns
));
58 for (unsigned int i
= 0; i
< matrix_rows
; i
++)
62 const table_column_info
*mod_matrix::get_table_columns(int param
)
67 uint32_t mod_matrix::get_table_rows(int param
)
72 std::string
mod_matrix::get_cell(int param
, int row
, int column
)
74 assert(row
>= 0 && row
< (int)matrix_rows
);
75 modulation_entry
&slot
= matrix
[row
];
78 return mod_src_names
[slot
.src1
];
79 case 1: // mapping mode
80 return mod_mapping_names
[slot
.mapping
];
82 return mod_src_names
[slot
.src2
];
84 return calf_utils::f2s(slot
.amount
);
85 case 4: // destination
86 return mod_dest_names
[slot
.dest
];
93 void mod_matrix::set_cell(int param
, int row
, int column
, const std::string
&src
, std::string
&error
)
95 assert(row
>= 0 && row
< (int)matrix_rows
);
96 modulation_entry
&slot
= matrix
[row
];
97 const char **arr
= mod_src_names
;
99 arr
= mod_mapping_names
;
101 arr
= mod_dest_names
;
108 for (int i
= 0; arr
[i
]; i
++)
114 else if (column
== 1)
115 slot
.mapping
= (mapping_mode
)i
;
116 else if (column
== 2)
118 else if (column
== 4)
124 error
= "Invalid name: " + src
;
129 stringstream
ss(src
);