Skip to content

Commit

Permalink
reorder synthesizer; enable zita1 by default; more cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Apr 3, 2013
1 parent a8a9241 commit b83a8ac
Show file tree
Hide file tree
Showing 10 changed files with 464 additions and 39 deletions.
436 changes: 426 additions & 10 deletions aeolus/aeolus/aeolus_gui.ui

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions effects/effectgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
// EffectGui
//---------------------------------------------------------

EffectGui::EffectGui()
EffectGui::EffectGui(Effect* e)
: QDeclarativeView(0)
{
_effect = e;
setResizeMode(QDeclarativeView::SizeViewToRootObject);
setFocusPolicy(Qt::StrongFocus);
}
Expand All @@ -29,10 +30,9 @@ EffectGui::EffectGui()
// init
//---------------------------------------------------------

void EffectGui::init(QUrl& url, double sr)
void EffectGui::init(QUrl& url)
{
if (_effect) {
_effect->init(sr);
rootContext()->setContextProperty("myEffect", _effect);
setSource(url);

Expand Down
5 changes: 2 additions & 3 deletions effects/effectgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ class EffectGui : public QDeclarativeView {
void valueChanged(const QString& name, qreal);

public:
EffectGui();
void init(QUrl& url, double sr);
EffectGui(Effect*);
void init(QUrl& url);
Effect* effect() const { return _effect; }
void setEffect(Effect* e) { _effect = e; }
virtual void updateValues();
};

Expand Down
5 changes: 2 additions & 3 deletions effects/freeverb/freeverbgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@

EffectGui* Freeverb::gui()
{
EffectGui* eg = new EffectGui;
eg->setEffect(this);
EffectGui* eg = new EffectGui(this);
QUrl url("qrc:/freeverb/freeverb.qml");
eg->init(url, 44100.0);
eg->init(url);
return eg;
}

5 changes: 2 additions & 3 deletions effects/noeffect/noeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ static const std::vector<ParDescr> noeffectPd;

EffectGui* NoEffect::gui()
{
EffectGui* eg = new EffectGui;
eg->setEffect(this);
EffectGui* eg = new EffectGui(this);
QUrl url("qrc:/noeffect/noeffect.qml");
eg->init(url, 44100.0);
eg->init(url);
return eg;
}

Expand Down
5 changes: 2 additions & 3 deletions effects/zita1/zitagui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ EffectGui* ZitaReverb::gui()
{
if (_gui)
return _gui;
_gui = new EffectGui;
_gui = new EffectGui(this);
_gui->setGeometry(0, 0, 644, 79);
_gui->setEffect(this);
QUrl url("qrc:/zita1/zita.qml");
_gui->init(url, 44100);
_gui->init(url);
return _gui;
}
14 changes: 7 additions & 7 deletions mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2158,6 +2158,12 @@ MasterSynthesizer* synthesizerFactory()
ms->setMasterTuning(preferences.tuning);
ms->setGain(preferences.masterGain);

#ifdef ZERBERUS
ms->registerSynthesizer(new Zerberus());
#endif
#ifdef AEOLUS
ms->registerSynthesizer(new Aeolus());
#endif
FluidS::Fluid* fluid = new FluidS::Fluid();
ms->registerSynthesizer(fluid);
printf("sound font <%s>\n", qPrintable(preferences.defaultSf));
Expand All @@ -2167,19 +2173,13 @@ printf("sound font <%s>\n", qPrintable(preferences.defaultSf));
fluid->loadSoundFonts(sfl);
fluid->gui()->synthesizerChanged();
}
#ifdef AEOLUS
ms->registerSynthesizer(new Aeolus());
#endif
#ifdef ZERBERUS
ms->registerSynthesizer(new Zerberus());
#endif
ms->registerEffect(0, new NoEffect);
ms->registerEffect(0, new ZitaReverb);
ms->registerEffect(0, new Freeverb);
ms->registerEffect(1, new NoEffect);
ms->registerEffect(1, new ZitaReverb);
ms->registerEffect(1, new Freeverb);
ms->setEffect(0, 0);
ms->setEffect(0, 1);
ms->setEffect(1, 0);
#if 0
Synthesizer* fluid = ms->synthesizer("Fluid");
Expand Down
2 changes: 2 additions & 0 deletions mscore/synthcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ SynthControl::SynthControl(QWidget* parent)
settings.endGroup();
}

updateSyntiValues();

tabWidget->setCurrentIndex(0);

connect(effectA, SIGNAL(currentIndexChanged(int)), SLOT(effectAChanged(int)));
Expand Down
19 changes: 15 additions & 4 deletions synthesizer/msynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ MasterSynthesizer::MasterSynthesizer()
: QObject(0)
{
lock1 = false;
lock2 = false;
lock2 = true;
_synthesizer.reserve(4);
_gain = 1.0;
for (int i = 0; i < MAX_EFFECTS; ++i)
Expand Down Expand Up @@ -169,6 +169,7 @@ void MasterSynthesizer::registerEffect(int ab, Effect* e)

void MasterSynthesizer::setEffect(int ab, int idx)
{
printf("MasterSynthesizer::setEffect: %d %d\n", ab, idx);
if (idx < 0 || idx >= int(_effectList[ab].size())) {
qDebug("MasterSynthesizer::setEffect: bad idx %d %d", ab, idx);
return;
Expand All @@ -193,13 +194,20 @@ Effect* MasterSynthesizer::effect(int idx)
// setSampleRate
//---------------------------------------------------------

void MasterSynthesizer::setSampleRate(int val)
void MasterSynthesizer::setSampleRate(float val)
{
_sampleRate = val;
for (Synthesizer* s : _synthesizer) {
s->init(_sampleRate);
connect(s->gui(), SIGNAL(sfChanged()), SLOT(sfChanged()));
}
for (Effect* e : _effectList[0])
e->init(_sampleRate);
for (Effect* e : _effectList[1])
e->init(_sampleRate);
lock2 = false;
lock1 = false;
printf("start master synthesizer\n");
}

//---------------------------------------------------------
Expand All @@ -211,16 +219,19 @@ void MasterSynthesizer::process(unsigned n, float* p)
// memset(effect1Buffer, 0, n * sizeof(float) * 2);
// memset(effect2Buffer, 0, n * sizeof(float) * 2);

if (lock2)
if (lock2) {
printf("lock2\n");
return;
}
lock1 = true;
if (lock2) {
lock1 = false;
return;
}
for (Synthesizer* s : _synthesizer) {
if (s->active())
if (s->active()) {
s->process(n, p, effect1Buffer, effect2Buffer);
}
}
if (_effect[0] && _effect[1]) {
memset(effect1Buffer, 0, n * sizeof(float) * 2);
Expand Down
6 changes: 3 additions & 3 deletions synthesizer/msynthesizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MasterSynthesizer : public QObject {
std::vector<Effect*> _effectList[2];
Effect* _effect[2];

int _sampleRate;
float _sampleRate;

float effect1Buffer[MAX_BUFFERSIZE];
float effect2Buffer[MAX_BUFFERSIZE];
Expand All @@ -64,8 +64,8 @@ class MasterSynthesizer : public QObject {
~MasterSynthesizer();
void registerSynthesizer(Synthesizer*);

int sampleRate() { return _sampleRate; }
void setSampleRate(int val);
float sampleRate() { return _sampleRate; }
void setSampleRate(float val);

void process(unsigned, float*);
void play(const Event&, unsigned);
Expand Down

0 comments on commit b83a8ac

Please sign in to comment.