BEAST/BSE - Better Audio System and Sound Engine  0.8.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
gslwaveosc.hh
Go to the documentation of this file.
00001  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
00002 #ifndef __GSL_WAVE_OSC_H__
00003 #define __GSL_WAVE_OSC_H__
00004 
00005 #include <bse/gsldefs.hh>
00006 #include <bse/gslwavechunk.hh>
00007 
00008 #ifdef __cplusplus
00009 extern "C" {
00010 #endif /* __cplusplus */
00011 
00012 
00013 #define GSL_WAVE_OSC_FILTER_ORDER       (8)     /* <= GslConfig.wave_chunk_padding ! */
00014 
00015 typedef struct
00016 {
00017   GslLong         start_offset;
00018   gint            play_dir, channel;
00019 
00020   gpointer        wchunk_data;
00021   GslWaveChunk* (*lookup_wchunk) (gpointer      wchunk_data,
00022                                   gfloat        freq,
00023                                   gfloat        velocity);
00024 
00025   gfloat          fm_strength;  /* linear: 0..1, exponential: n_octaves */
00026   guint           exponential_fm : 1;
00027   gfloat          cfreq;        /* for ifreq == NULL */
00028 } GslWaveOscConfig;
00029 
00030 typedef struct
00031 {
00032   GslWaveOscConfig  config;
00033   guint             last_mode;
00034   gfloat            last_sync_level, last_freq_level, last_mod_level;
00035   GslWaveChunkBlock block;
00036   gfloat           *x;                  /* pointer into block */
00037   guint             cur_pos, istep;     /* FIXME */
00038   gdouble           a[GSL_WAVE_OSC_FILTER_ORDER + 1];       /* order */
00039   gdouble           b[GSL_WAVE_OSC_FILTER_ORDER + 1];       /* reversed order */
00040   gdouble           y[GSL_WAVE_OSC_FILTER_ORDER + 1];
00041   guint             j;                  /* y[] index */
00042   GslWaveChunk     *wchunk;
00043   gfloat            mix_freq;           /* bse_engine_sample_freq() */
00044   gfloat            step_factor;
00045   gboolean          done;               /* FIXME. caution, this is TRUE only if
00046                                          * (play_dir < 0 && cur_pos < 0) ||
00047                                          * (play_dir > 0 && cur_pos > wchunk.length)
00048                                          */
00049 } GslWaveOscData;
00050 
00051 
00052 void            gsl_wave_osc_config     (GslWaveOscData *wosc,
00053                                          GslWaveOscConfig *config);
00054 void            gsl_wave_osc_reset      (GslWaveOscData *wosc);
00055 gboolean        gsl_wave_osc_process    (GslWaveOscData *wosc,
00056                                          guint           n_values,
00057                                          const gfloat   *ifreq,
00058                                          const gfloat   *mod,
00059                                          const gfloat   *sync,
00060                                          gfloat         *mono_out);
00061 void            gsl_wave_osc_retrigger  (GslWaveOscData *wosc,
00062                                          gfloat          freq);
00063 void            gsl_wave_osc_set_filter (GslWaveOscData *wosc,
00064                                          gfloat          freq,
00065                                          gboolean        clear_state);
00066 
00067 void            gsl_wave_osc_init       (GslWaveOscData *wosc);
00068 void            gsl_wave_osc_shutdown   (GslWaveOscData *wosc);
00069 GslLong         gsl_wave_osc_cur_pos    (GslWaveOscData *wosc);
00070 
00071 /* setup:
00072  * wosc = g_new0 (GslWaveOscData, 1);
00073  * wosc->mix_freq = bse_engine_sample_freq ();
00074  */
00075 
00076 
00077 
00078 #ifdef __cplusplus
00079 }
00080 #endif /* __cplusplus */
00081 
00082 #endif /* __GSL_WAVE_OSC_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines