diff --git a/data/themes/default/knob05.png b/data/themes/default/knob05.png new file mode 100644 index 000000000..7b98f097d Binary files /dev/null and b/data/themes/default/knob05.png differ diff --git a/include/graph.h b/include/graph.h index 1936da635..411224e1f 100644 --- a/include/graph.h +++ b/include/graph.h @@ -47,6 +47,7 @@ public: NearestStyle, LinearStyle, LinearNonCyclicStyle, + BarStyle, NumGraphStyles }; diff --git a/include/knob.h b/include/knob.h index b459663b2..2cdf40996 100644 --- a/include/knob.h +++ b/include/knob.h @@ -39,7 +39,7 @@ class textFloat; enum knobTypes { - knobDark_28, knobBright_26, knobSmall_17, knobGreen_17, knobStyled + knobDark_28, knobBright_26, knobSmall_17, knobGreen_17, knobVintage_32, knobStyled } ; diff --git a/plugins/stk/mallets/artwork.png b/plugins/stk/mallets/artwork.png index bd0bdf74a..6973ead12 100644 Binary files a/plugins/stk/mallets/artwork.png and b/plugins/stk/mallets/artwork.png differ diff --git a/plugins/stk/mallets/mallets.cpp b/plugins/stk/mallets/mallets.cpp index bfc6b4a45..c2d91f0c9 100644 --- a/plugins/stk/mallets/mallets.cpp +++ b/plugins/stk/mallets/mallets.cpp @@ -310,25 +310,29 @@ malletsInstrumentView::malletsInstrumentView( malletsInstrument * _instrument, { m_modalBarWidget = setupModalBarControls( this ); setWidgetBackground( m_modalBarWidget, "artwork" ); + m_modalBarWidget->show(); + m_modalBarWidget->move( 0,0 ); m_tubeBellWidget = setupTubeBellControls( this ); setWidgetBackground( m_tubeBellWidget, "artwork" ); m_tubeBellWidget->hide(); + m_tubeBellWidget->move( 0,0 ); m_bandedWGWidget = setupBandedWGControls( this ); setWidgetBackground( m_bandedWGWidget, "artwork" ); m_bandedWGWidget->hide(); + m_bandedWGWidget->move( 0,0 ); m_presetsCombo = new comboBox( this, tr( "Instrument" ) ); - m_presetsCombo->setGeometry( 64, 157, 99, 22 ); + m_presetsCombo->setGeometry( 140, 50, 99, 22 ); m_presetsCombo->setFont( pointSize<8>( m_presetsCombo->font() ) ); connect( &_instrument->m_presetsModel, SIGNAL( dataChanged() ), this, SLOT( changePreset() ) ); - m_spreadKnob = new knob( knobBright_26, this ); + m_spreadKnob = new knob( knobVintage_32, this ); m_spreadKnob->setLabel( tr( "Spread" ) ); - m_spreadKnob->move( 178, 173 ); + m_spreadKnob->move( 190, 140 ); m_spreadKnob->setHintText( tr( "Spread:" ) + " ", "" ); } @@ -358,29 +362,29 @@ QWidget * malletsInstrumentView::setupModalBarControls( QWidget * _parent ) QWidget * widget = new QWidget( _parent ); widget->setFixedSize( 250, 250 ); - m_hardnessKnob = new knob( knobBright_26, widget ); + m_hardnessKnob = new knob( knobVintage_32, widget ); m_hardnessKnob->setLabel( tr( "Hardness" ) ); - m_hardnessKnob->move( 145, 24 ); + m_hardnessKnob->move( 30, 90 ); m_hardnessKnob->setHintText( tr( "Hardness:" ) + " ", "" ); - m_positionKnob = new knob( knobBright_26, widget ); + m_positionKnob = new knob( knobVintage_32, widget ); m_positionKnob->setLabel( tr( "Position" ) ); - m_positionKnob->move( 195, 24 ); + m_positionKnob->move( 110, 90 ); m_positionKnob->setHintText( tr( "Position:" ) + " ", "" ); - m_vibratoGainKnob = new knob( knobBright_26, widget ); + m_vibratoGainKnob = new knob( knobVintage_32, widget ); m_vibratoGainKnob->setLabel( tr( "Vib Gain" ) ); - m_vibratoGainKnob->move( 56, 86 ); + m_vibratoGainKnob->move( 30, 140 ); m_vibratoGainKnob->setHintText( tr( "Vib Gain:" ) + " ", "" ); - m_vibratoFreqKnob = new knob( knobBright_26, widget ); + m_vibratoFreqKnob = new knob( knobVintage_32, widget ); m_vibratoFreqKnob->setLabel( tr( "Vib Freq" ) ); - m_vibratoFreqKnob->move( 117, 86 ); + m_vibratoFreqKnob->move( 110, 140 ); m_vibratoFreqKnob->setHintText( tr( "Vib Freq:" ) + " ", "" ); - m_stickKnob = new knob( knobBright_26, widget ); + m_stickKnob = new knob( knobVintage_32, widget ); m_stickKnob->setLabel( tr( "Stick Mix" ) ); - m_stickKnob->move( 178, 86 ); + m_stickKnob->move( 190, 90 ); m_stickKnob->setHintText( tr( "Stick Mix:" ) + " ", "" ); return( widget ); @@ -394,29 +398,29 @@ QWidget * malletsInstrumentView::setupTubeBellControls( QWidget * _parent ) QWidget * widget = new QWidget( _parent ); widget->setFixedSize( 250, 250 ); - m_modulatorKnob = new knob( knobBright_26, widget ); + m_modulatorKnob = new knob( knobVintage_32, widget ); m_modulatorKnob->setLabel( tr( "Modulator" ) ); - m_modulatorKnob->move( 145, 24 ); + m_modulatorKnob->move( 30, 90 ); m_modulatorKnob->setHintText( tr( "Modulator:" ) + " ", "" ); - m_crossfadeKnob = new knob( knobBright_26, widget ); + m_crossfadeKnob = new knob( knobVintage_32, widget ); m_crossfadeKnob->setLabel( tr( "Crossfade" ) ); - m_crossfadeKnob->move( 195, 24 ); + m_crossfadeKnob->move( 110, 90 ); m_crossfadeKnob->setHintText( tr( "Crossfade:" ) + " ", "" ); - m_lfoSpeedKnob = new knob( knobBright_26, widget ); + m_lfoSpeedKnob = new knob( knobVintage_32, widget ); m_lfoSpeedKnob->setLabel( tr( "LFO Speed" ) ); - m_lfoSpeedKnob->move( 56, 86 ); + m_lfoSpeedKnob->move( 30, 140 ); m_lfoSpeedKnob->setHintText( tr( "LFO Speed:" ) + " ", "" ); - m_lfoDepthKnob = new knob( knobBright_26, widget ); + m_lfoDepthKnob = new knob( knobVintage_32, widget ); m_lfoDepthKnob->setLabel( tr( "LFO Depth" ) ); - m_lfoDepthKnob->move( 117, 86 ); + m_lfoDepthKnob->move( 110, 140 ); m_lfoDepthKnob->setHintText( tr( "LFO Depth:" ) + " ", "" ); - m_adsrKnob = new knob( knobBright_26, widget ); + m_adsrKnob = new knob( knobVintage_32, widget ); m_adsrKnob->setLabel( tr( "ADSR" ) ); - m_adsrKnob->move( 178, 86 ); + m_adsrKnob->move( 190, 90 ); m_adsrKnob->setHintText( tr( "ADSR:" ) + " ", "" ); return( widget ); @@ -432,26 +436,26 @@ QWidget * malletsInstrumentView::setupBandedWGControls( QWidget * _parent ) widget->setFixedSize( 250, 250 ); m_strikeLED = new ledCheckBox( tr( "Bowed" ), widget ); - m_strikeLED->move( 165, 30 ); + m_strikeLED->move( 138, 25 ); - m_pressureKnob = new knob( knobBright_26, widget ); + m_pressureKnob = new knob( knobVintage_32, widget ); m_pressureKnob->setLabel( tr( "Pressure" ) ); - m_pressureKnob->move( 56, 86 ); + m_pressureKnob->move( 30, 90 ); m_pressureKnob->setHintText( tr( "Pressure:" ) + " ", "" ); - m_motionKnob = new knob( knobBright_26, widget ); + m_motionKnob = new knob( knobVintage_32, widget ); m_motionKnob->setLabel( tr( "Motion" ) ); - m_motionKnob->move( 117, 86 ); + m_motionKnob->move( 110, 90 ); m_motionKnob->setHintText( tr( "Motion:" ) + " ", "" ); - m_velocityKnob = new knob( knobBright_26, widget ); + m_velocityKnob = new knob( knobVintage_32, widget ); m_velocityKnob->setLabel( tr( "Speed" ) ); - m_velocityKnob->move( 178, 86 ); + m_velocityKnob->move( 30, 140 ); m_velocityKnob->setHintText( tr( "Speed:" ) + " ", "" ); - m_vibratoKnob = new knob( knobBright_26, widget, tr( "Vibrato" ) ); + m_vibratoKnob = new knob( knobVintage_32, widget, tr( "Vibrato" ) ); m_vibratoKnob->setLabel( tr( "Vibrato" ) ); - m_vibratoKnob->move( 178, 129 ); + m_vibratoKnob->move( 110, 140 ); m_vibratoKnob->setHintText( tr( "Vibrato:" ) + " ", "" ); return( widget ); diff --git a/plugins/waveshaper/add1_active.png b/plugins/waveshaper/add1_active.png new file mode 100644 index 000000000..89ae87e0f Binary files /dev/null and b/plugins/waveshaper/add1_active.png differ diff --git a/plugins/waveshaper/add1_inactive.png b/plugins/waveshaper/add1_inactive.png new file mode 100644 index 000000000..94213a27c Binary files /dev/null and b/plugins/waveshaper/add1_inactive.png differ diff --git a/plugins/waveshaper/artwork.png b/plugins/waveshaper/artwork.png index fac96bcb4..25c715144 100644 Binary files a/plugins/waveshaper/artwork.png and b/plugins/waveshaper/artwork.png differ diff --git a/plugins/waveshaper/reset_active.png b/plugins/waveshaper/reset_active.png index 0f4c8b9a6..7bb3957ee 100644 Binary files a/plugins/waveshaper/reset_active.png and b/plugins/waveshaper/reset_active.png differ diff --git a/plugins/waveshaper/reset_inactive.png b/plugins/waveshaper/reset_inactive.png index 57c0a7a85..5c3955b2b 100644 Binary files a/plugins/waveshaper/reset_inactive.png and b/plugins/waveshaper/reset_inactive.png differ diff --git a/plugins/waveshaper/smooth_active.png b/plugins/waveshaper/smooth_active.png index 62cba64b5..a44bef32d 100644 Binary files a/plugins/waveshaper/smooth_active.png and b/plugins/waveshaper/smooth_active.png differ diff --git a/plugins/waveshaper/smooth_inactive.png b/plugins/waveshaper/smooth_inactive.png index 53bddbb83..eb689a500 100644 Binary files a/plugins/waveshaper/smooth_inactive.png and b/plugins/waveshaper/smooth_inactive.png differ diff --git a/plugins/waveshaper/sub1_active.png b/plugins/waveshaper/sub1_active.png new file mode 100644 index 000000000..b82eb2585 Binary files /dev/null and b/plugins/waveshaper/sub1_active.png differ diff --git a/plugins/waveshaper/sub1_inactive.png b/plugins/waveshaper/sub1_inactive.png new file mode 100644 index 000000000..075239fd4 Binary files /dev/null and b/plugins/waveshaper/sub1_inactive.png differ diff --git a/plugins/waveshaper/wavegraph.png b/plugins/waveshaper/wavegraph.png index eb3efa968..650fcec02 100644 Binary files a/plugins/waveshaper/wavegraph.png and b/plugins/waveshaper/wavegraph.png differ diff --git a/plugins/waveshaper/waveshaper.cpp b/plugins/waveshaper/waveshaper.cpp index a7c1f037d..4f91c5e1a 100644 --- a/plugins/waveshaper/waveshaper.cpp +++ b/plugins/waveshaper/waveshaper.cpp @@ -1,9 +1,9 @@ /* * waveshaper.cpp - waveshaper effect-plugin * - * * Copyright * (c) 2014 Vesa Kivimäki + * Copyright (c) 2014 Vesa Kivimäki * Copyright (c) 2006-2009 Tobias Doerffel - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -89,31 +89,41 @@ bool waveShaperEffect::processAudioBuffer( sampleFrame * _buf, sample_t s[2] = { _buf[f][0], _buf[f][1] }; // apply input gain - s[0] *= m_wsControls.m_inputModel.value(); - s[1] *= m_wsControls.m_inputModel.value(); - + if( m_wsControls.m_inputModel.value() != 1.0f ) + { + s[0] *= m_wsControls.m_inputModel.value(); + s[1] *= m_wsControls.m_inputModel.value(); + } + +// clip if clip enabled + if( m_wsControls.m_clipModel.value() ) + { + s[0] = qBound( -1.0f, s[0], 1.0f ); + s[1] = qBound( -1.0f, s[1], 1.0f ); + } + // start effect for ( i=0; i <= 1; ++i ) { lookup = fabsf( s[i] ) * 200.0f; posneg = s[i] < 0 ? -1.0f : 1.0f; - - if ( lookup < 1 ) + + if ( lookup < 1 ) { - frac = lookup - truncf(lookup); + frac = lookup - truncf(lookup); s[i] = frac * m_wsControls.m_wavegraphModel.samples()[0] * posneg; } else if ( lookup < 200 ) { frac = lookup - truncf(lookup); - s[i] = + s[i] = (( (1.0f-frac) * m_wsControls.m_wavegraphModel.samples()[ (int)truncf(lookup) - 1 ] ) + - ( frac * m_wsControls.m_wavegraphModel.samples()[ (int)truncf(lookup) ] )) + ( frac * m_wsControls.m_wavegraphModel.samples()[ (int)truncf(lookup) ] )) * posneg; } - else + else { s[i] *= m_wsControls.m_wavegraphModel.samples()[199]; } @@ -122,7 +132,7 @@ bool waveShaperEffect::processAudioBuffer( sampleFrame * _buf, // apply output gain s[0] *= m_wsControls.m_outputModel.value(); s[1] *= m_wsControls.m_outputModel.value(); - + // mix wet/dry signals _buf[f][0] = d * _buf[f][0] + w * s[0]; _buf[f][1] = d * _buf[f][1] + w * s[1]; diff --git a/plugins/waveshaper/waveshaper.h b/plugins/waveshaper/waveshaper.h index 016cab4de..3fc3a536c 100644 --- a/plugins/waveshaper/waveshaper.h +++ b/plugins/waveshaper/waveshaper.h @@ -1,9 +1,9 @@ /* - * waveshaper.h - bass-booster-effect-plugin + * waveshaper.h - waveshaper effect-plugin * - * * Copyright * (c) 2014 Vesa Kivimäki + * Copyright (c) 2014 Vesa Kivimäki * Copyright (c) 2006-2008 Tobias Doerffel - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -49,7 +49,7 @@ public: private: - + waveShaperControls m_wsControls; friend class waveShaperControls; diff --git a/plugins/waveshaper/waveshaper_control_dialog.cpp b/plugins/waveshaper/waveshaper_control_dialog.cpp index dac97bfa0..5adb373de 100644 --- a/plugins/waveshaper/waveshaper_control_dialog.cpp +++ b/plugins/waveshaper/waveshaper_control_dialog.cpp @@ -1,9 +1,9 @@ /* * waveshaper_control_dialog.cpp - control-dialog for waveshaper-effect * - * Copyright * (c) 2014 Vesa Kivimäki - * Copyright * (c) 2006-2008 Tobias Doerffel - * + * Copyright (c) 2014 Vesa Kivimäki + * Copyright (c) 2006-2008 Tobias Doerffel + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -32,6 +32,7 @@ #include "graph.h" #include "pixmap_button.h" #include "tooltip.h" +#include "led_checkbox.h" waveShaperControlDialog::waveShaperControlDialog( @@ -45,23 +46,23 @@ waveShaperControlDialog::waveShaperControlDialog( setPalette( pal ); setFixedSize( 224, 300 ); - graph * waveGraph = new graph( this, graph::LinearNonCyclicStyle, 204, 204 ); + graph * waveGraph = new graph( this, graph::LinearNonCyclicStyle, 204, 205 ); waveGraph -> move( 10, 32 ); waveGraph -> setModel( &_controls -> m_wavegraphModel ); waveGraph -> setAutoFillBackground( true ); pal = QPalette(); - pal.setBrush( backgroundRole(), + pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap("wavegraph") ); waveGraph->setPalette( pal ); waveGraph->setGraphColor( QColor( 170, 255, 255 ) ); - waveGraph -> setMaximumSize( 204, 204 ); - + waveGraph -> setMaximumSize( 204, 205 ); + knob * inputKnob = new knob( knobBright_26, this); inputKnob -> move( 14, 251 ); inputKnob->setModel( &_controls->m_inputModel ); inputKnob->setLabel( tr( "INPUT" ) ); inputKnob->setHintText( tr( "Input gain:" ) + " ", "" ); - + knob * outputKnob = new knob( knobBright_26, this ); outputKnob -> move( 54, 251 ); outputKnob->setModel( &_controls->m_outputModel ); @@ -74,16 +75,40 @@ waveShaperControlDialog::waveShaperControlDialog( resetButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "reset_active" ) ); resetButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "reset_inactive" ) ); toolTip::add( resetButton, tr( "Click here to reset the wavegraph back to default" ) ); - + pixmapButton * smoothButton = new pixmapButton( this, tr("Smooth waveform") ); smoothButton -> move( 164, 267 ); smoothButton -> resize( 12, 48 ); smoothButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "smooth_active" ) ); smoothButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "smooth_inactive" ) ); - toolTip::add( smoothButton, tr( "Click here to apply smooth to wavegraph" ) ); - + toolTip::add( smoothButton, tr( "Click here to apply smoothing to wavegraph" ) ); + + pixmapButton * addOneButton = new pixmapButton( this, tr("Increase graph amplitude by 1dB") ); + addOneButton -> move( 133, 251 ); + addOneButton -> resize( 12, 29 ); + addOneButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "add1_active" ) ); + addOneButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "add1_inactive" ) ); + toolTip::add( addOneButton, tr( "Click here to increase wavegraph amplitude by 1dB" ) ); + + pixmapButton * subOneButton = new pixmapButton( this, tr("Decrease graph amplitude by 1dB") ); + subOneButton -> move( 133, 267 ); + subOneButton -> resize( 12, 29 ); + subOneButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "sub1_active" ) ); + subOneButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "sub1_inactive" ) ); + toolTip::add( subOneButton, tr( "Click here to decrease wavegraph amplitude by 1dB" ) ); + + ledCheckBox * clipInputToggle = new ledCheckBox( "Clip input", this, + tr( "Clip input" ), ledCheckBox::Green ); + clipInputToggle -> move( 133, 283 ); + clipInputToggle -> setModel( &_controls -> m_clipModel ); + toolTip::add( clipInputToggle, tr( "Clip input signal to 0dB" ) ); + connect( resetButton, SIGNAL (clicked () ), _controls, SLOT ( resetClicked() ) ); connect( smoothButton, SIGNAL (clicked () ), _controls, SLOT ( smoothClicked() ) ); + connect( addOneButton, SIGNAL( clicked() ), + _controls, SLOT( addOneClicked() ) ); + connect( subOneButton, SIGNAL( clicked() ), + _controls, SLOT( subOneClicked() ) ); } diff --git a/plugins/waveshaper/waveshaper_control_dialog.h b/plugins/waveshaper/waveshaper_control_dialog.h index d028ed04e..0ad4b0572 100644 --- a/plugins/waveshaper/waveshaper_control_dialog.h +++ b/plugins/waveshaper/waveshaper_control_dialog.h @@ -1,9 +1,9 @@ /* * waveshaper_control_dialog.h - control-dialog for waveshaper-effect * - * * Copyright * (c) 2014 Vesa Kivimäki + * * Copyright (c) 2014 Vesa Kivimäki * Copyright (c) 2006-2008 Tobias Doerffel - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or diff --git a/plugins/waveshaper/waveshaper_controls.cpp b/plugins/waveshaper/waveshaper_controls.cpp index 1af27fe66..dd06f75e4 100644 --- a/plugins/waveshaper/waveshaper_controls.cpp +++ b/plugins/waveshaper/waveshaper_controls.cpp @@ -1,9 +1,9 @@ /* * waveshaper_controls.cpp - controls for waveshaper-effect * - * Copyright * (c) 2014 Vesa Kivimäki + * Copyright (c) 2014 Vesa Kivimäki * Copyright (c) 2008 Tobias Doerffel - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -33,47 +33,53 @@ #include "song.h" +#define onedB 1.1220184543019633f + waveShaperControls::waveShaperControls( waveShaperEffect * _eff ) : EffectControls( _eff ), m_effect( _eff ), m_inputModel( 1.0f, 0.0f, 5.0f, 0.01f, this, tr( "Input gain" ) ), m_outputModel( 1.0f, 0.0f, 5.0f, 0.01f, this, tr( "Output gain" ) ), - m_wavegraphModel( 0.0f, 1.0f, 200, this ) + m_wavegraphModel( 0.0f, 1.0f, 200, this ), + m_clipModel( false, this ) { connect( &m_inputModel, SIGNAL( dataChanged() ), this, SLOT( changeInput() ) ); connect( &m_outputModel, SIGNAL( dataChanged() ), this, SLOT( changeOutput() ) ); + + connect( &m_clipModel, SIGNAL( dataChanged() ), + this, SLOT( changeClip() ) ); connect( &m_wavegraphModel, SIGNAL( samplesChanged( int, int ) ), this, SLOT( samplesChanged( int, int ) ) ); - changeInput(); - changeOutput(); - setDefaultShape(); - -} + setDefaultShape(); + +} void waveShaperControls::changeInput() { + engine::getSong()->setModified(); } - - - void waveShaperControls::changeOutput() { + engine::getSong()->setModified(); } - - +void waveShaperControls::changeClip() +{ + engine::getSong()->setModified(); +} void waveShaperControls::samplesChanged( int _begin, int _end) -{ +{ + engine::getSong()->setModified(); } @@ -85,11 +91,13 @@ void waveShaperControls::loadSettings( const QDomElement & _this ) m_inputModel.setValue( _this.attribute( "inputGain" ).toFloat() ); m_outputModel.setValue( _this.attribute( "outputGain" ).toFloat() ); + m_clipModel.loadSettings( _this, "clipInput" ); + //load waveshape int size = 0; char * dst = 0; base64::decode( _this.attribute( "waveShape"), &dst, &size ); - + m_wavegraphModel.setSamples( (float*) dst ); delete[] dst; @@ -98,12 +106,14 @@ void waveShaperControls::loadSettings( const QDomElement & _this ) -void waveShaperControls::saveSettings( QDomDocument & _doc, +void waveShaperControls::saveSettings( QDomDocument & _doc, QDomElement & _this ) { //save input, output knobs _this.setAttribute( "inputGain", m_inputModel.value() ); _this.setAttribute( "outputGain", m_outputModel.value() ); + + m_clipModel.saveSettings( _doc, _this, "clipInput" ); //save waveshape QString sampleString; @@ -117,7 +127,7 @@ void waveShaperControls::saveSettings( QDomDocument & _doc, void waveShaperControls::setDefaultShape() { float shp [200] = { }; - for ( int i = 0; i<200; i++) + for ( int i = 0; i<200; i++) { shp[i] = ((float)i + 1.0f) / 200.0f; } @@ -138,6 +148,23 @@ void waveShaperControls::smoothClicked() engine::getSong()->setModified(); } +void waveShaperControls::addOneClicked() +{ + for( int i=0; i<200; i++ ) + { + m_wavegraphModel.setSampleAt( i, qBound( 0.0f, m_wavegraphModel.samples()[i] * onedB, 1.0f ) ); + } + engine::getSong()->setModified(); +} + +void waveShaperControls::subOneClicked() +{ + for( int i=0; i<200; i++ ) + { + m_wavegraphModel.setSampleAt( i, qBound( 0.0f, m_wavegraphModel.samples()[i] / onedB, 1.0f ) ); + } + engine::getSong()->setModified(); +} #include "moc_waveshaper_controls.cxx" diff --git a/plugins/waveshaper/waveshaper_controls.h b/plugins/waveshaper/waveshaper_controls.h index a77c6a2e7..3dc70bddc 100644 --- a/plugins/waveshaper/waveshaper_controls.h +++ b/plugins/waveshaper/waveshaper_controls.h @@ -1,9 +1,9 @@ /* * waveshaper_controls.h - controls for waveshaper-effect * - * Copyright * (c) 2014 Vesa Kivimäki + * Copyright (c) 2014 Vesa Kivimäki * Copyright (c) 2008 Tobias Doerffel - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -49,12 +49,12 @@ public: { return( "waveshapercontrols" ); } - + virtual void setDefaultShape(); virtual int controlCount() { - return( 3 ); + return( 4 ); } virtual EffectControlDialog * createView() @@ -67,15 +67,20 @@ private slots: void changeInput(); void changeOutput(); void samplesChanged( int, int ); - + void changeClip(); + void resetClicked(); void smoothClicked(); + void addOneClicked(); + void subOneClicked(); + private: waveShaperEffect * m_effect; FloatModel m_inputModel; FloatModel m_outputModel; graphModel m_wavegraphModel; + BoolModel m_clipModel; friend class waveShaperControlDialog; friend class waveShaperEffect; diff --git a/src/gui/widgets/graph.cpp b/src/gui/widgets/graph.cpp index e3f20391b..966d94486 100644 --- a/src/gui/widgets/graph.cpp +++ b/src/gui/widgets/graph.cpp @@ -128,12 +128,12 @@ void graph::mouseMoveEvent ( QMouseEvent * _me ) x = qMax( 2, m_lastCursorX - 1 ); }*/ - x = qMax( 2, qMin( x, width()-3 ) ); + x = qMax( 2, qMin( x, width()-3 ) ); y = qMax( 2, qMin( y, height()-3 ) ); if( qAbs( diff ) > 1 ) - { - drawLineAt( x, y, m_lastCursorX ); + { + drawLineAt( x, y, m_lastCursorX ); } else { @@ -205,7 +205,7 @@ void graph::drawLineAt( int _x, int _y, int _lastx ) _x -= 2; _y -= 2; _lastx -= 2; - + _lastx = qMax( 0, qMin( _lastx, width()-5 ) ); float range = minVal - maxVal; @@ -270,13 +270,15 @@ void graph::paintEvent( QPaintEvent * ) QPainter p( this ); p.setPen( QPen( m_graphColor, 1 ) ); + QColor gcol = QColor( m_graphColor.red(), m_graphColor.green(), m_graphColor.blue(), 100 ); QVector * samps = &(model()->m_samples); int length = model()->length(); const float maxVal = model()->maxValue(); - + const float minVal = model()->minValue(); + float xscale = (float)( width()-4 ) / length; - float yscale = (float)( height()-4 ) / ( model()->minValue() - maxVal ); + float yscale = (float)( height()-4 ) / ( minVal - maxVal ); // Max index, more useful below length--; @@ -284,7 +286,7 @@ void graph::paintEvent( QPaintEvent * ) switch( m_graphStyle ) { - case graph::LinearStyle: + case graph::LinearStyle: p.setRenderHints( QPainter::Antialiasing, true ); for( int i=0; i < length; i++ ) @@ -328,7 +330,7 @@ void graph::paintEvent( QPaintEvent * ) width()-3, 2+static_cast( ( (*samps)[length] - maxVal ) * yscale ) ); break; - + case graph::LinearNonCyclicStyle: p.setRenderHints( QPainter::Antialiasing, true ); @@ -347,7 +349,26 @@ void graph::paintEvent( QPaintEvent * ) p.setRenderHints( QPainter::Antialiasing, false ); break; - + + case graph::BarStyle: + for( int i=0; i <= length; i++ ) + { + p.fillRect( 2+static_cast( i*xscale ), + 2+static_cast( ( (*samps)[i] - maxVal ) * yscale ), + qMax( static_cast(xscale) - 1, 1 ), + qMax( static_cast( ( minVal - maxVal ) * yscale ) - static_cast( ( (*samps)[i] - maxVal ) * yscale ), 1 ), + gcol ); + + p.setPen( QPen( m_graphColor, 1 ) ); + + p.drawLine( 2+static_cast(i*xscale), + 2+static_cast( ( (*samps)[i] - maxVal ) * yscale ), + qMax( static_cast(i*xscale) + static_cast(xscale), 2+static_cast(i*xscale) ), + 2+static_cast( ( (*samps)[i] - maxVal ) * yscale ) + ); + } + + break; default: break; @@ -472,7 +493,7 @@ void graphModel::setSampleAt( int _x, float _val ) //snap to the grid _val -= ( m_step != 0.0 ) ? fmod( _val, m_step ) * m_step : 0; - // boundary crop + // boundary crop _x = qMax( 0, qMin( length()-1, _x ) ); _val = qMax( minValue(), qMin( maxValue(), _val ) ); diff --git a/src/gui/widgets/knob.cpp b/src/gui/widgets/knob.cpp index e03d2a6fc..ffcaac812 100644 --- a/src/gui/widgets/knob.cpp +++ b/src/gui/widgets/knob.cpp @@ -321,7 +321,6 @@ void knob::drawKnob( QPainter * _p ) width() / 2 - m_knobPixmap->width() / 2 ), 0, *m_knobPixmap ); -// p.setPen( QPen( QColor( 200, 0, 0 ), 2 ) ); p.setRenderHint( QPainter::Antialiasing ); const int centerAngle = angleFromValue( model()->centerValue(), model()->minValue(), model()->maxValue(), m_totalAngle ); @@ -329,7 +328,11 @@ void knob::drawKnob( QPainter * _p ) const int arcLineWidth = 2; const int arcRectSize = m_knobPixmap->width() - arcLineWidth; - QColor col = QApplication::palette().color( QPalette::Active, QPalette::WindowText ); + QColor col; + if( m_knobNum == knobVintage_32 ) + { col = QApplication::palette().color( QPalette::Active, QPalette::Shadow ); } + else + { col = QApplication::palette().color( QPalette::Active, QPalette::WindowText ); } col.setAlpha( 70 ); p.setPen( QPen( col, 2 ) ); @@ -368,6 +371,13 @@ void knob::drawKnob( QPainter * _p ) p.drawLine( calculateLine( mid, radius ) ); break; } + case knobVintage_32: + { + p.setPen( QPen( QApplication::palette().color( QPalette::Active, + QPalette::Shadow), 2 ) ); + p.drawLine( calculateLine( mid, radius-2, 2 ) ); + break; + } } p.drawArc( mid.x() - arcRectSize/2, 1, arcRectSize, arcRectSize, (90-centerAngle)*16, -16*(m_angle-centerAngle) );