BEAST - Free Software Audio Synthesizer and Tracker  0.10.0
gslosctable.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_OSC_TABLE_H__
3 #define __GSL_OSC_TABLE_H__
4 
5 #include <bse/gsldefs.hh>
6 #include <sfi/gbsearcharray.hh>
7 
8 G_BEGIN_DECLS
9 
10 
11 /* --- structures & enums --- */
12 typedef enum /*< skip >*/
13 {
14  GSL_OSC_WAVE_NONE,
15  GSL_OSC_WAVE_SINE,
16  GSL_OSC_WAVE_TRIANGLE,
17  GSL_OSC_WAVE_SAW_RISE,
18  GSL_OSC_WAVE_SAW_FALL,
19  GSL_OSC_WAVE_PEAK_RISE,
20  GSL_OSC_WAVE_PEAK_FALL,
21  GSL_OSC_WAVE_MOOG_SAW,
22  GSL_OSC_WAVE_SQUARE,
23  GSL_OSC_WAVE_PULSE_SAW
24 } GslOscWaveForm;
25 
26 typedef struct
27 {
28  gfloat mix_freq;
29  GslOscWaveForm wave_form;
30  GBSearchArray *entry_array;
31 } GslOscTable;
32 
33 typedef struct
34 {
35  gfloat min_freq;
36  gfloat max_freq;
37  guint n_values;
38  const gfloat *values; /* contains n_values+1 values with values[0]==values[n_values] */
39  /* integer stepping (block size dependant) */
40  guint32 n_frac_bits;
41  guint32 frac_bitmask;
42  gfloat freq_to_step; /* freq -> int.frac */
43  gfloat phase_to_pos; /* 0..1 -> int.frac */
44  gfloat ifrac_to_float; /* frac -> 0..1 float */
45  guint min_pos, max_pos; /* pulse extension */
46 } GslOscWave;
47 
48 
49 /* --- oscillator table --- */
50 GslOscTable* gsl_osc_table_create (gfloat mix_freq,
51  GslOscWaveForm wave_form,
52  double (*filter_func) (double),
53  guint n_freqs,
54  const gfloat *freqs);
55 void gsl_osc_table_lookup (const GslOscTable *table,
56  gfloat freq,
57  GslOscWave *wave);
58 void gsl_osc_table_free (GslOscTable *table);
59 
60 
61 /* --- oscillator wave utils --- */
62 void gsl_osc_wave_fill_buffer (GslOscWaveForm type,
63  guint n_values,
64  gfloat *values);
65 void gsl_osc_wave_extrema (guint n_values,
66  const gfloat *values,
67  gfloat *min,
68  gfloat *max);
69 void gsl_osc_wave_normalize (guint n_values,
70  gfloat *values,
71  gfloat new_center,
72  gfloat new_max);
73 void gsl_osc_wave_adjust_range (guint n_values,
74  gfloat *values,
75  gfloat min,
76  gfloat max,
77  gfloat new_center,
78  gfloat new_max);
79 const gchar* gsl_osc_wave_form_name (GslOscWaveForm wave_form);
80 
81 
82 G_END_DECLS
83 
84 #endif /* __GSL_OSC_TABLE_H__ */
Definition: gslosctable.hh:33
Definition: gbsearcharray.hh:37
Definition: gslosctable.hh:26