Newer
Older
music / app / src / main / cpp / waveforms / Sawtooth.cpp
  1. #include "Sawtooth.h"
  2.  
  3. void Sawtooth::setFrequency(float frequency) {
  4. step = 2 * frequency / (double) host->sampleRate;
  5. }
  6.  
  7. void Sawtooth::renderWaveform(uint32_t frameCount) {
  8. for (uint32_t i = 0; i < frameCount; i++) {
  9. buffer[i] = value;
  10. value += step;
  11. if (value > 1) {
  12. value = -1;
  13. }
  14. }
  15. }