commit a955ea14ba8ce28d730e7f6f4c5bfdc51292c8fb parent 953cfb1efa3eca90934e13562ae9f5d30aeb04f2 Author: Johannes Lorenz <[email protected]> Date: Mon, 10 Apr 2017 21:46:46 +0200 Add zyn namespace to core and plugins, but not FLTK, ntk and tests. Diffstat:
173 files changed, 758 insertions(+), 135 deletions(-)
diff --git a/src/Containers/MultiPseudoStack.cpp b/src/Containers/MultiPseudoStack.cpp @@ -15,6 +15,9 @@ #define INVALID ((int32_t)0xffffffff) #define MAX ((int32_t)0x7fffffff) + +namespace zyn { + QueueListItem::QueueListItem(void) :memory(0), size(0) { @@ -114,3 +117,5 @@ MultiQueue::~MultiQueue(void) delete [] pool[i].memory; delete [] pool; } + +} diff --git a/src/Containers/MultiPseudoStack.h b/src/Containers/MultiPseudoStack.h @@ -13,6 +13,8 @@ #include <atomic> #include <cassert> +namespace zyn { + //XXX rename this thing typedef struct QueueListItem qli_t; struct QueueListItem @@ -60,3 +62,5 @@ class MultiQueue void write(qli_t *q) { m_msgs.write(q); } qli_t *read(void) { return m_msgs.read(); } }; + +} diff --git a/src/Containers/NotePool.cpp b/src/Containers/NotePool.cpp @@ -19,6 +19,8 @@ #define SUSTAIN_BIT 0x04 #define NOTE_MASK 0x03 +namespace zyn { + enum NoteStatus { KEY_OFF = 0x00, KEY_PLAYING = 0x01, @@ -430,3 +432,5 @@ void NotePool::dump(void) } printf(">NotePool::dump\n"); } + +} diff --git a/src/Containers/NotePool.h b/src/Containers/NotePool.h @@ -17,6 +17,8 @@ //Expected upper bound of synths given that max polyphony is hit #define EXPECTED_USAGE 3 +namespace zyn { + struct LegatoParams; class NotePool { @@ -145,3 +147,5 @@ class NotePool void dump(void); }; + +} diff --git a/src/Containers/ScratchString.cpp b/src/Containers/ScratchString.cpp @@ -2,6 +2,8 @@ #include <cstring> #include <cstdio> +namespace zyn { + ScratchString::ScratchString(void) { memset(c_str, 0, sizeof(c_str)); @@ -37,3 +39,5 @@ ScratchString ScratchString::operator+(const ScratchString s) //{ // return c_str; //} + +} diff --git a/src/Containers/ScratchString.h b/src/Containers/ScratchString.h @@ -1,6 +1,8 @@ #pragma once #define SCRATCH_SIZE 128 +namespace zyn { + //Fixed Size String Substitute struct ScratchString { @@ -15,3 +17,6 @@ struct ScratchString char c_str[SCRATCH_SIZE]; }; + +} + diff --git a/src/DSP/AnalogFilter.cpp b/src/DSP/AnalogFilter.cpp @@ -20,6 +20,8 @@ #include "../Misc/Util.h" #include "AnalogFilter.h" +namespace zyn { + AnalogFilter::AnalogFilter(unsigned char Ftype, float Ffreq, float Fq, @@ -423,3 +425,5 @@ float AnalogFilter::H(float freq) h = h / (x * x + y * y); return powf(h, (stages + 1.0f) / 2.0f); } + +} diff --git a/src/DSP/AnalogFilter.h b/src/DSP/AnalogFilter.h @@ -19,6 +19,8 @@ #include "../globals.h" #include "Filter.h" +namespace zyn { + /**Implementation of Several analog filters (lowpass, highpass...) * Implemented with IIR filters * Coefficients generated with "Cookbook formulae for audio EQ"*/ @@ -77,5 +79,6 @@ class AnalogFilter:public Filter //(used to see if it needs interpolation) }; +} #endif diff --git a/src/DSP/FFTwrapper.cpp b/src/DSP/FFTwrapper.cpp @@ -17,6 +17,8 @@ #include <pthread.h> #include "FFTwrapper.h" +namespace zyn { + static pthread_mutex_t *mutex = NULL; FFTwrapper::FFTwrapper(int fftsize_) @@ -91,3 +93,5 @@ void FFT_cleanup() delete mutex; mutex = NULL; } + +} diff --git a/src/DSP/FFTwrapper.h b/src/DSP/FFTwrapper.h @@ -17,6 +17,8 @@ #include <complex> #include "../globals.h" +namespace zyn { + /**A wrapper for the FFTW library (Fast Fourier Transforms)*/ class FFTwrapper { @@ -58,4 +60,7 @@ FFTpolar(const _Tp& __rho, const _Tp& __theta = _Tp(0)) } void FFT_cleanup(); + +} + #endif diff --git a/src/DSP/Filter.cpp b/src/DSP/Filter.cpp @@ -22,6 +22,8 @@ #include "../Params/FilterParams.h" #include "../Misc/Allocator.h" +namespace zyn { + Filter::Filter(unsigned int srate, int bufsize) : outgain(1.0f), samplerate(srate), @@ -65,3 +67,5 @@ float Filter::getrealfreq(float freqpitch) { return powf(2.0f, freqpitch + 9.96578428f); //log2(1000)=9.95748f } + +} diff --git a/src/DSP/Filter.h b/src/DSP/Filter.h @@ -16,6 +16,8 @@ #include "../globals.h" +namespace zyn { + class Filter { public: @@ -53,4 +55,6 @@ class Filter } }; +} + #endif diff --git a/src/DSP/FormantFilter.cpp b/src/DSP/FormantFilter.cpp @@ -19,6 +19,8 @@ #include "AnalogFilter.h" #include "../Params/FilterParams.h" +namespace zyn { + FormantFilter::FormantFilter(const FilterParams *pars, Allocator *alloc, unsigned int srate, int bufsize) :Filter(srate, bufsize), memory(*alloc) { @@ -215,3 +217,5 @@ void FormantFilter::filterout(float *smp) oldformantamp[j] = currentformants[j].amp; } } + +} diff --git a/src/DSP/FormantFilter.h b/src/DSP/FormantFilter.h @@ -17,6 +17,7 @@ #include "../globals.h" #include "Filter.h" +namespace zyn { class FormantFilter:public Filter { @@ -55,4 +56,6 @@ class FormantFilter:public Filter Allocator &memory; }; +} + #endif diff --git a/src/DSP/SVFilter.cpp b/src/DSP/SVFilter.cpp @@ -24,6 +24,8 @@ #include <err.h> #endif +namespace zyn { + SVFilter::SVFilter(unsigned char Ftype, float Ffreq, float Fq, unsigned char Fstages, unsigned int srate, int bufsize) :Filter(srate, bufsize), @@ -229,3 +231,5 @@ void SVFilter::filterout(float *smp) for(int i = 0; i < buffersize; ++i) smp[i] *= outgain; } + +} diff --git a/src/DSP/SVFilter.h b/src/DSP/SVFilter.h @@ -17,6 +17,8 @@ #include "../globals.h" #include "Filter.h" +namespace zyn { + class SVFilter:public Filter { public: @@ -67,4 +69,6 @@ class SVFilter:public Filter bool needsinterpolation, firsttime; }; +} + #endif diff --git a/src/DSP/Unison.cpp b/src/DSP/Unison.cpp @@ -24,6 +24,8 @@ #include <err.h> #endif +namespace zyn { + Unison::Unison(Allocator *alloc_, int update_period_samples_, float max_delay_sec_, float srate_f) :unison_size(0), base_freq(1.0f), @@ -196,3 +198,5 @@ void Unison::updateUnisonData() } first_time = false; } + +} diff --git a/src/DSP/Unison.h b/src/DSP/Unison.h @@ -18,6 +18,9 @@ //how much the unison frequencies varies (always >= 1.0) #define UNISON_FREQ_SPAN 2.0f + +namespace zyn { + class Allocator; class Unison @@ -67,4 +70,7 @@ class Unison float samplerate_f; Allocator &alloc; }; + +} + #endif diff --git a/src/Effects/Alienwah.cpp b/src/Effects/Alienwah.cpp @@ -17,6 +17,8 @@ #include "../Misc/Allocator.h" #include "Alienwah.h" +namespace zyn { + using std::complex; #define rObject Alienwah @@ -257,3 +259,5 @@ unsigned char Alienwah::getpar(int npar) const default: return 0; } } + +} diff --git a/src/Effects/Alienwah.h b/src/Effects/Alienwah.h @@ -20,6 +20,8 @@ #define MAX_ALIENWAH_DELAY 100 +namespace zyn { + /**"AlienWah" Effect*/ class Alienwah:public Effect { @@ -58,4 +60,6 @@ class Alienwah:public Effect int oldk; }; +} + #endif diff --git a/src/Effects/Chorus.cpp b/src/Effects/Chorus.cpp @@ -17,9 +17,10 @@ #include "../Misc/Allocator.h" #include "Chorus.h" #include <iostream> - using namespace std; +namespace zyn { + #define rObject Chorus #define rBegin [](const char *msg, rtosc::RtData &d) { #define rEnd } @@ -294,3 +295,5 @@ unsigned char Chorus::getpar(int npar) const default: return 0; } } + +} diff --git a/src/Effects/Chorus.h b/src/Effects/Chorus.h @@ -19,6 +19,8 @@ #define MAX_CHORUS_DELAY 250.0f //ms +namespace zyn { + /**Chorus and Flange effects*/ class Chorus:public Effect { @@ -95,4 +97,6 @@ class Chorus:public Effect float getdelay(float xlfo); }; +} + #endif diff --git a/src/Effects/Distorsion.cpp b/src/Effects/Distorsion.cpp @@ -19,6 +19,8 @@ #include <rtosc/ports.h> #include <rtosc/port-sugar.h> +namespace zyn { + #define rObject Distorsion #define rBegin [](const char *msg, rtosc::RtData &d) { #define rEnd } @@ -293,3 +295,5 @@ unsigned char Distorsion::getpar(int npar) const default: return 0; //in case of bogus parameter number } } + +} diff --git a/src/Effects/Distorsion.h b/src/Effects/Distorsion.h @@ -16,6 +16,8 @@ #include "Effect.h" +namespace zyn { + /**Distortion Effect*/ class Distorsion:public Effect { @@ -50,4 +52,6 @@ class Distorsion:public Effect class AnalogFilter * lpfl, *lpfr, *hpfl, *hpfr; }; +} + #endif diff --git a/src/Effects/DynamicFilter.cpp b/src/Effects/DynamicFilter.cpp @@ -20,6 +20,8 @@ #include <rtosc/ports.h> #include <rtosc/port-sugar.h> +namespace zyn { + #define rObject DynamicFilter #define rBegin [](const char *msg, rtosc::RtData &d) { #define rEnd } @@ -351,3 +353,5 @@ unsigned char DynamicFilter::getpar(int npar) const default: return 0; } } + +} diff --git a/src/Effects/DynamicFilter.h b/src/Effects/DynamicFilter.h @@ -17,6 +17,8 @@ #include "Effect.h" #include "EffectLFO.h" +namespace zyn { + /**DynamicFilter Effect*/ class DynamicFilter:public Effect { @@ -56,4 +58,6 @@ class DynamicFilter:public Effect float ms1, ms2, ms3, ms4; //mean squares }; +} + #endif diff --git a/src/Effects/EQ.cpp b/src/Effects/EQ.cpp @@ -18,6 +18,8 @@ #include "../DSP/AnalogFilter.h" #include "../Misc/Allocator.h" +namespace zyn { + using rtosc::RtData; #define rObject EQ #define rBegin [](const char *msg, RtData &d) {\ @@ -297,3 +299,5 @@ void EQ::getFilter(float *a, float *b) const } } } + +} diff --git a/src/Effects/EQ.h b/src/Effects/EQ.h @@ -16,6 +16,8 @@ #include "Effect.h" +namespace zyn { + /**EQ Effect*/ class EQ:public Effect { @@ -53,4 +55,6 @@ class EQ:public Effect } filter[MAX_EQ_BANDS]; }; +} + #endif diff --git a/src/Effects/Echo.cpp b/src/Effects/Echo.cpp @@ -21,6 +21,8 @@ #define MAX_DELAY 2 +namespace zyn { + #define rObject Echo #define rBegin [](const char *msg, rtosc::RtData &d) { #define rEnd } @@ -255,3 +257,5 @@ unsigned char Echo::getpar(int npar) const default: return 0; // in case of bogus parameter number } } + +} diff --git a/src/Effects/Echo.h b/src/Effects/Echo.h @@ -17,6 +17,8 @@ #include "Effect.h" #include "../Misc/Stereo.h" +namespace zyn { + /**Echo Effect*/ class Echo:public Effect { @@ -94,4 +96,6 @@ class Echo:public Effect Stereo<int> ndelta; }; +} + #endif diff --git a/src/Effects/Effect.cpp b/src/Effects/Effect.cpp @@ -17,6 +17,8 @@ #include "../Params/FilterParams.h" #include <cmath> +namespace zyn { + EffectParams::EffectParams(Allocator &alloc_, bool insertion_, float *efxoutl_, float *efxoutr_, unsigned char Ppreset_, unsigned int srate_, int bufsize_, FilterParams *filterpars_, bool filterprotect_) @@ -63,3 +65,5 @@ void Effect::setlrcross(char Plrcross_) Plrcross = Plrcross_; lrcross = (float)Plrcross / 127.0f; } + +} diff --git a/src/Effects/Effect.h b/src/Effects/Effect.h @@ -19,9 +19,6 @@ #include "../Params/FilterParams.h" #include "../Misc/Stereo.h" -class FilterParams; -class Allocator; - #ifndef rEffPar #define rEffPar(name, idx, ...) \ {STRINGIFY(name) "::i", rProp(parameter) DOC(__VA_ARGS__), NULL, rEffParCb(idx)} @@ -43,6 +40,11 @@ class Allocator; d.reply(d.loc, obj.getpar(idx)?"T":"F");} #endif +namespace zyn { + +class FilterParams; +class Allocator; + struct EffectParams { /** @@ -154,4 +156,6 @@ class Effect } }; +} + #endif diff --git a/src/Effects/EffectLFO.cpp b/src/Effects/EffectLFO.cpp @@ -17,6 +17,8 @@ #include <cmath> #include "globals.h" +namespace zyn { + EffectLFO::EffectLFO(float srate_f, float bufsize_f) :Pfreq(40), Prandomness(0), @@ -104,3 +106,5 @@ void EffectLFO::effectlfoout(float *outl, float *outr) } *outr = (out + 1.0f) * 0.5f; } + +} diff --git a/src/Effects/EffectLFO.h b/src/Effects/EffectLFO.h @@ -14,6 +14,8 @@ #ifndef EFFECT_LFO_H #define EFFECT_LFO_H +namespace zyn { + /**LFO for some of the Effect objects * \todo see if this should inherit LFO*/ class EffectLFO @@ -41,4 +43,6 @@ class EffectLFO float buffersize_f; }; +} + #endif diff --git a/src/Effects/EffectMgr.cpp b/src/Effects/EffectMgr.cpp @@ -16,7 +16,6 @@ #include <iostream> #include <cassert> - #include "EffectMgr.h" #include "Effect.h" #include "Alienwah.h" @@ -32,6 +31,7 @@ #include "../Params/FilterParams.h" #include "../Misc/Allocator.h" +namespace zyn { #define rObject EffectMgr #define rSubtype(name) \ @@ -515,3 +515,5 @@ void EffectMgr::getfromXML(XMLwrapper& xml) } cleanup(); } + +} diff --git a/src/Effects/EffectMgr.h b/src/Effects/EffectMgr.h @@ -16,14 +16,16 @@ #include <pthread.h> +#include "../Params/FilterParams.h" +#include "../Params/Presets.h" + +namespace zyn { + class Effect; class FilterParams; class XMLwrapper; class Allocator; -#include "../Params/FilterParams.h" -#include "../Params/Presets.h" - /** Effect manager, an interface between the program and effects */ class EffectMgr:public Presets { @@ -82,4 +84,6 @@ class EffectMgr:public Presets const SYNTH_T &synth; }; +} + #endif diff --git a/src/Effects/Phaser.cpp b/src/Effects/Phaser.cpp @@ -21,9 +21,10 @@ #include <rtosc/port-sugar.h> #include "../Misc/Allocator.h" #include "Phaser.h" - using namespace std; +namespace zyn { + #define rObject Phaser #define rBegin [](const char *msg, rtosc::RtData &d) { #define rEnd } @@ -496,3 +497,5 @@ unsigned char Phaser::getpar(int npar) const default: return 0; } } + +} diff --git a/src/Effects/Phaser.h b/src/Effects/Phaser.h @@ -23,6 +23,8 @@ #define MAX_PHASER_STAGES 12 +namespace zyn { + class Phaser:public Effect { public: @@ -87,4 +89,6 @@ class Phaser:public Effect float applyPhase(float x, float g, float *old); }; +} + #endif diff --git a/src/Effects/Reverb.cpp b/src/Effects/Reverb.cpp @@ -20,6 +20,8 @@ #include <rtosc/ports.h> #include <rtosc/port-sugar.h> +namespace zyn { + #define rObject Reverb #define rBegin [](const char *msg, rtosc::RtData &d) { #define rEnd } @@ -516,3 +518,5 @@ unsigned char Reverb::getpar(int npar) const default: return 0; } } + +} diff --git a/src/Effects/Reverb.h b/src/Effects/Reverb.h @@ -19,6 +19,8 @@ #define REV_COMBS 8 #define REV_APS 4 +namespace zyn { + /**Creates Reverberation Effects*/ class Reverb:public Effect { @@ -83,4 +85,6 @@ class Reverb:public Effect class AnalogFilter * lpf, *hpf; //filters }; +} + #endif diff --git a/src/Misc/Allocator.cpp b/src/Misc/Allocator.cpp @@ -17,6 +17,8 @@ #include "../../tlsf/tlsf.h" #include "Allocator.h" +namespace zyn { + //Used for dummy allocations DummyAllocator DummyAlloc; @@ -230,3 +232,5 @@ void Allocator::rollbackTransaction() { * pool size and the next pool in the list as this information is not * accessible in O(good) time */ + +} diff --git a/src/Misc/Allocator.h b/src/Misc/Allocator.h @@ -14,6 +14,8 @@ #include <utility> #include <new> +namespace zyn { + //! Allocator Base class //! subclasses must specify allocation and deallocation class Allocator @@ -198,3 +200,5 @@ extern DummyAllocator DummyAlloc; * * A new one is constructed with a deep copy * * The old one is returned to middleware for deallocation */ + + } diff --git a/src/Misc/Bank.cpp b/src/Misc/Bank.cpp @@ -31,12 +31,14 @@ #include "Part.h" #include "BankDb.h" -#define INSTRUMENT_EXTENSION ".xiz" +using namespace std; -//if this file exists into a directory, this make the directory to be considered as a bank, even if it not contains a instrument file -#define FORCE_BANK_DIR_FILE ".bankdir" +namespace zyn { -using namespace std; +static const char* INSTRUMENT_EXTENSION = ".xiz"; + +//if this file exists into a directory, this make the directory to be considered as a bank, even if it not contains a instrument file +const char* FORCE_BANK_DIR_FILE = ".bankdir"; Bank::Bank(Config *config) :bankpos(0), defaultinsname(" "), config(config), @@ -544,3 +546,5 @@ void Bank::normalizedirsuffix(string &dirname) const { && ((dirname[dirname.size() - 1]) != '\\')) dirname += "/"; } + +} diff --git a/src/Misc/Bank.h b/src/Misc/Bank.h @@ -22,6 +22,8 @@ //entries in a bank #define BANK_SIZE 160 +namespace zyn { + /**The instrument Bank*/ class Bank { @@ -110,4 +112,6 @@ class Bank uint8_t bank_lsb; }; +} + #endif diff --git a/src/Misc/BankDb.cpp b/src/Misc/BankDb.cpp @@ -6,7 +6,9 @@ #include <dirent.h> #include <sys/stat.h> -#define INSTRUMENT_EXTENSION ".xiz" +namespace zyn { + +static const char* INSTRUMENT_EXTENSION = ".xiz"; using std::string; typedef BankDb::svec svec; @@ -339,3 +341,5 @@ BankEntry BankDb::processXiz(std::string filename, return entry; } + +} diff --git a/src/Misc/BankDb.h b/src/Misc/BankDb.h @@ -3,6 +3,8 @@ #include <vector> #include <map> +namespace zyn { + struct BankEntry { BankEntry(void); @@ -53,3 +55,5 @@ class BankDb bvec fields; svec banks; }; + +} diff --git a/src/Misc/CallbackRepeater.cpp b/src/Misc/CallbackRepeater.cpp @@ -10,6 +10,9 @@ of the License, or (at your option) any later version. */ #include "CallbackRepeater.h" + +namespace zyn { + CallbackRepeater::CallbackRepeater(int interval, cb_t cb_) :last(time(0)), dt(interval), cb(cb_) {} @@ -22,3 +25,5 @@ void CallbackRepeater::tick(void) last = now; } } + +} diff --git a/src/Misc/CallbackRepeater.h b/src/Misc/CallbackRepeater.h @@ -13,6 +13,8 @@ #include <functional> #include <ctime> +namespace zyn { + struct CallbackRepeater { typedef std::function<void(void)> cb_t ; @@ -27,3 +29,5 @@ struct CallbackRepeater std::time_t dt; cb_t cb; }; + +} diff --git a/src/Misc/Config.cpp b/src/Misc/Config.cpp @@ -22,6 +22,8 @@ #include "../globals.h" #include "XMLwrapper.h" +namespace zyn { + #define rStdString(name, len, ...) \ {STRINGIFY(name) "::s", rMap(length, len) rProp(parameter) DOC(__VA_ARGS__), NULL, rStringCb(name,len)} #define rStdStringCb(name, length) rBOIL_BEGIN \ @@ -168,7 +170,7 @@ static const rtosc::Ports ports = { delete [] args; }}, }; -const rtosc::Ports &Config::ports = ::ports; +const rtosc::Ports &Config::ports = zyn::ports; #endif Config::Config() @@ -449,3 +451,5 @@ void Config::getConfigFileName(char *name, int namesize) const name[0] = 0; snprintf(name, namesize, "%s%s", getenv("HOME"), "/.zynaddsubfxXML.cfg"); } + +} diff --git a/src/Misc/Config.h b/src/Misc/Config.h @@ -23,6 +23,8 @@ namespace rtosc struct Ports; } +namespace zyn { + class oss_devs_t { public: @@ -73,4 +75,7 @@ class Config void saveConfig(const char *filename) const; void getConfigFileName(char *name, int namesize) const; }; + +} + #endif diff --git a/src/Misc/LASHClient.cpp b/src/Misc/LASHClient.cpp @@ -16,6 +16,7 @@ #include "LASHClient.h" +namespace zyn { LASHClient::LASHClient(int *argc, char ***argv) { @@ -92,3 +93,5 @@ void LASHClient::confirmevent(Event event) if(event == Restore) lash_send_event(client, lash_event_new_with_type(LASH_Restore_File)); } + +} diff --git a/src/Misc/LASHClient.h b/src/Misc/LASHClient.h @@ -17,6 +17,7 @@ #include <pthread.h> #include <lash/lash.h> +namespace zyn { /** This class wraps up some functions for initialising and polling * the LASH daemon.*/ @@ -50,5 +51,6 @@ class LASHClient lash_client_t *client; }; +} #endif diff --git a/src/Misc/Master.cpp b/src/Misc/Master.cpp @@ -36,11 +36,13 @@ #include <algorithm> #include <cmath> #include <atomic> - #include <unistd.h> using namespace std; using namespace rtosc; + +namespace zyn { + #define rObject Master static const Ports sysefxPort = @@ -1250,3 +1252,5 @@ void Master::getfromXML(XMLwrapper& xml) xml.exitbranch(); } } + +} diff --git a/src/Misc/Master.h b/src/Misc/Master.h @@ -26,6 +26,8 @@ #include "../Params/Controller.h" #include "../Synth/WatchPoint.h" +namespace zyn { + class Allocator; struct vuData { @@ -199,4 +201,6 @@ class Master void* mastercb_ptr; }; +} + #endif diff --git a/src/Misc/Microtonal.cpp b/src/Misc/Microtonal.cpp @@ -25,11 +25,13 @@ #include "Util.h" #include "Microtonal.h" +using namespace rtosc; #define MAX_LINE_SIZE 80 +namespace zyn { + #define rObject Microtonal -using namespace rtosc; /** * TODO @@ -852,3 +854,5 @@ void Microtonal::apply(void) int err = texttotunings(buf); } } + +} diff --git a/src/Misc/Microtonal.h b/src/Misc/Microtonal.h @@ -20,6 +20,9 @@ #define MAX_OCTAVE_SIZE 128 #define MICROTONAL_MAX_NAME_LEN 120 + +namespace zyn { + class XMLwrapper; struct KbmInfo @@ -154,4 +157,6 @@ class Microtonal const int& gzip_compression; }; +} + #endif diff --git a/src/Misc/MiddleWare.cpp b/src/Misc/MiddleWare.cpp @@ -56,6 +56,8 @@ #include <err.h> #endif +namespace zyn { + using std::string; int Pexitprogram = 0; @@ -2165,3 +2167,5 @@ PresetsStore& MiddleWare::getPresetsStore() { return impl->presetsstore; } + +} diff --git a/src/Misc/MiddleWare.h b/src/Misc/MiddleWare.h @@ -14,6 +14,10 @@ #include <cstdarg> #include <string> +class Fl_Osc_Interface; + +namespace zyn { + struct SYNTH_T; class Master; class PresetsStore; @@ -41,7 +45,7 @@ class MiddleWare void removeAutoSave(void); //return UI interface - class Fl_Osc_Interface *spawnUiApi(void); + Fl_Osc_Interface *spawnUiApi(void); //Set callback to push UI events to void setUiCallback(void(*cb)(void*,const char *),void *ui); //Set callback to run while busy @@ -81,3 +85,6 @@ class MiddleWare private: class MiddleWareImpl *impl; }; + +} + diff --git a/src/Misc/Part.cpp b/src/Misc/Part.cpp @@ -37,6 +37,8 @@ #include <rtosc/port-sugar.h> #include <iostream> +namespace zyn { + using rtosc::Ports; using rtosc::RtData; @@ -1208,3 +1210,5 @@ bool Part::Kit::validNote(char note) const { return !Pmuted && inRange((uint8_t)note, Pminkey, Pmaxkey); } + +} diff --git a/src/Misc/Part.h b/src/Misc/Part.h @@ -22,6 +22,8 @@ #include <functional> +namespace zyn { + /** Part implementation*/ class Part { @@ -200,4 +202,6 @@ class Part const int &gzip_compression, &interpolation; }; +} + #endif diff --git a/src/Misc/PresetExtractor.cpp b/src/Misc/PresetExtractor.cpp @@ -31,8 +31,10 @@ #include <rtosc/ports.h> #include <rtosc/port-sugar.h> #include <string> -using std::string; +namespace zyn { + +using std::string; static void dummy(const char *, rtosc::RtData&) {} const rtosc::Ports real_preset_ports = @@ -491,3 +493,5 @@ bool presetCheckClipboardType() printf("PresetCheckClipboardType()<UNIMPLEMENTED>\n"); return true; } + +} diff --git a/src/Misc/PresetExtractor.h b/src/Misc/PresetExtractor.h @@ -13,8 +13,11 @@ #include <string> #include <rtosc/ports.h> +namespace zyn { + extern const rtosc::Ports real_preset_ports; extern const rtosc::Ports preset_ports; + struct Clipboard { std::string data; std::string type; @@ -31,3 +34,5 @@ void presetDelete(int); void presetRescan(); std::string presetClipboardType(); bool presetCheckClipboardType(); + +} diff --git a/src/Misc/Recorder.cpp b/src/Misc/Recorder.cpp @@ -17,6 +17,8 @@ #include "../globals.h" #include "../Nio/Nio.h" +namespace zyn { + Recorder::Recorder(const SYNTH_T &synth_) :status(0), notetrigger(0),synth(synth_) {} @@ -81,3 +83,4 @@ void Recorder::triggernow() } //TODO move recorder inside nio system +} diff --git a/src/Misc/Recorder.h b/src/Misc/Recorder.h @@ -15,6 +15,8 @@ #define RECORDER_H #include <string> +namespace zyn { + struct SYNTH_T; /**Records sound to a file*/ class Recorder @@ -43,4 +45,6 @@ class Recorder const SYNTH_T &synth; }; +} + #endif diff --git a/src/Misc/Schema.cpp b/src/Misc/Schema.cpp @@ -1,6 +1,16 @@ #include <ostream> #include <rtosc/ports.h> using namespace rtosc; + +// forwards declaration from rtosc lib +void walk_ports2(const rtosc::Ports *base, + char *name_buffer, + size_t buffer_size, + void *data, + rtosc::port_walker_t walker); + +namespace zyn { + /* * root : * - 'parameters' : [parameter...] @@ -25,13 +35,6 @@ using namespace rtosc; * - 'value' : string-rep */ -void walk_ports2(const rtosc::Ports *base, - char *name_buffer, - size_t buffer_size, - void *data, - rtosc::port_walker_t walker); - - using std::ostream; using std::string; static int enum_min(Port::MetaContainer meta) @@ -221,4 +224,4 @@ void dump_json(std::ostream &o, const rtosc::Ports &p) o << "}"; } - +} diff --git a/src/Misc/Stereo.cpp b/src/Misc/Stereo.cpp @@ -11,6 +11,8 @@ of the License, or (at your option) any later version. */ +namespace zyn { + template<class T> Stereo<T>::Stereo(const T &left, const T &right) :l(left), r(right) @@ -28,3 +30,5 @@ Stereo<T> &Stereo<T>::operator=(const Stereo<T> &nstr) r = nstr.r; return *this; } + +} diff --git a/src/Misc/Stereo.h b/src/Misc/Stereo.h @@ -13,6 +13,8 @@ #ifndef STEREO_H #define STEREO_H +namespace zyn { + template<class T> struct Stereo { public: @@ -28,5 +30,8 @@ struct Stereo { //data T l, r; }; + +} + #include "Stereo.cpp" #endif diff --git a/src/Misc/Time.h b/src/Misc/Time.h @@ -13,6 +13,8 @@ #include <stdint.h> #include "../globals.h" +namespace zyn { + class AbsTime { public: @@ -51,3 +53,5 @@ class RelTime int32_t sample; const AbsTime &t; }; + +} diff --git a/src/Misc/Util.cpp b/src/Misc/Util.cpp @@ -36,6 +36,8 @@ #include <rtosc/rtosc.h> +namespace zyn { + bool isPlugin = false; prng_t prng_state = 0x1234; @@ -225,3 +227,5 @@ char *rtosc_splat(const char *path, std::set<std::string> v) rtosc_amessage(buf, len, path, argT, arg); return buf; } + +} diff --git a/src/Misc/Util.h b/src/Misc/Util.h @@ -23,6 +23,8 @@ #include <rtosc/ports.h> #include <rtosc/port-sugar.h> +namespace zyn { + using std::min; using std::max; @@ -181,4 +183,6 @@ rPresetType, \ rObject &o = *(rObject*)d.obj;\ o.pasteArray(paste,field);}} +} + #endif diff --git a/src/Misc/WavFile.cpp b/src/Misc/WavFile.cpp @@ -19,6 +19,8 @@ #include "WavFile.h" using namespace std; +namespace zyn { + WavFile::WavFile(string filename, int samplerate, int channels) :sampleswritten(0), samplerate(samplerate), channels(channels), file(fopen(filename.c_str(), "w")) @@ -90,3 +92,5 @@ void WavFile::writeMonoSamples(int nsmps, short int *smps) sampleswritten += nsmps; } } + +} diff --git a/src/Misc/WavFile.h b/src/Misc/WavFile.h @@ -16,6 +16,8 @@ #define WAVFILE_H #include <string> +namespace zyn { + class WavFile { public: @@ -33,4 +35,7 @@ class WavFile int channels; FILE *file; }; + +} + #endif diff --git a/src/Misc/WaveShapeSmps.cpp b/src/Misc/WaveShapeSmps.cpp @@ -14,6 +14,8 @@ #include "WaveShapeSmps.h" #include <cmath> +namespace zyn { + void waveShapeSmps(int n, float *smps, unsigned char type, @@ -178,3 +180,5 @@ void waveShapeSmps(int n, break; } } + +} diff --git a/src/Misc/WaveShapeSmps.h b/src/Misc/WaveShapeSmps.h @@ -13,10 +13,14 @@ #ifndef WAVESHAPESMPS_H #define WAVESHAPESMPS_H +namespace zyn { + //Waveshaping(called by Distorsion effect and waveshape from OscilGen) void waveShapeSmps(int n, float *smps, unsigned char type, unsigned char drive); +} + #endif diff --git a/src/Misc/XMLwrapper.cpp b/src/Misc/XMLwrapper.cpp @@ -27,6 +27,8 @@ using namespace std; +namespace zyn { + int xml_k = 0; bool verbose = false; @@ -677,3 +679,5 @@ std::vector<XmlNode> XMLwrapper::getBranch(void) const } return res; } + +} diff --git a/src/Misc/XMLwrapper.h b/src/Misc/XMLwrapper.h @@ -21,6 +21,8 @@ #ifndef XML_WRAPPER_H #define XML_WRAPPER_H +namespace zyn { + class XmlAttr { public: @@ -285,4 +287,6 @@ public: version_type _fileversion; }; +} + #endif diff --git a/src/Nio/AlsaEngine.cpp b/src/Nio/AlsaEngine.cpp @@ -15,8 +15,6 @@ #include <iostream> #include <cmath> -using namespace std; - #include "../Misc/Util.h" #include "../Misc/Config.h" #include "InMgr.h" @@ -24,6 +22,10 @@ using namespace std; #include "Compressor.h" #include "Nio.h" +using namespace std; + +namespace zyn { + AlsaEngine::AlsaEngine(const SYNTH_T &synth) :AudioOut(synth) { @@ -397,3 +399,5 @@ void *AlsaEngine::processAudio() } return NULL; } + +} diff --git a/src/Nio/AlsaEngine.h b/src/Nio/AlsaEngine.h @@ -24,6 +24,8 @@ #include "OutMgr.h" #include "../Misc/Stereo.h" +namespace zyn { + class AlsaEngine:public AudioOut, MidiIn { public: @@ -74,4 +76,6 @@ class AlsaEngine:public AudioOut, MidiIn void *processAudio(); }; +} + #endif diff --git a/src/Nio/AudioOut.cpp b/src/Nio/AudioOut.cpp @@ -15,12 +15,14 @@ #include <cstring> #include "SafeQueue.h" -using namespace std; - #include "OutMgr.h" #include "../Misc/Master.h" #include "AudioOut.h" +using namespace std; + +namespace zyn { + AudioOut::AudioOut(const SYNTH_T &synth_) :synth(synth_), samplerate(synth.samplerate), bufferSize(synth.buffersize) {} @@ -47,3 +49,5 @@ const Stereo<float *> AudioOut::getNext() { return OutMgr::getInstance().tick(bufferSize); } + +} diff --git a/src/Nio/AudioOut.h b/src/Nio/AudioOut.h @@ -18,6 +18,8 @@ #include "../globals.h" #include "Engine.h" +namespace zyn { + class AudioOut:public virtual Engine { public: @@ -50,4 +52,6 @@ class AudioOut:public virtual Engine int bufferSize; }; +} + #endif diff --git a/src/Nio/Engine.cpp b/src/Nio/Engine.cpp @@ -12,8 +12,12 @@ */ #include "Engine.h" +namespace zyn { + Engine::Engine() {} Engine::~Engine() {} + +} diff --git a/src/Nio/Engine.h b/src/Nio/Engine.h @@ -14,6 +14,9 @@ #ifndef ENGINE_H #define ENGINE_H #include <string> + +namespace zyn { + /**Marker for input/output driver*/ class Engine { @@ -29,4 +32,7 @@ class Engine std::string name; }; + +} + #endif diff --git a/src/Nio/EngineMgr.cpp b/src/Nio/EngineMgr.cpp @@ -19,6 +19,8 @@ #include "AudioOut.h" #include "MidiIn.h" #include "NulEngine.h" +using namespace std; + #if OSS #include "OssEngine.h" #include "OssMultiEngine.h" @@ -34,7 +36,7 @@ #include "PaEngine.h" #endif -using namespace std; +namespace zyn { EngineMgr &EngineMgr::getInstance(const SYNTH_T *synth, const oss_devs_t *oss_devs) @@ -172,3 +174,5 @@ bool EngineMgr::setOutDefault(string name) cerr << " Defaulting to the NULL audio backend" << endl; return false; } + +} diff --git a/src/Nio/EngineMgr.h b/src/Nio/EngineMgr.h @@ -16,6 +16,7 @@ #include <string> #include "Engine.h" +namespace zyn { class MidiIn; class AudioOut; @@ -54,4 +55,7 @@ class EngineMgr private: EngineMgr(const SYNTH_T *synth, const oss_devs_t &oss_devs); }; + +} + #endif diff --git a/src/Nio/InMgr.cpp b/src/Nio/InMgr.cpp @@ -17,10 +17,11 @@ #include "../Misc/MiddleWare.h" #include <rtosc/thread-link.h> #include <iostream> - using namespace std; -extern MiddleWare *middleware; +extern zyn::MiddleWare *middleware; + +namespace zyn { ostream &operator<<(ostream &out, const MidiEvent &ev) { @@ -172,3 +173,5 @@ void InMgr::setMaster(Master *master_) { master = master_; } + +} diff --git a/src/Nio/InMgr.h b/src/Nio/InMgr.h @@ -16,6 +16,8 @@ #include "ZynSema.h" #include "SafeQueue.h" +namespace zyn { + enum midi_type { M_NOTE = 1, M_CONTROLLER = 2, @@ -65,4 +67,6 @@ class InMgr class Master *master; }; +} + #endif diff --git a/src/Nio/JackEngine.cpp b/src/Nio/JackEngine.cpp @@ -32,10 +32,12 @@ #include "JackEngine.h" -using namespace std; - extern char *instance_name; +namespace zyn { + +using namespace std; + JackEngine::JackEngine(const SYNTH_T &synth) :AudioOut(synth), jackClient(NULL) { @@ -438,3 +440,5 @@ void JackEngine::handleMidi(unsigned long frames) } } } + +} diff --git a/src/Nio/JackEngine.h b/src/Nio/JackEngine.h @@ -23,6 +23,8 @@ #include "MidiIn.h" #include "AudioOut.h" +namespace zyn { + typedef jack_default_audio_sample_t jsample_t; class JackEngine:public AudioOut, MidiIn @@ -83,4 +85,6 @@ class JackEngine:public AudioOut, MidiIn void handleMidi(unsigned long frames); }; +} + #endif diff --git a/src/Nio/JackMultiEngine.cpp b/src/Nio/JackMultiEngine.cpp @@ -26,7 +26,10 @@ #include "JackMultiEngine.h" -extern MiddleWare *middleware; +extern zyn::MiddleWare *middleware; + +namespace zyn { + using std::string; struct jack_multi @@ -170,3 +173,5 @@ void JackMultiEngine::Stop() impl->running = false; } + +} diff --git a/src/Nio/JackMultiEngine.h b/src/Nio/JackMultiEngine.h @@ -15,6 +15,8 @@ #include "AudioOut.h" +namespace zyn { + class JackMultiEngine:public AudioOut { public: @@ -34,4 +36,6 @@ class JackMultiEngine:public AudioOut struct jack_multi *impl; }; +} + #endif diff --git a/src/Nio/MidiIn.cpp b/src/Nio/MidiIn.cpp @@ -15,6 +15,8 @@ #include "../globals.h" #include "InMgr.h" +namespace zyn { + void MidiIn::midiProcess(unsigned char head, unsigned char num, unsigned char value) @@ -66,3 +68,5 @@ void MidiIn::midiProcess(unsigned char head, break; } } + +} diff --git a/src/Nio/MidiIn.h b/src/Nio/MidiIn.h @@ -18,6 +18,8 @@ #include "Engine.h" +namespace zyn { + /**This class is inherited by all the Midi input classes*/ class MidiIn:public virtual Engine { @@ -31,4 +33,6 @@ class MidiIn:public virtual Engine unsigned char value); }; +} + #endif diff --git a/src/Nio/Nio.cpp b/src/Nio/Nio.cpp @@ -20,6 +20,9 @@ #include <cstring> #include <iostream> #include <algorithm> + +namespace zyn { + using std::string; using std::set; using std::cerr; @@ -183,3 +186,5 @@ void Nio::waveEnd(void) { out->wave->destroyFile(); } + +} diff --git a/src/Nio/Nio.h b/src/Nio/Nio.h @@ -14,6 +14,8 @@ #include <string> #include <set> +namespace zyn { + class WavFile; class Master; struct SYNTH_T; @@ -61,4 +63,6 @@ namespace Nio extern std::string defaultSink; }; +} + #endif diff --git a/src/Nio/NulEngine.cpp b/src/Nio/NulEngine.cpp @@ -16,9 +16,10 @@ #include <unistd.h> #include <iostream> - using namespace std; +namespace zyn { + NulEngine::NulEngine(const SYNTH_T &synth_) :AudioOut(synth_), pThread(NULL) { @@ -102,3 +103,5 @@ bool NulEngine::getAudioEn() const { return pThread; } + +} diff --git a/src/Nio/NulEngine.h b/src/Nio/NulEngine.h @@ -20,6 +20,8 @@ #include "AudioOut.h" #include "MidiIn.h" +namespace zyn { + class NulEngine:public AudioOut, MidiIn { public: @@ -44,4 +46,6 @@ class NulEngine:public AudioOut, MidiIn pthread_t *pThread; }; +} + #endif diff --git a/src/Nio/OssEngine.cpp b/src/Nio/OssEngine.cpp @@ -34,6 +34,8 @@ using namespace std; +namespace zyn { + /* * The following statemachine converts MIDI commands to USB MIDI * packets, derived from Linux's usbmidi.c, which was written by @@ -471,3 +473,5 @@ done: pthread_exit(NULL); return NULL; } + +} diff --git a/src/Nio/OssEngine.h b/src/Nio/OssEngine.h @@ -19,6 +19,8 @@ #include "AudioOut.h" #include "MidiIn.h" +namespace zyn { + struct OssMidiParse { unsigned char *temp_cmd; unsigned char temp_0[4]; @@ -95,4 +97,6 @@ class OssEngine:public AudioOut, MidiIn const char* linux_oss_seq_in_dev; }; +} + #endif diff --git a/src/Nio/OssMultiEngine.cpp b/src/Nio/OssMultiEngine.cpp @@ -31,10 +31,12 @@ #include "OssMultiEngine.h" #include "Compressor.h" -extern MiddleWare *middleware; - using namespace std; +extern zyn::MiddleWare *middleware; + +namespace zyn { + OssMultiEngine :: OssMultiEngine(const SYNTH_T &synth, const oss_devs_t &oss_devs) :AudioOut(synth), @@ -265,3 +267,5 @@ done: pthread_exit(0); return (0); } + +} diff --git a/src/Nio/OssMultiEngine.h b/src/Nio/OssMultiEngine.h @@ -17,6 +17,8 @@ #include "../globals.h" #include "AudioOut.h" +namespace zyn { + class OssMultiEngine : public AudioOut { public: @@ -61,4 +63,6 @@ class OssMultiEngine : public AudioOut const char* linux_oss_wave_out_dev; }; +} + #endif diff --git a/src/Nio/OutMgr.cpp b/src/Nio/OutMgr.cpp @@ -20,9 +20,10 @@ #include "WavEngine.h" #include "../Misc/Master.h" #include "../Misc/Util.h" //for set_realtime() - using namespace std; +namespace zyn { + OutMgr &OutMgr::getInstance(const SYNTH_T *synth) { static OutMgr instance(synth); @@ -199,3 +200,5 @@ void OutMgr::removeStaleSmps() stales = 0; } + +} diff --git a/src/Nio/OutMgr.h b/src/Nio/OutMgr.h @@ -18,6 +18,7 @@ #include <string> #include <semaphore.h> +namespace zyn { class AudioOut; struct SYNTH_T; @@ -78,4 +79,6 @@ class OutMgr const SYNTH_T &synth; }; +} + #endif diff --git a/src/Nio/PaEngine.cpp b/src/Nio/PaEngine.cpp @@ -13,9 +13,10 @@ #include "PaEngine.h" #include <iostream> - using namespace std; +namespace zyn { + PaEngine::PaEngine(const SYNTH_T &synth) :AudioOut(synth), stream(NULL) { @@ -107,3 +108,5 @@ void PaEngine::Stop() stream = NULL; Pa_Terminate(); } + +} diff --git a/src/Nio/PaEngine.h b/src/Nio/PaEngine.h @@ -18,6 +18,8 @@ #include "../globals.h" #include "AudioOut.h" +namespace zyn { + class PaEngine:public AudioOut { public: @@ -42,7 +44,8 @@ class PaEngine:public AudioOut PaStream *stream; }; - void PAfinish(); +} + #endif diff --git a/src/Nio/SafeQueue.cpp b/src/Nio/SafeQueue.cpp @@ -10,6 +10,8 @@ of the License, or (at your option) any later version. */ +namespace zyn { + template<class T> SafeQueue<T>::SafeQueue(size_t maxlen) :writePtr(0), readPtr(0), bufSize(maxlen) @@ -98,3 +100,5 @@ void SafeQueue<T>::clear() w_space.post(); readPtr = writePtr; } + +} diff --git a/src/Nio/SafeQueue.h b/src/Nio/SafeQueue.h @@ -16,6 +16,8 @@ #include "ZynSema.h" #include <pthread.h> +namespace zyn { + /** * C++ thread safe lockless queue * Based off of jack's ringbuffer*/ @@ -55,5 +57,7 @@ class SafeQueue T *buffer; }; +} + #include "SafeQueue.cpp" #endif diff --git a/src/Nio/WavEngine.cpp b/src/Nio/WavEngine.cpp @@ -17,9 +17,10 @@ #include <cstdlib> #include "../Misc/WavFile.h" #include "../Misc/Util.h" - using namespace std; +namespace zyn { + WavEngine::WavEngine(const SYNTH_T &synth_) :AudioOut(synth_), file(NULL), buffer(synth.samplerate * 4), pThread(NULL) { @@ -127,3 +128,5 @@ void *WavEngine::AudioThread() return NULL; } + +} diff --git a/src/Nio/WavEngine.h b/src/Nio/WavEngine.h @@ -20,6 +20,8 @@ #include "ZynSema.h" #include "SafeQueue.h" +namespace zyn { + class WavFile; class WavEngine:public AudioOut { @@ -50,4 +52,6 @@ class WavEngine:public AudioOut pthread_t *pThread; }; + +} #endif diff --git a/src/Nio/ZynSema.h b/src/Nio/ZynSema.h @@ -16,6 +16,8 @@ #include <pthread.h> +namespace zyn { + class ZynSema { public: @@ -77,10 +79,14 @@ private: pthread_cond_t _cond; }; +} + #else // POSIX sempahore #include <semaphore.h> +namespace zyn { + class ZynSema { public: @@ -118,6 +124,8 @@ private: sem_t _sema; }; +} + #endif // POSIX semapore #endif // ZYNSEMA_H diff --git a/src/Output/DSSIControl.cpp b/src/Output/DSSIControl.cpp @@ -14,6 +14,6 @@ #include "DSSIControl.h" #include "../Misc/Master.h" -void DSSIControl::forward_control(Master *master) { +void DSSIControl::forward_control(zyn::Master *master) { master->setController(0, description.controller_code, get_scaled_data()); } diff --git a/src/Output/DSSIControl.h b/src/Output/DSSIControl.h @@ -34,7 +34,7 @@ struct DSSIControl { * update the current control to the Master in charge of dispatching them to the parts, effects, ... * @param master the controller master in charge of further dispatch */ - void forward_control(Master *master); + void forward_control(zyn::Master *master); /** * scale the incoming value refereced by data in the hinted range to one expected by the Master dispatcher. diff --git a/src/Output/DSSIControlDescription.cpp b/src/Output/DSSIControlDescription.cpp @@ -15,16 +15,16 @@ // Mapping from dssi control index to midi CC const DSSIControlDescription dssi_control_description[DSSIControlDescription::MAX_DSSI_CONTROLS] = { - { C_modwheel, "Modwheel", {LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MIDDLE, 1, 127 }}, - { C_volume, "Volume", {LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MAXIMUM, 1, 127 }}, - { C_panning, "Panning"}, - { C_expression, "Expression", {LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MAXIMUM, 1, 127 }}, - { C_sustain, "Sustain", {LADSPA_HINT_TOGGLED| LADSPA_HINT_DEFAULT_0, 0, 1}}, - { C_portamento, "Portamento", {LADSPA_HINT_TOGGLED| LADSPA_HINT_DEFAULT_0, 0, 1}}, - { C_filterq, "Filter Q", {LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MIDDLE, 0, 128 }}, - { C_filtercutoff, "Filter cutoff", {LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_0, -1, 1 }}, - { C_bandwidth, "Bandwidth"}, - { C_fmamp, "FM amplification", {LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MAXIMUM, 1, 127 }}, - { C_resonance_center, "Renonance center", {LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_0, -1, 1 }}, - { C_resonance_bandwidth, "Resonance bandwidth", {LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_0, -1, 1 }}, + { zyn::C_modwheel, "Modwheel", {LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MIDDLE, 1, 127 }}, + { zyn::C_volume, "Volume", {LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MAXIMUM, 1, 127 }}, + { zyn::C_panning, "Panning"}, + { zyn::C_expression, "Expression", {LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MAXIMUM, 1, 127 }}, + { zyn::C_sustain, "Sustain", {LADSPA_HINT_TOGGLED| LADSPA_HINT_DEFAULT_0, 0, 1}}, + { zyn::C_portamento, "Portamento", {LADSPA_HINT_TOGGLED| LADSPA_HINT_DEFAULT_0, 0, 1}}, + { zyn::C_filterq, "Filter Q", {LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MIDDLE, 0, 128 }}, + { zyn::C_filtercutoff, "Filter cutoff", {LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_0, -1, 1 }}, + { zyn::C_bandwidth, "Bandwidth"}, + { zyn::C_fmamp, "FM amplification", {LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MAXIMUM, 1, 127 }}, + { zyn::C_resonance_center, "Renonance center", {LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_0, -1, 1 }}, + { zyn::C_resonance_bandwidth, "Resonance bandwidth", {LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_0, -1, 1 }}, }; diff --git a/src/Output/DSSIControlDescription.h b/src/Output/DSSIControlDescription.h @@ -26,7 +26,7 @@ struct DSSIControlDescription { const static int MAX_DSSI_CONTROLS = 12; - const MidiControllers controller_code; /// controler code, as accepted by the Controller class + const zyn::MidiControllers controller_code; /// controler code, as accepted by the Controller class const char *name; /// human readable name of this control /** hint about usable range of value for this control, defaulting to 0-128, initially at 64 */ @@ -38,8 +38,9 @@ struct DSSIControlDescription { * @param controller_code the controller code * @param name the human readable code name */ - DSSIControlDescription(MidiControllers controller_code, const char *name) : controller_code(controller_code), - name(name) { } + DSSIControlDescription(zyn::MidiControllers controller_code, const char *name) : + controller_code(controller_code), + name(name) { } /** * Ctr for a DSSIControlDescription @@ -47,7 +48,7 @@ struct DSSIControlDescription { * @param name the human readable code name * @param port_range_hint the accepted range of values */ - DSSIControlDescription(MidiControllers controller_code, const char *name, LADSPA_PortRangeHint port_range_hint) : + DSSIControlDescription(zyn::MidiControllers controller_code, const char *name, LADSPA_PortRangeHint port_range_hint) : controller_code(controller_code), name(name), port_range_hint(port_range_hint) { } }; diff --git a/src/Output/DSSIaudiooutput.cpp b/src/Output/DSSIaudiooutput.cpp @@ -34,7 +34,7 @@ class WavFile; namespace Nio { bool start(void){return 1;}; void stop(void){}; - void masterSwap(Master *){}; + void masterSwap(zyn::Master *){}; void waveNew(WavFile *){} void waveStart(void){} void waveStop(void){} @@ -422,7 +422,7 @@ void DSSIaudiooutput::runSynth(unsigned long sample_count, unsigned long next_event_frame = 0; unsigned long to_frame = 0; - Master *master = middleware->spawnMaster(); + zyn::Master *master = middleware->spawnMaster(); // forward all dssi control values to the middleware for (size_t dssi_control_index = 0; @@ -616,7 +616,7 @@ DSSIaudiooutput::DSSIaudiooutput(unsigned long sampleRate) : dssi_control{dssi_c dssi_control_description[10], dssi_control_description[11]} { - SYNTH_T synth; + zyn::SYNTH_T synth; synth.samplerate = sampleRate; this->sampleRate = sampleRate; @@ -624,10 +624,10 @@ DSSIaudiooutput::DSSIaudiooutput(unsigned long sampleRate) : dssi_control{dssi_c config.init(); - sprng(time(NULL)); + zyn::sprng(time(NULL)); synth.alias(); - middleware = new MiddleWare(std::move(synth), &config); + middleware = new zyn::MiddleWare(std::move(synth), &config); initBanks(); loadThread = new std::thread([this]() { while(middleware) { @@ -680,7 +680,7 @@ long DSSIaudiooutput::bankNoToMap = 1; */ bool DSSIaudiooutput::mapNextBank() { - Bank &bank = middleware->spawnMaster()->bank; + zyn::Bank &bank = middleware->spawnMaster()->bank; auto &banks = bank.banks; if(bankNoToMap >= (int)banks.size() || banks[bankNoToMap].dir.empty()) return false; diff --git a/src/Output/DSSIaudiooutput.h b/src/Output/DSSIaudiooutput.h @@ -96,7 +96,7 @@ class DSSIaudiooutput LADSPA_Data *outl; LADSPA_Data *outr; long sampleRate; - MiddleWare *middleware; + zyn::MiddleWare *middleware; std::thread *loadThread; static DSSI_Descriptor *dssiDescriptor; static std::string bankDirNames[]; @@ -110,7 +110,7 @@ class DSSIaudiooutput bool banksInited; static long bankNoToMap; - Config config; + zyn::Config config; }; #endif diff --git a/src/Params/ADnoteParameters.cpp b/src/Params/ADnoteParameters.cpp @@ -27,6 +27,9 @@ #include <rtosc/ports.h> #include <rtosc/port-sugar.h> + +namespace zyn { + using rtosc::Ports; using rtosc::RtData; @@ -1247,3 +1250,5 @@ void ADnoteVoiceParam::getfromXML(XMLwrapper& xml, unsigned nvoice) xml.exitbranch(); } } + +} diff --git a/src/Params/ADnoteParameters.h b/src/Params/ADnoteParameters.h @@ -17,6 +17,8 @@ #include "../globals.h" #include "PresetsArray.h" +namespace zyn { + enum FMTYPE { NONE, MORPH, RING_MOD, PHASE_MOD, FREQ_MOD, PW_MOD }; @@ -338,4 +340,6 @@ class ADnoteParameters:public PresetsArray int64_t last_update_timestamp; }; +} + #endif diff --git a/src/Params/Controller.cpp b/src/Params/Controller.cpp @@ -22,6 +22,8 @@ #include <rtosc/port-sugar.h> using namespace rtosc; +namespace zyn { + #define rObject Controller #undef rChangeCb @@ -467,3 +469,5 @@ void Controller::getfromXML(XMLwrapper& xml) resonancebandwidth.depth = xml.getpar127("resonance_bandwidth_depth", resonancebandwidth.depth); } + +} diff --git a/src/Params/Controller.h b/src/Params/Controller.h @@ -18,6 +18,8 @@ #include <stdint.h> #include "../globals.h" +namespace zyn { + /**(Midi) Controllers implementation*/ class Controller { @@ -216,4 +218,6 @@ class Controller const SYNTH_T &synth; }; +} + #endif diff --git a/src/Params/EnvelopeParams.cpp b/src/Params/EnvelopeParams.cpp @@ -22,8 +22,11 @@ #include "../Misc/Util.h" #include "../Misc/Time.h" -#define rObject EnvelopeParams using namespace rtosc; + +namespace zyn { + +#define rObject EnvelopeParams #define rBegin [](const char *msg, RtData &d) { \ EnvelopeParams *env = (rObject*) d.obj #define rEnd } @@ -482,3 +485,5 @@ void EnvelopeParams::store2defaults() DS_val = PS_val; DR_val = PR_val; } + +} diff --git a/src/Params/EnvelopeParams.h b/src/Params/EnvelopeParams.h @@ -18,6 +18,8 @@ #include "../Misc/XMLwrapper.h" #include "Presets.h" +namespace zyn { + class EnvelopeParams:public Presets { public: @@ -86,4 +88,6 @@ class EnvelopeParams:public Presets DA_val, DD_val, DS_val, DR_val; }; +} + #endif diff --git a/src/Params/FilterParams.cpp b/src/Params/FilterParams.cpp @@ -23,9 +23,10 @@ #include <rtosc/rtosc.h> #include <rtosc/ports.h> #include <rtosc/port-sugar.h> - using namespace rtosc; +namespace zyn { + // g++ 4.8 needs this variable saved separately, otherwise it segfaults constexpr int sizeof_pvowels = sizeof(FilterParams::Pvowels); @@ -577,3 +578,5 @@ void FilterParams::pasteArray(FilterParams &x, int nvowel) last_update_timestamp = time->time(); } } + +} diff --git a/src/Params/FilterParams.h b/src/Params/FilterParams.h @@ -18,6 +18,8 @@ #include "../Misc/XMLwrapper.h" #include "PresetsArray.h" +namespace zyn { + class FilterParams:public PresetsArray { public: @@ -98,4 +100,6 @@ class FilterParams:public PresetsArray unsigned char Dq; }; +} + #endif diff --git a/src/Params/LFOParams.cpp b/src/Params/LFOParams.cpp @@ -23,6 +23,7 @@ #include <rtosc/ports.h> using namespace rtosc; +namespace zyn { #define rObject LFOParams #undef rChangeCb @@ -173,3 +174,5 @@ void LFOParams::paste(LFOParams &x) } } #undef COPY + +} diff --git a/src/Params/LFOParams.h b/src/Params/LFOParams.h @@ -18,8 +18,6 @@ #include <rtosc/ports.h> #include "Presets.h" -class XMLwrapper; - #define LFO_SINE 0 #define LFO_TRIANGLE 1 #define LFO_SQUARE 2 @@ -29,6 +27,10 @@ class XMLwrapper; #define LFO_EXP_DOWN2 6 #define LFO_RANDOM 7 +namespace zyn { + +class XMLwrapper; + class LFOParams:public Presets { public: @@ -78,4 +80,6 @@ class LFOParams:public Presets unsigned char Dcontinous; }; +} + #endif diff --git a/src/Params/PADnoteParameters.cpp b/src/Params/PADnoteParameters.cpp @@ -25,6 +25,7 @@ #include <rtosc/port-sugar.h> using namespace rtosc; +namespace zyn { #define rObject PADnoteParameters #undef rChangeCb @@ -253,8 +254,8 @@ static const rtosc::Ports non_realtime_ports = }; #undef rChangeCb -const rtosc::Ports &PADnoteParameters::non_realtime_ports = ::non_realtime_ports; -const rtosc::Ports &PADnoteParameters::realtime_ports = ::realtime_ports; +const rtosc::Ports &PADnoteParameters::non_realtime_ports = zyn::non_realtime_ports; +const rtosc::Ports &PADnoteParameters::realtime_ports = zyn::realtime_ports; const rtosc::MergePorts PADnoteParameters::ports = @@ -1244,3 +1245,5 @@ void PADnoteParameters::pasteRT(PADnoteParameters &x) } } #undef COPY + +} diff --git a/src/Params/PADnoteParameters.h b/src/Params/PADnoteParameters.h @@ -20,6 +20,8 @@ #include <string> #include <functional> +namespace zyn { + /** * Parameters for PAD synthesis * @@ -190,6 +192,6 @@ class PADnoteParameters:public Presets const SYNTH_T &synth; }; - +} #endif diff --git a/src/Params/Presets.cpp b/src/Params/Presets.cpp @@ -16,6 +16,7 @@ #include "PresetsStore.h" #include <string.h> +namespace zyn { Presets::Presets() { @@ -95,3 +96,5 @@ void Presets::deletepreset(PresetsStore &ps, int npreset) { ps.deletepreset(npreset); } + +} diff --git a/src/Params/Presets.h b/src/Params/Presets.h @@ -15,6 +15,9 @@ #define PRESETS_H #include "../globals.h" + +namespace zyn { + class PresetsStore; /**Presets and Clipboard management*/ @@ -40,4 +43,6 @@ class Presets //virtual void defaults() = 0; }; +} + #endif diff --git a/src/Params/PresetsArray.cpp b/src/Params/PresetsArray.cpp @@ -15,6 +15,7 @@ #include "PresetsArray.h" #include <string.h> +namespace zyn { PresetsArray::PresetsArray() { @@ -126,3 +127,5 @@ bool PresetsArray::checkclipboardtype(PresetsStore &ps) // // presetsstore.rescanforpresets(type); //} + +} diff --git a/src/Params/PresetsArray.h b/src/Params/PresetsArray.h @@ -18,6 +18,8 @@ #include "Presets.h" +namespace zyn { + /**PresetsArray and Clipboard management*/ class PresetsArray:public Presets { @@ -39,4 +41,6 @@ class PresetsArray:public Presets //virtual void defaults(int n) = 0; }; +} + #endif diff --git a/src/Params/PresetsStore.cpp b/src/Params/PresetsStore.cpp @@ -25,6 +25,8 @@ using namespace std; +namespace zyn { + //XXX to remove //PresetsStore presetsstore; @@ -181,3 +183,5 @@ void PresetsStore::deletepreset(std::string filename) } } } + +} diff --git a/src/Params/PresetsStore.h b/src/Params/PresetsStore.h @@ -17,6 +17,8 @@ #include <string> #include <vector> +namespace zyn { + class XMLwrapper; class PresetsStore { @@ -55,4 +57,7 @@ class PresetsStore }; //extern PresetsStore presetsstore; + +} + #endif diff --git a/src/Params/SUBnoteParameters.cpp b/src/Params/SUBnoteParameters.cpp @@ -22,10 +22,11 @@ #include <rtosc/ports.h> #include <rtosc/port-sugar.h> - -#define rObject SUBnoteParameters using namespace rtosc; +namespace zyn { + +#define rObject SUBnoteParameters #define rBegin [](const char *msg, RtData &d) { \ SUBnoteParameters *obj = (SUBnoteParameters*) d.obj #define rEnd } @@ -590,3 +591,5 @@ void SUBnoteParameters::getfromXML(XMLwrapper& xml) xml.exitbranch(); } } + +} diff --git a/src/Params/SUBnoteParameters.h b/src/Params/SUBnoteParameters.h @@ -18,6 +18,8 @@ #include "../globals.h" #include "Presets.h" +namespace zyn { + class SUBnoteParameters:public Presets { public: @@ -112,4 +114,6 @@ class SUBnoteParameters:public Presets static const rtosc::Ports &ports; }; +} + #endif diff --git a/src/Plugin/AbstractFX.hpp b/src/Plugin/AbstractFX.hpp @@ -51,7 +51,7 @@ public: { efxoutl = new float[bufferSize]; efxoutr = new float[bufferSize]; - filterpar = new FilterParams(); + filterpar = new zyn::FilterParams(); std::memset(efxoutl, 0, sizeof(float)*bufferSize); std::memset(efxoutr, 0, sizeof(float)*bufferSize); @@ -100,9 +100,9 @@ protected: */ uint32_t getVersion() const noexcept override { - return d_version(version.get_major(), - version.get_minor(), - version.get_revision()); + return d_version(zyn::version.get_major(), + zyn::version.get_minor(), + zyn::version.get_revision()); } /* -------------------------------------------------------------------------------------------------------- @@ -179,7 +179,7 @@ protected: multiply(outputs[1], 0.5f, frames); // FIXME: Make Zyn use const floats - effect->out(Stereo<float*>((float*)inputs[0], (float*)inputs[1])); + effect->out(zyn::Stereo<float*>((float*)inputs[0], (float*)inputs[1])); addWithMultiply(outputs[0], efxoutl, 0.5f, frames); addWithMultiply(outputs[1], efxoutr, 0.5f, frames); @@ -234,12 +234,12 @@ private: uint32_t bufferSize; double sampleRate; - Effect* effect; + zyn::Effect* effect; float* efxoutl; float* efxoutr; - FilterParams* filterpar; + zyn::FilterParams* filterpar; - AllocatorClass allocator; + zyn::AllocatorClass allocator; void doReinit(const bool firstInit) { @@ -254,7 +254,7 @@ private: delete effect; } - EffectParams pars(allocator, false, efxoutl, efxoutr, 0, static_cast<uint>(sampleRate), static_cast<int>(bufferSize), filterpar); + zyn::EffectParams pars(allocator, false, efxoutl, efxoutr, 0, static_cast<uint>(sampleRate), static_cast<int>(bufferSize), filterpar); effect = new ZynFX(pars); if (firstInit) diff --git a/src/Plugin/AlienWah/AlienWah.cpp b/src/Plugin/AlienWah/AlienWah.cpp @@ -20,7 +20,7 @@ /* ------------------------------------------------------------------------------------------------------------ * AlienWah plugin class */ -class AlienWahPlugin : public AbstractPluginFX<Alienwah> +class AlienWahPlugin : public AbstractPluginFX<zyn::Alienwah> { public: AlienWahPlugin() diff --git a/src/Plugin/Chorus/Chorus.cpp b/src/Plugin/Chorus/Chorus.cpp @@ -20,7 +20,7 @@ /* ------------------------------------------------------------------------------------------------------------ * Chorus plugin class */ -class ChorusPlugin : public AbstractPluginFX<Chorus> +class ChorusPlugin : public AbstractPluginFX<zyn::Chorus> { public: ChorusPlugin() diff --git a/src/Plugin/Distortion/Distortion.cpp b/src/Plugin/Distortion/Distortion.cpp @@ -20,7 +20,7 @@ /* ------------------------------------------------------------------------------------------------------------ * Distortion plugin class */ -class DistortionPlugin : public AbstractPluginFX<Distorsion> +class DistortionPlugin : public AbstractPluginFX<zyn::Distorsion> { public: DistortionPlugin() diff --git a/src/Plugin/DynamicFilter/DynamicFilter.cpp b/src/Plugin/DynamicFilter/DynamicFilter.cpp @@ -20,7 +20,7 @@ /* ------------------------------------------------------------------------------------------------------------ * DynamicFilter plugin class */ -class DynamicFilterPlugin : public AbstractPluginFX<DynamicFilter> +class DynamicFilterPlugin : public AbstractPluginFX<zyn::DynamicFilter> { public: DynamicFilterPlugin() diff --git a/src/Plugin/Echo/Echo.cpp b/src/Plugin/Echo/Echo.cpp @@ -20,7 +20,7 @@ /* ------------------------------------------------------------------------------------------------------------ * Echo plugin class */ -class EchoPlugin : public AbstractPluginFX<Echo> +class EchoPlugin : public AbstractPluginFX<zyn::Echo> { public: EchoPlugin() diff --git a/src/Plugin/Phaser/Phaser.cpp b/src/Plugin/Phaser/Phaser.cpp @@ -20,7 +20,7 @@ /* ------------------------------------------------------------------------------------------------------------ * Phaser plugin class */ -class PhaserPlugin : public AbstractPluginFX<Phaser> +class PhaserPlugin : public AbstractPluginFX<zyn::Phaser> { public: PhaserPlugin() diff --git a/src/Plugin/Reverb/Reverb.cpp b/src/Plugin/Reverb/Reverb.cpp @@ -20,7 +20,7 @@ /* ------------------------------------------------------------------------------------------------------------ * Reverb plugin class */ -class ReverbPlugin : public AbstractPluginFX<Reverb> +class ReverbPlugin : public AbstractPluginFX<zyn::Reverb> { public: ReverbPlugin() diff --git a/src/Plugin/ZynAddSubFX/ZynAddSubFX.cpp b/src/Plugin/ZynAddSubFX/ZynAddSubFX.cpp @@ -52,7 +52,7 @@ public: thread.start(middleware); } - void updateMiddleWare(MiddleWare* const mw) noexcept + void updateMiddleWare(zyn::MiddleWare* const mw) noexcept { middleware = mw; } @@ -60,7 +60,7 @@ public: private: const bool wasRunning; MiddleWareThread& thread; - MiddleWare* middleware; + zyn::MiddleWare* middleware; DISTRHO_PREVENT_HEAP_ALLOCATION DISTRHO_DECLARE_NON_COPY_CLASS(ScopedStopper) @@ -70,7 +70,7 @@ public: : Thread("ZynMiddleWare"), middleware(nullptr) {} - void start(MiddleWare* const mw) noexcept + void start(zyn::MiddleWare* const mw) noexcept { middleware = mw; startThread(); @@ -96,7 +96,7 @@ protected: } private: - MiddleWare* middleware; + zyn::MiddleWare* middleware; DISTRHO_DECLARE_NON_COPY_CLASS(MiddleWareThread) }; @@ -191,7 +191,9 @@ protected: */ uint32_t getVersion() const noexcept override { - return d_version(version.get_major(), version.get_minor(), version.get_revision()); + return d_version(zyn::version.get_major(), + zyn::version.get_minor(), + zyn::version.get_revision()); } /** @@ -398,7 +400,7 @@ protected: const uint8_t msb = midiEvent.data[2]; const int value = ((msb << 7) | lsb) - 8192; - master->setController(channel, C_pitchwheel, value); + master->setController(channel, zyn::C_pitchwheel, value); } break; } } @@ -464,10 +466,10 @@ protected: } private: - Config config; - Master* master; - MiddleWare* middleware; - SYNTH_T synth; + zyn::Config config; + zyn::Master* master; + zyn::MiddleWare* middleware; + zyn::SYNTH_T synth; Mutex mutex; char* defaultState; @@ -486,7 +488,7 @@ private: void _initMaster() { - middleware = new MiddleWare(std::move(synth), &config); + middleware = new zyn::MiddleWare(std::move(synth), &config); middleware->setUiCallback(__uiCallback, this); middleware->setIdleCallback(__idleCallback, this); _masterChangedCallback(middleware->spawnMaster()); @@ -512,13 +514,13 @@ private: /* -------------------------------------------------------------------------------------------------------- * ZynAddSubFX Callbacks */ - void _masterChangedCallback(Master* m) + void _masterChangedCallback(zyn::Master* m) { master = m; master->setMasterChangedCallback(__masterChangedCallback, this); } - static void __masterChangedCallback(void* ptr, Master* m) + static void __masterChangedCallback(void* ptr, zyn::Master* m) { ((ZynAddSubFX*)ptr)->_masterChangedCallback(m); } @@ -559,7 +561,7 @@ START_NAMESPACE_DISTRHO Plugin* createPlugin() { - ::isPlugin = true; + zyn::isPlugin = true; return new ZynAddSubFX(); } @@ -570,7 +572,7 @@ END_NAMESPACE_DISTRHO class WavFile; namespace Nio { - void masterSwap(Master*){} + void masterSwap(zyn::Master*){} bool setSource(std::string){return true;} bool setSink(std::string){return true;} std::set<std::string> getSources(void){return std::set<std::string>();} diff --git a/src/Synth/ADnote.cpp b/src/Synth/ADnote.cpp @@ -27,6 +27,8 @@ #include "OscilGen.h" #include "ADnote.h" +namespace zyn { + ADnote::ADnote(ADnoteParameters *pars_, SynthParams &spars, WatchManager *wm, const char *prefix) :SynthNote(spars), pars(*pars_) @@ -1962,3 +1964,5 @@ void ADnote::Global::initparameters(const ADnoteGlobalParam ¶m, param.PFilterVelocityScaleFunction); } } + +} diff --git a/src/Synth/ADnote.h b/src/Synth/ADnote.h @@ -27,6 +27,8 @@ #define OSCIL_SMP_EXTRA_SAMPLES 5 +namespace zyn { + /**The "additive" synthesizer*/ class ADnote:public SynthNote { @@ -322,4 +324,6 @@ class ADnote:public SynthNote float bandwidthDetuneMultiplier; }; +} + #endif diff --git a/src/Synth/Envelope.cpp b/src/Synth/Envelope.cpp @@ -15,6 +15,8 @@ #include "Envelope.h" #include "../Params/EnvelopeParams.h" +namespace zyn { + Envelope::Envelope(EnvelopeParams &pars, float basefreq, float bufferdt, WatchManager *m, const char *watch_prefix) :watchOut(m, watch_prefix, "out") @@ -212,3 +214,5 @@ bool Envelope::finished() const { return envfinish; } + +} diff --git a/src/Synth/Envelope.h b/src/Synth/Envelope.h @@ -17,6 +17,8 @@ #include "../globals.h" #include "WatchPoint.h" +namespace zyn { + /**Implementation of a general Envelope*/ class Envelope { @@ -54,5 +56,6 @@ class Envelope VecWatchPoint watchOut; }; +} #endif diff --git a/src/Synth/LFO.cpp b/src/Synth/LFO.cpp @@ -19,6 +19,8 @@ #include <cstdio> #include <cmath> +namespace zyn { + LFO::LFO(const LFOParams &lfopars, float basefreq, const AbsTime &t, WatchManager *m, const char *watch_prefix) :first_half(-1), @@ -191,3 +193,5 @@ void LFO::computeNextFreqRnd() incrnd = nextincrnd; nextincrnd = powf(0.5f, lfofreqrnd) + RND * (powf(2.0f, lfofreqrnd) - 1.0f); } + +} diff --git a/src/Synth/LFO.h b/src/Synth/LFO.h @@ -18,6 +18,8 @@ #include "../Misc/Time.h" #include "WatchPoint.h" +namespace zyn { + /**Class for creating Low Frequency Oscillators*/ class LFO { @@ -70,4 +72,6 @@ class LFO void computeNextFreqRnd(void); }; +} + #endif diff --git a/src/Synth/ModFilter.cpp b/src/Synth/ModFilter.cpp @@ -21,6 +21,8 @@ #include "../DSP/FormantFilter.h" #include <cassert> +namespace zyn { + ModFilter::ModFilter(const FilterParams &pars_, const SYNTH_T &synth_, const AbsTime &time_, @@ -159,3 +161,5 @@ void ModFilter::anParamUpdate(AnalogFilter &an) an.setstages(pars.Pstages); an.setgain(pars.getgain()); } + +} diff --git a/src/Synth/ModFilter.h b/src/Synth/ModFilter.h @@ -13,6 +13,8 @@ #include "../globals.h" #include "../Misc/Time.h" +namespace zyn { + //Modulated instance of one of the filters in src/DSP/ //Supports stereo modes class ModFilter @@ -64,3 +66,5 @@ class ModFilter Envelope *env; //center freq envelope LFO *lfo; //center freq lfo }; + +} diff --git a/src/Synth/OscilGen.cpp b/src/Synth/OscilGen.cpp @@ -27,6 +27,8 @@ #include <rtosc/ports.h> #include <rtosc/port-sugar.h> +namespace zyn { + #define rObject OscilGen const rtosc::Ports OscilGen::non_realtime_ports = { rSelf(OscilGen), @@ -772,7 +774,7 @@ void OscilGen::shiftharmonics(fft_t *freqs) } else for(int i = 0; i < synth.oscilsize / 2 - 1; ++i) { - int oldh = i + abs(harmonicshift); + int oldh = i + ::abs(harmonicshift); if(oldh >= (synth.oscilsize / 2 - 1)) h = 0.0f; else { @@ -1790,3 +1792,5 @@ filter_func getFilter(unsigned char func) }; return functions[func]; } + +} diff --git a/src/Synth/OscilGen.h b/src/Synth/OscilGen.h @@ -18,6 +18,8 @@ #include <rtosc/ports.h> #include "../Params/Presets.h" +namespace zyn { + class OscilGen:public Presets { public: @@ -183,5 +185,6 @@ filter_func getFilter(unsigned char func); typedef float (*base_func)(float, float); base_func getBaseFunction(unsigned char func); +} #endif diff --git a/src/Synth/PADnote.cpp b/src/Synth/PADnote.cpp @@ -22,6 +22,8 @@ #include "../Containers/ScratchString.h" #include "../Misc/Util.h" +namespace zyn { + PADnote::PADnote(const PADnoteParameters *parameters, SynthParams pars, const int& interpolation, WatchManager *wm, const char *prefix) @@ -446,3 +448,5 @@ void PADnote::releasekey() NoteGlobalPar.FilterEnvelope->releasekey(); NoteGlobalPar.AmpEnvelope->releasekey(); } + +} diff --git a/src/Synth/PADnote.h b/src/Synth/PADnote.h @@ -18,6 +18,8 @@ #include "Envelope.h" #include "LFO.h" +namespace zyn { + /**The "pad" synthesizer*/ class PADnote:public SynthNote { @@ -100,5 +102,6 @@ class PADnote:public SynthNote const int& interpolation; }; +} #endif diff --git a/src/Synth/Resonance.cpp b/src/Synth/Resonance.cpp @@ -18,12 +18,14 @@ #include <rtosc/ports.h> #include <rtosc/port-sugar.h> +using namespace rtosc; + +namespace zyn { #define rObject Resonance #define rBegin [](const char *msg, RtData &d) { rObject &o = *(rObject*)d.obj - #define rEnd } -using namespace rtosc; + const rtosc::Ports Resonance::ports = { rSelf(Resonance), rPaste, @@ -319,3 +321,5 @@ void Resonance::getfromXML(XMLwrapper& xml) xml.exitbranch(); } } + +} diff --git a/src/Synth/Resonance.h b/src/Synth/Resonance.h @@ -21,6 +21,8 @@ #define N_RES_POINTS 256 +namespace zyn { + class Resonance:public Presets { public: @@ -61,4 +63,6 @@ class Resonance:public Presets static const rtosc::Ports ports; }; +} + #endif diff --git a/src/Synth/SUBnote.cpp b/src/Synth/SUBnote.cpp @@ -32,6 +32,8 @@ # define M_PI 3.14159265358979323846 /* pi */ #endif +namespace zyn { + SUBnote::SUBnote(const SUBnoteParameters *parameters, SynthParams &spars) :SynthNote(spars), pars(*parameters), AmpEnvelope(nullptr), @@ -618,3 +620,5 @@ void SUBnote::entomb(void) { AmpEnvelope->forceFinish(); } + +} diff --git a/src/Synth/SUBnote.h b/src/Synth/SUBnote.h @@ -17,6 +17,8 @@ #include "SynthNote.h" #include "../globals.h" +namespace zyn { + class SUBnote:public SynthNote { public: @@ -104,4 +106,6 @@ class SUBnote:public SynthNote WatchManager *wm; }; +} + #endif diff --git a/src/Synth/SynthNote.cpp b/src/Synth/SynthNote.cpp @@ -15,6 +15,8 @@ #include <new> #include <iostream> +namespace zyn { + SynthNote::SynthNote(SynthParams &pars) :memory(pars.memory), legato(pars.synth, pars.frequency, pars.velocity, pars.portamento, @@ -158,3 +160,5 @@ void SynthNote::setVelocity(float velocity_) { } legato.setDecounter(0); //avoid chopping sound due fade-in } + +} diff --git a/src/Synth/SynthNote.h b/src/Synth/SynthNote.h @@ -14,6 +14,8 @@ #define SYNTH_NOTE_H #include "../globals.h" +namespace zyn { + class Allocator; class Controller; struct SynthParams @@ -111,4 +113,6 @@ class SynthNote WatchManager *wm; }; +} + #endif diff --git a/src/Synth/WatchPoint.cpp b/src/Synth/WatchPoint.cpp @@ -23,6 +23,7 @@ #include <cstring> #include <rtosc/thread-link.h> +namespace zyn { WatchPoint::WatchPoint(WatchManager *ref, const char *prefix, const char *id) :active(false), samples_left(0), reference(ref) @@ -166,3 +167,5 @@ void WatchManager::satisfy(const char *id, float *f, int n) for(int i=0; i<n; ++i) data_list[selected][sample_list[selected]++] = f[i]; } + +} diff --git a/src/Synth/WatchPoint.h b/src/Synth/WatchPoint.h @@ -13,9 +13,12 @@ #pragma once -struct WatchManager; namespace rtosc {class ThreadLink;} +namespace zyn { + +struct WatchManager; + struct WatchPoint { bool active; @@ -79,3 +82,5 @@ struct VecWatchPoint : public WatchPoint } } }; + +} diff --git a/src/UI/Connection.h b/src/UI/Connection.h @@ -14,7 +14,11 @@ //remove the tendrils of the UI from the RT code class Fl_Osc_Interface; -class MiddleWare; +namespace zyn +{ + class MiddleWare; +} + namespace GUI { typedef void *ui_handle_t; @@ -25,5 +29,5 @@ void raiseUi(ui_handle_t, const char *); void raiseUi(ui_handle_t, const char *, const char *, ...); void tickUi(ui_handle_t); -Fl_Osc_Interface *genOscInterface(MiddleWare*); +Fl_Osc_Interface *genOscInterface(zyn::MiddleWare*); }; diff --git a/src/UI/ConnectionDummy.cpp b/src/UI/ConnectionDummy.cpp @@ -29,7 +29,7 @@ void tickUi(ui_handle_t) { usleep(1000); } -Fl_Osc_Interface *genOscInterface(MiddleWare*) +Fl_Osc_Interface *genOscInterface(zyn::MiddleWare*) { return NULL; } diff --git a/src/UI/NSM.C b/src/UI/NSM.C @@ -41,7 +41,7 @@ extern MasterUI *ui; extern NSM_Client *nsm; extern char *instance_name; -NSM_Client::NSM_Client(MiddleWare *m) +NSM_Client::NSM_Client(zyn::MiddleWare *m) :project_filename(0), display_name(0), middleware(m) @@ -71,14 +71,14 @@ NSM_Client::command_open(const char *name, const char *client_id, char **out_msg) { - Nio::stop(); + zyn::Nio::stop(); if(instance_name) free(instance_name); instance_name = strdup(client_id); - Nio::start(); + zyn::Nio::start(); char *new_filename; diff --git a/src/UI/NSM.H b/src/UI/NSM.H @@ -29,9 +29,9 @@ class NSM_Client:public NSM::Client char *project_filename; char *display_name; - MiddleWare *middleware; + zyn::MiddleWare *middleware; - NSM_Client(MiddleWare *m); + NSM_Client(zyn::MiddleWare *m); ~NSM_Client() { } protected: diff --git a/src/globals.cpp b/src/globals.cpp @@ -15,6 +15,8 @@ #include "Misc/Util.h" #include "globals.h" +namespace zyn { + void SYNTH_T::alias(bool randomize) { halfsamplerate_f = (samplerate_f = samplerate) / 2.0f; @@ -32,3 +34,5 @@ void SYNTH_T::alias(bool randomize) else denormalkillbuf[i] = 0; } + +} diff --git a/src/globals.h b/src/globals.h @@ -25,7 +25,18 @@ #endif //Forward Declarations -namespace rtosc{struct Ports; struct ClonePorts; struct MergePorts; class ThreadLink;}; + +#if defined(__APPLE__) || defined(__FreeBSD__) +#include <complex> +#else +namespace std { + template<class T> struct complex; +} +#endif + +namespace rtosc{struct Ports; struct ClonePorts; struct MergePorts; class ThreadLink;} +namespace zyn { + class EffectMgr; class ADnoteParameters; struct ADnoteGlobalParam; @@ -60,14 +71,6 @@ class SVFilter; class FormantFilter; class ModFilter; -#if defined(__APPLE__) || defined(__FreeBSD__) -#include <complex> -#else -namespace std { - template<class T> struct complex; -}; -#endif - typedef double fftw_real; typedef std::complex<fftw_real> fft_t; @@ -336,4 +339,6 @@ struct SYNTH_T { void alias(bool randomize=true); static float numRandom(void); //defined in Util.cpp for now }; + +} #endif diff --git a/src/main.cpp b/src/main.cpp @@ -53,14 +53,22 @@ GUI::ui_handle_t gui; //Glue Layer #include "Misc/MiddleWare.h" -MiddleWare *middleware; using namespace std; +using namespace zyn; + +MiddleWare *middleware; Master *master; int swaplr = 0; //1 for left-right swapping -extern int Pexitprogram; //if the UI set this to 1, the program will exit +// forward declarations of namespace zyn +namespace zyn +{ + extern int Pexitprogram; //if the UI set this to 1, the program will exit + void dump_json(std::ostream &o, + const rtosc::Ports &p); +} #if LASH #include "Misc/LASHClient.h" @@ -435,8 +443,6 @@ int wmidi = -1; if(optarguments) { ofstream outfile(optarguments); - void dump_json(std::ostream &o, - const rtosc::Ports &p); dump_json(outfile, Master::ports); } break; diff --git a/src/version.cpp b/src/version.cpp @@ -15,6 +15,8 @@ #include "zyn-version.h" +namespace zyn { + std::ostream& operator<< (std::ostream& os, const version_type& v) { @@ -30,3 +32,5 @@ static_assert(version_type(2,9,9) < version_type(3,4,3), static_assert(!(version_type(2,4,3) < version_type(2,4,3)), "version operator failed"); +} + diff --git a/src/zyn-version.h.in b/src/zyn-version.h.in @@ -17,6 +17,8 @@ #include <iosfwd> +namespace zyn { + //! class containing a zynaddsubfx version class version_type { @@ -67,5 +69,7 @@ public: //! the current zynaddsubfx version constexpr version_type version; +} + #endif