BEAST/BSE - Better Audio System and Sound Engine  0.8.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
gslosctable.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_OSC_TABLE_H__
00003 #define __GSL_OSC_TABLE_H__
00004 
00005 #include <bse/gsldefs.hh>
00006 #include <sfi/gbsearcharray.hh>
00007 
00008 G_BEGIN_DECLS
00009 
00010 
00011 /* --- structures & enums --- */
00012 typedef enum    /*< skip >*/
00013 {
00014   GSL_OSC_WAVE_NONE,
00015   GSL_OSC_WAVE_SINE,
00016   GSL_OSC_WAVE_TRIANGLE,
00017   GSL_OSC_WAVE_SAW_RISE,
00018   GSL_OSC_WAVE_SAW_FALL,
00019   GSL_OSC_WAVE_PEAK_RISE,
00020   GSL_OSC_WAVE_PEAK_FALL,
00021   GSL_OSC_WAVE_MOOG_SAW,
00022   GSL_OSC_WAVE_SQUARE,
00023   GSL_OSC_WAVE_PULSE_SAW
00024 } GslOscWaveForm;
00025 
00026 typedef struct
00027 {
00028   gfloat         mix_freq;
00029   GslOscWaveForm wave_form;
00030   GBSearchArray *entry_array;
00031 } GslOscTable;
00032 
00033 typedef struct
00034 {
00035   gfloat        min_freq;
00036   gfloat        max_freq;
00037   guint         n_values;
00038   const gfloat *values; /* contains n_values+1 values with values[0]==values[n_values] */
00039   /* integer stepping (block size dependant) */
00040   guint32       n_frac_bits;
00041   guint32       frac_bitmask;
00042   gfloat        freq_to_step;           /* freq -> int.frac */
00043   gfloat        phase_to_pos;           /* 0..1 -> int.frac */
00044   gfloat        ifrac_to_float;         /* frac -> 0..1 float */
00045   guint         min_pos, max_pos;       /* pulse extension */
00046 } GslOscWave;
00047 
00048 
00049 /* --- oscillator table --- */
00050 GslOscTable*    gsl_osc_table_create            (gfloat                  mix_freq,
00051                                                  GslOscWaveForm          wave_form,
00052                                                  double                (*filter_func) (double),
00053                                                  guint                   n_freqs,
00054                                                  const gfloat           *freqs);
00055 void            gsl_osc_table_lookup            (const GslOscTable      *table,
00056                                                  gfloat                  freq,
00057                                                  GslOscWave             *wave);
00058 void            gsl_osc_table_free              (GslOscTable            *table);
00059 
00060 
00061 /* --- oscillator wave utils --- */
00062 void            gsl_osc_wave_fill_buffer        (GslOscWaveForm          type,
00063                                                  guint                   n_values,
00064                                                  gfloat                 *values);
00065 void            gsl_osc_wave_extrema            (guint                   n_values,
00066                                                  const gfloat           *values,
00067                                                  gfloat                 *min,
00068                                                  gfloat                 *max);
00069 void            gsl_osc_wave_normalize          (guint                   n_values,
00070                                                  gfloat                 *values,
00071                                                  gfloat                  new_center,
00072                                                  gfloat                  new_max);
00073 void            gsl_osc_wave_adjust_range       (guint                   n_values,
00074                                                  gfloat                 *values,
00075                                                  gfloat                  min,
00076                                                  gfloat                  max,
00077                                                  gfloat                  new_center,
00078                                                  gfloat                  new_max);
00079 const gchar*    gsl_osc_wave_form_name          (GslOscWaveForm          wave_form);
00080 
00081 
00082 G_END_DECLS
00083 
00084 #endif /* __GSL_OSC_TABLE_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines