Files
lmms/plugins/xpressive/expressive_plugin.h
gnudles dff76b2e83 Xpressive plugin (#3259)
* First Preview of the X-Pressive Plugin
(exprtk.hpp is not included, get it from my exprtk fork in the branch
internal_data_functions)
available keys:
f- note's frequency. available only in the output expressions
t- time in seconds. in the Waves (W1,W2,W3) it's in the range [0,1)
key- the note's keyboard key. available only in the output expressions.
v- the note's velocity (divided by 255.0 so it is in the range [0,1]).
available only in the output expressions.
rel- gives 0 while the key is holded, and 1 after the key release.
available only in the output expressions.
A1,A2,A3- general purpose knobs (you can control them with the
automations). available only in the output expressions.
W1,W2,W3- precalculated wave forms. can be also load from file. you can
use them only in the output expressions
available functions:
cent(x)- gives pow(2,x/1200)
rand()- random number generator. in range [-1,1). each call gives other
value.
randv(i)- random vector (with pseudo infinite integer cells). the values
are in range [-1,1). it's stays consistent only across the note
playback. so each note playback will get other vector (even on the same
key).
sinew- sine wave with period of 1.
saww- saw wave with period of 1.
squarew- square wave with period of 1.
trianglew- triangle wave with period of 1.
expw- exponent wave with period of 1.
expnw- another exponent wave with period of 1.
moogw- moog wave with period of 1.
moogsaww- moog-saw wave with period of 1.
you can use * % ^ / + - pow sin log pi etc.

* Xpressive Plug-In:
Added Release transition knob that control the "rel" variable. (the
duration of transit from 0 to 1)
Fixed some problems in the displays. (update display when changing
A1,A2,A3, clear display with invalid expression.

* X-Pressive Plug-In: Few more fixes
Changed the callbacks in exprfront.cpp to be templated.
Added help.
Added ExprTk.hpp.
some bug fixes (inf issues).
Added integrate function.

* Special version of ExprTk with modified license (BSL) for the LMMS project https://github.com/LMMS/lmms

* Xpressive Plug-In- fixed some building errors.
Added the "e" euler's constant.

* Xpressive Plug-In - fix mingw64 issues

* X-Pressive Plug-in:
Added "trel" (time since release) variable.
The integrate function can now have unlimited usage.
Added selective interpolation per wave.
Improved a little the random vector function.
Some other improvements, code cleaning, etc...

* Xpressive Plug-In:
move clearGraph definition into Graph.cpp.
fixed compilation errors. (oops..)

* X-Pressive plug-in: updated presets names

* X-Pressive plug-in
added semitone function, added sample-rate variable

* X-Pressive plug-in, code cleaning, changed the rendering function to
achieve performace gain.

* X-Pressive plug-in - fix the string counting function

* X-Pressive plug-in - until somebody will find a better solution,
exprtk.hpp is patched under the name exprtk.patched.hpp ...

* X-Pressive plug-in - fix compiling errors.

* X-Pressive plug-in - added patch file for exprtk.hpp,
added last function that gives last calculated samples.
moved ExprSynth to be with ExprFront for performance reasons.

* X-Pressive plugin - moved the patched file back to the source tree, added .gitignore file..

* X-Pressive plugin - fix compilation error. (isnan isinf)

* X-Pressive plugin - tried to fix embed.cpp problem,
added new variable to the parser (tempo)

* X-Pressive plugin - fixed cmake script

* X-Pressive plugin - updated the license and the diff file.

* Updates to ExprTk

* Added return statement enable/disable via parser settings

Added exprtk_disable_return_statement macro for disabling return statements and associated exceptions at the source code level.

* X-Pressive plugin - updated CMakeLists.txt to use the correct flags on each platform.
also added exprtk.hpp as a dependency for the patch command.
Updated the exprtk diff file.

* X-Pressive plugin - moved the enhanced features flag to the WIN64 installation.

* X-Pressive plugin - another fix for CMakeLists.txt

* Minor updates to ExprTk

Updated multi-sub expression operator to return final sub-expression type.
Updates to exprtk_disable_return_statement macro for disabling return statements and associated exceptions at the source code level.

* X-Pressive plug-in - added try-block around exprtk calls and enabled the
-fexceptions flag, so patch file is no longer needed.

* X-Pressive plug-in - small fix in CMakeLists.txt

* Update ExprTk to tip of branch.

* X-Pressive plugin - added graph drawing feature..

* Updating exprtk.hpp to the latest upstream version
2017-06-26 19:45:59 +02:00

228 lines
5.6 KiB
C++

/*
* expressive_plugin.h - instrument which uses a mathematical formula
*
* Copyright (c) 2016-2017 Orr Dvori
*
* 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 EXPRESSIVE_PLUGIN_H
#define EXPRESSIVE_PLUGIN_H
#include <QPlainTextEdit>
#include "Graph.h"
#include "Instrument.h"
#include "InstrumentView.h"
#include "Knob.h"
#include "LedCheckbox.h"
#include "PixmapButton.h"
#include "exprsynth.h"
class oscillator;
class expressiveView;
const int W1_EXPR = 0;
const int W2_EXPR = 1;
const int W3_EXPR = 2;
const int O1_EXPR = 3;
const int O2_EXPR = 4;
const int NUM_EXPRS = 5;
class ExprFront;
class SubWindow;
class Expressive : public Instrument
{
Q_OBJECT
public:
Expressive(InstrumentTrack* instrument_track );
virtual ~Expressive();
virtual void playNote(NotePlayHandle* nph,
sampleFrame* working_buffer );
virtual void deleteNotePluginData( NotePlayHandle* nph );
virtual void saveSettings( QDomDocument& _doc,
QDomElement& _this );
virtual void loadSettings( const QDomElement& _this );
virtual QString nodeName() const;
virtual PluginView* instantiateView( QWidget * parent );
graphModel& graphO1() { return m_graphO1; }
graphModel& graphO2() { return m_graphO2; }
graphModel& graphW1() { return m_graphW1; }
graphModel& graphW2() { return m_graphW2; }
graphModel& graphW3() { return m_graphW3; }
graphModel& rawgraphW1() { return m_rawgraphW1; }
graphModel& rawgraphW2() { return m_rawgraphW2; }
graphModel& rawgraphW3() { return m_rawgraphW3; }
IntModel& selectedGraph() { return m_selectedGraph; }
QByteArray& wavesExpression(int i) { return m_wavesExpression[i]; }
QByteArray& outputExpression(int i) { return m_outputExpression[i]; }
FloatModel& parameterA1() { return m_parameterA1; }
FloatModel& parameterA2() { return m_parameterA2; }
FloatModel& parameterA3() { return m_parameterA3; }
FloatModel& smoothW1() { return m_smoothW1; }
FloatModel& smoothW2() { return m_smoothW2; }
FloatModel& smoothW3() { return m_smoothW3; }
BoolModel& interpolateW1() { return m_interpolateW1; }
BoolModel& interpolateW2() { return m_interpolateW2; }
BoolModel& interpolateW3() { return m_interpolateW3; }
FloatModel& panning1() { return m_panning1; }
FloatModel& panning2() { return m_panning2; }
FloatModel& relTransition() { return m_relTransition; }
WaveSample& W1() { return m_W1; }
WaveSample& W2() { return m_W2; }
WaveSample& W3() { return m_W3; }
BoolModel& exprValid() { return m_exprValid; }
static void smooth(float smoothness,const graphModel* in,graphModel* out);
protected:
protected slots:
private:
graphModel m_graphO1;
graphModel m_graphO2;
graphModel m_graphW1;
graphModel m_graphW2;
graphModel m_graphW3;
graphModel m_rawgraphW1;
graphModel m_rawgraphW2;
graphModel m_rawgraphW3;
IntModel m_selectedGraph;
QByteArray m_wavesExpression[3];
QByteArray m_outputExpression[2];
FloatModel m_parameterA1;
FloatModel m_parameterA2;
FloatModel m_parameterA3;
FloatModel m_smoothW1;
FloatModel m_smoothW2;
FloatModel m_smoothW3;
BoolModel m_interpolateW1;
BoolModel m_interpolateW2;
BoolModel m_interpolateW3;
FloatModel m_panning1;
FloatModel m_panning2;
FloatModel m_relTransition;
float m_A1,m_A2,m_A3;
WaveSample m_W1, m_W2, m_W3;
BoolModel m_exprValid;
} ;
class expressiveView : public InstrumentView
{
Q_OBJECT
public:
expressiveView( Instrument* _instrument,
QWidget* _parent );
virtual ~expressiveView();
protected:
protected slots:
void updateLayout();
void sinWaveClicked();
void triangleWaveClicked();
void sqrWaveClicked();
void sawWaveClicked();
void noiseWaveClicked();
void moogSawWaveClicked();
void expWaveClicked();
void usrWaveClicked();
void helpClicked();
void expressionChanged( );
void smoothChanged( );
void graphDrawn( );
private:
virtual void modelChanged();
Knob *m_generalPurposeKnob[3];
Knob *m_panningKnob[2];
Knob *m_relKnob;
Knob *m_smoothKnob;
QPlainTextEdit * m_expressionEditor;
automatableButtonGroup *m_selectedGraphGroup;
PixmapButton *m_w1Btn;
PixmapButton *m_w2Btn;
PixmapButton *m_w3Btn;
PixmapButton *m_o1Btn;
PixmapButton *m_o2Btn;
PixmapButton *m_sinWaveBtn;
PixmapButton *m_triangleWaveBtn;
PixmapButton *m_sqrWaveBtn;
PixmapButton *m_sawWaveBtn;
PixmapButton *m_whiteNoiseWaveBtn;
PixmapButton *m_usrWaveBtn;
PixmapButton *m_moogWaveBtn;
PixmapButton *m_expWaveBtn;
static QPixmap *s_artwork;
Graph *m_graph;
graphModel *m_raw_graph;
LedCheckBox *m_expressionValidToggle;
LedCheckBox *m_waveInterpolate;
bool m_output_expr;
bool m_wave_expr;
} ;
class expressiveHelpView: public QTextEdit
{
Q_OBJECT
public:
static expressiveHelpView* getInstance()
{
if (!s_instance)
{
s_instance = new expressiveHelpView();
}
return s_instance;
}
static void finalize()
{
if (s_instance) { delete s_instance; }
}
private:
expressiveHelpView();
static expressiveHelpView *s_instance;
static QString s_helpText;
};
#endif