Beast - Music Synthesizer and Composer  0.11.1+10.g2da35
bsesource.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __BSE_SOURCE_H__
3 #define __BSE_SOURCE_H__
4 #include <bse/bseitem.hh>
5 #include <bse/gsldefs.hh>
6 #include <sfi/gbsearcharray.hh>
7 
8 /* --- BseSource type macros --- */
9 #define BSE_TYPE_SOURCE (BSE_TYPE_ID (BseSource))
10 #define BSE_SOURCE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_SOURCE, BseSource))
11 #define BSE_SOURCE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), BSE_TYPE_SOURCE, BseSourceClass))
12 #define BSE_IS_SOURCE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_SOURCE))
13 #define BSE_IS_SOURCE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), BSE_TYPE_SOURCE))
14 #define BSE_SOURCE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_SOURCE, BseSourceClass))
15 
16 
17 /* --- BseSource member macros --- */
18 #define BSE_SOURCE_PREPARED(src) ((BSE_OBJECT_FLAGS (src) & BSE_SOURCE_FLAG_PREPARED) != 0)
19 #define BSE_SOURCE_COLLECTED(src) ((BSE_OBJECT_FLAGS (src) & BSE_SOURCE_FLAG_COLLECTED) != 0)
20 #define BSE_SOURCE_N_ICHANNELS(src) (BSE_SOURCE (src)->channel_defs->n_ichannels)
21 #define BSE_SOURCE_ICHANNEL_IDENT(src,id) (BSE_SOURCE (src)->channel_defs->ichannel_idents[(id)])
22 #define BSE_SOURCE_ICHANNEL_LABEL(src,id) (BSE_SOURCE (src)->channel_defs->ichannel_labels[(id)])
23 #define BSE_SOURCE_ICHANNEL_BLURB(src,id) (BSE_SOURCE (src)->channel_defs->ichannel_blurbs[(id)])
24 #define BSE_SOURCE_IS_JOINT_ICHANNEL(s,i) ((BSE_SOURCE (s)->channel_defs->ijstreams[(i)] & BSE_SOURCE_JSTREAM_FLAG) != 0)
25 #define BSE_SOURCE_N_JOINT_ICHANNELS(src) (BSE_SOURCE (src)->channel_defs->n_jstreams)
26 #define BSE_SOURCE_N_OCHANNELS(src) (BSE_SOURCE (src)->channel_defs->n_ochannels)
27 #define BSE_SOURCE_OCHANNEL_IDENT(src,id) (BSE_SOURCE (src)->channel_defs->ochannel_idents[(id)])
28 #define BSE_SOURCE_OCHANNEL_LABEL(src,id) (BSE_SOURCE (src)->channel_defs->ochannel_labels[(id)])
29 #define BSE_SOURCE_OCHANNEL_BLURB(src,id) (BSE_SOURCE (src)->channel_defs->ochannel_blurbs[(id)])
30 /* BseSourceClass */
31 #define BSE_SOURCE_CLASS_N_ICHANNELS(sc) (BSE_SOURCE_CLASS (sc)->channel_defs.n_ichannels)
32 #define BSE_SOURCE_CLASS_N_OCHANNELS(sc) (BSE_SOURCE_CLASS (sc)->channel_defs.n_ochannels)
33 /*< private >*/
34 #define BSE_SOURCE_INPUT(src,id) (BSE_SOURCE (src)->inputs + (guint) (id))
35 #define BSE_SOURCE_OCHANNEL_OSTREAM(s,oc) ((oc) < BSE_SOURCE_N_OCHANNELS (s) ? (oc) : 0xffffffff)
36 #define BSE_SOURCE_ICHANNEL_ISTREAM(s,ic) ((ic) < BSE_SOURCE_N_ICHANNELS (s) \
37  && !BSE_SOURCE_IS_JOINT_ICHANNEL ((s), (ic)) ? \
38  BSE_SOURCE (s)->channel_defs->ijstreams[(ic)] & ~BSE_SOURCE_JSTREAM_FLAG : \
39  0xffffffff)
40 #define BSE_SOURCE_ICHANNEL_JSTREAM(s,ic) ((ic) < BSE_SOURCE_N_ICHANNELS (s) \
41  && BSE_SOURCE_IS_JOINT_ICHANNEL ((s), (ic)) ? \
42  BSE_SOURCE (s)->channel_defs->ijstreams[(ic)] & ~BSE_SOURCE_JSTREAM_FLAG : \
43  0xffffffff)
44 #define BSE_SOURCE_JSTREAM_FLAG ((guint) 1 << 31)
45 #define BSE_SOURCE_PRIVATE_INPUTS(src) ((BSE_OBJECT_FLAGS (src) & BSE_SOURCE_FLAG_PRIVATE_INPUTS) != 0)
46 
47 typedef enum /*< skip >*/
48 {
49  BSE_SOURCE_FLAG_PRIVATE_INPUTS = 1 << (BSE_ITEM_FLAGS_USHIFT + 0),
50  BSE_SOURCE_FLAG_PREPARED = 1 << (BSE_ITEM_FLAGS_USHIFT + 1),
51  BSE_SOURCE_FLAG_COLLECTED = 1 << (BSE_ITEM_FLAGS_USHIFT + 2)
52 } BseSourceFlags;
53 #define BSE_SOURCE_FLAGS_USHIFT (BSE_ITEM_FLAGS_USHIFT + 3)
54 
55 typedef struct _BseSourceProbes BseSourceProbes;
56 typedef void (*BseSourceFreeContextData) (BseSource *source,
57  gpointer data,
58  BseTrans *trans);
60  BseSource *osource;
61  guint ochannel;
62 };
64  BseSourceOutput idata;
65  struct {
66  guint n_joints;
67  BseSourceOutput *joints;
68  } jdata;
69 };
71  guint n_ichannels;
72  gchar **ichannel_idents;
73  gchar **ichannel_labels;
74  gchar **ichannel_blurbs;
75  guint *ijstreams;
76  guint n_jstreams;
77  guint n_ochannels;
78  gchar **ochannel_idents;
79  gchar **ochannel_labels;
80  gchar **ochannel_blurbs;
81 };
82 struct BseSource : BseItem {
83  BseSourceChannelDefs *channel_defs;
84  BseSourceInput *inputs; /* [n_ichannels] */
85  GSList *outputs;
86  GBSearchArray *contexts; /* bsearch array of type BseSourceContext */
87  SfiReal pos_x, pos_y;
88  BseSourceProbes *probes;
89 };
91  BseSourceChannelDefs channel_defs;
92  void (*property_updated) (BseSource *source, /* overridable method */
93  guint property_id,
94  guint64 tick_stamp,
95  double value,
96  GParamSpec *pspec);
97  void (*prepare) (BseSource *source);
98  void (*context_create) (BseSource *source,
99  guint context_handle,
100  BseTrans *trans);
101  void (*context_connect) (BseSource *source,
102  guint context_handle,
103  BseTrans *trans);
104  void (*context_dismiss) (BseSource *source,
105  guint context_handle,
106  BseTrans *trans);
107  void (*reset) (BseSource *source);
108 
109  /*< private >*/
110  void (*add_input) (BseSource *source,
111  guint ichannel,
112  BseSource *osource,
113  guint ochannel);
114  void (*remove_input) (BseSource *source,
115  guint ichannel,
116  BseSource *osource,
117  guint ochannel);
118  BseModuleClass *engine_class;
119  gboolean filtered_properties;
120  SfiRing *unprepared_properties;
121  SfiRing *automation_properties;
122 };
123 
124 guint bse_source_find_ichannel (BseSource *source,
125  const gchar *ichannel_ident);
126 guint bse_source_find_ochannel (BseSource *source,
127  const gchar *ochannel_ident);
128 Bse::Error bse_source_set_input (BseSource *source,
129  guint ichannel,
130  BseSource *osource,
131  guint ochannel);
132 Bse::Error bse_source_unset_input (BseSource *source,
133  guint ichannel,
134  BseSource *osource,
135  guint ochannel);
136 gboolean bse_source_get_input (BseSource *source,
137  guint ichannel,
138  BseSource **osourcep,
139  guint *ochannelp);
140 void bse_source_must_set_input_loc (BseSource *source,
141  guint ichannel,
142  BseSource *osource,
143  guint ochannel,
144  const gchar *strloc);
145 #define bse_source_must_set_input(is,ic,os,oc) \
146  bse_source_must_set_input_loc (is, ic, os, oc, G_STRLOC)
147 
148 
149 /* --- source implementations --- */
150 guint bse_source_class_add_ichannel (BseSourceClass *source_class,
151  const gchar *ident,
152  const gchar *label,
153  const gchar *blurb);
154 guint bse_source_class_add_jchannel (BseSourceClass *source_class,
155  const gchar *ident,
156  const gchar *label,
157  const gchar *blurb);
158 guint bse_source_class_add_ochannel (BseSourceClass *source_class,
159  const gchar *ident,
160  const gchar *label,
161  const gchar *blurb);
162 void bse_source_class_inherit_channels (BseSourceClass *source_class);
163 void bse_source_set_context_imodule (BseSource *source,
164  guint context_handle,
165  BseModule *imodule);
166 void bse_source_set_context_omodule (BseSource *source,
167  guint context_handle,
168  BseModule *omodule);
169 BseModule* bse_source_get_context_imodule (BseSource *source,
170  guint context_handle);
171 BseModule* bse_source_get_context_omodule (BseSource *source,
172  guint context_handle);
173 void bse_source_flow_access_module (BseSource *source,
174  guint context_handle,
175  guint64 tick_stamp,
176  BseEngineAccessFunc access_func,
177  gpointer data,
178  BseFreeFunc data_free_func,
179  BseTrans *trans);
180 void bse_source_flow_access_modules (BseSource *source,
181  guint64 tick_stamp,
182  BseEngineAccessFunc access_func,
183  gpointer data,
184  BseFreeFunc data_free_func,
185  BseTrans *trans);
186 void bse_source_access_modules (BseSource *source,
187  BseEngineAccessFunc access_func,
188  gpointer data,
189  BseFreeFunc data_free_func,
190  BseTrans *trans);
191 Bse::Error bse_source_check_input (BseSource *source,
192  guint ichannel,
193  BseSource *osource,
194  guint ochannel);
195 gboolean bse_source_has_output (BseSource *source,
196  guint ochannel);
197 void bse_source_backup_ichannels_to_undo (BseSource *source);
198 void bse_source_backup_ochannels_to_undo (BseSource *source);
199 void bse_source_input_backup_to_undo (BseSource *source,
200  guint ichannel,
201  BseSource *osource,
202  guint ochannel);
203 /* convenience */
204 void bse_source_class_cache_engine_class (BseSourceClass *source_class,
205  const BseModuleClass *engine_class);
206 void bse_source_set_context_module (BseSource *source,
207  guint context_handle,
208  BseModule *module);
209 void bse_source_update_modules (BseSource *source,
210  guint member_offset,
211  gpointer member_data,
212  guint member_size,
213  BseTrans *trans);
214 void bse_source_clear_ichannels (BseSource *source);
215 void bse_source_clear_ochannels (BseSource *source);
216 Bse::MusicalTuning bse_source_prepared_musical_tuning (BseSource *source);
217 
218 /* automation */
219 typedef struct {
220  GParamSpec *pspec;
221  guint midi_channel;
222  Bse::MidiSignal signal_type;
224 Bse::Error bse_source_set_automation_property (BseSource *source,
225  const gchar *prop_name,
226  guint midi_channel,
227  Bse::MidiSignal signal_type);
228 void bse_source_get_automation_property (BseSource *source,
229  const gchar *prop_name,
230  guint *pmidi_channel,
231  Bse::MidiSignal *psignal_type);
232 BseAutomationProperty* bse_source_get_automation_properties (BseSource *source,
233  guint *n_props);
234 
235 /* --- internal --- */
236 SfiRing* bse_source_collect_inputs_flat (BseSource *source); /* sets mark */
237 SfiRing* bse_source_collect_inputs_recursive (BseSource *source); /* sets mark */
238 void bse_source_free_collection (SfiRing *ring); /* unsets mark */
239 gboolean bse_source_test_input_recursive (BseSource *source, /* sets+unsets mark */
240  BseSource *test);
241 gpointer bse_source_get_context_data (BseSource *source,
242  guint context_handle);
243 void bse_source_create_context_with_data (BseSource *source,
244  guint context_handle,
245  gpointer data,
246  BseSourceFreeContextData free_data,
247  BseTrans *trans);
248 void bse_source_create_context (BseSource *source,
249  guint context_handle,
250  BseTrans *trans);
251 void bse_source_connect_context (BseSource *source,
252  guint context_handle,
253  BseTrans *trans);
254 void bse_source_dismiss_context (BseSource *source,
255  guint context_handle,
256  BseTrans *trans);
257 void bse_source_recreate_context (BseSource *source,
258  guint context_handle,
259  BseTrans *trans);
260 void bse_source_prepare (BseSource *source);
261 void bse_source_reset (BseSource *source);
262 guint* bse_source_context_ids (BseSource *source,
263  guint *n_ids);
264 gboolean bse_source_has_context (BseSource *source,
265  guint context_handle);
266 SfiRing* bse_source_list_omodules (BseSource *source);
267 /* implemented in bseprobe.cc */
268 void bse_source_clear_probes (BseSource *source);
269 void bse_source_class_add_probe_signals (BseSourceClass *klass);
270 void bse_source_probes_modules_changed (BseSource *source);
271 
272 namespace Bse {
273 
274 class SourceImpl : public ItemImpl, public virtual SourceIface {
275 protected:
276  virtual ~SourceImpl ();
277 public:
278  explicit SourceImpl (BseObject*);
279  virtual SourceIfaceP ichannel_get_osource (int input_channel, int input_joint) override;
280 };
281 
282 } // Bse
283 
284 #endif /* __BSE_SOURCE_H__ */
The Bse namespace contains all functions of the synthesis engine.
Definition: bstbseutils.cc:91
Definition: gbsearcharray.hh:37
Definition: bsesource.hh:70
Definition: bsesource.hh:59
Definition: bsesource.hh:219
Definition: bseobject.hh:57
void(* BseEngineAccessFunc)(BseModule *module, gpointer data)
Definition: bsedefs.hh:130
Definition: bsesource.hh:82
Definition: sfiring.hh:21
Definition: bsesource.hh:90
Definition: bseitem.hh:148
Definition: bseitem.hh:37
Definition: bseitem.hh:32
Definition: bsesource.hh:63
Definition: bsesource.hh:274