1 /* Calf DSP plugin pack
2 * Tools to use in plugins
4 * Copyright (C) 2001-2010 Krzysztof Foltman, Markus Schmidt, Thor Harald Johansen and others
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 02111-1307, USA.
21 #ifndef CALF_PLUGIN_TOOLS_H
22 #define CALF_PLUGIN_TOOLS_H
29 namespace calf_plugins
{
41 std::vector
<meter_data
> meters
;
44 void init(float *const *prms
, int *lvls
, int *clps
, int length
, uint32_t srate
) {
45 meters
.resize(length
);
46 for (int i
= 0; i
< length
; i
++) {
47 meter_data
&md
= meters
[i
];
48 md
.level_idx
= lvls
[i
];
49 md
.clip_idx
= clps
[i
];
50 md
.meter
.set_reverse(lvls
[i
] < -1);
51 md
.meter
.set_falloff(1.f
, srate
);
55 void process(float *values
) {
56 for (size_t i
= 0; i
< meters
.size(); ++i
) {
57 meter_data
&md
= meters
[i
];
58 if ((md
.level_idx
!= -1 && params
[(int)fabs(md
.level_idx
)] != NULL
) ||
59 (md
.clip_idx
!= -1 && params
[(int)fabs(md
.clip_idx
)] != NULL
))
61 md
.meter
.process(values
[i
]);
62 if (md
.level_idx
!= -1 && params
[(int)fabs(md
.level_idx
)])
63 *params
[(int)fabs(md
.level_idx
)] = md
.meter
.level
;
64 if (md
.clip_idx
!= -1 && params
[(int)fabs(md
.clip_idx
)])
65 *params
[(int)fabs(md
.clip_idx
)] = md
.meter
.clip
> 0 ? 1.f
: 0.f
;
69 void fall(unsigned int numsamples
) {
70 for (size_t i
= 0; i
< meters
.size(); ++i
)
71 if (meters
[i
].level_idx
!= -1)
72 meters
[i
].meter
.fall(numsamples
);
76 struct debug_send_configure_iface
: public send_configure_iface
78 void send_configure(const char *key
, const char *value
)
80 printf("send_configure key=%s value=%s\n", key
, value
);