aRts audio server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gslosctable.h 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* GSL - Generic Sound Layer
  2. * Copyright (C) 2001-2002 Tim Janik
  3. *
  4. * This library is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU Library General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Library General Public
  15. * License along with this library; if not, write to the
  16. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17. * Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef __GSL_OSC_TABLE_H__
  20. #define __GSL_OSC_TABLE_H__
  21. #include <gsl/gsldefs.h>
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif /* __cplusplus */
  25. /* --- structures & enums --- */
  26. typedef enum /*< skip >*/
  27. {
  28. GSL_OSC_WAVE_NONE,
  29. GSL_OSC_WAVE_SINE,
  30. GSL_OSC_WAVE_TRIANGLE,
  31. GSL_OSC_WAVE_SAW_RISE,
  32. GSL_OSC_WAVE_SAW_FALL,
  33. GSL_OSC_WAVE_PEAK_RISE,
  34. GSL_OSC_WAVE_PEAK_FALL,
  35. GSL_OSC_WAVE_MOOG_SAW,
  36. GSL_OSC_WAVE_SQUARE,
  37. GSL_OSC_WAVE_PULSE_SAW
  38. } GslOscWaveForm;
  39. typedef struct
  40. {
  41. gfloat mix_freq;
  42. GslOscWaveForm wave_form;
  43. gpointer entry_array;
  44. } GslOscTable;
  45. typedef struct
  46. {
  47. gfloat min_freq;
  48. gfloat max_freq;
  49. guint n_values;
  50. const gfloat *values; /* contains n_values+1 values with values[0]==values[n_values] */
  51. /* integer stepping (block size dependant) */
  52. guint32 n_frac_bits;
  53. guint32 frac_bittqmask;
  54. gfloat freq_to_step; /* freq -> int.frac */
  55. gfloat phase_to_pos; /* 0..1 -> int.frac */
  56. gfloat ifrac_to_float; /* frac -> 0..1 float */
  57. guint min_pos, max_pos; /* pulse extension */
  58. } GslOscWave;
  59. /* --- oscillator table --- */
  60. GslOscTable* gsl_osc_table_create (gfloat mix_freq,
  61. GslOscWaveForm wave_form,
  62. double (*filter_func) (double),
  63. guint n_freqs,
  64. const gfloat *freqs);
  65. void gsl_osc_table_lookup (const GslOscTable *table,
  66. gfloat freq,
  67. GslOscWave *wave);
  68. void gsl_osc_table_free (GslOscTable *table);
  69. /* --- oscillator wave utils --- */
  70. void gsl_osc_wave_fill_buffer (GslOscWaveForm type,
  71. guint n_values,
  72. gfloat *values);
  73. void gsl_osc_wave_extrema (guint n_values,
  74. const gfloat *values,
  75. gfloat *min,
  76. gfloat *max);
  77. void gsl_osc_wave_normalize (guint n_values,
  78. gfloat *values,
  79. gfloat new_center,
  80. gfloat new_max);
  81. void gsl_osc_wave_adjust_range (guint n_values,
  82. gfloat *values,
  83. gfloat min,
  84. gfloat max,
  85. gfloat new_center,
  86. gfloat new_max);
  87. #ifdef __cplusplus
  88. }
  89. #endif /* __cplusplus */
  90. #endif /* __GSL_OSC_TABLE_H__ */