Very first implementation of peak controller

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1107 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Paul Giblock
2008-06-08 19:02:28 +00:00
parent 4247c93972
commit 7915537f30
18 changed files with 860 additions and 1 deletions

View File

@@ -27,6 +27,7 @@ SUBDIRS = \
midi_import \
organic \
patman \
peak_controller_effect \
$(SF2PLAYER_DIR) \
$(SINGERBOT_DIR) \
stereo_enhancer \

View File

@@ -0,0 +1,52 @@
AUTOMAKE_OPTIONS = foreign 1.4
PLUGIN_NAME = peakcontroller_effect
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/src/gui
AM_CXXFLAGS := $(AM_CXXFLAGS) $(QT_CXXFLAGS) -DPLUGIN_NAME="$(PLUGIN_NAME)"
%.moc: ./%.h
$(MOC) -o $@ $<
MOC_FILES = ./peak_controller_effect_controls.moc
if BUILD_WIN32
DLL=$(PLUGIN_NAME).dll
$(DLL): lib$(PLUGIN_NAME).la
$(CXX) *.o -L$(top_srcdir) -llmms-imp -shared -Wl,-no-undefined -o $@ $(QT_LDADD) && $(STRIP) $@
install-exec-hook: $(DLL)
cp $< $(pkglibdir)
rm $(pkglibdir)/lib$(PLUGIN_NAME).a $(pkglibdir)/lib$(PLUGIN_NAME).la
else
DLL=
endif
BUILT_SOURCES = $(MOC_FILES) ./embedded_resources.h $(DLL)
EMBEDDED_RESOURCES = $(wildcard *png)
./embedded_resources.h: $(EMBEDDED_RESOURCES)
$(BIN2RES) $(EMBEDDED_RESOURCES) > $@
EXTRA_DIST = $(EMBEDDED_RESOURCES)
CLEANFILES = $(MOC_FILES) ./embedded_resources.h
pkglib_LTLIBRARIES= libpeakcontroller_effect.la
libpeakcontroller_effect_la_SOURCES = peak_controller_effect.cpp \
peak_controller_effect.h \
peak_controller_effect_control_dialog.cpp \
peak_controller_effect_control_dialog.h \
peak_controller_effect_controls.cpp \
peak_controller_effect_controls.h
$(libpeakcontroller_effect_la_SOURCES): ./embedded_resources.h

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -0,0 +1,127 @@
/*
* stereo_matrix.cpp - stereo-matrix-effect-plugin
*
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail/dot/com>
*
* 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 "controller.h"
#include "song.h"
#include "peak_controller.h"
#include "peak_controller_effect.h"
#undef SINGLE_SOURCE_COMPILE
#include "embed.cpp"
extern "C"
{
plugin::descriptor PLUGIN_EXPORT peakcontroller_effect_plugin_descriptor =
{
STRINGIFY_PLUGIN_NAME( PLUGIN_NAME ),
"Peak Controller",
QT_TRANSLATE_NOOP( "pluginBrowser",
"Plugin for controlling knobs with sound peaks" ),
"Paul Giblock <drfaygo/at/gmail.com>",
0x0100,
plugin::Effect,
new pluginPixmapLoader( "logo" ),
NULL
} ;
}
peakControllerEffect::peakControllerEffect(
model * _parent,
const descriptor::subPluginFeatures::key * _key ) :
effect( &peakcontroller_effect_plugin_descriptor, _parent, _key ),
m_peakControls( this )
{
engine::getSong()->addController( new peakController( engine::getSong(), this ) );
}
peakControllerEffect::~peakControllerEffect()
{
}
bool peakControllerEffect::processAudioBuffer( sampleFrame * _buf,
const fpp_t _frames )
{
peakControllerEffectControls & c = m_peakControls;
// This appears to be used for determining whether or not to continue processing
// audio with this effect
if( !isEnabled() || !isRunning() )
{
return( FALSE );
}
// RMS:
float sum = 0;
if( c.m_muteModel.value() )
{
for( int i = 0; i < _frames; ++i )
{
sum += (_buf[i][0]+_buf[i][0]) * (_buf[i][1]+_buf[i][1]);
_buf[i][0] = _buf[i][1] = 0.0f;
}
}
else
{
for( int i = 0; i < _frames; ++i )
{
sum += (_buf[i][0]+_buf[i][0]) * (_buf[i][1]+_buf[i][1]);
}
}
m_lastSample = c.m_baseModel.value() + c.m_amountModel.value() * sqrtf( 0.5f * sum / _frames );
//checkGate( out_sum / _frames );
return( isRunning() );
}
extern "C"
{
// neccessary for getting instance out of shared lib
plugin * PLUGIN_EXPORT lmms_plugin_main( model * _parent, void * _data )
{
return( new peakControllerEffect( _parent,
static_cast<const plugin::descriptor::subPluginFeatures::key *>(
_data ) ) );
}
}

View File

@@ -0,0 +1,67 @@
/*
* stereo_matrix.h - stereo-matrix-effect-plugin
*
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail/dot/com>
*
* 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 _PEAK_CONTROLLER_EFFECT_H
#define _PEAK_CONTROLLER_EFFECT_H
#include <QtGui/QWorkspace>
#include "effect.h"
#include "effect_lib.h"
#include "engine.h"
#include "main_window.h"
#include "peak_controller_effect_controls.h"
class peakControllerEffect : public effect
{
public:
peakControllerEffect( model * parent,
const descriptor::subPluginFeatures::key * _key );
virtual ~peakControllerEffect();
virtual bool processAudioBuffer( sampleFrame * _buf,
const fpp_t _frames );
virtual effectControls * getControls( void )
{
return &m_peakControls;
}
float lastSample( void )
{
return m_lastSample;
}
private:
peakControllerEffectControls m_peakControls;
friend class peakControllerEffectControls;
float m_lastSample;
} ;
#endif

View File

@@ -0,0 +1,66 @@
/*
* stereomatrix_control_dialog.cpp - control dialog for stereoMatrix-effect
*
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail/dot/com>
*
* 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 <QtGui/QLayout>
#include <QtGui/QLabel>
#include "peak_controller_effect_control_dialog.h"
#include "peak_controller_effect_controls.h"
#include "knob.h"
#include "tempo_sync_knob.h"
#include "led_checkbox.h"
peakControllerEffectControlDialog::peakControllerEffectControlDialog(
peakControllerEffectControls * _controls ) :
effectControlDialog( _controls )
{
setFixedSize( 120, 90 );
const int knobY = 10;
m_baseKnob = new knob( knobBright_26, this );
m_baseKnob->setLabel( tr( "BASE" ) );
m_baseKnob->move( 10, knobY );
m_baseKnob->setModel( &_controls->m_baseModel );
m_baseKnob->setHintText( tr( "Base amount:" ) + " ", "" );
m_amountKnob = new knob( knobBright_26, this );
m_amountKnob->setLabel( tr( "AMT" ) );
m_amountKnob->move( 45, knobY );
m_amountKnob->setModel( &_controls->m_amountModel );
m_amountKnob->setHintText( tr( "Modulation amount:" ) + " ", "" );
m_decayKnob = new tempoSyncKnob( knobBright_26, this );
m_decayKnob->setLabel( tr( "DECAY" ) );
m_decayKnob->move( 80, knobY );
m_decayKnob->setModel( &_controls->m_decayModel );
m_decayKnob->setHintText( tr( "Release decay (not implemented):" ) + " ", "" );
m_muteLed = new ledCheckBox( "Mute", this );
m_muteLed->move( 10, 60);
m_muteLed->setModel( &_controls->m_muteModel );
}

View File

@@ -0,0 +1,53 @@
/*
* stereomatrix_control_dialog.h - control dialog for stereoMatrix-effect
*
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail/dot/com>
*
* 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 _PEAK_CONTROLLER_EFFECT_CONTROL_DIALOG_H
#define _PEAK_CONTROLLER_EFFECT_CONTROL_DIALOG_H
#include "effect_control_dialog.h"
class peakControllerEffectControls;
class knob;
class tempoSyncKnob;
class ledCheckBox;
class peakControllerEffectControlDialog : public effectControlDialog
{
public:
peakControllerEffectControlDialog( peakControllerEffectControls * _controls );
virtual ~peakControllerEffectControlDialog()
{
}
protected:
knob * m_baseKnob;
knob * m_amountKnob;
tempoSyncKnob * m_decayKnob;
ledCheckBox * m_muteLed;
};
#endif

View File

@@ -0,0 +1,57 @@
/*
* stereomatrix_controls.cpp - controls for stereoMatrix-effect
*
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail/dot/com>
*
* 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 "peak_controller_effect_controls.h"
#include "peak_controller_effect.h"
peakControllerEffectControls::
peakControllerEffectControls( peakControllerEffect * _eff ) :
effectControls( _eff ),
m_effect( _eff ),
m_baseModel( 0.5, 0.0, 1.0, 0.001, this, tr( "Base value" ) ),
m_amountModel( 1.0, -1.0, 1.0, 0.005, this, tr( "Modulation amount" ) ),
m_decayModel( 0.1, 0.01, 5.0, 0.0001, 20000.0, this, tr( "Release decay" ) ),
m_muteModel( FALSE, this, tr( "Mute output" ) )
{
}
void peakControllerEffectControls::loadSettings( const QDomElement & _this )
{
}
void peakControllerEffectControls::saveSettings( QDomDocument & _doc,
QDomElement & _this )
{
}
#include "peak_controller_effect_controls.moc"

View File

@@ -0,0 +1,75 @@
/*
* stereomatrix_controls.h - controls for stereoMatrix-effect
*
* Copyright (c) 2008 Paul Giblock <drfaygo/at/gmail/dot/com>
*
* 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 _PEAK_CONTROLLER_EFFECT_CONTROLS_H
#define _PEAK_CONTROLLER_EFFECT_CONTROLS_H
#include "effect_controls.h"
#include "peak_controller_effect_control_dialog.h"
#include "knob.h"
class peakControllerEffect;
class peakControllerEffectControls : public effectControls
{
Q_OBJECT
public:
peakControllerEffectControls( peakControllerEffect( * _eff ) );
virtual ~peakControllerEffectControls()
{
}
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
inline virtual QString nodeName( void ) const
{
return( "peakcontrollereffectcontrols" );
}
virtual ch_cnt_t getControlCount( void )
{
return( 1 );
}
virtual effectControlDialog * createView( void )
{
return new peakControllerEffectControlDialog( this );
}
private:
peakControllerEffect * m_effect;
floatModel m_baseModel;
floatModel m_amountModel;
tempoSyncKnobModel m_decayModel;
boolModel m_muteModel;
friend class peakControllerEffectControlDialog;
friend class peakControllerEffect;
} ;
#endif