Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

synth_tonesweep.h 2.0KB

10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* Audio Library for Teensy 3.X
  2. * Copyright (c) 2014, Pete (El Supremo)
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. * THE SOFTWARE.
  21. */
  22. #ifndef synth_tonesweep_h_
  23. #define synth_tonesweep_h_
  24. #include <core/Arduino.h>
  25. #include <core/AudioStream.h>
  26. // A u d i o S y n t h T o n e S w e e p
  27. // Written by Pete (El Supremo) Feb 2014
  28. class AudioSynthToneSweep : public AudioStream
  29. {
  30. public:
  31. AudioSynthToneSweep(void) :
  32. AudioStream(0,NULL), sweep_busy(0)
  33. { }
  34. boolean play(float t_amp,int t_lo,int t_hi,float t_time);
  35. virtual void update(void);
  36. unsigned char isPlaying(void);
  37. float read(void) {
  38. __disable_irq();
  39. uint64_t freq = tone_freq;
  40. unsigned char busy = sweep_busy;
  41. __enable_irq();
  42. if (!busy) return 0.0f;
  43. return (float)(freq >> 32);
  44. }
  45. private:
  46. short tone_amp;
  47. unsigned int tone_lo;
  48. unsigned int tone_hi;
  49. uint64_t tone_freq;
  50. uint64_t tone_phase;
  51. uint64_t tone_incr;
  52. int tone_sign;
  53. unsigned char sweep_busy;
  54. };
  55. #endif