-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved Waveshaper / Spline-based graph replacement #4367
Open
SecondFlight
wants to merge
52
commits into
LMMS:master
Choose a base branch
from
SecondFlight:waveshaper2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 46 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
578415a
Create copy of original waveshaper
SecondFlight e99b4ec
Merge branch 'master' into waveshaper2
SecondFlight 2f9bc3e
Begin VectorGraph class
SecondFlight ae58cf7
Begin adding model
SecondFlight c0a2ef8
Basic data storage and rendering
SecondFlight a3a062a
Initial revision of drawing code
SecondFlight b851c69
Create points with right click
SecondFlight ba67f4f
Move newly created points before releasing right click
SecondFlight 8de2637
Points cannot be moved above 1 or below 0
SecondFlight 4c60044
Make points movable
SecondFlight ba5069f
Add tension handles
SecondFlight e47df2a
Add locking to points
SecondFlight 9a2a8f8
Editible tension points
SecondFlight caa6039
Fix mouse tracking bug
SecondFlight c3104b3
Hook up DSP
SecondFlight fa7a784
Various tension tweaks
SecondFlight 44ea721
Allow points to be deleted via right click
SecondFlight 36f1691
Prevent a point and a tension handle from being manipulated simultane…
SecondFlight e6c217a
Fix warnings
SecondFlight e6a3464
Change curve to be based on a cycloid instead of a parabola
SecondFlight 43b61db
spaces -> tabs
SecondFlight a2f9fd1
Points that are completely locked cannot be targeted for drag
SecondFlight a02372c
Make handles more grabbable
SecondFlight 8b59d77
Reset tension on handle right click
SecondFlight 5a32215
Make mouse move to end point on tension move
SecondFlight 9a14ee8
Fix handles sometimes drawing a pixel above where they should
SecondFlight 5f729a1
Fix issue where lines weren't drawing between points sometimes
SecondFlight 39adedd
Partially fix tension handles on vertical lines
SecondFlight 852ee61
Allow curve types to be changed, implement stairs and hold types
SecondFlight f5e2db9
Fix line sometimes not drawing all the way to the last point
SecondFlight 6c1c3e7
Remember last curve adjustment for new point creation
SecondFlight 98e1b62
Tweaks and improvements to the stairs curve type
SecondFlight 57d339d
Add pulse curve type
SecondFlight 3f5abf7
Add double curve type
SecondFlight 10d681d
Add wave tension type
SecondFlight 811370b
Fix some tension handles drawing inconsistently
SecondFlight 4010a34
Don't draw tension handle on hold
SecondFlight 8ff2214
Prevent first and last points from being deleted
SecondFlight 2be53e9
Reset last remembered tension on right click
SecondFlight 6dde7e6
Color ui based on work by @budislav
SecondFlight 01d99d1
Remove unnecessary buttons
SecondFlight 823e8f9
Apparently removing those pictures was a bad idea
SecondFlight 5a342fc
Clean up
SecondFlight a84fd70
Enable snap to grid when alt is pressed
SecondFlight 6d202ad
Warning fixed I think
SecondFlight a650529
How about now
SecondFlight 234dd95
Merge branch 'master' into waveshaper2
PhysSong 3ed3520
Rename to WaveShaper2 and fix merge errors
PhysSong 31fb248
VectorGraph: don't try to hide and fix cursors
PhysSong d7141c0
Fix a double free of VectorGraphModel
PhysSong 970ce05
Revert submodule changes
PhysSong 56dc975
Partially address review comments
PhysSong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
INCLUDE(BuildPlugin) | ||
|
||
BUILD_PLUGIN(waveshaper2 waveshaper2.cpp waveshaper2_controls.cpp waveshaper2_control_dialog.cpp MOCFILES waveshaper2_controls.h waveshaper2_control_dialog.h EMBEDDED_RESOURCES *.png) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
/* | ||
* waveshaper.cpp - waveshaper effect-plugin | ||
* | ||
* Copyright (c) 2018 Joshua Wade (https://github.com/SecondFlight) | ||
* Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi> | ||
* Copyright (c) 2006-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net> | ||
* | ||
* This file is part of LMMS - https://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 "waveshaper2.h" | ||
#include "lmms_math.h" | ||
#include "embed.h" | ||
#include "interpolation.h" | ||
|
||
|
||
extern "C" | ||
{ | ||
|
||
Plugin::Descriptor PLUGIN_EXPORT waveshaper2_plugin_descriptor = | ||
{ | ||
STRINGIFY( PLUGIN_NAME ), | ||
"Waveshaper 2", | ||
QT_TRANSLATE_NOOP( "pluginBrowser", | ||
"plugin for waveshaping" ), | ||
"Joshua Wade <lastname/firstinitial/at/southern/dot/edu>", | ||
0x0100, | ||
Plugin::Effect, | ||
new PluginPixmapLoader("logo"), | ||
NULL, | ||
NULL | ||
} ; | ||
|
||
} | ||
|
||
|
||
|
||
waveShaper2Effect::waveShaper2Effect( Model * _parent, | ||
const Descriptor::SubPluginFeatures::Key * _key ) : | ||
Effect( &waveshaper2_plugin_descriptor, _parent, _key ), | ||
m_wsControls( this ) | ||
{ | ||
} | ||
|
||
|
||
|
||
|
||
waveShaper2Effect::~waveShaper2Effect() | ||
{ | ||
} | ||
|
||
|
||
|
||
|
||
bool waveShaper2Effect::processAudioBuffer( sampleFrame * _buf, | ||
const fpp_t _frames ) | ||
{ | ||
if( !isEnabled() || !isRunning () ) | ||
{ | ||
return( false ); | ||
} | ||
|
||
// variables for effect | ||
int i = 0; | ||
|
||
double out_sum = 0.0; | ||
const float d = dryLevel(); | ||
const float w = wetLevel(); | ||
float input = m_wsControls.m_inputModel.value(); | ||
float output = m_wsControls.m_outputModel.value(); | ||
|
||
ValueBuffer *inputBuffer = m_wsControls.m_inputModel.valueBuffer(); | ||
ValueBuffer *outputBufer = m_wsControls.m_outputModel.valueBuffer(); | ||
|
||
int inputInc = inputBuffer ? 1 : 0; | ||
int outputInc = outputBufer ? 1 : 0; | ||
|
||
const float *inputPtr = inputBuffer ? &( inputBuffer->values()[ 0 ] ) : &input; | ||
const float *outputPtr = outputBufer ? &( outputBufer->values()[ 0 ] ) : &output; | ||
|
||
for( fpp_t f = 0; f < _frames; ++f ) | ||
{ | ||
float s[2] = { _buf[f][0], _buf[f][1] }; | ||
|
||
// apply input gain | ||
s[0] *= *inputPtr; | ||
s[1] *= *inputPtr; | ||
|
||
// clip if clip enabled | ||
//if( clip ) | ||
PhysSong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
//{ | ||
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 ) | ||
{ | ||
bool invert = false; | ||
if (s[i] < 0) | ||
invert = true; | ||
|
||
if (invert) | ||
s[i] *= -1; | ||
|
||
s[i] = m_wsControls.m_vectorGraphModel.calculateSample(s[i]); | ||
|
||
if (invert) | ||
s[i] *= -1; | ||
} | ||
|
||
// apply output gain | ||
s[0] *= *outputPtr; | ||
s[1] *= *outputPtr; | ||
|
||
out_sum += _buf[f][0]*_buf[f][0] + _buf[f][1]*_buf[f][1]; | ||
// mix wet/dry signals | ||
_buf[f][0] = d * _buf[f][0] + w * s[0]; | ||
_buf[f][1] = d * _buf[f][1] + w * s[1]; | ||
|
||
outputPtr += outputInc; | ||
inputPtr += inputInc; | ||
} | ||
|
||
checkGate( out_sum / _frames ); | ||
|
||
return( isRunning() ); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
extern "C" | ||
{ | ||
|
||
// necessary for getting instance out of shared lib | ||
PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * _parent, void * _data ) | ||
{ | ||
return( new waveShaper2Effect( _parent, | ||
static_cast<const Plugin::Descriptor::SubPluginFeatures::Key *>( | ||
_data ) ) ); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* waveshaper.h - waveshaper effect-plugin | ||
* | ||
* Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi> | ||
* Copyright (c) 2006-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net> | ||
* | ||
* This file is part of LMMS - https://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 _WAVESHAPER_H | ||
#define _WAVESHAPER_H | ||
|
||
#include "Effect.h" | ||
#include "waveshaper2_controls.h" | ||
|
||
|
||
|
||
class waveShaper2Effect : public Effect | ||
{ | ||
public: | ||
waveShaper2Effect( Model * _parent, | ||
const Descriptor::SubPluginFeatures::Key * _key ); | ||
virtual ~waveShaper2Effect(); | ||
virtual bool processAudioBuffer( sampleFrame * _buf, | ||
const fpp_t _frames ); | ||
|
||
virtual EffectControls * controls() | ||
{ | ||
return( &m_wsControls ); | ||
} | ||
|
||
|
||
private: | ||
|
||
waveShaper2Controls m_wsControls; | ||
|
||
friend class waveShaper2Controls; | ||
|
||
} ; | ||
|
||
|
||
|
||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* waveshaper_control_dialog.cpp - control-dialog for waveshaper-effect | ||
* | ||
* Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi> | ||
* Copyright (c) 2006-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net> | ||
* | ||
* This file is part of LMMS - https://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 "waveshaper2_control_dialog.h" | ||
#include "waveshaper2_controls.h" | ||
#include "embed.h" | ||
//#include "Graph.h" | ||
#include "VectorGraph.h" | ||
#include "PixmapButton.h" | ||
#include "ToolTip.h" | ||
#include "LedCheckbox.h" | ||
|
||
|
||
waveShaper2ControlDialog::waveShaper2ControlDialog( | ||
waveShaper2Controls * _controls ) : | ||
EffectControlDialog( _controls ) | ||
{ | ||
setAutoFillBackground( true ); | ||
QPalette pal; | ||
pal.setBrush( backgroundRole(), | ||
PLUGIN_NAME::getIconPixmap( "artwork" ) ); | ||
setPalette( pal ); | ||
setFixedSize( 224, 274 ); | ||
|
||
VectorGraph * graph = new VectorGraph( this, 204, 205 ); | ||
graph->move( 10, 6 ); | ||
graph->setMaximumSize( 204, 205 ); | ||
graph -> setModel( &_controls -> m_vectorGraphModel ); | ||
|
||
|
||
|
||
Knob * inputKnob = new Knob( knobBright_26, this); | ||
inputKnob -> setVolumeKnob( true ); | ||
inputKnob -> setVolumeRatio( 1.0 ); | ||
inputKnob -> move( 26, 225 ); | ||
inputKnob->setModel( &_controls->m_inputModel ); | ||
inputKnob->setLabel( tr( "INPUT" ) ); | ||
inputKnob->setHintText( tr( "Input gain:" ) , "" ); | ||
|
||
Knob * outputKnob = new Knob( knobBright_26, this ); | ||
outputKnob -> setVolumeKnob( true ); | ||
outputKnob -> setVolumeRatio( 1.0 ); | ||
outputKnob -> move( 76, 225 ); | ||
outputKnob->setModel( &_controls->m_outputModel ); | ||
outputKnob->setLabel( tr( "OUTPUT" ) ); | ||
outputKnob->setHintText( tr( "Output gain:" ), "" ); | ||
|
||
LedCheckBox * clipInputToggle = new LedCheckBox( "Clip input", this, | ||
tr( "Clip input" ), LedCheckBox::Green ); | ||
clipInputToggle -> move( 131, 252 ); | ||
clipInputToggle -> setModel( &_controls -> m_clipModel ); | ||
ToolTip::add( clipInputToggle, tr( "Clip input signal to 0dB" ) ); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* waveshaper_control_dialog.h - control-dialog for waveshaper-effect | ||
* | ||
* * Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi> | ||
* Copyright (c) 2006-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net> | ||
* | ||
* This file is part of LMMS - https://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 _WAVESHAPER_CONTROL_DIALOG_H | ||
#define _WAVESHAPER_CONTROL_DIALOG_H | ||
|
||
#include "EffectControlDialog.h" | ||
#include "VectorGraph.h" | ||
|
||
|
||
class waveShaper2Controls; | ||
|
||
|
||
class waveShaper2ControlDialog : public EffectControlDialog | ||
{ | ||
Q_OBJECT | ||
public: | ||
waveShaper2ControlDialog( waveShaper2Controls * _controls ); | ||
virtual ~waveShaper2ControlDialog() | ||
{ | ||
} | ||
|
||
|
||
private: | ||
} ; | ||
|
||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor, but use tabs instead of spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do, I edited that with a different editor. Thanks for catching this.