Update NTK.
[nondaw.git] / mixer / src / Mono_Pan_Module.C
blob441f6895af5f0d677ba03e97a9ecc704eafd1901
2 /*******************************************************************************/
3 /* Copyright (C) 2009 Jonathan Moore Liles                                     */
4 /*                                                                             */
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.                                                  */
9 /*                                                                             */
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   */
13 /* more details.                                                               */
14 /*                                                                             */
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 /*******************************************************************************/
20 #include "const.h"
22 #include <math.h>
23 #include <dsp.h>
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 );
41     add_port( p );
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 ) );
47     end();
49     log_create();
52 Mono_Pan_Module::~Mono_Pan_Module ( )
54     delete (float*)control_input[0].buffer();
55     log_destroy();
60 bool
61 Mono_Pan_Module::configure_inputs ( int )
63     return true;
68 /**********/
69 /* Engine */
70 /**********/
72 void
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() )
83     {
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 );
87     }