Skip to content
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

Xpressive plugin fixes #5979

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions data/presets/Xpressive/Accordion.xpf

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions data/presets/Xpressive/Ambition.xpf

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions data/presets/Xpressive/Baby Violin.xpf

Large diffs are not rendered by default.

22 changes: 0 additions & 22 deletions data/presets/Xpressive/Bad Singer.xpf

This file was deleted.

2 changes: 1 addition & 1 deletion data/presets/Xpressive/Creature.xpf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</xpressive>
</instrument>
<eldata ftype="0" fres="0.5" fwet="0" fcut="14000">
<elvol lspd_numerator="4" lshp="4" att="0.03" ctlenvamt="0" dec="0.803409" amt="1" lspd_denominator="4" x100="0" hold="0.203666" pdel="0" lspd="0.139294" userwavefile="/home/orr/workspace/lmms/data/samples/waveforms/10tri.flac" sustain="0.212332" latt="0.0333333" lspd_syncmode="0" rel="0.600836" lpdel="0" lamt="0"/>
<elvol lspd_numerator="4" lshp="4" att="0.03" ctlenvamt="0" dec="0.803409" amt="1" lspd_denominator="4" x100="0" hold="0.203666" pdel="0" lspd="0.139294" sustain="0.212332" latt="0.0333333" lspd_syncmode="0" rel="0.600836" lpdel="0" lamt="0"/>
<elcut lspd_numerator="4" lshp="0" att="0" ctlenvamt="0" dec="0.5" amt="0" lspd_denominator="4" x100="0" hold="0.5" pdel="0" lspd="0.1" userwavefile="" sustain="0.5" latt="0" lspd_syncmode="0" rel="0.1" lpdel="0" lamt="0"/>
<elres lspd_numerator="4" lshp="0" att="0" ctlenvamt="0" dec="0.5" amt="0" lspd_denominator="4" x100="0" hold="0.5" pdel="0" lspd="0.1" userwavefile="" sustain="0.5" latt="0" lspd_syncmode="0" rel="0.1" lpdel="0" lamt="0"/>
</eldata>
Expand Down
14 changes: 7 additions & 7 deletions data/presets/Xpressive/Electric Shock.xpf

Large diffs are not rendered by default.

22 changes: 0 additions & 22 deletions data/presets/Xpressive/Faded Colors - notes test.xpf

This file was deleted.

18 changes: 9 additions & 9 deletions data/presets/Xpressive/Faded Colors.xpf

Large diffs are not rendered by default.

22 changes: 0 additions & 22 deletions data/presets/Xpressive/Fat Flute.xpf

This file was deleted.

19 changes: 10 additions & 9 deletions data/presets/Xpressive/Frog.xpf

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions data/presets/Xpressive/Horn.xpf

Large diffs are not rendered by default.

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions data/presets/Xpressive/Piano-Gong.xpf

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/presets/Xpressive/Rubber Bass.xpf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</xpressive>
</instrument>
<eldata ftype="0" fres="0.5" fwet="0" fcut="14000">
<elvol lspd_numerator="4" lshp="4" att="0.01" ctlenvamt="0" dec="0.623993" amt="1" lspd_denominator="4" x100="0" hold="0.203666" pdel="0" lspd="0.139294" userwavefile="/home/orr/workspace/lmms/data/samples/waveforms/10tri.flac" sustain="0.186999" latt="0.0333333" lspd_syncmode="0" rel="0.332169" lpdel="0" lamt="0"/>
<elvol lspd_numerator="4" lshp="4" att="0.01" ctlenvamt="0" dec="0.623993" amt="1" lspd_denominator="4" x100="0" hold="0.203666" pdel="0" lspd="0.139294" sustain="0.186999" latt="0.0333333" lspd_syncmode="0" rel="0.332169" lpdel="0" lamt="0"/>
<elcut lspd_numerator="4" lshp="0" att="0" ctlenvamt="0" dec="0.5" amt="0" lspd_denominator="4" x100="0" hold="0.5" pdel="0" lspd="0.1" userwavefile="" sustain="0.5" latt="0" lspd_syncmode="0" rel="0.1" lpdel="0" lamt="0"/>
<elres lspd_numerator="4" lshp="0" att="0" ctlenvamt="0" dec="0.5" amt="0" lspd_denominator="4" x100="0" hold="0.5" pdel="0" lspd="0.1" userwavefile="" sustain="0.5" latt="0" lspd_syncmode="0" rel="0.1" lpdel="0" lamt="0"/>
</eldata>
Expand Down
14 changes: 7 additions & 7 deletions data/presets/Xpressive/Space Echoes.xpf

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions data/presets/Xpressive/Speaker Swapper.xpf

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions data/presets/Xpressive/Toss.xpf

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions data/presets/Xpressive/Untuned Bell.xpf

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions data/presets/Xpressive/Vibrato.xpf

Large diffs are not rendered by default.

22 changes: 0 additions & 22 deletions data/presets/Xpressive/X-Distorted.xpf

This file was deleted.

2 changes: 2 additions & 0 deletions plugins/Xpressive/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ BUILD_PLUGIN(xpressive
Xpressive.cpp
ExprSynth.cpp
Xpressive.h
XpressiveView.h
exprtk/exprtk.hpp
MOCFILES Xpressive.h
MOCFILES XpressiveView.h
EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png"
)

Expand Down
68 changes: 62 additions & 6 deletions plugins/Xpressive/ExprSynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,20 @@ struct LastSampleFunction : public exprtk::ifunction<T>
if (!std::isnan(x) && !std::isinf(x))
{
const int ix=(int)x;
if (ix>=1 && ix<=m_history_size)
const float xfrc = fraction(x);
if (xfrc == 0)
{
return m_samples[(ix + m_pivot_last) % m_history_size];
if (ix>=1 && ix<=m_history_size)
{
return m_samples[(ix + m_pivot_last) % m_history_size];
}
}
else
{
if (ix>=1 && ix<m_history_size)
{
return linearInterpolate(m_samples[(ix + m_pivot_last) % m_history_size], m_samples[(ix + 1 + m_pivot_last) % m_history_size], xfrc);
}
}
}
return 0;
Expand All @@ -162,6 +173,10 @@ struct LastSampleFunction : public exprtk::ifunction<T>
{
m_samples[m_pivot_last] = sample;
}
else
{
m_samples[m_pivot_last] = 0;
}
if (m_pivot_last == 0)
{
m_pivot_last = m_history_size - 1;
Expand Down Expand Up @@ -194,6 +209,26 @@ struct WaveValueFunction : public exprtk::ifunction<T>
const std::size_t m_size;
};
template <typename T>
struct EnvelopeFunction : public exprtk::ifunction<T>
{
using exprtk::ifunction<T>::operator();

EnvelopeFunction(const T* v, std::size_t s)
: exprtk::ifunction<T>(1),
m_vec(v),
m_size(s)
{}

inline T operator()(const T& index)
{
if (index< 1 && index>=0)
return m_vec[(int) ( index * m_size )];
return 0;
}
const T *m_vec;
const std::size_t m_size;
};
template <typename T>
struct WaveValueFunctionInterpolate : public exprtk::ifunction<T>
{
using exprtk::ifunction<T>::operator();
Expand Down Expand Up @@ -385,6 +420,10 @@ class ExprFrontData
{
delete cyclic;
}
for (int i = 0; i < m_envelopes.size() ; ++i)
{
delete m_envelopes[i];
}
if (m_integ_func)
{
delete m_integ_func;
Expand All @@ -396,6 +435,7 @@ class ExprFrontData
std::string m_expression_string;
std::vector<WaveValueFunction<float>* > m_cyclics;
std::vector<WaveValueFunctionInterpolate<float>* > m_cyclics_interp;
std::vector<EnvelopeFunction<float>* > m_envelopes;
RandomVectorFunction m_rand_vec;
IntegrateFunction<float> *m_integ_func;
LastSampleFunction<float> m_last_func;
Expand Down Expand Up @@ -530,8 +570,7 @@ ExprFront::ExprFront(const char * expr, int last_func_samples)
m_data->m_expression_string = expr;
m_data->m_symbol_table.add_pi();

m_data->m_symbol_table.add_constant("e", F_E);

//m_data->m_symbol_table.add_constant("e", F_E); // use exp function instead...
m_data->m_symbol_table.add_constant("seed", SimpleRandom::generator() & max_float_integer_mask);

m_data->m_symbol_table.add_function("sinew", sin_wave_func);
Expand Down Expand Up @@ -574,7 +613,7 @@ bool ExprFront::compile()
m_data->m_expression.register_symbol_table(m_data->m_symbol_table);
parser_t::settings_store sstore;
sstore.disable_all_logic_ops();
sstore.disable_all_assignment_ops();
//sstore.disable_all_assignment_ops();
sstore.disable_all_control_structures();
parser_t parser(sstore);

Expand Down Expand Up @@ -651,6 +690,20 @@ bool ExprFront::add_cyclic_vector(const char* name, const float* data, size_t le
}
return false;
}
bool ExprFront::add_envelope(const char* name, const float* data, size_t length)
{
try
{
EnvelopeFunction<float> *wvf = new EnvelopeFunction<float>(data, length);
m_data->m_envelopes.push_back(wvf);
return m_data->m_symbol_table.add_function(name, *wvf);
}
catch(...)
{
WARN_EXPRTK;
}
return false;
}
size_t find_occurances(const std::string& haystack, const char* const needle)
{
size_t last_pos = 0;
Expand Down Expand Up @@ -717,6 +770,9 @@ ExprSynth::ExprSynth(const WaveSample *gW1, const WaveSample *gW2, const WaveSam
e->add_cyclic_vector("W1", m_W1->m_samples,m_W1->m_length, m_W1->m_interpolate);
e->add_cyclic_vector("W2", m_W2->m_samples,m_W2->m_length, m_W2->m_interpolate);
e->add_cyclic_vector("W3", m_W3->m_samples,m_W3->m_length, m_W3->m_interpolate);
e->add_envelope("N1", m_W1->m_samples,m_W1->m_length);
e->add_envelope("N2", m_W2->m_samples,m_W2->m_length);
e->add_envelope("N3", m_W3->m_samples,m_W3->m_length);
e->add_variable("t", m_note_sample_sec);
e->add_variable("f", m_frequency);
e->add_variable("rel",m_released);
Expand Down Expand Up @@ -826,4 +882,4 @@ void ExprSynth::renderOutput(fpp_t frames, sampleFrame *buf)
}


} // namespace lmms
} // namespace lmms
1 change: 1 addition & 0 deletions plugins/Xpressive/ExprSynth.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class ExprFront
bool add_variable(const char* name, float & ref);
bool add_constant(const char* name, float ref);
bool add_cyclic_vector(const char* name, const float* data, size_t length, bool interp = false);
bool add_envelope(const char* name, const float* data, size_t length);
void setIntegrate(const unsigned int* frameCounter, unsigned int sample_rate);
ExprFrontData* getData() { return m_data; }
private:
Expand Down
Loading