voices.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Copyright 2016 Jack Humbert
  2. * Copyright 2020 JohSchneider
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program 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 General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #pragma once
  18. #include <stdint.h>
  19. #include <stdbool.h>
  20. #include "wait.h"
  21. #include "luts.h"
  22. float voice_envelope(float frequency);
  23. typedef enum {
  24. default_voice,
  25. #ifdef AUDIO_VOICES
  26. vibrating,
  27. something,
  28. drums,
  29. butts_fader,
  30. octave_crunch,
  31. duty_osc,
  32. duty_octave_down,
  33. delayed_vibrato,
  34. // delayed_vibrato_octave,
  35. // duty_fifth_down,
  36. // duty_fourth_down,
  37. // duty_third_down,
  38. // duty_fifth_third_down,
  39. #endif
  40. number_of_voices // important that this is last
  41. } voice_type;
  42. void set_voice(voice_type v);
  43. void voice_iterate(void);
  44. void voice_deiterate(void);
  45. // Vibrato functions
  46. void voice_set_vibrato_rate(float rate);
  47. void voice_increase_vibrato_rate(float change);
  48. void voice_decrease_vibrato_rate(float change);
  49. void voice_set_vibrato_strength(float strength);
  50. void voice_increase_vibrato_strength(float change);
  51. void voice_decrease_vibrato_strength(float change);
  52. // Timbre functions
  53. /**
  54. * @brief set the global timbre for tones to be played
  55. * @note: only applies to pwm implementations - where it adjusts the duty-cycle
  56. * @note: using any instrument from voices.[ch] other than 'default' may override the set value
  57. * @param[in]: timbre: valid range is (0,100)
  58. */
  59. void voice_set_timbre(uint8_t timbre);
  60. uint8_t voice_get_timbre(void);