# Difference between revisions of "Signal generator hints"

From CCRMA Wiki

(→saw wave) |
|||

Line 1: | Line 1: | ||

− | These are listed in some what easiest-to-hardest. As we did the sine wave in class, it's first! | + | <!--These are listed in some what easiest-to-hardest. As we did the sine wave in class, it's first!--> |

==sine wave== | ==sine wave== | ||

Line 15: | Line 15: | ||

* This will be very similar to the saw | * This will be very similar to the saw | ||

− | ==saw wave== | + | <!--==saw wave== |

− | * The saw wave output should visually look the the teeth of a saw. The width (w) is a number between 0.0 and 1.0 the shape of the wave (e.g., width=.5 should result in a triangle wave, width=0 has shoots straight up to 1, and then has a negative slope downward, etc). First use the center frequency to determine how many sample you need to create the correct time period (T) in samples. Then use the width control to divide up the period into two section lengths (left and right) proportional to the width value. From there, "draw" a line with the correct slopes within each section. | + | * The saw wave output should visually look the the teeth of a saw. The width (w) is a number between 0.0 and 1.0 the shape of the wave (e.g., width=.5 should result in a triangle wave, width=0 has shoots straight up to 1, and then has a negative slope downward, etc). First use the center frequency to determine how many sample you need to create the correct time period (T) in samples. Then use the width control to divide up the period into two section lengths (left and right) proportional to the width value. From there, "draw" a %line with the correct slopes within each section.--> |

## Latest revision as of 20:13, 27 September 2017

## Contents

## sine wave

- 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.

## noise

- For simplicity, you can use a uniform distributed random number generator. If you want, try to find a Gaussian distributed random number generator!

## impulse train

- 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.

## pulse wave

- 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