Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Sound/Sound.cpp
- Committer:
- lukeocarwright
- Date:
- 2020-05-19
- Revision:
- 14:9cfe0041cc4e
- Child:
- 15:1c67f064278e
File content as of revision 14:9cfe0041cc4e:
#include "Sound.h" //Global Variables volatile extern uint16_t sin_wavtable[1024]; volatile extern uint16_t tri_wavtable[1024]; volatile extern uint16_t pulse_wavtable[1024]; //Constructor/Destructor Sound::Sound() { } Sound::~Sound() { } //PUBLIC:----------------------------------------------------------------------- uint16_t Sound::sound_main(bool initial, int waveform, int frequency) { if (initial==true) { i=0; return(i); } i=wavetable_itt(i,frequency); if (waveform==1) { #ifdef SLOW_TIME printf("SIN_wavtable[%u]=",i) #endif return (sin_wavtable[i]); } return(0); } //PRIVATE:---------------------------------------------------------------------- uint16_t Sound::wavetable_itt(uint16_t i, int frequency) { i_d = i + ((1024*frequency)/4000); //i+((samples*f)*Ts) i=ceil(i_d); //ROUND IN FUTURE************* if (i>=1024) { i=i-1024; } return(i); }