voices.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #if defined(__AVR__)
  21. # include <avr/io.h>
  22. #endif
  23. #include "wait.h"
  24. #include "luts.h"
  25. float voice_envelope(float frequency);
  26. typedef enum {
  27. default_voice,
  28. #ifdef AUDIO_VOICES
  29. vibrating,
  30. something,
  31. drums,
  32. butts_fader,
  33. octave_crunch,
  34. duty_osc,
  35. duty_octave_down,
  36. delayed_vibrato,
  37. // delayed_vibrato_octave,
  38. // duty_fifth_down,
  39. // duty_fourth_down,
  40. // duty_third_down,
  41. // duty_fifth_third_down,
  42. #endif
  43. number_of_voices // important that this is last
  44. } voice_type;
  45. void set_voice(voice_type v);
  46. void voice_iterate(void);
  47. void voice_deiterate(void);
  48. // Vibrato functions
  49. void voice_set_vibrato_rate(float rate);
  50. void voice_increase_vibrato_rate(float change);
  51. void voice_decrease_vibrato_rate(float change);
  52. void voice_set_vibrato_strength(float strength);
  53. void voice_increase_vibrato_strength(float change);
  54. void voice_decrease_vibrato_strength(float change);
  55. // Timbre functions
  56. /**
  57. * @brief set the global timbre for tones to be played
  58. * @note: only applies to pwm implementations - where it adjusts the duty-cycle
  59. * @note: using any instrument from voices.[ch] other than 'default' may override the set value
  60. * @param[in]: timbre: valid range is (0,100)
  61. */
  62. void voice_set_timbre(uint8_t timbre);
  63. uint8_t voice_get_timbre(void);