2 * stereo_enhancer.cpp - stereo-enhancer-effect-plugin
4 * Copyright (c) 2006-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
6 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
26 #include "stereo_enhancer.h"
34 Plugin::Descriptor PLUGIN_EXPORT stereoenhancer_plugin_descriptor
=
36 STRINGIFY( PLUGIN_NAME
),
37 "StereoEnhancer Effect",
38 QT_TRANSLATE_NOOP( "pluginBrowser",
39 "Plugin for enhancing stereo separation of a stereo input file" ),
40 "Lou Herard <lherard/at/gmail.com>",
43 new PluginPixmapLoader( "logo" ),
52 stereoEnhancerEffect::stereoEnhancerEffect(
54 const Descriptor::SubPluginFeatures::Key
* _key
) :
55 Effect( &stereoenhancer_plugin_descriptor
, _parent
, _key
),
56 m_seFX( effectLib::stereoEnhancer( 0.0f
) ),
57 m_delayBuffer( new sampleFrame
[DEFAULT_BUFFER_SIZE
] ),
61 // TODO: Make m_delayBuffer customizable?
68 stereoEnhancerEffect::~stereoEnhancerEffect()
72 //delete [] m_delayBuffer;
82 bool stereoEnhancerEffect::processAudioBuffer( sampleFrame
* _buf
,
86 // This appears to be used for determining whether or not to continue processing
87 // audio with this effect
94 if( !isEnabled() || !isRunning() )
99 const float d
= dryLevel();
100 const float w
= wetLevel();
102 for( fpp_t f
= 0; f
< _frames
; ++f
)
105 // copy samples into the delay buffer
106 m_delayBuffer
[m_currFrame
][0] = _buf
[f
][0];
107 m_delayBuffer
[m_currFrame
][1] = _buf
[f
][1];
109 // Get the width knob value from the Stereo Enhancer effect
110 width
= m_seFX
.getWideCoeff();
112 // Calculate the correct sample frame for processing
113 frameIndex
= m_currFrame
- width
;
117 // e.g. difference = -10, frameIndex = DBS - 10
118 frameIndex
+= DEFAULT_BUFFER_SIZE
;
121 //sample_t s[2] = { _buf[f][0], _buf[f][1] }; //Vanilla
122 sample_t s
[2] = { _buf
[f
][0], m_delayBuffer
[frameIndex
][1] }; //Chocolate
124 m_seFX
.nextSample( s
[0], s
[1] );
126 _buf
[f
][0] = d
* _buf
[f
][0] + w
* s
[0];
127 _buf
[f
][1] = d
* _buf
[f
][1] + w
* s
[1];
128 out_sum
+= _buf
[f
][0]*_buf
[f
][0] + _buf
[f
][1]*_buf
[f
][1];
132 m_currFrame
%= DEFAULT_BUFFER_SIZE
;
135 checkGate( out_sum
/ _frames
);
141 return( isRunning() );
147 void stereoEnhancerEffect::clearMyBuffer()
150 for (i
= 0; i
< DEFAULT_BUFFER_SIZE
; i
++)
152 m_delayBuffer
[i
][0] = 0.0f
;
153 m_delayBuffer
[i
][1] = 0.0f
;
166 // necessary for getting instance out of shared lib
167 Plugin
* PLUGIN_EXPORT
lmms_plugin_main( Model
* _parent
, void * _data
)
169 return( new stereoEnhancerEffect( _parent
,
170 static_cast<const Plugin::Descriptor::SubPluginFeatures::Key
*>(