1
// ------------------------------------------------------------------------
2
// stamp-ctrl.cpp: Controller sources that analyze audio stamps
3
// and produce control data.
4
// Copyright (C) 2000,2001 Kai Vehmanen
6
// This program is fre software; you can redistribute it and/or modify
7
// it under the terms of the GNU General Public License as published by
8
// the Free Software Foundation; either version 2 of the License, or
9
// (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
14
// GNU General Public License for more details.
16
// You should have received a copy of the GNU General Public License
17
// along with this program; if not, write to the Free Software
18
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
// ------------------------------------------------------------------------
21
#include "samplebuffer_functions.h"
22
#include "stamp-ctrl.h"
24
VOLUME_ANALYZE_CONTROLLER::VOLUME_ANALYZE_CONTROLLER(void)
28
CONTROLLER_SOURCE::parameter_t VOLUME_ANALYZE_CONTROLLER::value(void)
30
fetch_stamp(&sbuf_rep);
32
if (rms_mode_rep != 0)
33
v = SAMPLE_BUFFER_FUNCTIONS::RMS_volume(sbuf_rep);
35
v = SAMPLE_BUFFER_FUNCTIONS::average_amplitude(sbuf_rep);
36
if (!(v > 0.0f)) v = 0.0f;
37
// cerr << "(volume-analyze-ctrl) Fetches a sbuf with value " << v << endl;
41
void VOLUME_ANALYZE_CONTROLLER::init(void)
45
void VOLUME_ANALYZE_CONTROLLER::set_parameter(int param, CONTROLLER_SOURCE::parameter_t value)
49
set_id(static_cast<int>(value));
53
rms_mode_rep = static_cast<int>(value);
59
CONTROLLER_SOURCE::parameter_t VOLUME_ANALYZE_CONTROLLER::get_parameter(int param) const
63
return(static_cast<parameter_t>(id()));
66
return(static_cast<parameter_t>(rms_mode_rep));