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 /*******************************************************************************/
25 #include "Mono_Pan_Module.H"
29 Mono_Pan_Module::Mono_Pan_Module ( )
30 : Module ( 50, 24, name() )
32 Port p( this, Port::INPUT, Port::CONTROL, "Pan" );
33 p.hints.ranged = true;
34 p.hints.minimum = -1.0f;
35 p.hints.maximum = 1.0f;
36 p.hints.default_value = 0.0f;
38 p.connect_to( new float );
39 p.control_value( p.hints.default_value );
43 add_port( Port( this, Port::INPUT, Port::AUDIO ) );
44 add_port( Port( this, Port::OUTPUT, Port::AUDIO ) );
45 add_port( Port( this, Port::OUTPUT, Port::AUDIO ) );
52 Mono_Pan_Module::~Mono_Pan_Module ( )
54 delete (float*)control_input[0].buffer();
61 Mono_Pan_Module::configure_inputs ( int )
73 Mono_Pan_Module::process ( nframes_t nframes )
75 const float g = control_input[0].control_value();
77 const float lg = (0.0f - g) + 1.0f;
78 const float rg = g + 1.0f;
80 if ( audio_input[0].connected() &&
81 audio_output[0].connected() &&
82 audio_output[1].connected() )
84 buffer_copy_and_apply_gain( (sample_t*)audio_output[1].buffer(), (sample_t*)audio_input[0].buffer(), nframes, rg );
86 buffer_apply_gain( (sample_t*)audio_output[0].buffer(), nframes, lg );