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