Beast - Music Synthesizer and Composer  0.11.1+10.g2da35
gsldatahandle.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 __GSL_DATA_HANDLE_H__
3 #define __GSL_DATA_HANDLE_H__
4 
5 #include <bse/bseutils.hh>
6 
7 
8 /* --- macros --- */
9 #define GSL_DATA_HANDLE_OPENED(handle) (((GslDataHandle*) (handle))->open_count > 0)
10 #define GSL_DATA_HANDLE_READ_LINEAR(handle) (((GslDataHandle*) (handle))->vtable->coarse_seek != NULL)
11 
12 
13 /* --- typedefs & structures --- */
14 typedef struct {
15  guint n_channels;
16  int64 n_values;
17  gchar **xinfos;
18  guint bit_depth : 8;
19  guint needs_cache : 1;
20  gfloat mix_freq;
23 {
24  /* constant members */
25  GslDataHandleFuncs *vtable;
26  gchar *name;
27  /* common members */
28  Bse::Spinlock spinlock;
29  guint ref_count;
30  guint open_count;
31  /* opened data handle setup (open_count > 0) */
32  GslDataHandleSetup setup;
33 };
34 typedef void (*GslDataHandleRecurse) (GslDataHandle *data_handle,
35  gpointer data);
37 {
38  Bse::Error (*open) (GslDataHandle *data_handle,
39  GslDataHandleSetup *setup);
40  int64 (*read) (GslDataHandle *data_handle,
41  int64 voffset, /* in values */
42  int64 n_values,
43  gfloat *values);
44  void (*close) (GslDataHandle *data_handle);
45  GslDataHandle* (*get_source) (GslDataHandle *data_handle);
46  int64 (*get_state_length) (GslDataHandle *data_handle);
47  void (*destroy) (GslDataHandle *data_handle);
48 };
49 
50 
51 
52 /* --- standard functions --- */
53 GslDataHandle* gsl_data_handle_ref (GslDataHandle *dhandle);
54 void gsl_data_handle_unref (GslDataHandle *dhandle);
55 Bse::Error gsl_data_handle_open (GslDataHandle *dhandle);
56 void gsl_data_handle_close (GslDataHandle *dhandle);
57 int64 gsl_data_handle_length (GslDataHandle *data_handle);
58 #define gsl_data_handle_n_values( dh) \
59  gsl_data_handle_length (dh)
60 guint gsl_data_handle_n_channels (GslDataHandle *data_handle);
61 guint gsl_data_handle_bit_depth (GslDataHandle *data_handle);
62 gfloat gsl_data_handle_mix_freq (GslDataHandle *data_handle);
63 gfloat gsl_data_handle_osc_freq (GslDataHandle *data_handle);
64 gfloat gsl_data_handle_volume (GslDataHandle *data_handle);
65 gfloat gsl_data_handle_fine_tune (GslDataHandle *data_handle);
66 const gchar* gsl_data_handle_name (GslDataHandle *data_handle);
67 int64 gsl_data_handle_read (GslDataHandle *data_handle,
68  int64 value_offset,
69  int64 n_values,
70  gfloat *values);
71 int64 gsl_data_handle_get_state_length (GslDataHandle *dhandle);
72 GslDataHandle* gsl_data_handle_get_source (GslDataHandle *dhandle);
73 GslDataHandle* gsl_data_handle_new_scale (GslDataHandle *src_handle,
74  double factor);
75 GslDataHandle* gsl_data_handle_new_cut (GslDataHandle *src_handle,
76  int64 cut_offset,
77  int64 n_cut_values);
78 GslDataHandle* gsl_data_handle_new_crop (GslDataHandle *src_handle,
79  int64 n_head_cut,
80  int64 n_tail_cut);
81 GslDataHandle* gsl_data_handle_new_reverse (GslDataHandle *src_handle);
82 GslDataHandle* gsl_data_handle_new_insert (GslDataHandle *src_handle,
83  guint pasted_bit_depth,
84  int64 insertion_offset,
85  int64 n_paste_values,
86  const gfloat *paste_values,
87  void (*free) (gpointer values));
88 GslDataHandle* gsl_data_handle_new_mem (guint n_channels,
89  guint bit_depth,
90  gfloat mix_freq,
91  gfloat osc_freq,
92  int64 n_values,
93  const gfloat *values,
94  void (*free) (gpointer values));
95 GslDataHandle* gsl_data_handle_new_dcached (GslDataCache *dcache);
96 /* cheap and inefficient, testpurpose only */
97 GslDataHandle* gsl_data_handle_new_looped (GslDataHandle *src_handle,
98  int64 loop_first,
99  int64 loop_last);
100 
101 /* --- factor 2 resampling datahandles --- */
102 GslDataHandle* bse_data_handle_new_upsample2 (GslDataHandle *src_handle, // implemented in bsedatahandle-resample.cc
103  int precision_bits);
104 GslDataHandle* bse_data_handle_new_downsample2 (GslDataHandle *src_handle,
105  int precision_bits); // implemented in bsedatahandle-resample.cc
106 
107 GslDataHandle* bse_data_handle_new_fir_highpass (GslDataHandle *src_handle, // implemented in bsedatahandle-fir.cc
108  gdouble cutoff_freq,
109  guint order);
110 GslDataHandle* bse_data_handle_new_fir_lowpass (GslDataHandle *src_handle, // implemented in bsedatahandle-fir.cc
111  gdouble cutoff_freq,
112  guint order);
113 gdouble bse_data_handle_fir_response_db (GslDataHandle *fir_handle, // implemented in bsedatahandle-fir.cc
114  gdouble freq);
115 
116 /* --- xinfo handling --- */
117 GslDataHandle* gsl_data_handle_new_add_xinfos (GslDataHandle *src_handle,
118  gchar **xinfos);
119 GslDataHandle* gsl_data_handle_new_remove_xinfos (GslDataHandle *src_handle,
120  gchar **xinfos);
121 GslDataHandle* gsl_data_handle_new_clear_xinfos (GslDataHandle *src_handle);
122 
123 
124 /* --- wave specific functions --- */
125 typedef enum /*< skip >*/
126 {
127  GSL_WAVE_FORMAT_NONE,
128  GSL_WAVE_FORMAT_UNSIGNED_8,
129  GSL_WAVE_FORMAT_SIGNED_8,
130  GSL_WAVE_FORMAT_ALAW,
131  GSL_WAVE_FORMAT_ULAW,
132  GSL_WAVE_FORMAT_UNSIGNED_12,
133  GSL_WAVE_FORMAT_SIGNED_12,
134  GSL_WAVE_FORMAT_UNSIGNED_16,
135  GSL_WAVE_FORMAT_SIGNED_16,
136  GSL_WAVE_FORMAT_SIGNED_24,
137  GSL_WAVE_FORMAT_SIGNED_24_PAD4,
138  GSL_WAVE_FORMAT_SIGNED_32,
139  GSL_WAVE_FORMAT_FLOAT,
140  GSL_WAVE_FORMAT_LAST
141 } GslWaveFormatType;
142 #define GSL_WAVE_FORMAT_IS_LAW(f) ((f) == GSL_WAVE_FORMAT_ALAW || (f) == GSL_WAVE_FORMAT_ULAW)
143 
144 const gchar* gsl_wave_format_to_string (GslWaveFormatType format);
145 GslWaveFormatType gsl_wave_format_from_string (const gchar *string);
146 GslDataHandle* gsl_wave_handle_new (const gchar *file_name,
147  guint n_channels,
148  GslWaveFormatType format,
149  guint byte_order,
150  gfloat mix_freq,
151  gfloat osc_freq,
152  int64 byte_offset,
153  int64 n_values,
154  gchar **xinfos);
155 GslDataHandle* gsl_wave_handle_new_zoffset (const gchar *file_name,
156  guint n_channels,
157  GslWaveFormatType format,
158  guint byte_order,
159  gfloat mix_freq,
160  gfloat osc_freq,
161  int64 byte_offset,
162  int64 byte_size,
163  gchar **xinfos);
164 guint gsl_wave_format_bit_depth (GslWaveFormatType format);
165 guint gsl_wave_format_byte_width (GslWaveFormatType format);
166 
167 
168 /* --- data handle optimization jobs --- */
169 gboolean gsl_data_handle_needs_cache (GslDataHandle *data_handle);
170 
171 
172 /* --- auxillary functions --- */
173 gboolean gsl_data_handle_common_init (GslDataHandle *dhandle,
174  const gchar *file_name);
175 void gsl_data_handle_common_free (GslDataHandle *dhandle);
176 
177 
178 #endif /* __GSL_DATA_HANDLE_H__ */
GslDataHandle * bse_data_handle_new_fir_lowpass(GslDataHandle *src_handle, gdouble cutoff_freq, guint order)
Definition: bsedatahandle-fir.cc:393
read
int64 gsl_data_handle_get_state_length(GslDataHandle *dhandle)
Definition: gsldatahandle.cc:182
Definition: gsldatahandle.hh:22
free
GslDataHandle * gsl_data_handle_new_cut(GslDataHandle *src_handle, int64 cut_offset, int64 n_cut_values)
Definition: gsldatahandle.cc:973
Definition: gsldatahandle.hh:36
int64_t int64
A 64-bit unsigned integer, use PRI*64 in format strings.
Definition: glib-extra.hh:9
close
GslDataHandle * gsl_data_handle_new_crop(GslDataHandle *src_handle, int64 n_head_cut, int64 n_tail_cut)
Definition: gsldatahandle.cc:991
Definition: gsldatahandle.hh:14
open
GslDataHandle * bse_data_handle_new_fir_highpass(GslDataHandle *src_handle, gdouble cutoff_freq, guint order)
Definition: bsedatahandle-fir.cc:371
int64_t int64