EffectMgr.h (3887B)
1 /* 2 ZynAddSubFX - a software synthesizer 3 4 EffectMgr.h - Effect manager, an interface between the program and effects 5 Copyright (C) 2002-2005 Nasca Octavian Paul 6 Author: Nasca Octavian Paul 7 8 This program is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2 11 of the License, or (at your option) any later version. 12 */ 13 14 #ifndef EFFECTMGR_H 15 #define EFFECTMGR_H 16 17 #include <pthread.h> 18 19 #include "../Params/FilterParams.h" 20 #include "../Params/Presets.h" 21 #include "../globals.h" 22 23 namespace zyn { 24 25 class Effect; 26 class FilterParams; 27 class XMLwrapper; 28 class Allocator; 29 30 /** Effect manager, an interface between the program and effects */ 31 class EffectMgr:public Presets 32 { 33 public: 34 EffectMgr(Allocator &alloc, const SYNTH_T &synth, const bool insertion_, 35 const AbsTime *time_ = nullptr, Sync *sync_ = nullptr); 36 ~EffectMgr() override; 37 38 void paste(EffectMgr &e); 39 void add2XML(XMLwrapper& xml) override; 40 void defaults(void) REALTIME; 41 void getfromXML(XMLwrapper& xml); 42 43 void out(float *smpsl, float *smpsr) REALTIME; 44 45 void setdryonly(bool value); 46 47 /**get the output(to speakers) volume of the systemeffect*/ 48 float sysefxgetvolume(void); 49 50 void init(void) REALTIME; 51 void kill(void) REALTIME; 52 void cleanup(void) REALTIME; 53 54 void changesettingsrt(const short int *) REALTIME; 55 void changeeffectrt(int nefx_, bool avoidSmash=false) REALTIME; 56 void changeeffect(int nefx_) NONREALTIME; 57 int geteffect(void); 58 void changepreset(unsigned char npreset) NONREALTIME; 59 void changepresetrt(unsigned char npreset, bool avoidSmash=false) REALTIME; 60 unsigned char getpreset(void); 61 void seteffectparrt(int npar, unsigned char value) REALTIME; 62 unsigned char geteffectpar(int npar); 63 unsigned char geteffectparrt(int npar) REALTIME; 64 65 const bool insertion; //!< true iff insertion or part fx 66 float *efxoutl, *efxoutr; 67 68 // used by UI 69 float getEQfreqresponse(float freq); 70 71 FilterParams *filterpars; 72 73 static const rtosc::Ports &ports; 74 int nefx; 75 Effect *efx; 76 const AbsTime *time; 77 Sync *sync; 78 79 int numerator; 80 int denominator; 81 82 private: 83 84 //Parameters Prior to initialization 85 char preset; 86 87 /** 88 * When loading an effect from XML the child effect cannot be loaded 89 * directly as it would require access to the realtime memory pool, 90 * which cannot be done outside of the realtime thread. 91 * Therefore, parameters are loaded to this array which can then be used 92 * to construct the full effect (via init()) once the object is in the 93 * realtime context. 94 * 95 * Additionally this structure is used in the case of pasting effects as 96 * pasted effect object are *not* fully initialized when they're put on 97 * the middleware -> backend ringbuffer, but settings has the values 98 * loaded from the XML serialization. 99 * The settings values can be pasted once they're on the realtime thread 100 * and then they can be applied. 101 * 102 * The requirement that the realtime memory pool is used to create the 103 * effect is in place as it is possible to change the effect type in the 104 * realtime thread and thus the new effect would draw from the realtime 105 * memory pool and the old object would be expected to be freed to the 106 * realtime memory pool. 107 * 108 * See also: PresetExtractor.cpp 109 */ 110 short int settings[128]; 111 112 bool dryonly; 113 Allocator &memory; 114 const SYNTH_T &synth; 115 116 117 }; 118 119 } 120 121 #endif