BEAST/BSE - Better Audio System and Sound Engine  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gslwaveosc.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_WAVE_OSC_H__
3 #define __GSL_WAVE_OSC_H__
4 
5 #include <bse/gsldefs.hh>
6 #include <bse/gslwavechunk.hh>
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif /* __cplusplus */
11 
12 
13 #define GSL_WAVE_OSC_FILTER_ORDER (8) /* <= GslConfig.wave_chunk_padding ! */
14 
15 typedef struct
16 {
17  GslLong start_offset;
18  gint play_dir, channel;
19 
20  gpointer wchunk_data;
21  GslWaveChunk* (*lookup_wchunk) (gpointer wchunk_data,
22  gfloat freq,
23  gfloat velocity);
24 
25  gfloat fm_strength; /* linear: 0..1, exponential: n_octaves */
26  guint exponential_fm : 1;
27  gfloat cfreq; /* for ifreq == NULL */
29 
30 typedef struct
31 {
32  GslWaveOscConfig config;
33  guint last_mode;
34  gfloat last_sync_level, last_freq_level, last_mod_level;
35  GslWaveChunkBlock block;
36  gfloat *x; /* pointer into block */
37  guint cur_pos, istep; /* FIXME */
38  gdouble a[GSL_WAVE_OSC_FILTER_ORDER + 1]; /* order */
39  gdouble b[GSL_WAVE_OSC_FILTER_ORDER + 1]; /* reversed order */
40  gdouble y[GSL_WAVE_OSC_FILTER_ORDER + 1];
41  guint j; /* y[] index */
42  GslWaveChunk *wchunk;
43  gfloat mix_freq; /* bse_engine_sample_freq() */
44  gfloat step_factor;
45  gboolean done; /* FIXME. caution, this is TRUE only if
46  * (play_dir < 0 && cur_pos < 0) ||
47  * (play_dir > 0 && cur_pos > wchunk.length)
48  */
50 
51 
52 void gsl_wave_osc_config (GslWaveOscData *wosc,
53  GslWaveOscConfig *config);
54 void gsl_wave_osc_reset (GslWaveOscData *wosc);
55 gboolean gsl_wave_osc_process (GslWaveOscData *wosc,
56  guint n_values,
57  const gfloat *ifreq,
58  const gfloat *mod,
59  const gfloat *sync,
60  gfloat *mono_out);
61 void gsl_wave_osc_retrigger (GslWaveOscData *wosc,
62  gfloat freq);
63 void gsl_wave_osc_set_filter (GslWaveOscData *wosc,
64  gfloat freq,
65  gboolean clear_state);
66 
67 void gsl_wave_osc_init (GslWaveOscData *wosc);
68 void gsl_wave_osc_shutdown (GslWaveOscData *wosc);
69 GslLong gsl_wave_osc_cur_pos (GslWaveOscData *wosc);
70 
71 /* setup:
72  * wosc = g_new0 (GslWaveOscData, 1);
73  * wosc->mix_freq = bse_engine_sample_freq ();
74  */
75 
76 
77 
78 #ifdef __cplusplus
79 }
80 #endif /* __cplusplus */
81 
82 #endif /* __GSL_WAVE_OSC_H__ */
Definition: gslwaveosc.hh:30
Definition: gslwaveosc.hh:15