Signal generator hints
From CCRMA Wiki
- Use the <math.h> library sine function to compute the sine wave. You'll have to make sure to normalize the input to the sine wave by the sampling rate.
- For class one simple way to do it was: sin( 2 * pi * fc * t / fs ) where fc is the center frequency, t is a time increment increasing by 1 each sample, and fs is the sample rate.
- For simplicity, you can use a uniform distributed random number generator. If you want, try to find a Gaussian distributed random number generator!
- Use the center frequency to the fundamental period (T) in samples. The signal should be all zeros, except have a value of 1.0 at the period T.
- Compute the period (T) as above. Now divide up the period into two sections proportional to the width control (e.g., width=.5 should result in a square wave). You should probably disallow width of exactly 1.0 or 0.0 as this could create a constant amplitude signal (DC)..and you won't hear anything.
- This will be very similar to the saw