slope param for kicker
This commit is contained in:
88
plugins/kicker/KickerOsc.h
Normal file
88
plugins/kicker/KickerOsc.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* KickerOsc.h - alternative sweeping oscillator
|
||||
*
|
||||
* Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
* Copyright (c) 2014 Hannu Haahti <grejppi/at/gmail.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 KICKER_OSC_H
|
||||
#define KICKER_OSC_H
|
||||
|
||||
#include "DspEffectLibrary.h"
|
||||
#include "Oscillator.h"
|
||||
|
||||
|
||||
template<class FX = DspEffectLibrary::StereoBypass>
|
||||
class KickerOsc
|
||||
{
|
||||
public:
|
||||
KickerOsc( const FX & fx, const float start, const float end, const float slope, const float length ) :
|
||||
m_phase( 0.25f ),
|
||||
m_startFreq( start ),
|
||||
m_endFreq( end ),
|
||||
m_slope( slope ),
|
||||
m_length( length ),
|
||||
m_FX( fx ),
|
||||
m_counter( 0 ),
|
||||
m_freq( start )
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~KickerOsc()
|
||||
{
|
||||
}
|
||||
|
||||
void update( sampleFrame* buf, const fpp_t frames, const float sampleRate )
|
||||
{
|
||||
for( fpp_t frame = 0; frame < frames; ++frame )
|
||||
{
|
||||
//~ if( m_counter > m_length )
|
||||
//~ {
|
||||
//~ buf[frame][0] = 0.0f;
|
||||
//~ buf[frame][1] = 0.0f;
|
||||
//~ continue;
|
||||
//~ }
|
||||
const sample_t s = Oscillator::sinSample( m_phase );
|
||||
buf[frame][0] = s;
|
||||
buf[frame][1] = s;
|
||||
m_FX.nextSample( buf[frame][0], buf[frame][1] );
|
||||
m_phase += m_freq / sampleRate;
|
||||
m_freq = m_endFreq + ( ( m_startFreq - m_endFreq ) * ( 1 - powf( m_counter / m_length, m_slope ) ) );
|
||||
++m_counter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
float m_phase;
|
||||
const float m_startFreq;
|
||||
const float m_endFreq;
|
||||
const float m_slope;
|
||||
const float m_length;
|
||||
FX m_FX;
|
||||
|
||||
fpp_t m_counter;
|
||||
float m_freq;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "InstrumentTrack.h"
|
||||
#include "knob.h"
|
||||
#include "NotePlayHandle.h"
|
||||
#include "SweepOscillator.h"
|
||||
#include "KickerOsc.h"
|
||||
|
||||
#include "embed.cpp"
|
||||
|
||||
@@ -62,7 +62,8 @@ kickerInstrument::kickerInstrument( InstrumentTrack * _instrument_track ) :
|
||||
m_endFreqModel( 40.0f, 5.0f, 1000.0f, 1.0f, this, tr( "End frequency" ) ),
|
||||
m_decayModel( 120.0f, 5.0f, 1000.0f, 1.0f, this, tr( "Decay" ) ),
|
||||
m_distModel( 0.8f, 0.0f, 100.0f, 0.1f, this, tr( "Distortion" ) ),
|
||||
m_gainModel( 1.0f, 0.1f, 5.0f, 0.05f, this, tr( "Gain" ) )
|
||||
m_gainModel( 1.0f, 0.1f, 5.0f, 0.05f, this, tr( "Gain" ) ),
|
||||
m_slopeModel( 0.5f, 0.001f, 1.0f, 0.001f, this, tr( "Slope" ) )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -84,6 +85,7 @@ void kickerInstrument::saveSettings( QDomDocument & _doc,
|
||||
m_decayModel.saveSettings( _doc, _this, "decay" );
|
||||
m_distModel.saveSettings( _doc, _this, "dist" );
|
||||
m_gainModel.saveSettings( _doc, _this, "gain" );
|
||||
m_slopeModel.saveSettings( _doc, _this, "slope" );
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +98,7 @@ void kickerInstrument::loadSettings( const QDomElement & _this )
|
||||
m_decayModel.loadSettings( _this, "decay" );
|
||||
m_distModel.loadSettings( _this, "dist" );
|
||||
m_gainModel.loadSettings( _this, "gain" );
|
||||
m_slopeModel.loadSettings( _this, "slope" );
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +113,7 @@ QString kickerInstrument::nodeName() const
|
||||
|
||||
//typedef DspEffectLibrary::foldbackDistortion<> DistFX;
|
||||
typedef DspEffectLibrary::Distortion DistFX;
|
||||
typedef SweepOscillator<DspEffectLibrary::MonoToStereoAdaptor<DistFX> > SweepOsc;
|
||||
typedef KickerOsc<DspEffectLibrary::MonoToStereoAdaptor<DistFX> > SweepOsc;
|
||||
|
||||
|
||||
void kickerInstrument::playNote( NotePlayHandle * _n,
|
||||
@@ -124,7 +127,11 @@ void kickerInstrument::playNote( NotePlayHandle * _n,
|
||||
{
|
||||
_n->m_pluginData = new SweepOsc(
|
||||
DistFX( m_distModel.value(),
|
||||
m_gainModel.value() ) );
|
||||
m_gainModel.value() ),
|
||||
m_startFreqModel.value(),
|
||||
m_endFreqModel.value(),
|
||||
m_slopeModel.value(),
|
||||
decfr );
|
||||
}
|
||||
else if( tfp > decfr && !_n->isReleased() )
|
||||
{
|
||||
@@ -132,7 +139,7 @@ void kickerInstrument::playNote( NotePlayHandle * _n,
|
||||
}
|
||||
|
||||
//const float freq = instrumentTrack()->frequency( _n ) / 2;
|
||||
const float fdiff = m_endFreqModel.value() - m_startFreqModel.value();
|
||||
//~ const float fdiff = m_endFreqModel.value() - m_startFreqModel.value();
|
||||
/* const fpp_t frames = _n->isReleased() ?
|
||||
tMax( tMin<f_cnt_t>( desiredReleaseFrames() -
|
||||
_n->releaseFramesDone(),
|
||||
@@ -140,12 +147,15 @@ void kickerInstrument::playNote( NotePlayHandle * _n,
|
||||
:
|
||||
engine::mixer()->framesPerAudioBuffer();*/
|
||||
const fpp_t frames = _n->framesLeftForCurrentPeriod();
|
||||
const float f1 = m_startFreqModel.value() + tfp * fdiff / decfr;
|
||||
const float f2 = m_startFreqModel.value() + (frames+tfp-1)*fdiff/decfr;
|
||||
//~ const float slopePoint = powf( fdiff / decfr, 1 + m_slopeModel.value() * 6 );
|
||||
|
||||
//~ const float f1 = m_startFreqModel.value() + tfp * ((fdiff/decfr) * slopePoint);
|
||||
//~ const float f2 = m_startFreqModel.value() + (frames+tfp-1) * ((fdiff/decfr) * slopePoint);
|
||||
|
||||
|
||||
|
||||
SweepOsc * so = static_cast<SweepOsc *>( _n->m_pluginData );
|
||||
so->update( _working_buffer, frames, f1, f2,
|
||||
so->update( _working_buffer, frames,
|
||||
engine::mixer()->processingSampleRate() );
|
||||
|
||||
if( _n->isReleased() )
|
||||
@@ -219,6 +229,10 @@ kickerInstrumentView::kickerInstrumentView( Instrument * _instrument,
|
||||
m_gainKnob->setHintText( tr( "Gain:" ) + " ", "" );
|
||||
m_gainKnob->move( 203, 124 );
|
||||
|
||||
m_slopeKnob = new kickerKnob( this );
|
||||
m_slopeKnob->setHintText( tr( "Slope:" ) + " ", "" );
|
||||
m_slopeKnob->move( 203, 164 );
|
||||
|
||||
setAutoFillBackground( true );
|
||||
QPalette pal;
|
||||
pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap(
|
||||
@@ -244,6 +258,7 @@ void kickerInstrumentView::modelChanged()
|
||||
m_decayKnob->setModel( &k->m_decayModel );
|
||||
m_distKnob->setModel( &k->m_distModel );
|
||||
m_gainKnob->setModel( &k->m_gainModel );
|
||||
m_slopeKnob->setModel( &k->m_slopeModel );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ private:
|
||||
FloatModel m_decayModel;
|
||||
FloatModel m_distModel;
|
||||
FloatModel m_gainModel;
|
||||
FloatModel m_slopeModel;
|
||||
|
||||
friend class kickerInstrumentView;
|
||||
|
||||
@@ -88,6 +89,7 @@ private:
|
||||
knob * m_decayKnob;
|
||||
knob * m_distKnob;
|
||||
knob * m_gainKnob;
|
||||
knob * m_slopeKnob;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user