diff options
author | Robert Jonsson <spamatica@gmail.com> | 2011-09-15 12:14:55 +0000 |
---|---|---|
committer | Robert Jonsson <spamatica@gmail.com> | 2011-09-15 12:14:55 +0000 |
commit | b0546e5e7f7044019892543c6c82029db8d564a7 (patch) | |
tree | 1b96a6260900f3fbf3513fb48a5a72aa89052dc8 /attic/muse2-oom/muse2/plugins/pandelay/pandelaymodel.cpp | |
parent | 583c73d1a07154d3d2672d65d8cce6495f490454 (diff) |
moved attic to a branch of it's own
Diffstat (limited to 'attic/muse2-oom/muse2/plugins/pandelay/pandelaymodel.cpp')
-rw-r--r-- | attic/muse2-oom/muse2/plugins/pandelay/pandelaymodel.cpp | 157 |
1 files changed, 0 insertions, 157 deletions
diff --git a/attic/muse2-oom/muse2/plugins/pandelay/pandelaymodel.cpp b/attic/muse2-oom/muse2/plugins/pandelay/pandelaymodel.cpp deleted file mode 100644 index a30d0646..00000000 --- a/attic/muse2-oom/muse2/plugins/pandelay/pandelaymodel.cpp +++ /dev/null @@ -1,157 +0,0 @@ -//=========================================================================== -// -// PanDelay, panoramic rotating delay -// -// version 0.0.1 -// -// pandelaymodel.cpp -// -// -// Copyright (c) 2006 Nil Geisweiller -// -// -// -// 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; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA or point your web browser to http://www.gnu.org. -//=========================================================================== - -#include "pandelaymodel.h" -#include <stdio.h> - -PanDelayModel::PanDelayModel(int samplerate) { - for(int i = 0; i < MAXBUFFERLENGTH; i++) { - _leftBuffer[i] = 0.0; - _rightBuffer[i] = 0.0; - } - _bufferPointer = 0; - _inc = 0.0; - _l = 1.0; - _r = 1.0; - - _samplerate = samplerate; - _beatRatio = 4; - setBPM(120); - setPanDelay(); -} - -PanDelayModel::~PanDelayModel() { -} - -void PanDelayModel::setSamplerate(int sr) { - _samplerate = sr; - setPanDelay(); -} - -void PanDelayModel::setBPM(float bpm) { - _BPM = bpm; - _delayTime = _beatRatio * 60.0 / _BPM; - setPanDelay(); -} - -void PanDelayModel::setBeatRatio(float br) { - _beatRatio = br; - _delayTime = _beatRatio * 60.0 / _BPM; - setPanDelay(); -} - -void PanDelayModel::setDelayTime(float dt) { - if(dt < MINDELAYTIME) _delayTime = MINDELAYTIME; - else if(dt > MAXDELAYTIME) _delayTime = MAXDELAYTIME; - else _delayTime = dt; - setPanDelay(); -} - -void PanDelayModel::setFeedback(float fb) { - _feedback = fb; - setPanDelay(); -} - -void PanDelayModel::setPanLFOFreq(float pf) { - _panLFOFreq = pf; - setPanDelay(); -} - -void PanDelayModel::setPanLFODepth(float pd) { - _panLFODepth = pd; - setPanDelay(); -} - -void PanDelayModel::setDryWet(float dw) { - _dryWet = dw; -} - -void PanDelayModel::setPanDelay() { - float numLFOSample = (1.0/_panLFOFreq) * (float)_samplerate; - _inc = 2.0 / numLFOSample; - _delaySampleSize = (int)(_delayTime * (float)_samplerate); - _lBound = 1.0 - _panLFODepth; - _rBound = 1.0 + _panLFODepth; -} - -void PanDelayModel::processMix(float* leftSamplesIn, float* rightSamplesIn, - float* leftSamplesOut, float* rightSamplesOut, - unsigned n) { - float ls, rs, p; - p = 1.0 - _dryWet; - for(unsigned i = 0; i < n; i++) { - //read buffer - ls = _leftBuffer[_bufferPointer]; - rs = _rightBuffer[_bufferPointer]; - //write buffer - _leftBuffer[_bufferPointer] *= _feedback; - _leftBuffer[_bufferPointer] += leftSamplesIn[i]; - _rightBuffer[_bufferPointer] *= _feedback; - _rightBuffer[_bufferPointer] += rightSamplesIn[i]; - //write out - leftSamplesOut[i] += _l * _dryWet * ls + p * leftSamplesIn[i]; - rightSamplesOut[i] += _r * _dryWet * rs + p * rightSamplesIn[i]; - //update _bufferPointer - _bufferPointer++; - _bufferPointer%=_delaySampleSize; - //update _l _r - _r += _inc; - _l -= _inc; - //update _inc - if(_r > _rBound || _r < _lBound) _inc = -_inc; - } -} - -void PanDelayModel::processReplace(float* leftSamplesIn, float* rightSamplesIn, - float* leftSamplesOut, - float* rightSamplesOut, unsigned n) { - float ls, rs, p; - p = 1.0 - _dryWet; - for(unsigned i = 0; i < n; i++) { - //read buffer - ls = _leftBuffer[_bufferPointer]; - rs = _rightBuffer[_bufferPointer]; - //write buffer - _leftBuffer[_bufferPointer] *= _feedback; - _leftBuffer[_bufferPointer] += leftSamplesIn[i]; - _rightBuffer[_bufferPointer] *= _feedback; - _rightBuffer[_bufferPointer] += rightSamplesIn[i]; - //write out - leftSamplesOut[i] = _l * _dryWet * ls + p * leftSamplesIn[i]; - rightSamplesOut[i] = _r * _dryWet * rs + p * rightSamplesIn[i]; - //update _bufferPointer - _bufferPointer++; - _bufferPointer%=_delaySampleSize; - //update _l _r - _r += _inc; - _l -= _inc; - //update _inc - if(_r > _rBound || _r < _lBound) _inc = -_inc; - } -} |