Skip to content

Commit

Permalink
Automized formatting changes only
Browse files Browse the repository at this point in the history
No functional changes at all!
  • Loading branch information
JohannesLorenz committed Nov 1, 2018
1 parent da9fcfc commit bdde4e3
Show file tree
Hide file tree
Showing 5 changed files with 347 additions and 345 deletions.
25 changes: 14 additions & 11 deletions include/SpaOscModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@

#include "AutomatableModel.h"

template<class Base>
class SpaOscModel : public Base
template <class Base> class SpaOscModel : public Base
{
protected:
class SpaInstrument* inst_ref;
class SpaInstrument *inst_ref;
QByteArray dest;

using Base::Base;
void init(class SpaInstrument* _inst_ref, const QString _dest) {
void init(class SpaInstrument *_inst_ref, const QString _dest)
{
inst_ref = _inst_ref;
dest = _dest.toUtf8();
}
Expand All @@ -46,35 +46,38 @@ class BoolOscModel : public SpaOscModel<BoolModel>
Q_OBJECT
private slots:
void sendOsc();

public:
BoolOscModel(class SpaInstrument* inst_ref, const QString dest,
bool val);
BoolOscModel(
class SpaInstrument *inst_ref, const QString dest, bool val);
};

class IntOscModel : public SpaOscModel<IntModel>
{
Q_OBJECT
private slots:
void sendOsc();

public:
IntOscModel(class SpaInstrument* inst_ref, const QString dest,
int min, int max, int val);
IntOscModel(class SpaInstrument *inst_ref, const QString dest, int min,
int max, int val);
};

class FloatOscModel : public SpaOscModel<FloatModel>
{
Q_OBJECT
private slots:
void sendOsc();

public:
FloatOscModel(class SpaInstrument* inst_ref, const QString dest,
FloatOscModel(class SpaInstrument *inst_ref, const QString dest,
float min, float max, float val);
};

struct SpaOscModelFactory
{
AutomatableModel* res;
SpaOscModelFactory(class SpaInstrument* inst_ref, const QString &dest);
AutomatableModel *res;
SpaOscModelFactory(class SpaInstrument *inst_ref, const QString &dest);
};

#endif // SPAOSCMODEL_H
2 changes: 1 addition & 1 deletion src/core/PluginFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void PluginFactory::discoverPlugins()

const char** xpm = descriptor->xpm_load();
assert(xpm);
QString xpmKey= "spa-plugin:" +
QString xpmKey = "spa-plugin:" +
QString::fromStdString(unique_name);

// spa (simple plugin API) plugin
Expand Down
80 changes: 46 additions & 34 deletions src/core/SpaOscModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,76 +22,88 @@
*
*/

#include "SpaOscModel.h"

#include <QDebug>
#include <spa/audio.h>
#include "SpaOscModel.h"

#include "spa/SpaInstrument.h"

struct SpaOscModelFactoryVisitor : public spa::audio::visitor
{
class SpaInstrument* inst_ref;
const QString* dest;
AutomatableModel* res = nullptr;
class SpaInstrument *inst_ref;
const QString *dest;
AutomatableModel *res = nullptr;

template<class ModelType, class T>
void make(T min, T max, T val) {
template <class ModelType, class T> void make(T min, T max, T val)
{
res = new ModelType(inst_ref, *dest, min, max, val);
}

template<class T> using c_in = spa::audio::control_in<T>;
virtual void visit(c_in<float>& in) {
make<FloatOscModel>(in.min, in.max, in.def); }
virtual void visit(c_in<double>& in) {
make<FloatOscModel>(in.min, in.max, in.def); }
virtual void visit(c_in<int>& in) {
make<IntOscModel>(in.min, in.max, in.def); }
virtual void visit(c_in<bool>& in) {
res = new BoolOscModel(inst_ref, *dest, in.def); }
template <class T> using c_in = spa::audio::control_in<T>;
virtual void visit(c_in<float> &in)
{
make<FloatOscModel>(in.min, in.max, in.def);
}
virtual void visit(c_in<double> &in)
{
make<FloatOscModel>(in.min, in.max, in.def);
}
virtual void visit(c_in<int> &in)
{
make<IntOscModel>(in.min, in.max, in.def);
}
virtual void visit(c_in<bool> &in)
{
res = new BoolOscModel(inst_ref, *dest, in.def);
}
};

SpaOscModelFactory::SpaOscModelFactory(SpaInstrument *inst_ref,
const QString& dest)
SpaOscModelFactory::SpaOscModelFactory(
SpaInstrument *inst_ref, const QString &dest)
{
SpaOscModelFactoryVisitor vis;
vis.inst_ref = inst_ref;
vis.dest = &dest;
spa::port_ref_base& base = inst_ref->plugin->port(dest.toUtf8().data());
spa::port_ref_base &base = inst_ref->plugin->port(dest.toUtf8().data());
base.accept(vis);
res = vis.res;
}

void BoolOscModel::sendOsc() { inst_ref->writeOsc(dest.data(),
value() ? "T" : "F"); }
void BoolOscModel::sendOsc()
{
inst_ref->writeOsc(dest.data(), value() ? "T" : "F");
}
void IntOscModel::sendOsc() { inst_ref->writeOsc(dest.data(), "i", value()); }
void FloatOscModel::sendOsc() { inst_ref->writeOsc(dest.data(), "f", value()); }

BoolOscModel::BoolOscModel(SpaInstrument *inst_ref, const QString dest,
bool val)
: SpaOscModel<BoolModel>(val, nullptr, dest, false)
BoolOscModel::BoolOscModel(
SpaInstrument *inst_ref, const QString dest, bool val) :
SpaOscModel<BoolModel>(val, nullptr, dest, false)
{
qDebug() << "LMMS: receiving bool model: val = " << val;
init(inst_ref, dest);
QObject::connect(this, SIGNAL(dataChanged()), this, SLOT(sendOsc()));
}

IntOscModel::IntOscModel(SpaInstrument *inst_ref, const QString dest,
int min, int max, int val)
: SpaOscModel<IntModel>(val, min, max, nullptr, dest, false)
IntOscModel::IntOscModel(SpaInstrument *inst_ref, const QString dest, int min,
int max, int val) :
SpaOscModel<IntModel>(val, min, max, nullptr, dest, false)
{
qDebug() << "LMMS: receiving int model: (val, min, max) = ("
<< val << ", " << min << ", " << max << ")";
qDebug() << "LMMS: receiving int model: (val, min, max) = (" << val
<< ", " << min << ", " << max << ")";
init(inst_ref, dest);
QObject::connect(this, SIGNAL(dataChanged()), this, SLOT(sendOsc()));
}

FloatOscModel::FloatOscModel(SpaInstrument *inst_ref, const QString dest,
float min, float max, float val)
: SpaOscModel<FloatModel>(val, min, max, 0.1f, nullptr, dest, false)
/* TODO: get step from plugin (we currently need a plugin where this
can be tested) */
float min, float max, float val) :
SpaOscModel<FloatModel>(val, min, max, 0.1f, nullptr, dest, false)
/* TODO: get step from plugin (we currently need a plugin where this
can be tested) */
{
qDebug() << "LMMS: receiving float model: (val, min, max) = ("
<< val << ", " << min << ", " << max << ")";
qDebug() << "LMMS: receiving float model: (val, min, max) = (" << val
<< ", " << min << ", " << max << ")";
init(inst_ref, dest);
QObject::connect(this, SIGNAL(dataChanged()), this, SLOT(sendOsc()));
}
Loading

0 comments on commit bdde4e3

Please sign in to comment.