|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185 |
- /*
- * Carla Native Plugins
- * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * For a full copy of the GNU General Public License see the doc/GPL.txt file.
- */
-
- // for UINT32_MAX
- #define __STDC_LIMIT_MACROS
- #include <cstdint>
-
- #include "CarlaNative.hpp"
- #include "CarlaMIDI.h"
- #include "CarlaString.hpp"
- #include "RtList.hpp"
-
- #include <QtCore/QThread>
-
- #include "zynaddsubfx/Misc/Master.h"
- #include "zynaddsubfx/Misc/Part.h"
- #include "zynaddsubfx/Misc/Util.h"
-
- #include "zynaddsubfx/Effects/Alienwah.h"
- #include "zynaddsubfx/Effects/Chorus.h"
- #include "zynaddsubfx/Effects/Distorsion.h"
- #include "zynaddsubfx/Effects/DynamicFilter.h"
- #include "zynaddsubfx/Effects/Echo.h"
- #include "zynaddsubfx/Effects/Phaser.h"
- #include "zynaddsubfx/Effects/Reverb.h"
-
- #ifdef WANT_ZYNADDSUBFX_UI
- # ifdef override
- # define override_hack
- # undef override
- # endif
-
- # include "zynaddsubfx/UI/common.H"
- # include "zynaddsubfx/UI/MasterUI.h"
- # include <FL/Fl_Shared_Image.H>
- # include <FL/Fl_Tiled_Image.H>
- # include <FL/Fl_Theme.H>
-
- # ifdef override_hack
- # define override
- # undef override_hack
- # endif
- #endif
-
- #include <ctime>
- #include <set>
- #include <string>
-
- // Dummy variables and functions for linking purposes
- const char* instance_name = nullptr;
- class WavFile;
- namespace Nio {
- bool start(void){return 1;}
- void stop(void){}
- bool setSource(std::string){return true;}
- bool setSink(std::string){return true;}
- std::set<std::string> getSources(void){return std::set<std::string>();}
- std::set<std::string> getSinks(void){return std::set<std::string>();}
- std::string getSource(void){return "";}
- std::string getSink(void){return "";}
- void waveNew(WavFile*){}
- void waveStart(void){}
- void waveStop(void){}
- void waveEnd(void){}
- }
-
- SYNTH_T* synth = nullptr;
-
- #ifdef WANT_ZYNADDSUBFX_UI
- #define PIXMAP_PATH "/resources/zynaddsubfx/"
-
- static Fl_Tiled_Image* gModuleBackdrop = nullptr;
- static CarlaString gPixmapPath;
- extern CarlaString gUiPixmapPath;
-
- void set_module_parameters(Fl_Widget* o)
- {
- CARLA_ASSERT(gModuleBackdrop != nullptr);
-
- o->box(FL_DOWN_FRAME);
- o->align(o->align() | FL_ALIGN_IMAGE_BACKDROP);
- o->color(FL_BLACK);
- o->labeltype(FL_SHADOW_LABEL);
-
- if (gModuleBackdrop != nullptr)
- o->image(gModuleBackdrop);
- }
- #endif
-
- // -----------------------------------------------------------------------
-
- class ZynAddSubFxPrograms
- {
- public:
- ZynAddSubFxPrograms()
- : fInitiated(false)
- {
- }
-
- ~ZynAddSubFxPrograms()
- {
- if (! fInitiated)
- return;
-
- for (auto it = fPrograms.begin(); it.valid(); it.next())
- {
- const ProgramInfo*& pInfo(*it);
- delete pInfo;
- }
-
- fPrograms.clear();
- }
-
- void init()
- {
- if (fInitiated)
- return;
- fInitiated = true;
-
- fPrograms.append(new ProgramInfo(0, 0, "default"));
-
- Master& master(Master::getInstance());
-
- pthread_mutex_lock(&master.mutex);
-
- // refresh banks
- master.bank.rescanforbanks();
-
- for (uint32_t i=0, size = master.bank.banks.size(); i < size; ++i)
- {
- if (master.bank.banks[i].dir.empty())
- continue;
-
- master.bank.loadbank(master.bank.banks[i].dir);
-
- for (unsigned int instrument = 0; instrument < BANK_SIZE; ++instrument)
- {
- const std::string insName(master.bank.getname(instrument));
-
- if (insName.empty() || insName[0] == '\0' || insName[0] == ' ')
- continue;
-
- fPrograms.append(new ProgramInfo(i+1, instrument, insName.c_str()));
- }
- }
-
- pthread_mutex_unlock(&master.mutex);
- }
-
- void load(Master* const master, const uint8_t channel, const uint32_t bank, const uint32_t program)
- {
- if (bank == 0)
- {
- pthread_mutex_lock(&master->mutex);
-
- master->partonoff(channel, 1);
- master->part[channel]->defaults();
- master->part[channel]->applyparameters(false);
-
- pthread_mutex_unlock(&master->mutex);
-
- return;
- }
-
- const std::string& bankdir(master->bank.banks[bank-1].dir);
-
- if (! bankdir.empty())
- {
- pthread_mutex_lock(&master->mutex);
-
- master->partonoff(channel, 1);
-
- master->bank.loadbank(bankdir);
- master->bank.loadfromslot(program, master->part[channel]);
-
- master->part[channel]->applyparameters(false);
-
- pthread_mutex_unlock(&master->mutex);
- }
- }
-
- uint32_t count()
- {
- return fPrograms.count();
- }
-
- const MidiProgram* getInfo(const uint32_t index)
- {
- if (index >= fPrograms.count())
- return nullptr;
-
- const ProgramInfo*& pInfo(fPrograms.getAt(index));
-
- fRetProgram.bank = pInfo->bank;
- fRetProgram.program = pInfo->prog;
- fRetProgram.name = pInfo->name;
-
- return &fRetProgram;
- }
-
- private:
- struct ProgramInfo {
- uint32_t bank;
- uint32_t prog;
- const char* name;
-
- ProgramInfo(uint32_t bank_, uint32_t prog_, const char* name_)
- : bank(bank_),
- prog(prog_),
- name(carla_strdup(name_)) {}
-
- ~ProgramInfo()
- {
- if (name != nullptr)
- {
- delete[] name;
- name = nullptr;
- }
- }
-
- #ifdef CARLA_PROPER_CPP11_SUPPORT
- ProgramInfo() = delete;
- ProgramInfo(ProgramInfo&) = delete;
- ProgramInfo(const ProgramInfo&) = delete;
- #endif
- };
-
- bool fInitiated;
- MidiProgram fRetProgram;
- NonRtList<const ProgramInfo*> fPrograms;
-
- CARLA_DECLARE_NON_COPYABLE(ZynAddSubFxPrograms)
- };
-
- static ZynAddSubFxPrograms sPrograms;
-
- // -----------------------------------------------------------------------
-
- class ZynAddSubFxInstanceCount
- {
- public:
- ZynAddSubFxInstanceCount()
- : fCount(0)
- {
- }
-
- ~ZynAddSubFxInstanceCount()
- {
- CARLA_ASSERT(fCount == 0);
- }
-
- void addOne(const HostDescriptor* const host)
- {
- if (fCount++ == 0)
- {
- CARLA_ASSERT(synth == nullptr);
- CARLA_ASSERT(denormalkillbuf == nullptr);
-
- reinit(host);
-
- #ifdef WANT_ZYNADDSUBFX_UI
- if (gPixmapPath.isEmpty())
- {
- gPixmapPath = host->resourceDir;
- gPixmapPath += PIXMAP_PATH;
- gUiPixmapPath = gPixmapPath;
- }
- #endif
- }
- }
-
- void removeOne()
- {
- if (--fCount == 0)
- {
- CARLA_ASSERT(synth != nullptr);
- CARLA_ASSERT(denormalkillbuf != nullptr);
-
- Master::deleteInstance();
-
- delete[] denormalkillbuf;
- denormalkillbuf = nullptr;
-
- delete synth;
- synth = nullptr;
- }
- }
-
- void reinit(const HostDescriptor* const host)
- {
- Master::deleteInstance();
-
- if (denormalkillbuf != nullptr)
- {
- delete[] denormalkillbuf;
- denormalkillbuf = nullptr;
- }
-
- if (synth != nullptr)
- {
- delete synth;
- synth = nullptr;
- }
-
- synth = new SYNTH_T();
- synth->buffersize = host->get_buffer_size(host->handle);
- synth->samplerate = host->get_sample_rate(host->handle);
- synth->alias();
-
- config.init();
- config.cfg.SoundBufferSize = synth->buffersize;
- config.cfg.SampleRate = synth->samplerate;
- config.cfg.GzipCompression = 0;
-
- sprng(std::time(nullptr));
-
- denormalkillbuf = new float[synth->buffersize];
- for (int i=0; i < synth->buffersize; ++i)
- denormalkillbuf[i] = (RND - 0.5f) * 1e-16;
-
- Master::getInstance();
- }
-
- void maybeReinit(const HostDescriptor* const host)
- {
- if (host->get_buffer_size(host->handle) == static_cast<uint32_t>(synth->buffersize) &&
- host->get_sample_rate(host->handle) == static_cast<double>(synth->samplerate))
- return;
-
- reinit(host);
- }
-
- private:
- int fCount;
-
- CARLA_DECLARE_NON_COPYABLE(ZynAddSubFxInstanceCount)
- };
-
- static ZynAddSubFxInstanceCount sInstanceCount;
-
- // -----------------------------------------------------------------------
-
- class ZynAddSubFxThread : public QThread
- {
- public:
- ZynAddSubFxThread(Master* const master, const HostDescriptor* const host)
- : fMaster(master),
- kHost(host),
- #ifdef WANT_ZYNADDSUBFX_UI
- fUi(nullptr),
- fUiClosed(0),
- fNextUiAction(-1),
- #endif
- fQuit(false),
- fChangeProgram(false),
- fNextChannel(0),
- fNextBank(0),
- fNextProgram(0)
- {
- }
-
- ~ZynAddSubFxThread()
- {
- // must be closed by now
- #ifdef WANT_ZYNADDSUBFX_UI
- CARLA_ASSERT(fUi == nullptr);
- #endif
- CARLA_ASSERT(fQuit);
- }
-
- void loadProgramLater(const uint8_t channel, const uint32_t bank, const uint32_t program)
- {
- fNextChannel = channel;
- fNextBank = bank;
- fNextProgram = program;
- fChangeProgram = true;
- }
-
- void stopLoadProgramLater()
- {
- fChangeProgram = false;
- fNextChannel = 0;
- fNextBank = 0;
- fNextProgram = 0;
- }
-
- void setMaster(Master* const master)
- {
- fMaster = master;
- }
-
- void stop()
- {
- fQuit = true;
- quit();
- }
-
- #ifdef WANT_ZYNADDSUBFX_UI
- void uiHide()
- {
- fNextUiAction = 0;
- }
-
- void uiShow()
- {
- fNextUiAction = 1;
- }
-
- void uiRepaint()
- {
- if (fUi != nullptr)
- fNextUiAction = 2;
- }
- #endif
-
- protected:
- void run() override
- {
- while (! fQuit)
- {
- #ifdef WANT_ZYNADDSUBFX_UI
- Fl::lock();
-
- if (fNextUiAction == 2) // repaint
- {
- CARLA_ASSERT(fUi != nullptr);
-
- if (fUi != nullptr)
- fUi->refresh_master_ui();
- }
- else if (fNextUiAction == 1) // init/show
- {
- static bool initialized = false;
-
- if (! initialized)
- {
- initialized = true;
- fl_register_images();
-
- Fl_Dial::default_style(Fl_Dial::PIXMAP_DIAL);
-
- if (Fl_Shared_Image* const img = Fl_Shared_Image::get(gPixmapPath + "knob.png"))
- Fl_Dial::default_image(img);
-
- if (Fl_Shared_Image* const img = Fl_Shared_Image::get(gPixmapPath + "window_backdrop.png"))
- Fl::scheme_bg(new Fl_Tiled_Image(img));
-
- if(Fl_Shared_Image* const img = Fl_Shared_Image::get(gPixmapPath + "module_backdrop.png"))
- gModuleBackdrop = new Fl_Tiled_Image(img);
-
- Fl::background(50, 50, 50);
- Fl::background2(70, 70, 70);
- Fl::foreground(255, 255, 255);
-
- Fl_Theme::set("Cairo");
- }
-
- CARLA_ASSERT(fUi == nullptr);
-
- if (fUi == nullptr)
- {
- fUiClosed = 0;
- fUi = new MasterUI(fMaster, &fUiClosed);
- fUi->masterwindow->label(kHost->uiName);
- fUi->showUI();
- }
- }
- else if (fNextUiAction == 0) // close
- {
- CARLA_ASSERT(fUi != nullptr);
-
- if (fUi != nullptr)
- {
- delete fUi;
- fUi = nullptr;
- }
- }
-
- fNextUiAction = -1;
-
- if (fUiClosed != 0)
- {
- fUiClosed = 0;
- fNextUiAction = 0;
- kHost->ui_closed(kHost->handle);
- }
-
- Fl::check();
- Fl::unlock();
- #endif
-
- if (fChangeProgram)
- {
- fChangeProgram = false;
- sPrograms.load(fMaster, fNextChannel, fNextBank, fNextProgram);
- fNextChannel = 0;
- fNextBank = 0;
- fNextProgram = 0;
-
- #ifdef WANT_ZYNADDSUBFX_UI
- if (fUi != nullptr)
- {
- Fl::lock();
- fUi->refresh_master_ui();
- Fl::unlock();
- }
- #endif
-
- carla_msleep(15);
- }
- else
- {
- carla_msleep(30);
- }
- }
-
- #ifdef WANT_ZYNADDSUBFX_UI
- if (fQuit && fUi != nullptr)
- {
- Fl::lock();
- delete fUi;
- fUi = nullptr;
- Fl::check();
- Fl::unlock();
- }
- #endif
- }
-
- private:
- Master* fMaster;
- const HostDescriptor* const kHost;
-
- #ifdef WANT_ZYNADDSUBFX_UI
- MasterUI* fUi;
- int fUiClosed;
- int fNextUiAction;
- #endif
-
- bool fQuit;
- bool fChangeProgram;
- uint8_t fNextChannel;
- uint32_t fNextBank;
- uint32_t fNextProgram;
- };
-
- // -----------------------------------------------------------------------
-
- #define ZynPluginDescriptorClassEND(ClassName) \
- public: \
- static PluginHandle _instantiate(HostDescriptor* host) \
- { \
- sInstanceCount.addOne(host); \
- return new ClassName(host); \
- } \
- static void _cleanup(PluginHandle handle) \
- { \
- delete (ClassName*)handle; \
- sInstanceCount.removeOne(); \
- }
-
- // -----------------------------------------------------------------------
-
- class FxAbstractPlugin : public PluginDescriptorClass
- {
- protected:
- FxAbstractPlugin(const HostDescriptor* const host, const uint32_t paramCount, const uint32_t programCount)
- : PluginDescriptorClass(host),
- fEffect(nullptr),
- efxoutl(new float[synth->buffersize]),
- efxoutr(new float[synth->buffersize]),
- fFirstInit(true),
- kParamCount(paramCount-2), // volume and pan handled by host
- kProgramCount(programCount)
- {
- carla_zeroFloat(efxoutl, synth->buffersize);
- carla_zeroFloat(efxoutr, synth->buffersize);
- }
-
- ~FxAbstractPlugin() override
- {
- CARLA_ASSERT(fEffect != nullptr);
-
- if (efxoutl != nullptr)
- {
- delete[] efxoutl;
- efxoutl = nullptr;
- }
-
- if (efxoutr != nullptr)
- {
- delete[] efxoutr;
- efxoutr = nullptr;
- }
-
- if (fEffect != nullptr)
- {
- delete fEffect;
- fEffect = nullptr;
- }
- }
-
- // -------------------------------------------------------------------
- // Plugin parameter calls
-
- uint32_t getParameterCount() final
- {
- return kParamCount;
- }
-
- float getParameterValue(const uint32_t index) final
- {
- return fEffect->getpar(index+2);
- }
-
- // -------------------------------------------------------------------
- // Plugin midi-program calls
-
- uint32_t getMidiProgramCount() final
- {
- return kProgramCount;
- }
-
- // -------------------------------------------------------------------
- // Plugin state calls
-
- void setParameterValue(const uint32_t index, const float value) final
- {
- fEffect->changepar(index+2, value);
- fFirstInit = false;
- }
-
- void setMidiProgram(const uint8_t, const uint32_t, const uint32_t program) final
- {
- fEffect->setpreset(program);
-
- const float volume(float(fEffect->getpar(0))/127.0f);
- hostDispatcher(HOST_OPCODE_SET_VOLUME, 0, 0, nullptr, volume);
-
- const unsigned char pan(fEffect->getpar(1));
- const float panning(float(pan)/63.5f-1.0f);
- hostDispatcher(HOST_OPCODE_SET_PANNING, 0, 0, nullptr, (pan == 64) ? 0.0f : panning);
-
- fEffect->changepar(0, 127);
- fEffect->changepar(1, 64);
- }
-
- // -------------------------------------------------------------------
- // Plugin process calls
-
- void activate() final
- {
- fEffect->cleanup();
-
- if (fFirstInit)
- {
- fFirstInit = false;
- hostDispatcher(HOST_OPCODE_SET_DRYWET, 0, 0, nullptr, 0.5f);
- }
- }
-
- void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const uint32_t, const MidiEvent* const) final
- {
- CARLA_ASSERT(synth->buffersize == static_cast<int>(frames));
-
- fEffect->out(Stereo<float*>(inBuffer[0], inBuffer[1]));
-
- carla_copyFloat(outBuffer[0], efxoutl, frames);
- carla_copyFloat(outBuffer[1], efxoutr, frames);
- }
-
- // -------------------------------------------------------------------
- // Plugin dispatcher
-
- intptr_t pluginDispatcher(const PluginDispatcherOpcode opcode, const int32_t, const intptr_t, void* const, const float) final
- {
- switch (opcode)
- {
- case PLUGIN_OPCODE_BUFFER_SIZE_CHANGED:
- {
- const uint32_t bufferSize(getBufferSize());
- delete[] efxoutl;
- delete[] efxoutr;
- efxoutl = new float[bufferSize];
- efxoutr = new float[bufferSize];
- carla_zeroFloat(efxoutl, synth->buffersize);
- carla_zeroFloat(efxoutr, synth->buffersize);
- *((float**)&fEffect->efxoutl) = efxoutl;
- *((float**)&fEffect->efxoutr) = efxoutr;
- // no break
- }
- case PLUGIN_OPCODE_SAMPLE_RATE_CHANGED:
- sInstanceCount.maybeReinit(getHostHandle());
- break;
- default:
- break;
- }
-
- return 0;
- }
-
- Effect* fEffect;
- float* efxoutl;
- float* efxoutr;
- bool fFirstInit;
- const uint32_t kParamCount;
- const uint32_t kProgramCount;
- };
-
- // -----------------------------------------------------------------------
-
- class FxAlienWahPlugin : public FxAbstractPlugin
- {
- public:
- FxAlienWahPlugin(const HostDescriptor* const host)
- : FxAbstractPlugin(host, 11, 4)
- {
- fEffect = new Alienwah(false, efxoutl, efxoutr);
- }
-
- protected:
- // -------------------------------------------------------------------
- // Plugin parameter calls
-
- const Parameter* getParameterInfo(const uint32_t index) override
- {
- if (index >= kParamCount)
- return nullptr;
-
- static Parameter param;
- static ParameterScalePoint scalePoints[2];
-
- int hints = PARAMETER_IS_ENABLED|PARAMETER_IS_INTEGER;
-
- param.name = nullptr;
- param.unit = nullptr;
- param.ranges.def = 1.0f;
- param.ranges.min = 0.0f;
- param.ranges.max = 127.0f;
- param.ranges.step = 1.0f;
- param.ranges.stepSmall = 1.0f;
- param.ranges.stepLarge = 20.0f;
- param.scalePointCount = 0;
- param.scalePoints = nullptr;
-
- switch (index)
- {
- case 0:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "LFO Frequency";
- param.ranges.def = 70.0f;
- break;
- case 1:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "LFO Randomness";
- param.ranges.def = 0.0f;
- break;
- case 2:
- hints |= PARAMETER_IS_AUTOMABLE|PARAMETER_IS_BOOLEAN|PARAMETER_USES_SCALEPOINTS;
- param.name = "LFO Type";
- param.ranges.def = 0.0f;
- param.ranges.max = 1.0f;
- param.scalePointCount = 2;
- param.scalePoints = scalePoints;
- scalePoints[0].label = "Sine";
- scalePoints[1].label = "Triangle";
- scalePoints[0].value = 0.0f;
- scalePoints[1].value = 1.0f;
- break;
- case 3:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "LFO Stereo";
- param.ranges.def = 62.0f;
- break;
- case 4:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Depth";
- param.ranges.def = 60.0f;
- break;
- case 5:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Feedback";
- param.ranges.def = 105.0f;
- break;
- case 6:
- param.name = "Delay";
- param.ranges.def = 25.0f;
- param.ranges.min = 1.0f;
- param.ranges.max = 100.0f;
- break;
- case 7:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "L/R Cross";
- param.ranges.def = 0.0f;
- break;
- case 8:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Phase";
- param.ranges.def = 64.0f;
- break;
- }
-
- param.hints = static_cast<ParameterHints>(hints);
-
- return ¶m;
- }
-
- // -------------------------------------------------------------------
- // Plugin midi-program calls
-
- const MidiProgram* getMidiProgramInfo(const uint32_t index) override
- {
- if (index >= kProgramCount)
- return nullptr;
-
- static MidiProgram midiProg;
-
- midiProg.bank = 0;
- midiProg.program = index;
-
- switch (index)
- {
- case 0:
- midiProg.name = "AlienWah1";
- break;
- case 1:
- midiProg.name = "AlienWah2";
- break;
- case 2:
- midiProg.name = "AlienWah3";
- break;
- case 3:
- midiProg.name = "AlienWah4";
- break;
- default:
- midiProg.name = nullptr;
- break;
- }
-
- return &midiProg;
- }
-
- ZynPluginDescriptorClassEND(FxAlienWahPlugin)
- CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FxAlienWahPlugin)
- };
-
- // -----------------------------------------------------------------------
-
- class FxChorusPlugin : public FxAbstractPlugin
- {
- public:
- FxChorusPlugin(const HostDescriptor* const host)
- : FxAbstractPlugin(host, 12, 10)
- {
- fEffect = new Chorus(false, efxoutl, efxoutr);
- }
-
- protected:
- // -------------------------------------------------------------------
- // Plugin parameter calls
-
- const Parameter* getParameterInfo(const uint32_t index) override
- {
- if (index >= kParamCount)
- return nullptr;
-
- static Parameter param;
- static ParameterScalePoint scalePoints[2];
-
- int hints = PARAMETER_IS_ENABLED|PARAMETER_IS_INTEGER;
-
- param.name = nullptr;
- param.unit = nullptr;
- param.ranges.def = 1.0f;
- param.ranges.min = 0.0f;
- param.ranges.max = 127.0f;
- param.ranges.step = 1.0f;
- param.ranges.stepSmall = 1.0f;
- param.ranges.stepLarge = 20.0f;
- param.scalePointCount = 0;
- param.scalePoints = nullptr;
-
- switch (index)
- {
- case 0:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "LFO Frequency";
- param.ranges.def = 50.0f;
- break;
- case 1:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "LFO Randomness";
- param.ranges.def = 0.0f;
- break;
- case 2:
- hints |= PARAMETER_IS_AUTOMABLE|PARAMETER_IS_BOOLEAN|PARAMETER_USES_SCALEPOINTS;
- param.name = "LFO Type";
- param.ranges.def = 0.0f;
- param.ranges.max = 1.0f;
- param.scalePointCount = 2;
- param.scalePoints = scalePoints;
- scalePoints[0].label = "Sine";
- scalePoints[1].label = "Triangle";
- scalePoints[0].value = 0.0f;
- scalePoints[1].value = 1.0f;
- break;
- case 3:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "LFO Stereo";
- param.ranges.def = 90.0f;
- break;
- case 4:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Depth";
- param.ranges.def = 40.0f;
- break;
- case 5:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Delay";
- param.ranges.def = 85.0f;
- break;
- case 6:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Feedback";
- param.ranges.def = 64.0f;
- break;
- case 7:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "L/R Cross";
- param.ranges.def = 119.0f;
- break;
- case 8:
- hints |= PARAMETER_IS_AUTOMABLE|PARAMETER_IS_BOOLEAN;
- param.name = "Flange Mode";
- param.ranges.def = 0.0f;
- param.ranges.max = 1.0f;
- break;
- case 9:
- hints |= PARAMETER_IS_AUTOMABLE|PARAMETER_IS_BOOLEAN;
- param.name = "Subtract Output";
- param.ranges.def = 0.0f;
- param.ranges.max = 1.0f;
- break;
- }
-
- param.hints = static_cast<ParameterHints>(hints);
-
- return ¶m;
- }
-
- // -------------------------------------------------------------------
- // Plugin midi-program calls
-
- const MidiProgram* getMidiProgramInfo(const uint32_t index) override
- {
- if (index >= kProgramCount)
- return nullptr;
-
- static MidiProgram midiProg;
-
- midiProg.bank = 0;
- midiProg.program = index;
-
- switch (index)
- {
- case 0:
- midiProg.name = "Chorus1";
- break;
- case 1:
- midiProg.name = "Chorus2";
- break;
- case 2:
- midiProg.name = "Chorus3";
- break;
- case 3:
- midiProg.name = "Celeste1";
- break;
- case 4:
- midiProg.name = "Celeste2";
- break;
- case 5:
- midiProg.name = "Flange1";
- break;
- case 6:
- midiProg.name = "Flange2";
- break;
- case 7:
- midiProg.name = "Flange3";
- break;
- case 8:
- midiProg.name = "Flange4";
- break;
- case 9:
- midiProg.name = "Flange5";
- break;
- default:
- midiProg.name = nullptr;
- break;
- }
-
- return &midiProg;
- }
-
- ZynPluginDescriptorClassEND(FxChorusPlugin)
- CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FxChorusPlugin)
- };
-
- // -----------------------------------------------------------------------
-
- class FxDistortionPlugin : public FxAbstractPlugin
- {
- public:
- FxDistortionPlugin(const HostDescriptor* const host)
- : FxAbstractPlugin(host, 11, 6)
- {
- fEffect = new Distorsion(false, efxoutl, efxoutr);
- }
-
- protected:
- // -------------------------------------------------------------------
- // Plugin parameter calls
-
- const Parameter* getParameterInfo(const uint32_t index) override
- {
- if (index >= kParamCount)
- return nullptr;
-
- static Parameter param;
- static ParameterScalePoint scalePoints[14];
-
- int hints = PARAMETER_IS_ENABLED|PARAMETER_IS_INTEGER;
-
- param.name = nullptr;
- param.unit = nullptr;
- param.ranges.def = 1.0f;
- param.ranges.min = 0.0f;
- param.ranges.max = 127.0f;
- param.ranges.step = 1.0f;
- param.ranges.stepSmall = 1.0f;
- param.ranges.stepLarge = 20.0f;
- param.scalePointCount = 0;
- param.scalePoints = nullptr;
-
- switch (index)
- {
- case 0:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "L/R Cross";
- param.ranges.def = 35.0f;
- break;
- case 1:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Drive";
- param.ranges.def = 56.0f;
- break;
- case 2:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Level";
- param.ranges.def = 70.0f;
- break;
- case 3:
- hints |= PARAMETER_IS_AUTOMABLE|PARAMETER_USES_SCALEPOINTS;
- param.name = "Type";
- param.ranges.def = 0.0f;
- param.ranges.max = 13.0f;
- param.scalePointCount = 14;
- param.scalePoints = scalePoints;
- scalePoints[ 0].label = "Arctangent";
- scalePoints[ 1].label = "Asymmetric";
- scalePoints[ 2].label = "Pow";
- scalePoints[ 3].label = "Sine";
- scalePoints[ 4].label = "Quantisize";
- scalePoints[ 5].label = "Zigzag";
- scalePoints[ 6].label = "Limiter";
- scalePoints[ 7].label = "Upper Limiter";
- scalePoints[ 8].label = "Lower Limiter";
- scalePoints[ 9].label = "Inverse Limiter";
- scalePoints[10].label = "Clip";
- scalePoints[11].label = "Asym2";
- scalePoints[12].label = "Pow2";
- scalePoints[13].label = "Sigmoid";
- scalePoints[ 0].value = 0.0f;
- scalePoints[ 1].value = 1.0f;
- scalePoints[ 2].value = 2.0f;
- scalePoints[ 3].value = 3.0f;
- scalePoints[ 4].value = 4.0f;
- scalePoints[ 5].value = 5.0f;
- scalePoints[ 6].value = 6.0f;
- scalePoints[ 7].value = 7.0f;
- scalePoints[ 8].value = 8.0f;
- scalePoints[ 9].value = 9.0f;
- scalePoints[10].value = 10.0f;
- scalePoints[11].value = 11.0f;
- scalePoints[12].value = 12.0f;
- scalePoints[13].value = 13.0f;
- break;
- case 4:
- hints |= PARAMETER_IS_AUTOMABLE|PARAMETER_IS_BOOLEAN;
- param.name = "Negate";
- param.ranges.def = 0.0f;
- param.ranges.max = 1.0f;
- break;
- case 5:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Low-Pass Filter";
- param.ranges.def = 96.0f;
- break;
- case 6:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "High-Pass Filter";
- param.ranges.def = 0.0f;
- break;
- case 7:
- hints |= PARAMETER_IS_AUTOMABLE|PARAMETER_IS_BOOLEAN;
- param.name = "Stereo";
- param.ranges.def = 0.0f;
- param.ranges.max = 1.0f;
- break;
- case 8:
- hints |= PARAMETER_IS_AUTOMABLE|PARAMETER_IS_BOOLEAN;
- param.name = "Pre-Filtering";
- param.ranges.def = 0.0f;
- param.ranges.max = 1.0f;
- break;
- }
-
- param.hints = static_cast<ParameterHints>(hints);
-
- return ¶m;
- }
-
- // -------------------------------------------------------------------
- // Plugin midi-program calls
-
- const MidiProgram* getMidiProgramInfo(const uint32_t index) override
- {
- if (index >= kProgramCount)
- return nullptr;
-
- static MidiProgram midiProg;
-
- midiProg.bank = 0;
- midiProg.program = index;
-
- switch (index)
- {
- case 0:
- midiProg.name = "Overdrive 1";
- break;
- case 1:
- midiProg.name = "Overdrive 2";
- break;
- case 2:
- midiProg.name = "A. Exciter 1";
- break;
- case 3:
- midiProg.name = "A. Exciter 2";
- break;
- case 4:
- midiProg.name = "Guitar Amp";
- break;
- case 5:
- midiProg.name = "Quantisize";
- break;
- default:
- midiProg.name = nullptr;
- break;
- }
-
- return &midiProg;
- }
-
- ZynPluginDescriptorClassEND(FxDistortionPlugin)
- CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FxDistortionPlugin)
- };
-
- // -----------------------------------------------------------------------
-
- class FxDynamicFilterPlugin : public FxAbstractPlugin
- {
- public:
- FxDynamicFilterPlugin(const HostDescriptor* const host)
- : FxAbstractPlugin(host, 10, 5)
- {
- fEffect = new DynamicFilter(false, efxoutl, efxoutr);
- }
-
- protected:
- // -------------------------------------------------------------------
- // Plugin parameter calls
-
- const Parameter* getParameterInfo(const uint32_t index) override
- {
- if (index >= kParamCount)
- return nullptr;
-
- static Parameter param;
- static ParameterScalePoint scalePoints[2];
-
- int hints = PARAMETER_IS_ENABLED|PARAMETER_IS_INTEGER;
-
- param.name = nullptr;
- param.unit = nullptr;
- param.ranges.def = 1.0f;
- param.ranges.min = 0.0f;
- param.ranges.max = 127.0f;
- param.ranges.step = 1.0f;
- param.ranges.stepSmall = 1.0f;
- param.ranges.stepLarge = 20.0f;
- param.scalePointCount = 0;
- param.scalePoints = nullptr;
-
- switch (index)
- {
- case 0:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "LFO Frequency";
- param.ranges.def = 80.0f;
- break;
- case 1:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "LFO Randomness";
- param.ranges.def = 0.0f;
- break;
- case 2:
- hints |= PARAMETER_IS_AUTOMABLE|PARAMETER_IS_BOOLEAN|PARAMETER_USES_SCALEPOINTS;
- param.name = "LFO Type";
- param.ranges.def = 0.0f;
- param.ranges.max = 1.0f;
- param.scalePointCount = 2;
- param.scalePoints = scalePoints;
- scalePoints[0].label = "Sine";
- scalePoints[1].label = "Triangle";
- scalePoints[0].value = 0.0f;
- scalePoints[1].value = 1.0f;
- break;
- case 3:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "LFO Stereo";
- param.ranges.def = 64.0f;
- break;
- case 4:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "LFO Depth";
- param.ranges.def = 0.0f;
- break;
- case 5:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Amp sns";
- param.ranges.def = 90.0f;
- break;
- case 6:
- hints |= PARAMETER_IS_AUTOMABLE|PARAMETER_IS_BOOLEAN;
- param.name = "Amp sns inv";
- param.ranges.def = 0.0f;
- param.ranges.max = 1.0f;
- break;
- case 7:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Amp Smooth";
- param.ranges.def = 60.0f;
- break;
- }
-
- param.hints = static_cast<ParameterHints>(hints);
-
- return ¶m;
- }
-
- // -------------------------------------------------------------------
- // Plugin midi-program calls
-
- const MidiProgram* getMidiProgramInfo(const uint32_t index) override
- {
- if (index >= kProgramCount)
- return nullptr;
-
- static MidiProgram midiProg;
-
- midiProg.bank = 0;
- midiProg.program = index;
-
- switch (index)
- {
- case 0:
- midiProg.name = "WahWah";
- break;
- case 1:
- midiProg.name = "AutoWah";
- break;
- case 2:
- midiProg.name = "Sweep";
- break;
- case 3:
- midiProg.name = "VocalMorph1";
- break;
- case 4:
- midiProg.name = "VocalMorph2";
- break;
- default:
- midiProg.name = nullptr;
- break;
- }
-
- return &midiProg;
- }
-
- ZynPluginDescriptorClassEND(FxDynamicFilterPlugin)
- CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FxDynamicFilterPlugin)
- };
-
- // -----------------------------------------------------------------------
-
- class FxEchoPlugin : public FxAbstractPlugin
- {
- public:
- FxEchoPlugin(const HostDescriptor* const host)
- : FxAbstractPlugin(host, 7, 9)
- {
- fEffect = new Echo(false, efxoutl, efxoutr);
- }
-
- protected:
- // -------------------------------------------------------------------
- // Plugin parameter calls
-
- const Parameter* getParameterInfo(const uint32_t index) override
- {
- if (index >= kParamCount)
- return nullptr;
-
- static Parameter param;
-
- int hints = PARAMETER_IS_ENABLED|PARAMETER_IS_INTEGER;
-
- param.name = nullptr;
- param.unit = nullptr;
- param.ranges.def = 1.0f;
- param.ranges.min = 0.0f;
- param.ranges.max = 127.0f;
- param.ranges.step = 1.0f;
- param.ranges.stepSmall = 1.0f;
- param.ranges.stepLarge = 20.0f;
- param.scalePointCount = 0;
- param.scalePoints = nullptr;
-
- switch (index)
- {
- case 0:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Delay";
- param.ranges.def = 35.0f;
- break;
- case 1:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "L/R Delay";
- param.ranges.def = 64.0f;
- break;
- case 2:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "L/R Cross";
- param.ranges.def = 30.0f;
- break;
- case 3:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Feedback";
- param.ranges.def = 59.0f;
- break;
- case 4:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "High Damp";
- param.ranges.def = 0.0f;
- break;
- }
-
- param.hints = static_cast<ParameterHints>(hints);
-
- return ¶m;
- }
-
- // -------------------------------------------------------------------
- // Plugin midi-program calls
-
- const MidiProgram* getMidiProgramInfo(const uint32_t index) override
- {
- if (index >= kProgramCount)
- return nullptr;
-
- static MidiProgram midiProg;
-
- midiProg.bank = 0;
- midiProg.program = index;
-
- switch (index)
- {
- case 0:
- midiProg.name = "Echo 1";
- break;
- case 1:
- midiProg.name = "Echo 2";
- break;
- case 2:
- midiProg.name = "Echo 3";
- break;
- case 3:
- midiProg.name = "Simple Echo";
- break;
- case 4:
- midiProg.name = "Canyon";
- break;
- case 5:
- midiProg.name = "Panning Echo 1";
- break;
- case 6:
- midiProg.name = "Panning Echo 2";
- break;
- case 7:
- midiProg.name = "Panning Echo 3";
- break;
- case 8:
- midiProg.name = "Feedback Echo";
- break;
- default:
- midiProg.name = nullptr;
- break;
- }
-
- return &midiProg;
- }
-
- ZynPluginDescriptorClassEND(FxEchoPlugin)
- CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FxEchoPlugin)
- };
-
- // -----------------------------------------------------------------------
-
- class FxPhaserPlugin : public FxAbstractPlugin
- {
- public:
- FxPhaserPlugin(const HostDescriptor* const host)
- : FxAbstractPlugin(host, 15, 12)
- {
- fEffect = new Phaser(false, efxoutl, efxoutr);
- }
-
- protected:
- // -------------------------------------------------------------------
- // Plugin parameter calls
-
- const Parameter* getParameterInfo(const uint32_t index) override
- {
- if (index >= kParamCount)
- return nullptr;
-
- static Parameter param;
- static ParameterScalePoint scalePoints[2];
-
- int hints = PARAMETER_IS_ENABLED|PARAMETER_IS_INTEGER;
-
- param.name = nullptr;
- param.unit = nullptr;
- param.ranges.def = 1.0f;
- param.ranges.min = 0.0f;
- param.ranges.max = 127.0f;
- param.ranges.step = 1.0f;
- param.ranges.stepSmall = 1.0f;
- param.ranges.stepLarge = 20.0f;
- param.scalePointCount = 0;
- param.scalePoints = nullptr;
-
- switch (index)
- {
- case 0:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "LFO Frequency";
- param.ranges.def = 36.0f;
- break;
- case 1:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "LFO Randomness";
- param.ranges.def = 0.0f;
- break;
- case 2:
- hints |= PARAMETER_IS_AUTOMABLE|PARAMETER_IS_BOOLEAN|PARAMETER_USES_SCALEPOINTS;
- param.name = "LFO Type";
- param.ranges.def = 0.0f;
- param.ranges.max = 1.0f;
- param.scalePointCount = 2;
- param.scalePoints = scalePoints;
- scalePoints[0].label = "Sine";
- scalePoints[1].label = "Triangle";
- scalePoints[0].value = 0.0f;
- scalePoints[1].value = 1.0f;
- break;
- case 3:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "LFO Stereo";
- param.ranges.def = 64.0f;
- break;
- case 4:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Depth";
- param.ranges.def = 110.0f;
- break;
- case 5:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Feedback";
- param.ranges.def = 64.0f;
- break;
- case 6:
- param.name = "Stages";
- param.ranges.def = 1.0f;
- param.ranges.min = 1.0f;
- param.ranges.max = 12.0f;
- break;
- case 7:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "L/R Cross|Offset";
- param.ranges.def = 0.0f;
- break;
- case 8:
- hints |= PARAMETER_IS_AUTOMABLE|PARAMETER_IS_BOOLEAN;
- param.name = "Subtract Output";
- param.ranges.def = 0.0f;
- param.ranges.max = 1.0f;
- break;
- case 9:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Phase|Width";
- param.ranges.def = 20.0f;
- break;
- case 10:
- hints |= PARAMETER_IS_AUTOMABLE|PARAMETER_IS_BOOLEAN;
- param.name = "Hyper";
- param.ranges.def = 0.0f;
- param.ranges.max = 1.0f;
- break;
- case 11:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Distortion";
- param.ranges.def = 0.0f;
- break;
- case 12:
- hints |= PARAMETER_IS_AUTOMABLE|PARAMETER_IS_BOOLEAN;
- param.name = "Analog";
- param.ranges.def = 0.0f;
- param.ranges.max = 1.0f;
- break;
- }
-
- param.hints = static_cast<ParameterHints>(hints);
-
- return ¶m;
- }
-
- // -------------------------------------------------------------------
- // Plugin midi-program calls
-
- const MidiProgram* getMidiProgramInfo(const uint32_t index) override
- {
- if (index >= kProgramCount)
- return nullptr;
-
- static MidiProgram midiProg;
-
- midiProg.bank = 0;
- midiProg.program = index;
-
- switch (index)
- {
- case 0:
- midiProg.name = "Phaser 1";
- break;
- case 1:
- midiProg.name = "Phaser 2";
- break;
- case 2:
- midiProg.name = "Phaser 3";
- break;
- case 3:
- midiProg.name = "Phaser 4";
- break;
- case 4:
- midiProg.name = "Phaser 5";
- break;
- case 5:
- midiProg.name = "Phaser 6";
- break;
- case 6:
- midiProg.name = "APhaser 1";
- break;
- case 7:
- midiProg.name = "APhaser 2";
- break;
- case 8:
- midiProg.name = "APhaser 3";
- break;
- case 9:
- midiProg.name = "APhaser 4";
- break;
- case 10:
- midiProg.name = "APhaser 5";
- break;
- case 11:
- midiProg.name = "APhaser 6";
- break;
- default:
- midiProg.name = nullptr;
- break;
- }
-
- return &midiProg;
- }
-
- ZynPluginDescriptorClassEND(FxPhaserPlugin)
- CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FxPhaserPlugin)
- };
-
- // -----------------------------------------------------------------------
-
- class FxReverbPlugin : public FxAbstractPlugin
- {
- public:
- FxReverbPlugin(const HostDescriptor* const host)
- : FxAbstractPlugin(host, 13, 13)
- {
- fEffect = new Reverb(false, efxoutl, efxoutr);
- }
-
- protected:
- // -------------------------------------------------------------------
- // Plugin parameter calls
-
- const Parameter* getParameterInfo(const uint32_t index) override
- {
- if (index >= kParamCount)
- return nullptr;
-
- static Parameter param;
- static ParameterScalePoint scalePoints[3];
-
- int hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER;
-
- param.name = nullptr;
- param.unit = nullptr;
- param.ranges.def = 1.0f;
- param.ranges.min = 0.0f;
- param.ranges.max = 127.0f;
- param.ranges.step = 1.0f;
- param.ranges.stepSmall = 1.0f;
- param.ranges.stepLarge = 20.0f;
- param.scalePointCount = 0;
- param.scalePoints = nullptr;
-
- switch (index)
- {
- case 0:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Time";
- param.ranges.def = 63.0f;
- break;
- case 1:
- param.name = "Delay";
- param.ranges.def = 24.0f;
- break;
- case 2:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Feedback";
- param.ranges.def = 0.0f;
- break;
- case 3:
- hints = 0x0;
- param.name = "bw";
- break;
- case 4:
- hints = 0x0;
- param.name = "E/R";
- break;
- case 5:
- param.name = "Low-Pass Filter";
- param.ranges.def = 85.0f;
- break;
- case 6:
- param.name = "High-Pass Filter";
- param.ranges.def = 5.0f;
- break;
- case 7:
- hints |= PARAMETER_IS_AUTOMABLE;
- param.name = "Damp";
- param.ranges.def = 83.0f;
- param.ranges.min = 64.0f;
- break;
- case 8:
- hints |= PARAMETER_USES_SCALEPOINTS;
- param.name = "Type";
- param.ranges.def = 1.0f;
- param.ranges.max = 2.0f;
- param.scalePointCount = 3;
- param.scalePoints = scalePoints;
- scalePoints[0].label = "Random";
- scalePoints[1].label = "Freeverb";
- scalePoints[2].label = "Bandwidth";
- scalePoints[0].value = 0.0f;
- scalePoints[1].value = 1.0f;
- scalePoints[2].value = 2.0f;
- break;
- case 9:
- param.name = "Room size";
- param.ranges.def = 64.0f;
- param.ranges.min = 1.0f;
- break;
- case 10:
- param.name = "Bandwidth";
- param.ranges.def = 20.0f;
- break;
- }
-
- param.hints = static_cast<ParameterHints>(hints);
-
- return ¶m;
- }
-
- // -------------------------------------------------------------------
- // Plugin midi-program calls
-
- const MidiProgram* getMidiProgramInfo(const uint32_t index) override
- {
- if (index >= kProgramCount)
- return nullptr;
-
- static MidiProgram midiProg;
-
- midiProg.bank = 0;
- midiProg.program = index;
-
- switch (index)
- {
- case 0:
- midiProg.name = "Cathedral1";
- break;
- case 1:
- midiProg.name = "Cathedral2";
- break;
- case 2:
- midiProg.name = "Cathedral3";
- break;
- case 3:
- midiProg.name = "Hall1";
- break;
- case 4:
- midiProg.name = "Hall2";
- break;
- case 5:
- midiProg.name = "Room1";
- break;
- case 6:
- midiProg.name = "Room2";
- break;
- case 7:
- midiProg.name = "Basement";
- break;
- case 8:
- midiProg.name = "Tunnel";
- break;
- case 9:
- midiProg.name = "Echoed1";
- break;
- case 10:
- midiProg.name = "Echoed2";
- break;
- case 11:
- midiProg.name = "VeryLong1";
- break;
- case 12:
- midiProg.name = "VeryLong2";
- break;
- default:
- midiProg.name = nullptr;
- break;
- }
-
- return &midiProg;
- }
-
- ZynPluginDescriptorClassEND(FxReverbPlugin)
- CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FxReverbPlugin)
- };
-
- // -----------------------------------------------------------------------
-
- class ZynAddSubFxPlugin : public PluginDescriptorClass
- {
- public:
- ZynAddSubFxPlugin(const HostDescriptor* const host)
- : PluginDescriptorClass(host),
- fMaster(new Master()),
- fSampleRate(getSampleRate()),
- fIsActive(false),
- fThread(fMaster, host)
- {
- fThread.start();
-
- for (int i = 0; i < NUM_MIDI_PARTS; ++i)
- fMaster->partonoff(i, 1);
-
- sPrograms.init();
- }
-
- ~ZynAddSubFxPlugin() override
- {
- //ensure that everything has stopped
- pthread_mutex_lock(&fMaster->mutex);
- pthread_mutex_unlock(&fMaster->mutex);
- fThread.stop();
- fThread.wait();
-
- delete fMaster;
- fMaster = nullptr;
- }
-
- protected:
- // -------------------------------------------------------------------
- // Plugin midi-program calls
-
- uint32_t getMidiProgramCount() override
- {
- return sPrograms.count();
- }
-
- const MidiProgram* getMidiProgramInfo(const uint32_t index) override
- {
- return sPrograms.getInfo(index);
- }
-
- // -------------------------------------------------------------------
- // Plugin state calls
-
- void setMidiProgram(const uint8_t channel, const uint32_t bank, const uint32_t program) override
- {
- if (bank >= fMaster->bank.banks.size())
- return;
- if (program >= BANK_SIZE)
- return;
-
- if (isOffline() || ! fIsActive)
- {
- sPrograms.load(fMaster, channel, bank, program);
- #ifdef WANT_ZYNADDSUBFX_UI
- fThread.uiRepaint();
- #endif
- }
- else
- fThread.loadProgramLater(channel, bank, program);
- }
-
- void setCustomData(const char* const key, const char* const value) override
- {
- CARLA_ASSERT(key != nullptr);
- CARLA_ASSERT(value != nullptr);
-
- if (std::strcmp(key, "CarlaAlternateFile1") == 0) // xmz
- fMaster->loadXML(value);
- else if (std::strcmp(key, "CarlaAlternateFile2") == 0) // xiz
- fMaster->part[0]->loadXMLinstrument(value);
- }
-
- // -------------------------------------------------------------------
- // Plugin process calls
-
- void activate() override
- {
- fIsActive = true;
- }
-
- void deactivate() override
- {
- fIsActive = false;
- }
-
- void process(float**, float** const outBuffer, const uint32_t frames, const uint32_t midiEventCount, const MidiEvent* const midiEvents) override
- {
- if (pthread_mutex_trylock(&fMaster->mutex) != 0)
- {
- carla_zeroFloat(outBuffer[0], frames);
- carla_zeroFloat(outBuffer[1], frames);
- return;
- }
-
- for (uint32_t i=0; i < midiEventCount; ++i)
- {
- const MidiEvent* const midiEvent(&midiEvents[i]);
-
- const uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvent->data);
- const uint8_t channel = MIDI_GET_CHANNEL_FROM_DATA(midiEvent->data);
-
- if (MIDI_IS_STATUS_NOTE_OFF(status))
- {
- const uint8_t note = midiEvent->data[1];
-
- fMaster->noteOff(channel, note);
- }
- else if (MIDI_IS_STATUS_NOTE_ON(status))
- {
- const uint8_t note = midiEvent->data[1];
- const uint8_t velo = midiEvent->data[2];
-
- fMaster->noteOn(channel, note, velo);
- }
- else if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status))
- {
- const uint8_t note = midiEvent->data[1];
- const uint8_t pressure = midiEvent->data[2];
-
- fMaster->polyphonicAftertouch(channel, note, pressure);
- }
- else if (MIDI_IS_STATUS_CONTROL_CHANGE(status))
- {
- const uint8_t control = midiEvent->data[1];
- const uint8_t value = midiEvent->data[2];
-
- fMaster->setController(channel, control, value);
- }
- else if (MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status))
- {
- const uint8_t lsb = midiEvent->data[1];
- const uint8_t msb = midiEvent->data[2];
- const int value = ((msb << 7) | lsb) - 8192;
-
- fMaster->setController(channel, C_pitchwheel, value);
- }
- }
-
- fMaster->GetAudioOutSamples(frames, fSampleRate, outBuffer[0], outBuffer[1]);
-
- pthread_mutex_unlock(&fMaster->mutex);
- }
-
- #ifdef WANT_ZYNADDSUBFX_UI
- // -------------------------------------------------------------------
- // Plugin UI calls
-
- void uiShow(const bool show) override
- {
- if (show)
- fThread.uiShow();
- else
- fThread.uiHide();
- }
- #endif
-
- // -------------------------------------------------------------------
- // Plugin state calls
-
- char* getState() override
- {
- config.save();
-
- char* data = nullptr;
- fMaster->getalldata(&data);
- return data;
- }
-
- void setState(const char* const data) override
- {
- fThread.stopLoadProgramLater();
- fMaster->putalldata((char*)data, 0);
- fMaster->applyparameters(true);
- }
-
- // -------------------------------------------------------------------
- // Plugin dispatcher
-
- intptr_t pluginDispatcher(const PluginDispatcherOpcode opcode, const int32_t index, const intptr_t value, void* const ptr, const float) override
- {
- switch (opcode)
- {
- case PLUGIN_OPCODE_NULL:
- break;
- case PLUGIN_OPCODE_BUFFER_SIZE_CHANGED:
- // TODO
- break;
- case PLUGIN_OPCODE_SAMPLE_RATE_CHANGED:
- // TODO
- break;
- case PLUGIN_OPCODE_OFFLINE_CHANGED:
- break;
- case PLUGIN_OPCODE_UI_NAME_CHANGED:
- #ifdef WANT_ZYNADDSUBFX_UI
- // TODO
- #endif
- break;
- }
-
- return 0;
-
- // unused
- (void)index;
- (void)value;
- (void)ptr;
- }
-
- // -------------------------------------------------------------------
-
- private:
- Master* fMaster;
- unsigned fSampleRate;
- bool fIsActive;
-
- ZynAddSubFxThread fThread;
-
- ZynPluginDescriptorClassEND(ZynAddSubFxPlugin)
- CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ZynAddSubFxPlugin)
- };
-
- // -----------------------------------------------------------------------
-
- static const PluginDescriptor fxAlienWahDesc = {
- /* category */ PLUGIN_CATEGORY_MODULATOR,
- /* hints */ static_cast<PluginHints>(PLUGIN_IS_RTSAFE|PLUGIN_USES_PANNING|PLUGIN_USES_STATIC_BUFFERS),
- /* supports */ static_cast<PluginSupports>(0x0),
- /* audioIns */ 2,
- /* audioOuts */ 2,
- /* midiIns */ 0,
- /* midiOuts */ 0,
- /* paramIns */ 11-2,
- /* paramOuts */ 0,
- /* name */ "ZynAlienWah",
- /* label */ "zynAlienWah",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- PluginDescriptorFILL(FxAlienWahPlugin)
- };
-
- static const PluginDescriptor fxChorusDesc = {
- /* category */ PLUGIN_CATEGORY_MODULATOR,
- /* hints */ static_cast<PluginHints>(PLUGIN_IS_RTSAFE|PLUGIN_USES_PANNING|PLUGIN_USES_STATIC_BUFFERS),
- /* supports */ static_cast<PluginSupports>(0x0),
- /* audioIns */ 2,
- /* audioOuts */ 2,
- /* midiIns */ 0,
- /* midiOuts */ 0,
- /* paramIns */ 12-2,
- /* paramOuts */ 0,
- /* name */ "ZynChorus",
- /* label */ "zynChorus",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- PluginDescriptorFILL(FxChorusPlugin)
- };
-
- static const PluginDescriptor fxDistortionDesc = {
- /* category */ PLUGIN_CATEGORY_MODULATOR,
- /* hints */ static_cast<PluginHints>(PLUGIN_USES_PANNING|PLUGIN_USES_STATIC_BUFFERS),
- /* supports */ static_cast<PluginSupports>(0x0),
- /* audioIns */ 2,
- /* audioOuts */ 2,
- /* midiIns */ 0,
- /* midiOuts */ 0,
- /* paramIns */ 11-2,
- /* paramOuts */ 0,
- /* name */ "ZynDistortion",
- /* label */ "zynDistortion",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- PluginDescriptorFILL(FxDistortionPlugin)
- };
-
- static const PluginDescriptor fxDynamicFilterDesc = {
- /* category */ PLUGIN_CATEGORY_FILTER,
- /* hints */ static_cast<PluginHints>(PLUGIN_USES_PANNING|PLUGIN_USES_STATIC_BUFFERS),
- /* supports */ static_cast<PluginSupports>(0x0),
- /* audioIns */ 2,
- /* audioOuts */ 2,
- /* midiIns */ 0,
- /* midiOuts */ 0,
- /* paramIns */ 10-2,
- /* paramOuts */ 0,
- /* name */ "ZynDynamicFilter",
- /* label */ "zynDynamicFilter",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- PluginDescriptorFILL(FxDynamicFilterPlugin)
- };
-
- static const PluginDescriptor fxEchoDesc = {
- /* category */ PLUGIN_CATEGORY_DELAY,
- /* hints */ static_cast<PluginHints>(PLUGIN_IS_RTSAFE|PLUGIN_USES_PANNING|PLUGIN_USES_STATIC_BUFFERS),
- /* supports */ static_cast<PluginSupports>(0x0),
- /* audioIns */ 2,
- /* audioOuts */ 2,
- /* midiIns */ 0,
- /* midiOuts */ 0,
- /* paramIns */ 7-2,
- /* paramOuts */ 0,
- /* name */ "ZynEcho",
- /* label */ "zynEcho",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- PluginDescriptorFILL(FxEchoPlugin)
- };
-
- static const PluginDescriptor fxPhaserDesc = {
- /* category */ PLUGIN_CATEGORY_MODULATOR,
- /* hints */ static_cast<PluginHints>(PLUGIN_USES_PANNING|PLUGIN_USES_STATIC_BUFFERS),
- /* supports */ static_cast<PluginSupports>(0x0),
- /* audioIns */ 2,
- /* audioOuts */ 2,
- /* midiIns */ 0,
- /* midiOuts */ 0,
- /* paramIns */ 15-2,
- /* paramOuts */ 0,
- /* name */ "ZynPhaser",
- /* label */ "zynPhaser",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- PluginDescriptorFILL(FxPhaserPlugin)
- };
-
- static const PluginDescriptor fxReverbDesc = {
- /* category */ PLUGIN_CATEGORY_DELAY,
- /* hints */ static_cast<PluginHints>(PLUGIN_USES_PANNING|PLUGIN_USES_STATIC_BUFFERS),
- /* supports */ static_cast<PluginSupports>(0x0),
- /* audioIns */ 2,
- /* audioOuts */ 2,
- /* midiIns */ 0,
- /* midiOuts */ 0,
- /* paramIns */ 13-2,
- /* paramOuts */ 0,
- /* name */ "ZynReverb",
- /* label */ "zynReverb",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- PluginDescriptorFILL(FxReverbPlugin)
- };
-
- static const PluginDescriptor zynaddsubfxDesc = {
- /* category */ PLUGIN_CATEGORY_SYNTH,
- #ifdef WANT_ZYNADDSUBFX_UI
- /* hints */ static_cast<PluginHints>(PLUGIN_IS_SYNTH|PLUGIN_HAS_GUI|PLUGIN_USES_STATE),
- #else
- /* hints */ static_cast<PluginHints>(PLUGIN_IS_SYNTH|PLUGIN_USES_STATE),
- #endif
- /* supports */ static_cast<PluginSupports>(PLUGIN_SUPPORTS_CONTROL_CHANGES|PLUGIN_SUPPORTS_NOTE_AFTERTOUCH|PLUGIN_SUPPORTS_PITCHBEND|PLUGIN_SUPPORTS_ALL_SOUND_OFF),
- /* audioIns */ 0,
- /* audioOuts */ 2,
- /* midiIns */ 1,
- /* midiOuts */ 0,
- /* paramIns */ 0,
- /* paramOuts */ 0,
- /* name */ "ZynAddSubFX",
- /* label */ "zynaddsubfx",
- /* maker */ "falkTX",
- /* copyright */ "GNU GPL v2+",
- PluginDescriptorFILL(ZynAddSubFxPlugin)
- };
-
- // -----------------------------------------------------------------------
-
- CARLA_EXPORT
- void carla_register_native_plugin_zynaddsubfx()
- {
- carla_register_native_plugin(&fxAlienWahDesc);
- carla_register_native_plugin(&fxChorusDesc);
- carla_register_native_plugin(&fxDistortionDesc);
- carla_register_native_plugin(&fxDynamicFilterDesc);
- carla_register_native_plugin(&fxEchoDesc);
- carla_register_native_plugin(&fxPhaserDesc);
- carla_register_native_plugin(&fxReverbDesc);
- carla_register_native_plugin(&zynaddsubfxDesc);
- }
-
- // -----------------------------------------------------------------------
|