commit 6a1b57fc8af7d5f20275730ed1677b0611f0c22a
parent 24777fd9d0c94e823020c9ec62a537f04ff406f3
Author: Johannes Lorenz <[email protected]>
Date: Fri, 10 Jul 2015 19:56:56 +0200
MiddleWare now takes SYNTH_T by value. Fixed compile errors.
Diffstat:
8 files changed, 53 insertions(+), 29 deletions(-)
diff --git a/TODO.txt b/TODO.txt
@@ -11,7 +11,7 @@ in order to avoid denormalisation*/
(8) src/Params/PresetsStore.h:extern PresetsStore presetsstore;
Status:
-(1)
+(1) will be fixed by fundamental
(2) will be fixed with fftw3 (?), until then maybe use separate mutex?
(3) will be fixed by fundamental
(4)
diff --git a/src/Misc/Config.h b/src/Misc/Config.h
@@ -32,9 +32,10 @@ namespace rtosc
struct Ports;
}
-struct oss_devs_t
+class oss_devs_t
{
- char *linux_wave_out, *linux_seq_in;
+ public:
+ char *linux_wave_out, *linux_seq_in;
};
/**Configuration file functions*/
diff --git a/src/Misc/MiddleWare.cpp b/src/Misc/MiddleWare.cpp
@@ -554,7 +554,7 @@ class MiddleWareImpl
Config* const config;
public:
- MiddleWareImpl(MiddleWare *mw, const SYNTH_T &synth, Config* config,
+ MiddleWareImpl(MiddleWare *mw, SYNTH_T synth, Config* config,
int preferred_port);
~MiddleWareImpl(void);
@@ -857,14 +857,14 @@ public:
string last_url, curr_url;
//Synthesis Rate Parameters
- const SYNTH_T& synth;
+ const SYNTH_T synth;
PresetsStore presetsstore;
};
-MiddleWareImpl::MiddleWareImpl(MiddleWare *mw, const SYNTH_T& synth_,
+MiddleWareImpl::MiddleWareImpl(MiddleWare *mw, SYNTH_T synth_,
Config* config, int preferrred_port)
- :parent(mw), config(config), ui(nullptr), synth(synth_),
+ :parent(mw), config(config), ui(nullptr), synth(std::move(synth_)),
presetsstore(*config)
{
bToU = new rtosc::ThreadLink(4096*2,1024);
@@ -1299,9 +1299,9 @@ void MiddleWareImpl::warnMemoryLeaks(void)
/******************************************************************************
* MidleWare Forwarding Stubs *
******************************************************************************/
-MiddleWare::MiddleWare(const SYNTH_T &synth, Config* config,
+MiddleWare::MiddleWare(SYNTH_T synth, Config* config,
int preferred_port)
-:impl(new MiddleWareImpl(this, synth, config, preferred_port))
+:impl(new MiddleWareImpl(this, std::move(synth), config, preferred_port))
{}
MiddleWare::~MiddleWare(void)
{
diff --git a/src/Misc/MiddleWare.h b/src/Misc/MiddleWare.h
@@ -11,7 +11,7 @@ class PresetsStore;
class MiddleWare
{
public:
- MiddleWare(const SYNTH_T& synth, class Config *config,
+ MiddleWare(SYNTH_T synth, class Config *config,
int preferred_port = -1);
~MiddleWare(void);
void updateResources(Master *m);
diff --git a/src/UI/EffUI.fl b/src/UI/EffUI.fl
@@ -39,7 +39,13 @@ decl {\#include "../Misc/Util.h"} {public local
}
decl {\#include "../Effects/EffectMgr.h"} {public local
-}
+}
+
+decl {\#include "../Effects/Phaser.h" /* for macros only, TODO */} {public local
+}
+
+decl {\#include "../Effects/Alienwah.h" /* for macros only, TODO */ } {public local
+}
decl {\#include "PresetsUI.h"} {public local
}
diff --git a/src/globals.cpp b/src/globals.cpp
@@ -34,8 +34,7 @@ void SYNTH_T::alias()
//produce denormal buf
// note: once there will be more buffers, use a cleanup function
// for deleting the buffers and also call it in the dtor
- delete[] denormalkillbuf;
- denormalkillbuf = new float [buffersize];
+ denormalkillbuf.resize(buffersize);
for(int i = 0; i < buffersize; ++i)
denormalkillbuf[i] = (RND - 0.5f) * 1e-16;
}
diff --git a/src/globals.h b/src/globals.h
@@ -252,6 +252,28 @@ enum LegatoMsg {
#define O_BINARY 0
#endif
+template<class T>
+class m_unique_ptr
+{
+ T* ptr = nullptr;
+public:
+ m_unique_ptr() = default;
+ m_unique_ptr(m_unique_ptr&& other) {
+ ptr = other.ptr;
+ other.ptr = nullptr;
+ }
+ m_unique_ptr(const m_unique_ptr& other) = delete;
+ ~m_unique_ptr() { ptr = nullptr; }
+ void resize(unsigned sz) {
+ delete[] ptr;
+ ptr = new T[sz]; }
+
+ operator T*() { return ptr; }
+ operator const T*() const { return ptr; }
+ T& operator[](unsigned idx) { return ptr[idx]; }
+ const T& operator[](unsigned idx) const { return ptr[idx]; }
+};
+
//temporary include for synth->{samplerate/buffersize} members
struct SYNTH_T {
@@ -261,15 +283,11 @@ struct SYNTH_T {
alias();
}
- ~SYNTH_T()
- {
- delete [] denormalkillbuf;
- }
-
SYNTH_T(const SYNTH_T& ) = delete;
+ SYNTH_T(SYNTH_T&& ) = default;
/** the buffer to add noise in order to avoid denormalisation */
- float *denormalkillbuf = nullptr;
+ m_unique_ptr<float> denormalkillbuf;
/**Sampling rate*/
unsigned int samplerate;
diff --git a/src/main.cpp b/src/main.cpp
@@ -91,9 +91,9 @@ void sigterm_exit(int /*sig*/)
/*
* Program initialisation
*/
-void initprogram(const SYNTH_T& synth, Config* config, int prefered_port)
+void initprogram(SYNTH_T synth, Config* config, int prefered_port)
{
- middleware = new MiddleWare(synth, config, prefered_port);
+ middleware = new MiddleWare(std::move(synth), config, prefered_port);
master = middleware->spawnMaster();
master->swaplr = swaplr;
@@ -375,7 +375,14 @@ int main(int argc, char *argv[])
return 0;
}
- initprogram(synth, &config, prefered_port);
+ cerr.precision(1);
+ cerr << std::fixed;
+ cerr << "\nSample Rate = \t\t" << synth.samplerate << endl;
+ cerr << "Sound Buffer Size = \t" << synth.buffersize << " samples" << endl;
+ cerr << "Internal latency = \t" << synth.dt() * 1000.0f << " ms" << endl;
+ cerr << "ADsynth Oscil.Size = \t" << synth.oscilsize << " samples" << endl;
+
+ initprogram(std::move(synth), &config, prefered_port);
if(!loadfile.empty()) {
int tmp = master->loadXML(loadfile.c_str());
@@ -409,13 +416,6 @@ int main(int argc, char *argv[])
//Run the Nio system
bool ioGood = Nio::start();
- cerr.precision(1);
- cerr << std::fixed;
- cerr << "\nSample Rate = \t\t" << synth.samplerate << endl;
- cerr << "Sound Buffer Size = \t" << synth.buffersize << " samples" << endl;
- cerr << "Internal latency = \t" << synth.dt() * 1000.0f << " ms" << endl;
- cerr << "ADsynth Oscil.Size = \t" << synth.oscilsize << " samples" << endl;
-
if(!execAfterInit.empty()) {
cout << "Executing user supplied command: " << execAfterInit << endl;
if(system(execAfterInit.c_str()) == -1)