PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

synth_waveform.md 1.7KB

3 lat temu
123456789101112131415161718192021222324252627282930313233343536
  1. synth_waveform 140404
  2. This synthesizes a waveform of the specified type with a given amplitude
  3. and frequency. There are currently four types of waveform:
  4. #define TONE_TYPE_SINE 0
  5. #define TONE_TYPE_SAWTOOTH 1
  6. #define TONE_TYPE_SQUARE 2
  7. #define TONE_TYPE_TRIANGLE 3
  8. Sine wave generation uses a lookup table and linear interpolation.
  9. The other three waveforms are generated directly without using table lookup.
  10. boolean begin(float t_amp,float t_freq,short t_type)
  11. This starts generation of a waveform of given type, amplitude and frequency
  12. Example: begin(0.8,440.0,TONE_TYPE_SINE)
  13. void set_ramp_length(int16_t r_length)
  14. When a tone starts, or ends, playing it can generate an audible "thump" which can
  15. be very distracting, especially when playing musical notes. This function specifies
  16. a "ramp" length (in number of samples) and the beginning of the generated waveform
  17. will be ramped up in volume from zero to t_amp over the course of r_length samples.
  18. When the tone is switched off, by changing its volume to zero, instead of ending
  19. abruptly it will be ramped down to zero over the next r_length samples.
  20. For example, if r_length is 44, the beginning and end of the wave will have a ramp
  21. of approximately one millisecond.
  22. void frequency(float t_freq)
  23. Changes the frequency of the wave to the specified t_freq. This is done in a phase-
  24. continuous manner which should allow generation of audio frequency shift keying and
  25. other effects requiring a changing frequency.
  26. If the frequency is set to zero sample generation is stopped.
  27. void amplitude(float n)
  28. Changes the amplitude to 'n'. If 'n' is zero the wave is turned off and any further
  29. audio output will be zero.