LMMS
Loading...
Searching...
No Matches
modmatrix.h
Go to the documentation of this file.
1/* Calf DSP Library
2 * Modulation matrix boilerplate code.
3 *
4 * Copyright (C) 2009 Krzysztof Foltman
5 *
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.
10 *
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.
15 *
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 02111-1307, USA.
20 */
21#ifndef __CALF_MODMATRIX_H
22#define __CALF_MODMATRIX_H
23
24#include "giface.h"
25#include <stdio.h>
26
27namespace dsp {
28
31{
33 int src1;
37 int src2;
39 float amount;
41 int dest;
42
44 reset();
45 }
46 modulation_entry(int _src1, calf_plugins::mod_matrix_metadata::mapping_mode _mapping, int _src2, float _amount, int _dest) {
47 src1 = _src1;
48 mapping = _mapping;
49 src2 = _src2;
50 amount = _amount;
51 dest = _dest;
52 }
53
55 void reset() {
56 src1 = 0;
57 src2 = 0;
59 amount = 0.f;
60 dest = 0;
61 }
62};
63
64};
65
66namespace calf_plugins {
67
69{
70protected:
73 unsigned int matrix_rows;
76
77public:
79
81 inline void calculate_modmatrix(float *moddest, int moddest_count, float *modsrc)
82 {
83 for (int i = 0; i < moddest_count; i++)
84 moddest[i] = 0;
85 for (unsigned int i = 0; i < matrix_rows; ++i)
86 {
88 if (slot.dest) {
89 float value = modsrc[slot.src1];
90 const float *c = scaling_coeffs[slot.mapping];
91 value = c[0] + c[1] * value + c[2] * value * value;
92 moddest[slot.dest] += value * modsrc[slot.src2] * slot.amount;
93 }
94 }
95 }
97 char *configure(const char *key, const char *value);
98
100 { return NULL; }
101
102private:
103 std::string get_cell(int row, int column) const;
104 void set_cell(int row, int column, const std::string &src, std::string &error);
105};
106
107};
108
109#endif
#define NULL
Definition CarlaBridgeFormat.cpp:30
dsp::modulation_entry * matrix
Definition modmatrix.h:71
static const float scaling_coeffs[calf_plugins::mod_matrix_metadata::map_type_count][3]
Polynomials for different scaling modes (1, x, x^2).
Definition modmatrix.h:75
unsigned int matrix_rows
Definition modmatrix.h:73
mod_matrix_metadata * metadata
Definition modmatrix.h:72
mod_matrix_impl(dsp::modulation_entry *_matrix, calf_plugins::mod_matrix_metadata *_metadata)
Definition modmatrix.cpp:31
std::string get_cell(int row, int column) const
Definition modmatrix.cpp:51
void calculate_modmatrix(float *moddest, int moddest_count, float *modsrc)
Process modulation matrix, calculate outputs from inputs.
Definition modmatrix.h:81
void set_cell(int row, int column, const std::string &src, std::string &error)
Definition modmatrix.cpp:73
char * configure(const char *key, const char *value)
Definition modmatrix.cpp:125
virtual const dsp::modulation_entry * get_default_mod_matrix_value(int row) const
Definition modmatrix.h:99
void send_configures(send_configure_iface *)
Definition modmatrix.cpp:113
Implementation of table_metadata_iface providing metadata for mod matrices.
Definition giface.h:803
mapping_mode
Mapping modes.
Definition giface.h:806
@ map_positive
0..100%
Definition giface.h:807
@ map_type_count
Definition giface.h:815
register unsigned i
Definition inflate.c:1575
static PuglViewHint int value
Definition pugl.h:1708
Definition benchmark.cpp:53
Definition audio_fx.h:36
'may receive configure variables' interface
Definition giface.h:291
Single entry in modulation matrix.
Definition modmatrix.h:31
modulation_entry(int _src1, calf_plugins::mod_matrix_metadata::mapping_mode _mapping, int _src2, float _amount, int _dest)
Definition modmatrix.h:46
calf_plugins::mod_matrix_metadata::mapping_mode mapping
Source mapping mode.
Definition modmatrix.h:35
void reset()
Reset the row to default.
Definition modmatrix.h:55
int dest
Modulation destination.
Definition modmatrix.h:41
modulation_entry()
Definition modmatrix.h:43
int src2
Unmapped modulating source.
Definition modmatrix.h:37
float amount
Modulation amount.
Definition modmatrix.h:39
int src1
Mapped source.
Definition modmatrix.h:33
return c
Definition crypt.c:175
ZCONST char * key
Definition crypt.c:587
int error
Definition extract.c:1038