From 8146dc3d30bbe96ddd3805d645b67eee02e54532 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Thu, 3 Apr 2008 20:29:11 +0000 Subject: [PATCH] - made effect::processAudioBuffer(...) process a sampleFrame- instead of surroundSampleFrame-array - divide out_sum by number of frames processed to have a period-size-independent value git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@876 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 58 +++++++++++++++++++++ configure.in | 4 +- include/effect.h | 4 +- include/effect_select_dialog.h | 1 + include/surround_area.h | 2 +- plugins/bass_booster/bass_booster.cpp | 12 ++--- plugins/bass_booster/bass_booster.h | 2 +- plugins/ladspa_effect/ladspa_effect.cpp | 12 +++-- plugins/ladspa_effect/ladspa_effect.h | 2 +- plugins/stereo_enhancer/stereo_enhancer.cpp | 17 +++--- plugins/stereo_enhancer/stereo_enhancer.h | 6 +-- src/core/effect.cpp | 9 ---- src/gui/track_container_view.cpp | 7 ++- 13 files changed, 95 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index e125d2da3..f4a813f9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,61 @@ +2008-04-03 Tobias Doerffel + + * plugins/ladspa_effect/ladspa_effect.cpp: + * plugins/ladspa_effect/ladspa_effect.h: + * plugins/bass_booster/bass_booster.cpp: + * plugins/bass_booster/bass_booster.h: + * plugins/stereo_enhancer/stereo_enhancer.cpp: + * plugins/stereo_enhancer/stereo_enhancer.h: + * include/effect.h: + - made effect::processAudioBuffer(...) process a sampleFrame- instead of + surroundSampleFrame-array + - divide out_sum by number of frames processed to have a + period-size-independent value + + * src/core/note_play_handle.cpp: + * include/automatable_model.h: + renamed value( int ) to levelToValue( int ) as preparation for + controller-framework + + * include/mixer.h: + * src/core/mixer.cpp: + - made mixer::buffertToPort accept a stereoVolumeVector as audio-buffers + have stereo-audio-buffers now + - made peakValueLeft() and peakValueRight() take a sampleFrame-pointer + - process in stereo internally + + * include/instrument_track.h: + * src/tracks/instrument_track.cpp: + replaced surroundArea with panning-knob + + * include/audio_port.h: + * src/core/audio/audio_port.cpp: + use sampleFrame-array instead of surroundSampleFrame-array for + processing + + * src/core/fx_mixer.cpp: + * include/fx_mixer.h: + made mixToChannel() take a sampleFrame-pointer + + * include/volume.h: + * src/core/sample_play_handle.cpp: + * src/core/surround_area.cpp: + added stereoVolumeVector and surroundVolumeVector-declarations + + * include/dummy_effect.h: + implement pure-virtual processAudioBuffer()-method + + * include/panning.h: + new panningToVolumeVector()-inline-method + + * include/effect_chain.h: + * src/core/effect_chain.cpp: + made processAudioBuffer() take a sampleFrame-pointer + + * include/visualization_widget.h: + * src/gui/widgets/visualization_widget.cpp: + use sampleFrame-array instead of surroundSampleFrame-array internally + 2008-04-02 Tobias Doerffel * include/automatable_model.h: diff --git a/configure.in b/configure.in index e7cddf812..e2d13f572 100644 --- a/configure.in +++ b/configure.in @@ -2,8 +2,8 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.50) -AC_INIT(lmms, 0.4.0-svn20080330, lmms-devel/at/lists/dot/sf/dot/net) -AM_INIT_AUTOMAKE(lmms, 0.4.0-svn20080330) +AC_INIT(lmms, 0.4.0-svn20080403, lmms-devel/at/lists/dot/sf/dot/net) +AM_INIT_AUTOMAKE(lmms, 0.4.0-svn20080403) AM_CONFIG_HEADER(config.h) diff --git a/include/effect.h b/include/effect.h index 7993ce3c0..a1d28e925 100644 --- a/include/effect.h +++ b/include/effect.h @@ -62,8 +62,8 @@ public: } - virtual bool processAudioBuffer( - surroundSampleFrame * _buf, const fpp_t _frames ); + virtual bool processAudioBuffer( sampleFrame * _buf, + const fpp_t _frames ) = 0; inline ch_cnt_t getProcessorCount( void ) const { diff --git a/include/effect_select_dialog.h b/include/effect_select_dialog.h index d8c9c096e..1098df090 100644 --- a/include/effect_select_dialog.h +++ b/include/effect_select_dialog.h @@ -30,6 +30,7 @@ #include #include "effect_chain.h" +#include "effect.h" class QScrollArea; diff --git a/include/surround_area.h b/include/surround_area.h index bbd7bb312..a873cd7f2 100644 --- a/include/surround_area.h +++ b/include/surround_area.h @@ -51,7 +51,7 @@ public: surroundAreaModel( ::model * _parent, track * _track = NULL, bool _default_constructed = FALSE ); - volumeVector getVolumeVector( float _v_scale ) const; + surroundVolumeVector getVolumeVector( float _v_scale ) const; void saveSettings( QDomDocument & _doc, QDomElement & _this, const QString & _name = "surpos" ); diff --git a/plugins/bass_booster/bass_booster.cpp b/plugins/bass_booster/bass_booster.cpp index 95ffe8a5f..09b4a2077 100644 --- a/plugins/bass_booster/bass_booster.cpp +++ b/plugins/bass_booster/bass_booster.cpp @@ -70,7 +70,7 @@ bassBoosterEffect::~bassBoosterEffect() -bool FASTCALL bassBoosterEffect::processAudioBuffer( surroundSampleFrame * _buf, +bool bassBoosterEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) { if( !isEnabled() || !isRunning () ) @@ -79,20 +79,20 @@ bool FASTCALL bassBoosterEffect::processAudioBuffer( surroundSampleFrame * _buf, } double out_sum = 0.0; + const float d = getDryLevel(); + const float w = getWetLevel(); for( fpp_t f = 0; f < _frames; ++f ) { sample_t s[2] = { _buf[f][0], _buf[f][1] }; m_bbFX.nextSample( s[0], s[1] ); - for( ch_cnt_t ch = 0; ch < SURROUND_CHANNELS; ++ch ) + for( ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch ) { - _buf[f][ch] = getDryLevel() * _buf[f][ch] + - getWetLevel() * - s[ch%DEFAULT_CHANNELS]; + _buf[f][ch] = d * _buf[f][ch] + w * s[ch]; out_sum += _buf[f][ch]*_buf[f][ch]; } } - if( out_sum <= getGate()+0.00001f ) + if( out_sum / _frames <= getGate()+0.000001 ) { incrementBufferCount(); if( getBufferCount() > getTimeout() ) diff --git a/plugins/bass_booster/bass_booster.h b/plugins/bass_booster/bass_booster.h index 2ec5b15af..3c018f10c 100644 --- a/plugins/bass_booster/bass_booster.h +++ b/plugins/bass_booster/bass_booster.h @@ -43,7 +43,7 @@ public: bassBoosterEffect( model * _parent, const descriptor::subPluginFeatures::key * _key ); virtual ~bassBoosterEffect(); - virtual bool FASTCALL processAudioBuffer( surroundSampleFrame * _buf, + virtual bool processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ); virtual effectControls * getControls( void ) diff --git a/plugins/ladspa_effect/ladspa_effect.cpp b/plugins/ladspa_effect/ladspa_effect.cpp index ec0e1ab13..37aebbc83 100644 --- a/plugins/ladspa_effect/ladspa_effect.cpp +++ b/plugins/ladspa_effect/ladspa_effect.cpp @@ -328,7 +328,7 @@ ladspaEffect::~ladspaEffect() -bool FASTCALL ladspaEffect::processAudioBuffer( surroundSampleFrame * _buf, +bool ladspaEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) { if( !isOkay() || dontRun() || !isRunning() || !isEnabled() ) @@ -403,6 +403,8 @@ bool FASTCALL ladspaEffect::processAudioBuffer( surroundSampleFrame * _buf, // Copy the LADSPA output buffers to the LMMS buffer. double out_sum = 0.0; channel = 0; + const float d = getDryLevel(); + const float w = getWetLevel(); for( ch_cnt_t proc = 0; proc < getProcessorCount(); proc++) { for( Uint16 port = 0; port < m_portCount; port++ ) @@ -418,15 +420,15 @@ bool FASTCALL ladspaEffect::processAudioBuffer( surroundSampleFrame * _buf, frame < _frames; frame++ ) { _buf[frame][channel] = - getDryLevel() * + d * _buf[frame][channel] + - getWetLevel() * + w * m_ports[proc][port]->buffer[frame]; out_sum += _buf[frame][channel] * _buf[frame][channel]; } - channel++; + ++channel; break; case AUDIO_RATE_OUTPUT: case CONTROL_RATE_OUTPUT: @@ -439,7 +441,7 @@ bool FASTCALL ladspaEffect::processAudioBuffer( surroundSampleFrame * _buf, // Check whether we need to continue processing input. Restart the // counter if the threshold has been exceeded. - if( out_sum <= getGate()+0.00001f ) + if( out_sum / _frames <= getGate()+0.000001 ) { incrementBufferCount(); if( getBufferCount() > getTimeout() ) diff --git a/plugins/ladspa_effect/ladspa_effect.h b/plugins/ladspa_effect/ladspa_effect.h index 9ea8aa22d..127a7fcfb 100644 --- a/plugins/ladspa_effect/ladspa_effect.h +++ b/plugins/ladspa_effect/ladspa_effect.h @@ -44,7 +44,7 @@ public: const descriptor::subPluginFeatures::key * _key ); virtual ~ladspaEffect(); - virtual bool FASTCALL processAudioBuffer( surroundSampleFrame * _buf, + virtual bool processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ); void FASTCALL setControl( Uint16 _control, LADSPA_Data _data ); diff --git a/plugins/stereo_enhancer/stereo_enhancer.cpp b/plugins/stereo_enhancer/stereo_enhancer.cpp index d684e87fa..3116f4e1b 100644 --- a/plugins/stereo_enhancer/stereo_enhancer.cpp +++ b/plugins/stereo_enhancer/stereo_enhancer.cpp @@ -1,7 +1,7 @@ /* * stereo_enhancer.cpp - stereo-enhancer-effect-plugin * - * Copyright (c) 2006-2007 Tobias Doerffel + * Copyright (c) 2006-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -79,7 +79,7 @@ stereoEnhancerEffect::~stereoEnhancerEffect() -bool FASTCALL stereoEnhancerEffect::processAudioBuffer( surroundSampleFrame * _buf, +bool stereoEnhancerEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) { @@ -96,6 +96,9 @@ bool FASTCALL stereoEnhancerEffect::processAudioBuffer( surroundSampleFrame * _b return( FALSE ); } + const float d = getDryLevel(); + const float w = getWetLevel(); + for( fpp_t f = 0; f < _frames; ++f ) { @@ -120,11 +123,9 @@ bool FASTCALL stereoEnhancerEffect::processAudioBuffer( surroundSampleFrame * _b m_seFX.nextSample( s[0], s[1] ); - for( ch_cnt_t ch = 0; ch < SURROUND_CHANNELS; ++ch ) + for( ch_cnt_t ch = 0; ch < DEFAULT_CHANNELS; ++ch ) { - _buf[f][ch] = getDryLevel() * _buf[f][ch] + - getWetLevel() * - s[ch%DEFAULT_CHANNELS]; + _buf[f][ch] = d * _buf[f][ch] + w * s[ch]; out_sum += _buf[f][ch]*_buf[f][ch]; } @@ -133,7 +134,7 @@ bool FASTCALL stereoEnhancerEffect::processAudioBuffer( surroundSampleFrame * _b m_currFrame %= DEFAULT_BUFFER_SIZE; } - if( out_sum <= getGate() ) + if( out_sum / _frames <= getGate()+0.00001 ) { incrementBufferCount(); if( getBufferCount() > getTimeout() ) @@ -152,6 +153,8 @@ bool FASTCALL stereoEnhancerEffect::processAudioBuffer( surroundSampleFrame * _b } + + void stereoEnhancerEffect::clearMyBuffer() { int i; diff --git a/plugins/stereo_enhancer/stereo_enhancer.h b/plugins/stereo_enhancer/stereo_enhancer.h index 7796f084a..f6c602584 100644 --- a/plugins/stereo_enhancer/stereo_enhancer.h +++ b/plugins/stereo_enhancer/stereo_enhancer.h @@ -1,7 +1,7 @@ /* * stereo_enhancer.h - stereo-enhancer-effect-plugin * - * Copyright (c) 2006-2007 Tobias Doerffel + * Copyright (c) 2006-2008 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -40,8 +40,8 @@ public: stereoEnhancerEffect( model * parent, const descriptor::subPluginFeatures::key * _key ); virtual ~stereoEnhancerEffect(); - virtual bool FASTCALL processAudioBuffer( surroundSampleFrame * _buf, - const fpp_t _frames ); + virtual bool processAudioBuffer( sampleFrame * _buf, + const fpp_t _frames ); virtual effectControls * getControls( void ) { diff --git a/src/core/effect.cpp b/src/core/effect.cpp index 1eb1cc369..3692611fd 100644 --- a/src/core/effect.cpp +++ b/src/core/effect.cpp @@ -96,15 +96,6 @@ void effect::loadSettings( const QDomElement & _this ) -bool effect::processAudioBuffer( surroundSampleFrame * _buf, - const fpp_t _frames ) -{ - return( FALSE ); -} - - - - effect * effect::instantiate( const QString & _plugin_name, model * _parent, descriptor::subPluginFeatures::key * _key ) diff --git a/src/gui/track_container_view.cpp b/src/gui/track_container_view.cpp index 03c28ce4d..8a558fa71 100644 --- a/src/gui/track_container_view.cpp +++ b/src/gui/track_container_view.cpp @@ -23,10 +23,6 @@ */ -#include "track_container_view.h" -#include "track_container.h" - - #include #include #include @@ -34,9 +30,12 @@ #include +#include "track_container_view.h" +#include "track_container.h" #include "bb_track.h" #include "config_mgr.h" #include "debug.h" +#include "engine.h" #include "file_browser.h" #include "import_filter.h" #include "instrument.h"