added StereoEnhancer-plugin

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@589 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2007-11-12 20:57:21 +00:00
parent 6795bd35de
commit ccadd159ca
7 changed files with 457 additions and 0 deletions

View File

@@ -1,3 +1,13 @@
2007-11-12 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* plugins/stereo_enhancer/stereo_enhancer.h:
* plugins/stereo_enhancer/stereo_enhancer.cpp:
* plugins/stereo_enhancer/stereoenhancer_control_dialog.h:
* plugins/stereo_enhancer/stereoenhancer_control_dialog.cpp:
* plugins/stereo_enhancer/Makefile.am:
added StereoEnhancer-plugin from
Lou Herard <lherard /at/ gmail /dot/ com>
2007-11-12 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
* plugins/ladspa_effect/caps/basics.h:

View File

@@ -0,0 +1,36 @@
AUTOMAKE_OPTIONS = foreign 1.4
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src/lib
AM_CXXFLAGS := $(AM_CXXFLAGS) $(QT_CXXFLAGS) -DPLUGIN_NAME="stereoenhancer"
%.moc: ./%.h
$(MOC) -o $@ $<
MOC_FILES = ./stereoenhancer_control_dialog.moc
BUILT_SOURCES = $(MOC_FILES) ./embedded_resources.h
EMBEDDED_RESOURCES = $(wildcard *png)
./embedded_resources.h: $(EMBEDDED_RESOURCES)
$(BIN2RES) $(EMBEDDED_RESOURCES) > $@
EXTRA_DIST = $(EMBEDDED_RESOURCES)
CLEANFILES = $(MOC_FILES) ./embedded_resources.h
pkglib_LTLIBRARIES= libstereoenhancer.la
libstereoenhancer_la_SOURCES = stereo_enhancer.cpp \
stereo_enhancer.h \
stereoenhancer_control_dialog.cpp \
stereoenhancer_control_dialog.h
$(libstereoenhancer_la_SOURCES): ./embedded_resources.h

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -0,0 +1,181 @@
/*
* stereo_enhancer.cpp - stereo-enhancer-effect-plugin
*
* Copyright (c) 2006-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#include "stereo_enhancer.h"
#undef SINGLE_SOURCE_COMPILE
#include "embed.cpp"
extern "C"
{
plugin::descriptor stereoenhancer_plugin_descriptor =
{
STRINGIFY_PLUGIN_NAME( PLUGIN_NAME ),
"StereoEnhancer Effect",
QT_TRANSLATE_NOOP( "pluginBrowser",
"Plugin for enhancing stereo separation of a stereo input file" ),
"Lou Herard <lherard/at/gmail.com>",
0x0100,
plugin::Effect,
new QPixmap( PLUGIN_NAME::getIconPixmap( "logo" ) ),
NULL
} ;
}
stereoEnhancerEffect::stereoEnhancerEffect(
const descriptor::subPluginFeatures::key * _key ) :
effect( &stereoenhancer_plugin_descriptor, _key ),
m_seFX( effectLib::stereoEnhancer<>( 0.0f ) ),
m_delayBuffer( new surroundSampleFrame[DEFAULT_BUFFER_SIZE] ),
m_currFrame( 0 )
{
// TODO: Make m_delayBuffer customizable?
}
stereoEnhancerEffect::~stereoEnhancerEffect()
{
if( m_delayBuffer )
{
//delete [] m_delayBuffer;
delete m_delayBuffer;
}
m_currFrame = 0;
}
bool FASTCALL stereoEnhancerEffect::processAudioBuffer( surroundSampleFrame * _buf,
const fpp_t _frames )
{
// This appears to be used for determining whether or not to continue processing
// audio with this effect
double out_sum = 0.0;
float width;
int frameIndex = 0;
if( isBypassed() || !isRunning () )
{
return( FALSE );
}
for( fpp_t f = 0; f < _frames; ++f )
{
// copy samples into the delay buffer
m_delayBuffer[m_currFrame][0] = _buf[f][0];
m_delayBuffer[m_currFrame][1] = _buf[f][1];
// Get the width knob value from the Stereo Enhancer effect
width = m_seFX.getWideCoeff();
// Calculate the correct sample frame for processing
frameIndex = m_currFrame - width;
if( frameIndex < 0 )
{
// e.g. difference = -10, frameIndex = DBS - 10
frameIndex += DEFAULT_BUFFER_SIZE;
}
//sample_t s[2] = { _buf[f][0], _buf[f][1] }; //Vanilla
sample_t s[2] = { _buf[f][0], m_delayBuffer[frameIndex][1] }; //Chocolate
m_seFX.nextSample( s[0], s[1] );
for( ch_cnt_t ch = 0; ch < SURROUND_CHANNELS; ++ch )
{
_buf[f][ch] = getDryLevel() * _buf[f][ch] +
getWetLevel() *
s[ch%DEFAULT_CHANNELS];
out_sum += _buf[f][ch]*_buf[f][ch];
}
// Update currFrame
m_currFrame += 1;
m_currFrame %= DEFAULT_BUFFER_SIZE;
}
if( out_sum <= getGate() )
{
incrementBufferCount();
if( getBufferCount() > getTimeout() )
{
stopRunning();
resetBufferCount();
clearMyBuffer();
}
}
else
{
resetBufferCount();
//clearMyBuffer();
}
return( isRunning() );
}
void stereoEnhancerEffect::clearMyBuffer()
{
int i;
for (i = 0; i < DEFAULT_BUFFER_SIZE; i++)
{
m_delayBuffer[i][0] = 0.0f;
m_delayBuffer[i][1] = 0.0f;
}
m_currFrame = 0;
}
extern "C"
{
// neccessary for getting instance out of shared lib
plugin * lmms_plugin_main( void * _data )
{
return( new stereoEnhancerEffect(
static_cast<const plugin::descriptor::subPluginFeatures::key *>(
_data ) ) );
}
}

View File

@@ -0,0 +1,74 @@
/*
* stereo_enhancer.h - stereo-enhancer-effect-plugin
*
* Copyright (c) 2006-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef _STEREO_ENHANCER_H
#define _STEREO_ENHANCER_H
#include <QtGui/QWorkspace>
#include "effect.h"
#include "effect_lib.h"
#include "engine.h"
#include "main_window.h"
#include "stereoenhancer_control_dialog.h"
class stereoEnhancerEffect : public effect
{
public:
stereoEnhancerEffect( const descriptor::subPluginFeatures::key * _key );
virtual ~stereoEnhancerEffect();
virtual bool FASTCALL processAudioBuffer( surroundSampleFrame * _buf,
const fpp_t _frames );
inline virtual QString nodeName( void ) const
{
return( "stereoenhancereffect" );
}
virtual inline effectControlDialog * createControlDialog( track * )
{
return( new stereoEnhancerControlDialog(
engine::getMainWindow()->workspace(),
this ) );
}
void clearMyBuffer();
private:
//effectLib::monoToStereoAdaptor<effectLib::stereoEnhancer<> > m_seFX;
effectLib::stereoEnhancer<> m_seFX;
surroundSampleFrame * m_delayBuffer;
int m_currFrame;
friend class stereoEnhancerControlDialog;
} ;
#endif

View File

@@ -0,0 +1,89 @@
/*
* stereoenhancer_control_dialog.cpp - control-dialog for stereoenhancer-effect
*
* Copyright (c) 2006-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef QT3
#include <QtGui/QLayout>
#else
#include <qlayout.h>
#endif
#include "stereo_enhancer.h"
#include "knob.h"
stereoEnhancerControlDialog::stereoEnhancerControlDialog( QWidget * _parent,
stereoEnhancerEffect * _eff ) :
effectControlDialog( _parent, _eff ),
m_effect( _eff )
{
QHBoxLayout * l = new QHBoxLayout( this );
m_widthKnob = new knob( knobBright_26, this, tr( "Width" ), NULL );
m_widthKnob->setRange( 0.0f, 180.0f, 1.0f );
m_widthKnob->setInitValue( 0.0f );
m_widthKnob->setLabel( tr( "WIDE" ) );
m_widthKnob->setHintText( tr( "Width:" ) + " ", "samples" );
connect( m_widthKnob, SIGNAL( valueChanged( float ) ),
this, SLOT( changeWideCoeff( void ) ) );
l->addWidget( m_widthKnob );
changeWideCoeff();
}
void stereoEnhancerControlDialog::changeWideCoeff( void )
{
m_effect->m_seFX.setWideCoeff( m_widthKnob->value() );
}
void FASTCALL stereoEnhancerControlDialog::loadSettings(
const QDomElement & _this )
{
m_widthKnob->setValue( _this.attribute( "width" ).toFloat() );
}
void FASTCALL stereoEnhancerControlDialog::saveSettings( QDomDocument & _doc,
QDomElement & _this )
{
_this.setAttribute( "width", m_widthKnob->value() );
}
#include "stereoenhancer_control_dialog.moc"

View File

@@ -0,0 +1,67 @@
/*
* stereoenhancer_control_dialog.h - control-dialog for stereo-enhancer-effect
*
* Copyright (c) 2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef _STEREOENHANCER_CONTROL_DIALOG_H
#define _STEREOENHANCER_CONTROL_DIALOG_H
#include "effect_control_dialog.h"
class knob;
class stereoEnhancerEffect;
class stereoEnhancerControlDialog : public effectControlDialog
{
Q_OBJECT
public:
stereoEnhancerControlDialog( QWidget * _parent, stereoEnhancerEffect * _eff );
virtual ~stereoEnhancerControlDialog()
{
}
virtual void FASTCALL saveSettings( QDomDocument & _doc,
QDomElement & _parent );
virtual void FASTCALL loadSettings( const QDomElement & _this );
inline virtual QString nodeName( void ) const
{
return( "stereoenhancercontrols" );
}
virtual ch_cnt_t getControlCount( void )
{
return( 1 );
}
private slots:
void changeWideCoeff( void );
private:
stereoEnhancerEffect * m_effect;
knob * m_widthKnob;
} ;
#endif