2 /*******************************************************************************/
3 /* Copyright (C) 2009 Jonathan Moore Liles */
5 /* This program is free software; you can redistribute it and/or modify it */
6 /* under the terms of the GNU General Public License as published by the */
7 /* Free Software Foundation; either version 2 of the License, or (at your */
8 /* option) any later version. */
10 /* This program is distributed in the hope that it will be useful, but WITHOUT */
11 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
12 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
15 /* You should have received a copy of the GNU General Public License along */
16 /* with This program; see the file COPYING. If not,write to the Free Software */
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 /*******************************************************************************/
23 #include "Gain_Module.H"
27 Gain_Module::Gain_Module ( )
28 : Module ( 50, 24, name() )
30 add_port( Port( this, Port::INPUT, Port::AUDIO ) );
31 add_port( Port( this, Port::OUTPUT, Port::AUDIO ) );
33 Port p( this, Port::INPUT, Port::CONTROL, "Gain (dB)" );
34 p.hints.type = Port::Hints::LOGARITHMIC;
35 p.hints.ranged = true;
36 p.hints.minimum = -70.0f;
37 p.hints.maximum = 6.0f;
38 p.hints.default_value = 0.0f;
40 p.connect_to( new float );
41 p.control_value( p.hints.default_value );
50 Gain_Module::~Gain_Module ( )
52 delete (float*)control_input[0].buffer();
59 Gain_Module::configure_inputs ( int n )
63 // control_input.clear();
65 for ( int i = 0; i < n; ++i )
67 add_port( Port( this, Port::INPUT, Port::AUDIO ) );
68 add_port( Port( this, Port::OUTPUT, Port::AUDIO ) );
81 Gain_Module::process ( nframes_t nframes )
83 float g = DB_CO( control_input[0].control_value() );
85 for ( int i = audio_input.size(); i--; )
87 if ( audio_input[i].connected() && audio_output[i].connected() )
89 buffer_apply_gain( (sample_t*)audio_input[i].buffer(), nframes, g );