Merge master into ed_refac

This commit is contained in:
Lukas W
2014-12-09 00:20:28 +01:00
19 changed files with 736 additions and 38 deletions

View File

@@ -289,7 +289,6 @@ public:
m_sampleRatio( 1.0f / m_sampleRate ),
m_subFilter( NULL )
{
m_svsr = 1.0f - expf( -4646.39874051f / m_sampleRate );
clearHistory();
}
@@ -326,7 +325,6 @@ public:
m_delay2[_chnl] = 0.0f;
m_delay3[_chnl] = 0.0f;
m_delay4[_chnl] = 0.0f;
m_sva[_chnl] = 0.0f;
}
}
@@ -409,7 +407,6 @@ public:
case Lowpass_SV:
case Bandpass_SV:
{
m_sva[_chnl] += ( qAbs( _in0 ) - m_sva[_chnl] ) * m_svsr;
float highpass;
for( int i = 0; i < 2; ++i ) // 2x oversample
@@ -425,14 +422,13 @@ public:
/* mix filter output into output buffer */
return m_type == Lowpass_SV
? atanf( 3.0f * m_delay4[_chnl] * m_sva[_chnl] )
: atanf( 3.0f * m_delay3[_chnl] * m_sva[_chnl] );
? m_delay4[_chnl]
: m_delay3[_chnl];
break;
}
case Highpass_SV:
{
m_sva[_chnl] += ( qAbs( _in0 ) - m_sva[_chnl] ) * m_svsr;
float hp;
for( int i = 0; i < 2; ++i ) // 2x oversample
@@ -442,13 +438,12 @@ public:
m_delay1[_chnl] = m_svf1 * hp + m_delay1[_chnl];
}
return atanf( 3.0f * hp * m_sva[_chnl] );
return hp;
break;
}
case Notch_SV:
{
m_sva[_chnl] += ( qAbs( _in0 ) - m_sva[_chnl] ) * m_svsr;
float hp1, hp2;
for( int i = 0; i < 2; ++i ) // 2x oversample
@@ -463,7 +458,7 @@ public:
}
/* mix filter output into output buffer */
return atanf( 1.5f * ( m_delay4[_chnl] + hp1 ) * m_sva[_chnl] );
return m_delay4[_chnl] + hp1;
break;
}
@@ -899,7 +894,7 @@ private:
float m_vfa[4], m_vfb[4], m_vfc[4], m_vfq;
// coeffs for Lowpass_SV (state-variant lowpass)
float m_svf1, m_svf2, m_svq, m_svsr;
float m_svf1, m_svf2, m_svq;
typedef sample_t frame[CHANNELS];
@@ -916,7 +911,7 @@ private:
frame m_vfbp[6], m_vfhp[6], m_vflast[6];
// in/out history for Lowpass_SV (state-variant lowpass)
frame m_delay1, m_delay2, m_delay3, m_delay4, m_sva;
frame m_delay1, m_delay2, m_delay3, m_delay4;
FilterTypes m_type;
bool m_doubleFilter;

View File

@@ -145,6 +145,7 @@ private:
void finalize();
void toggleWindow( QWidget *window, bool forceShow = false );
void refocus();
QMdiArea * m_workspace;

View File

@@ -263,7 +263,7 @@ public slots:
void playAndRecord();
void playTrack( Track * _trackToPlay );
void playBB();
void playPattern( Pattern* patternToPlay, bool _loop = true );
void playPattern(const Pattern* patternToPlay, bool _loop = true );
void togglePause();
void stop();
@@ -354,7 +354,7 @@ private:
tact_t m_length;
Track * m_trackToPlay;
Pattern* m_patternToPlay;
const Pattern* m_patternToPlay;
bool m_loopPattern;
double m_elapsedMilliSeconds;

View File

@@ -468,7 +468,7 @@ public:
int numOfTCOs();
TrackContentObject * getTCO( int _tco_num );
int getTCONum( TrackContentObject * _tco );
int getTCONum(const TrackContentObject* _tco );
const tcoVector & getTCOs() const
{

View File

@@ -130,7 +130,17 @@ static inline int fast_rand()
return( (unsigned)( next / 65536 ) % 32768 );
}
static inline double fastRand( double range )
{
static const double fast_rand_ratio = 1.0 / FAST_RAND_MAX;
return fast_rand() * range * fast_rand_ratio;
}
static inline float fastRandf( float range )
{
static const float fast_rand_ratio = 1.0f / FAST_RAND_MAX;
return fast_rand() * range * fast_rand_ratio;
}
// source: http://martin.ankerl.com/2007/10/04/optimized-pow-approximation-for-java-and-c-c/
static inline double fastPow( double a, double b )
@@ -241,5 +251,4 @@ static inline float fastSqrt( float n )
return u.f;
}
#endif

View File

@@ -0,0 +1,245 @@
/*
* Bitcrush.cpp - A native bitcrusher
*
* Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
* Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of LMMS - http://lmms.io
*
* 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 "Bitcrush.h"
#include "embed.cpp"
const int OS_RATE = 5;
const float OS_RATIO = 1.0f / OS_RATE;
const float CUTOFF_RATIO = 0.353553391f;
const int SILENCEFRAMES = 10;
extern "C"
{
Plugin::Descriptor PLUGIN_EXPORT bitcrush_plugin_descriptor =
{
STRINGIFY( PLUGIN_NAME ),
"Bitcrush",
QT_TRANSLATE_NOOP( "pluginBrowser", "An oversampling bitcrusher" ),
"Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>",
0x0100,
Plugin::Effect,
new PluginPixmapLoader( "logo" ),
NULL,
NULL
};
}
BitcrushEffect::BitcrushEffect( Model * parent, const Descriptor::SubPluginFeatures::Key * key ) :
Effect( &bitcrush_plugin_descriptor, parent, key ),
m_controls( this ),
m_sampleRate( Engine::mixer()->processingSampleRate() ),
m_filter( m_sampleRate )
{
m_buffer = MM_ALLOC( sampleFrame, Engine::mixer()->framesPerPeriod() * OS_RATE );
m_filter.setLowpass( m_sampleRate * ( CUTOFF_RATIO * OS_RATIO ) );
m_needsUpdate = true;
m_bitCounterL = 0.0f;
m_bitCounterR = 0.0f;
m_left = 0.0f;
m_right = 0.0f;
m_silenceCounter = 0;
}
BitcrushEffect::~BitcrushEffect()
{
MM_FREE( m_buffer );
}
void BitcrushEffect::sampleRateChanged()
{
m_sampleRate = Engine::mixer()->processingSampleRate();
m_filter.setSampleRate( m_sampleRate );
m_filter.setLowpass( m_sampleRate * CUTOFF_RATIO );
m_needsUpdate = true;
}
inline float BitcrushEffect::depthCrush( float in )
{
return roundf( in * (float) m_levels ) * m_levelsRatio;
}
inline float BitcrushEffect::noise( float amt )
{
return fastRandf( amt * 2.0f ) - amt;
}
bool BitcrushEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
{
// update values
if( m_needsUpdate || m_controls.m_rateEnabled.isValueChanged() )
{
m_rateEnabled = m_controls.m_rateEnabled.value();
m_bitCounterL = 0.0f;
m_bitCounterR = 0.0f;
}
if( m_needsUpdate || m_controls.m_depthEnabled.isValueChanged() )
{
m_depthEnabled = m_controls.m_depthEnabled.value();
}
if( m_needsUpdate || m_controls.m_rate.isValueChanged() || m_controls.m_stereoDiff.isValueChanged() )
{
const float rate = m_controls.m_rate.value();
const float diff = m_controls.m_stereoDiff.value() * 0.005 * rate;
m_rateCoeffL = ( m_sampleRate * OS_RATE ) / ( rate - diff );
m_rateCoeffR = ( m_sampleRate * OS_RATE ) / ( rate + diff );
m_bitCounterL = 0.0f;
m_bitCounterR = 0.0f;
}
if( m_needsUpdate || m_controls.m_levels.isValueChanged() )
{
m_levels = m_controls.m_levels.value();
m_levelsRatio = 1.0f / (float) m_levels;
}
if( m_needsUpdate || m_controls.m_inGain.isValueChanged() )
{
m_inGain = dbvToAmp( m_controls.m_inGain.value() );
}
if( m_needsUpdate || m_controls.m_outGain.isValueChanged() )
{
m_outGain = dbvToAmp( m_controls.m_outGain.value() );
}
if( m_needsUpdate || m_controls.m_outClip.isValueChanged() )
{
m_outClip = dbvToAmp( m_controls.m_outClip.value() );
}
m_needsUpdate = false;
const float noiseAmt = m_controls.m_inNoise.value() * 0.01f;
// read input buffer and write it to oversampled buffer
if( m_rateEnabled ) // rate crushing enabled so do that
{
for( int f = 0; f < frames; ++f )
{
for( int o = 0; o < OS_RATE; ++o )
{
m_buffer[f * OS_RATE + o][0] = m_left;
m_buffer[f * OS_RATE + o][1] = m_right;
m_bitCounterL += 1.0f;
m_bitCounterR += 1.0f;
if( m_bitCounterL > m_rateCoeffL )
{
m_bitCounterL -= m_rateCoeffL;
m_left = m_depthEnabled
? depthCrush( buf[f][0] * m_inGain + noise( buf[f][0] * noiseAmt ) )
: buf[f][0] * m_inGain + noise( buf[f][0] * noiseAmt );
}
if( m_bitCounterR > m_rateCoeffR )
{
m_bitCounterR -= m_rateCoeffR;
m_right = m_depthEnabled
? depthCrush( buf[f][1] * m_inGain + noise( buf[f][1] * noiseAmt ) )
: buf[f][1] * m_inGain + noise( buf[f][1] * noiseAmt );
}
}
}
}
else // rate crushing disabled: simply oversample with zero-order hold
{
for( int f = 0; f < frames; ++f )
{
for( int o = 0; o < OS_RATE; ++o )
{
m_buffer[f * OS_RATE + o][0] = m_depthEnabled
? depthCrush( buf[f][0] * m_inGain + noise( buf[f][0] * noiseAmt ) )
: buf[f][0] * m_inGain + noise( buf[f][0] * noiseAmt );
m_buffer[f * OS_RATE + o][1] = m_depthEnabled
? depthCrush( buf[f][1] * m_inGain + noise( buf[f][1] * noiseAmt ) )
: buf[f][1] * m_inGain + noise( buf[f][1] * noiseAmt );
}
}
}
// the oversampled buffer is now written, so filter it to reduce aliasing
for( int f = 0; f < frames * OS_RATE; ++f )
{
if( qMax( qAbs( m_buffer[f][0] ), qAbs( m_buffer[f][1] ) ) >= 1.0e-10f )
{
m_silenceCounter = 0;
m_buffer[f][0] = m_filter.update( m_buffer[f][0], 0 );
m_buffer[f][1] = m_filter.update( m_buffer[f][1], 1 );
}
else
{
if( m_silenceCounter > SILENCEFRAMES )
{
m_buffer[f][0] = m_buffer[f][1] = 0.0f;
}
else
{
++m_silenceCounter;
m_buffer[f][0] = m_filter.update( m_buffer[f][0], 0 );
m_buffer[f][1] = m_filter.update( m_buffer[f][1], 1 );
}
}
}
// now downsample and write it back to main buffer
double outSum = 0.0;
const float d = dryLevel();
const float w = wetLevel();
for( int f = 0; f < frames; ++f )
{
float lsum = 0.0f;
float rsum = 0.0f;
for( int o = 0; o < OS_RATE; ++o )
{
lsum += m_buffer[f * OS_RATE + o][0] * OS_RATIO;
rsum += m_buffer[f * OS_RATE + o][1] * OS_RATIO;
}
buf[f][0] = d * buf[f][0] + w * qBound( -m_outClip, lsum, m_outClip ) * m_outGain;
buf[f][1] = d * buf[f][1] + w * qBound( -m_outClip, rsum, m_outClip ) * m_outGain;
outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1];
}
checkGate( outSum / frames );
return isRunning();
}
extern "C"
{
// necessary for getting instance out of shared lib
Plugin * PLUGIN_EXPORT lmms_plugin_main( Model* parent, void* data )
{
return new BitcrushEffect( parent, static_cast<const Plugin::Descriptor::SubPluginFeatures::Key *>( data ) );
}
}

View File

@@ -0,0 +1,83 @@
/*
* Bitcrush.h - A native bitcrusher
*
* Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
* Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of LMMS - http://lmms.io
*
* 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 BITCRUSH_H
#define BITCRUSH_H
#include "Effect.h"
#include "BitcrushControls.h"
#include "ValueBuffer.h"
#include "lmms_math.h"
#include "BasicFilters.h"
class BitcrushEffect : public Effect
{
public:
BitcrushEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key );
virtual ~BitcrushEffect();
virtual bool processAudioBuffer( sampleFrame* buf, const fpp_t frames );
virtual EffectControls* controls()
{
return &m_controls;
}
private:
void sampleRateChanged();
float depthCrush( float in );
float noise( float amt );
BitcrushControls m_controls;
sampleFrame * m_buffer;
float m_sampleRate;
StereoLinkwitzRiley m_filter;
float m_bitCounterL;
float m_rateCoeffL;
float m_bitCounterR;
float m_rateCoeffR;
bool m_rateEnabled;
float m_left;
float m_right;
int m_levels;
float m_levelsRatio;
bool m_depthEnabled;
float m_inGain;
float m_outGain;
float m_outClip;
bool m_needsUpdate;
int m_silenceCounter;
friend class BitcrushControls;
};
#endif

View File

@@ -0,0 +1,113 @@
/*
* BitcrushControlDialog.cpp - A native bitcrusher
*
* Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
* Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of LMMS - http://lmms.io
*
* 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 <QLayout>
#include <QLabel>
#include "BitcrushControlDialog.h"
#include "BitcrushControls.h"
#include "embed.h"
#include "ToolTip.h"
#include "LedCheckbox.h"
#include "Knob.h"
BitcrushControlDialog::BitcrushControlDialog( BitcrushControls * controls ) :
EffectControlDialog( controls )
{
setAutoFillBackground( true );
QPalette pal;
pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( "artwork" ) );
setPalette( pal );
setFixedSize( 215, 120 );
// labels
QLabel * inLabel = new QLabel( tr( "IN" ), this );
inLabel->move( 12, 10);
QLabel * outLabel = new QLabel( tr( "OUT" ), this );
outLabel->move( 176, 10 );
// input knobs
Knob * inGain = new Knob( knobBright_26, this );
inGain->move( 12, 25 );
inGain->setModel( & controls->m_inGain );
inGain->setLabel( tr( "GAIN" ) );
inGain->setHintText( tr( "Input Gain:" ) + " ", " dBV" );
Knob * inNoise = new Knob( knobBright_26, this );
inNoise->move( 12, 70 );
inNoise->setModel( & controls->m_inNoise );
inNoise->setLabel( tr( "NOIS" ) );
inNoise->setHintText( tr( "Input Noise:" ) + " ", "%" );
// output knobs
Knob * outGain = new Knob( knobBright_26, this );
outGain->move( 176, 25 );
outGain->setModel( & controls->m_outGain );
outGain->setLabel( tr( "GAIN" ) );
outGain->setHintText( tr( "Output Gain:" ) + " ", " dBV" );
Knob * outClip = new Knob( knobBright_26, this );
outClip->move( 176, 70 );
outClip->setModel( & controls->m_outClip );
outClip->setLabel( tr( "CLIP" ) );
outClip->setHintText( tr( "Output Clip:" ) + " ", "%" );
// leds
LedCheckBox * rateEnabled = new LedCheckBox( tr( "Rate" ), this, tr( "Rate Enabled" ), LedCheckBox::Green );
rateEnabled->move( 50, 30 );
rateEnabled->setModel( & controls->m_rateEnabled );
ToolTip::add( rateEnabled, tr( "Enable samplerate-crushing" ) );
LedCheckBox * depthEnabled = new LedCheckBox( tr( "Depth" ), this, tr( "Depth Enabled" ), LedCheckBox::Green );
depthEnabled->move( 50, 80 );
depthEnabled->setModel( & controls->m_depthEnabled );
ToolTip::add( depthEnabled, tr( "Enable bitdepth-crushing" ) );
// rate crushing knobs
Knob * rate = new Knob( knobBright_26, this );
rate->move( 100, 20 );
rate->setModel( & controls->m_rate );
rate->setLabel( tr( "Rate" ) );
rate->setHintText( tr( "Sample rate:" ) + " ", " Hz" );
Knob * stereoDiff = new Knob( knobBright_26, this );
stereoDiff->move( 140, 20 );
stereoDiff->setModel( & controls->m_stereoDiff );
stereoDiff->setLabel( tr( "STD" ) );
stereoDiff->setHintText( tr( "Stereo difference:" ) + " ", "%" );
// depth crushing knob
Knob * levels = new Knob( knobBright_26, this );
levels->move( 140, 70 );
levels->setModel( & controls->m_levels );
levels->setLabel( tr( "Levels" ) );
levels->setHintText( tr( "Levels:" ) + " ", "" );
}

View File

@@ -0,0 +1,44 @@
/*
* BitcrushControlDialog.h - A native bitcrusher
*
* Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
* Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of LMMS - http://lmms.io
*
* 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 BITCRUSH_CONTROL_DIALOG_H
#define BITCRUSH_CONTROL_DIALOG_H
#include "EffectControlDialog.h"
class BitcrushControls;
class BitcrushControlDialog : public EffectControlDialog
{
Q_OBJECT
public:
BitcrushControlDialog( BitcrushControls * controls );
virtual ~BitcrushControlDialog()
{
}
};
#endif

View File

@@ -0,0 +1,89 @@
/*
* BitcrushControls.cpp - A native bitcrusher
*
* Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
* Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of LMMS - http://lmms.io
*
* 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 <QDomElement>
#include "BitcrushControls.h"
#include "Bitcrush.h"
#include "lmms_math.h"
BitcrushControls::BitcrushControls( BitcrushEffect * eff ) :
EffectControls( eff ),
m_effect( eff ),
m_inGain( 0.0f, -20.0f, 20.0f, 0.1f, this, "Input gain" ),
m_inNoise( 0.0f, 0.0f, 100.0f, 0.1f, this, "Input noise" ),
m_outGain( 0.0f, -20.0f, 20.0f, 0.1f, this, "Output gain" ),
m_outClip( 0.0f, -20.0f, 20.0f, 0.1f, this, "Output clip" ),
m_rate( 44100.f, 20.f, 44100.f, 1.0f, this, "Samplerate" ),
m_stereoDiff( 0.f, 0.f, 50.f, 0.1f, this, "Stereo difference" ),
m_levels( 256.f, 1.f, 256.f, 1.0f, this, "Levels" ),
m_rateEnabled( true, this, "Rate enabled" ),
m_depthEnabled( true, this, "Depth enabled" )
{
m_rate.setStrictStepSize( true );
m_levels.setStrictStepSize( true );
connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( sampleRateChanged() ) );
}
BitcrushControls::~BitcrushControls()
{
}
void BitcrushControls::saveSettings( QDomDocument & doc, QDomElement & elem )
{
m_inGain.saveSettings( doc, elem, "ingain" );
m_inNoise.saveSettings( doc, elem, "innoise" );
m_outGain.saveSettings( doc, elem, "outgain" );
m_outClip.saveSettings( doc, elem, "outclip" );
m_rate.saveSettings( doc, elem, "rate" );
m_stereoDiff.saveSettings( doc, elem, "stereodiff" );
m_levels.saveSettings( doc, elem, "levels" );
m_rateEnabled.saveSettings( doc, elem, "rateon" );
m_depthEnabled.saveSettings( doc, elem, "depthon" );
}
void BitcrushControls::loadSettings( const QDomElement & elem )
{
m_inGain.loadSettings( elem, "ingain" );
m_inNoise.loadSettings( elem, "innoise" );
m_outGain.loadSettings( elem, "outgain" );
m_outClip.loadSettings( elem, "outclip" );
m_rate.loadSettings( elem, "rate" );
m_stereoDiff.loadSettings( elem, "stereodiff" );
m_levels.loadSettings( elem, "levels" );
m_rateEnabled.loadSettings( elem, "rateon" );
m_depthEnabled.loadSettings( elem, "depthon" );
m_effect->m_needsUpdate = true;
}
void BitcrushControls::sampleRateChanged()
{
m_effect->sampleRateChanged();
}

View File

@@ -0,0 +1,82 @@
/*
* BitcrushControls.h - A native bitcrusher
*
* Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
* Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of LMMS - http://lmms.io
*
* 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 BITCRUSH_CONTROLS_H
#define BITCRUSH_CONTROLS_H
#include "EffectControls.h"
#include "BitcrushControlDialog.h"
class BitcrushEffect;
class BitcrushControls : public EffectControls
{
Q_OBJECT
public:
BitcrushControls( BitcrushEffect * eff );
virtual ~BitcrushControls();
virtual void saveSettings( QDomDocument & doc, QDomElement & elem );
virtual void loadSettings( const QDomElement & elem );
inline virtual QString nodeName() const
{
return( "bitcrushcontrols" );
}
virtual int controlCount()
{
return( 9 );
}
virtual EffectControlDialog * createView()
{
return( new BitcrushControlDialog( this ) );
}
private slots:
void sampleRateChanged();
private:
BitcrushEffect * m_effect;
FloatModel m_inGain;
FloatModel m_inNoise;
FloatModel m_outGain;
FloatModel m_outClip;
FloatModel m_rate;
FloatModel m_stereoDiff;
FloatModel m_levels;
BoolModel m_rateEnabled;
BoolModel m_depthEnabled;
friend class BitcrushControlDialog;
friend class BitcrushEffect;
};
#endif

View File

@@ -0,0 +1,3 @@
INCLUDE(BuildPlugin)
BUILD_PLUGIN(bitcrush Bitcrush.cpp BitcrushControls.cpp BitcrushControlDialog.cpp MOCFILES BitcrushControls.h BitcrushControlDialog.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png")

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@@ -2,6 +2,7 @@ ADD_SUBDIRECTORY(Amplifier)
ADD_SUBDIRECTORY(audio_file_processor)
ADD_SUBDIRECTORY(BassBooster)
ADD_SUBDIRECTORY(bit_invader)
ADD_SUBDIRECTORY(Bitcrush)
ADD_SUBDIRECTORY(carlabase)
ADD_SUBDIRECTORY(carlapatchbay)
ADD_SUBDIRECTORY(carlarack)

View File

@@ -104,7 +104,6 @@ void FxChannel::incrementDeps()
{
m_queued = true;
MixerWorkerThread::addJob( this );
m_dependenciesMet = 0;
}
}
@@ -174,7 +173,7 @@ void FxChannel::doProcessing()
// only start fxchain when we have input...
m_fxChain.startRunning();
}
m_stillRunning = m_fxChain.processAudioBuffer( m_buffer, fpp, m_hasInput );
m_peakLeft = qMax( m_peakLeft, Engine::mixer()->peakValueLeft( m_buffer, fpp ) * v );
@@ -184,8 +183,8 @@ void FxChannel::doProcessing()
{
m_peakLeft = m_peakRight = 0.0f;
}
// increment dependency counter of all receivers
// increment dependency counter of all receivers
processed();
}
@@ -430,7 +429,7 @@ FxRoute * FxMixer::createRoute( FxChannel * from, FxChannel * to, float amount )
// add us to fxmixer's list
Engine::fxMixer()->m_fxRoutes.append( route );
m_sendsMutex.unlock();
return route;
}
@@ -613,6 +612,7 @@ void FxMixer::masterMix( sampleFrame * _buf )
m_fxChannels[i]->m_queued = false;
// also reset hasInput
m_fxChannels[i]->m_hasInput = false;
m_fxChannels[i]->m_dependenciesMet = 0;
}
}
@@ -688,7 +688,7 @@ void FxMixer::saveSettings( QDomDocument & _doc, QDomElement & _this )
ch->m_sends[si]->amount()->saveSettings( _doc, sendsDom, "amount" );
}
}
}
}
// make sure we have at least num channels
void FxMixer::allocateChannelsTo(int num)

View File

@@ -473,7 +473,7 @@ void Song::playBB()
void Song::playPattern( Pattern* patternToPlay, bool _loop )
void Song::playPattern( const Pattern* patternToPlay, bool _loop )
{
if( isStopped() == false )
{

View File

@@ -2139,7 +2139,7 @@ TrackContentObject * Track::getTCO( int _tco_num )
* \param _tco The TrackContentObject to search for.
* \return its number in our array.
*/
int Track::getTCONum( TrackContentObject * _tco )
int Track::getTCONum( const TrackContentObject * _tco )
{
// for( int i = 0; i < getTrackContentWidget()->numOfTCOs(); ++i )
tcoVector::iterator it = qFind( m_trackContentObjects.begin(),

View File

@@ -99,24 +99,24 @@ MainWindow::MainWindow() :
ConfigManager::inst()->userProjectsDir() + "*" +
ConfigManager::inst()->factoryProjectsDir(),
"*.mmp *.mmpz *.xml *.mid *.flp",
tr( "My projects" ),
tr( "My Projects" ),
embed::getIconPixmap( "project_file" ).transformed( QTransform().rotate( 90 ) ),
splitter ) );
sideBar->appendTab( new FileBrowser(
ConfigManager::inst()->userSamplesDir() + "*" +
ConfigManager::inst()->factorySamplesDir(),
"*", tr( "My samples" ),
"*", tr( "My Samples" ),
embed::getIconPixmap( "sample_file" ).transformed( QTransform().rotate( 90 ) ),
splitter ) );
sideBar->appendTab( new FileBrowser(
ConfigManager::inst()->userPresetsDir() + "*" +
ConfigManager::inst()->factoryPresetsDir(),
"*.xpf *.cs.xml *.xiz",
tr( "My presets" ),
tr( "My Presets" ),
embed::getIconPixmap( "preset_file" ).transformed( QTransform().rotate( 90 ) ),
splitter ) );
sideBar->appendTab( new FileBrowser( QDir::homePath(), "*",
tr( "My home" ),
tr( "My Home" ),
embed::getIconPixmap( "home" ).transformed( QTransform().rotate( 90 ) ),
splitter ) );
@@ -132,11 +132,11 @@ MainWindow::MainWindow() :
#endif
sideBar->appendTab( new FileBrowser( root_paths.join( "*" ), "*",
#ifdef LMMS_BUILD_WIN32
tr( "My computer" ),
tr( "My Computer" ),
#elif defined(LMMS_BUILD_APPLE)
tr( "Volumes" ),
#else
tr( "Root directory" ),
tr( "Root Directory" ),
#endif
embed::getIconPixmap( "computer" ).transformed( QTransform().rotate( 90 ) ),
@@ -245,7 +245,7 @@ void MainWindow::finalize()
m_recentlyOpenedProjectsMenu = project_menu->addMenu(
embed::getIconPixmap( "project_open_recent" ),
tr( "&Recently opened projects" ) );
tr( "&Recently Opened Projects" ) );
connect( m_recentlyOpenedProjectsMenu, SIGNAL( aboutToShow() ),
this, SLOT( updateRecentlyOpenedProjectsMenu() ) );
connect( m_recentlyOpenedProjectsMenu, SIGNAL( triggered( QAction * ) ),
@@ -257,7 +257,7 @@ void MainWindow::finalize()
Qt::CTRL + Qt::Key_S );
project_menu->addAction( embed::getIconPixmap( "project_save" ),
tr( "Save as new &version" ),
tr( "Save as New &Version" ),
this, SLOT( saveProjectAsNewVersion() ),
Qt::CTRL + Qt::ALT + Qt::Key_S );
project_menu->addAction( embed::getIconPixmap( "project_saveas" ),
@@ -275,7 +275,7 @@ void MainWindow::finalize()
SLOT( exportProject() ),
Qt::CTRL + Qt::Key_E );
project_menu->addAction( embed::getIconPixmap( "project_export" ),
tr( "E&xport tracks..." ),
tr( "E&xport Tracks..." ),
Engine::getSong(),
SLOT( exportProjectTracks() ),
Qt::CTRL + Qt::SHIFT + Qt::Key_E );
@@ -331,7 +331,7 @@ void MainWindow::finalize()
if( true )
{
help_menu->addAction( embed::getIconPixmap( "help" ),
tr( "Online help" ),
tr( "Online Help" ),
this, SLOT( browseHelp() ) );
}
else
@@ -341,7 +341,7 @@ void MainWindow::finalize()
this, SLOT( help() ) );
}
help_menu->addAction( embed::getIconPixmap( "whatsthis" ),
tr( "What's this?" ),
tr( "What's This?" ),
this, SLOT( enterWhatsThisMode() ) );
help_menu->addSeparator();
@@ -743,7 +743,7 @@ void MainWindow::openProject()
{
if( mayChangeProject() )
{
FileDialog ofd( this, tr( "Open project" ), "", tr( "LMMS (*.mmp *.mmpz)" ) );
FileDialog ofd( this, tr( "Open Project" ), "", tr( "LMMS (*.mmp *.mmpz)" ) );
ofd.setDirectory( ConfigManager::inst()->userProjectsDir() );
ofd.setFileMode( FileDialog::ExistingFiles );
@@ -808,7 +808,7 @@ bool MainWindow::saveProject()
bool MainWindow::saveProjectAs()
{
VersionedSaveDialog sfd( this, tr( "Save project" ), "",
VersionedSaveDialog sfd( this, tr( "Save Project" ), "",
tr( "LMMS Project (*.mmpz *.mmp);;"
"LMMS Project Template (*.mpt)" ) );
QString f = Engine::getSong()->projectFileName();
@@ -901,6 +901,7 @@ void MainWindow::toggleWindow( QWidget *window, bool forceShow )
else
{
parent->hide();
refocus();
}
// Workaround for Qt Bug #260116
@@ -913,6 +914,38 @@ void MainWindow::toggleWindow( QWidget *window, bool forceShow )
/*
* When an editor window with focus is toggled off, attempt to set focus
* to the next visible editor window, or if none are visible, set focus
* to the parent window.
*/
void MainWindow::refocus()
{
QList<QWidget*> editors;
editors
<< Engine::songEditor()->parentWidget()
<< Engine::getBBEditor()->parentWidget()
<< Engine::pianoRoll()->parentWidget()
<< Engine::automationEditor()->parentWidget();
bool found = false;
QList<QWidget*>::Iterator editor;
for( editor = editors.begin(); editor != editors.end(); ++editor )
{
if( ! (*editor)->isHidden() ) {
(*editor)->setFocus();
found = true;
break;
}
}
if( ! found )
this->setFocus();
}
void MainWindow::toggleBBEditorWin( bool forceShow )
{
toggleWindow( Engine::getBBEditor(), forceShow );

View File

@@ -1529,7 +1529,7 @@ void AutomationEditor::play()
if( Engine::getSong()->playMode() != Song::Mode_PlayPattern )
{
Engine::getSong()->stop();
Engine::getSong()->playPattern( (Pattern *) Engine::pianoRoll()->currentPattern() );
Engine::getSong()->playPattern( Engine::pianoRoll()->currentPattern() );
}
else if( Engine::getSong()->isStopped() == false )
{
@@ -1537,7 +1537,7 @@ void AutomationEditor::play()
}
else
{
Engine::getSong()->playPattern( (Pattern *) Engine::pianoRoll()->currentPattern() );
Engine::getSong()->playPattern( Engine::pianoRoll()->currentPattern() );
}
}
else if( inBBEditor() )