2 #ifndef __BSE_CXX_MODULE_H__
3 #define __BSE_CXX_MODULE_H__
34 template<
class T,
typename P>
class ClosureP1;
35 BseModule *intern_module;
39 virtual void reset () = 0;
40 virtual void process (uint n_values) = 0;
41 virtual const ProcessCost cost ();
42 inline const IStream& istream (uint istream_index)
const;
43 inline const JStream& jstream (uint jstream_index)
const;
44 inline const OStream& ostream (uint ostream_index)
const;
45 void ostream_set (uint ostream_index,
47 const float* const_values (
float value);
48 inline const uint mix_freq ()
const;
49 inline const uint block_size ()
const;
50 inline guint64 tick_stamp ();
51 inline BseModule* engine_module ();
52 static inline int dtoi (
double d) {
return bse_dtoi (d); }
53 static inline int ftoi (
float f) {
return bse_ftoi (f); }
60 template<
class D,
class C>
61 static Closure* make_closure (
void (C::*method) (D*),
64 void set_module (BseModule *module);
67 typedef void (*AutoUpdate) (BseModule*, gpointer);
79 static void auto_update_accessor (BseModule*, gpointer);
83 static void auto_update_accessor (BseModule*, gpointer);
86 static void auto_update_accessor (BseModule*, gpointer);
90 #define BSE_TYPE_EFFECT (BSE_CXX_TYPE_GET_REGISTERED (Bse, Effect))
94 guint64 last_module_update;
98 void set_property (guint prop_id,
101 void get_property (guint prop_id,
105 bool is_prepared()
const {
return BSE_SOURCE_PREPARED (gobject()); }
106 guint n_ichannels()
const {
return BSE_SOURCE_N_ICHANNELS (gobject()); }
107 guint n_joint_ichannels()
const {
return BSE_SOURCE_N_JOINT_ICHANNELS (gobject()); }
108 guint n_ochannels()
const {
return BSE_SOURCE_N_OCHANNELS (gobject()); }
109 bool is_joint_ichannel (guint i)
const {
return BSE_SOURCE_IS_JOINT_ICHANNEL (gobject(), i); }
110 guint ichannels_istream (guint i)
const {
return BSE_SOURCE_ICHANNEL_ISTREAM (gobject(), i); }
111 guint ichannels_jstream (guint i)
const {
return BSE_SOURCE_ICHANNEL_JSTREAM (gobject(), i); }
112 guint ochannels_ostream (guint i)
const {
return BSE_SOURCE_OCHANNEL_OSTREAM (gobject(), i); }
113 const gchar* ichannel_ident (guint i)
const {
return BSE_SOURCE_ICHANNEL_IDENT (gobject(), i); }
114 const gchar* ichannel_label (guint i)
const {
return BSE_SOURCE_ICHANNEL_LABEL (gobject(), i); }
115 const gchar* ichannel_blurb (guint i)
const {
return BSE_SOURCE_ICHANNEL_BLURB (gobject(), i); }
116 const gchar* ochannel_ident (guint i)
const {
return BSE_SOURCE_OCHANNEL_IDENT (gobject(), i); }
117 const gchar* ochannel_label (guint i)
const {
return BSE_SOURCE_OCHANNEL_LABEL (gobject(), i); }
118 const gchar* ochannel_blurb (guint i)
const {
return BSE_SOURCE_OCHANNEL_BLURB (gobject(), i); }
120 BseTrans *trans) = 0;
122 Closure* make_module_config_closure () = 0;
123 virtual SynthesisModule::
124 AutoUpdate get_module_auto_update () = 0;
125 void update_modules (BseTrans *trans = NULL);
126 guint64 module_update_tick_stamp () {
return last_module_update; }
128 virtual void prepare1() { }
129 virtual void prepare2() { }
130 virtual void reset1() { }
131 virtual void reset2() { }
135 const BseModuleClass* create_engine_class (
SynthesisModule *sample_module,
139 int n_ostreams = -1);
140 virtual BseModule* integrate_engine_module (uint context_handle,
142 virtual void dismiss_engine_module (BseModule *engine_module,
143 guint context_handle,
145 uint block_size ()
const;
146 uint max_block_size ()
const;
148 Bse::MusicalTuning current_musical_tuning ()
const;
151 #define BSE_EFFECT_INTEGRATE_MODULE(ObjectType,ModuleType,ParamType) \
152 Bse::SynthesisModule* \
153 create_module (uint context_handle, \
157 (void) const_cast<ObjectType*> (this); \
159 return new ModuleType(); \
161 Bse::SynthesisModule::Closure* \
162 make_module_config_closure() \
164 return SynthesisModule::make_closure (&ModuleType::config, ParamType (this)); \
166 Bse::SynthesisModule::AutoUpdate \
167 get_module_auto_update() \
169 return SynthesisModule::Trampoline<ModuleType,ParamType, \
170 ObjectType::AutoUpdateCategory>::auto_update_accessor; \
172 template<
class M,
class P>
178 M *m =
static_cast<M*
> (BSE_MODULE_GET_USER_DATA (bmodule));
179 AutoUpdateData *au =
static_cast<AutoUpdateData*
> (data);
180 typename P::IDType prop_id =
static_cast<typename P::IDType
> (au->prop_id);
182 (void)
static_cast<void (M::*) (typename P::IDType,
double)
> (&M::auto_update);
183 m->auto_update (prop_id, au->prop_value);
185 template<
class M,
class P>
187 SynthesisModule::Trampoline<M,P,void>::
188 auto_update_accessor (BseModule *bmodule,
195 namespace externC {
extern "C" {
196 extern guint bse_engine_exvar_sample_freq;
197 extern guint bse_engine_exvar_block_size;
201 SynthesisModule::engine_module ()
203 return intern_module;
206 SynthesisModule::mix_freq ()
const
208 return externC::bse_engine_exvar_sample_freq;
211 SynthesisModule::block_size ()
const
213 return externC::bse_engine_exvar_block_size;
216 SynthesisModule::tick_stamp ()
220 inline const IStream&
221 SynthesisModule::istream (uint istream_index)
const
223 void *istreams = BSE_MODULE_GET_ISTREAMSP (intern_module);
224 return reinterpret_cast<IStream*
> (istreams)[istream_index];
226 inline const JStream&
227 SynthesisModule::jstream (uint jstream_index)
const
229 void *jstreams = BSE_MODULE_GET_JSTREAMSP (intern_module);
230 return reinterpret_cast<JStream*
> (jstreams)[jstream_index];
232 inline const OStream&
233 SynthesisModule::ostream (uint ostream_index)
const
235 void *ostreams = BSE_MODULE_GET_OSTREAMSP (intern_module);
236 return reinterpret_cast<OStream*
> (ostreams)[ostream_index];
238 template<
class T,
typename P>
239 class SynthesisModule::ClosureP1 :
public SynthesisModule::Closure {
240 typedef void (T::*Member) (P*);
244 ClosureP1 (
void (T::*f) (P*), P *p)
247 assert_derived_from<T,SynthesisModule>();
249 void operator() (SynthesisModule *p)
251 T *t =
static_cast<T*
> (p);
259 template<
class D,
class C> SynthesisModule::Closure*
260 SynthesisModule::make_closure (
void (C::*method) (D*),
264 ClosureP1<C,D> *ac =
new ClosureP1<C,D> (method, d);
Definition: bsecxxmodule.hh:68
The Bse namespace contains all functions of the synthesis engine.
Definition: bstbseutils.cc:88
Definition: bsecxxmodule.hh:26
Definition: bsecxxmodule.hh:76
Definition: bsecxxvalue.hh:13
Definition: bsecxxmodule.hh:16
Definition: bsecxxmodule.hh:33
Definition: bsecxxmodule.hh:91
Definition: bsecxxbase.hh:43
guint64 bse_module_tick_stamp(BseModule *module)
Definition: bseengine.cc:86
Definition: bsecxxmodule.hh:22
Definition: bsecxxmodule.hh:55
Definition: bsecxxmodule.hh:78
Definition: bsecxxmodule.hh:92
Definition: bsecxxbase.hh:14