**square_sample(freq, amp, dur)**

This function returns a square wave with frequency freq, amplitude amp, and duration dur (in seconds). The amplitude should be specified with a range of 0 to 1 where 1 represents the maximal amplitude. To obtain the actual amplitude in the sample use the WAVE_MAX value to scale it to an appropriate value.

See http://en.wikipedia.org/wiki/Image:Waveforms.svg for an illustration.

**sawtooth_sample(freq, amp, dur)**

This function returns a sawtooth wave with frequency freq, amplitude amp, and duration dur (in seconds). The amplitude should be specified with a range of 0 to 1 where 1 represents the maximal amplitude. To obtain the actual amplitude in the sample use the WAVE_MAX value to scale it to an appropriate value.

See http://en.wikipedia.org/wiki/Image:Waveforms.svg for an illustration.

**ring_modulate(s1, s2)**

This function takes two waves and computes their ring modulation. The ring modulation is the product of the two input waves.

In order to calculate the ring modulation of the given waves, each wave is first scaled so that the samples range from 0 to 1. Each pair of corresponding sample is multiplied, and then scaled back to the original range of values (hint: use WAVE_MAX).

**just_scale(freq, amp, dur, sampler=sin_sample)**

This function is essentially the same as the scale in equal temperment, except that the frequency multipliers should be the ones provided in the ratios list.

See also http://thinkzone.wlonk.com/Music/12Tone.htm

—-

**partch_scale(freq, amp, dur, sampler=sin_sample)**

This function produces an ascending partch scale. This scale contains 43 tones which are calculated using the ratios in the ratios list.

The scale is not found in classical music, but rather in the electronic music of Harry Partch. Even to most musicians this scale will sound unfamiliar.

See also http://sonic-arts.org/monzo/partch/43lattice.htm

** fade_out(data, amount=.1) **

This function takes in an array of samples and implements a fading out effect over the last “amount” percent of the samples. The scaling function may be any decreasing curve, however a straightforward approach is to use a linear function. It may also be interesting to try this with an exponential function.

This function is particularly useful for eliminating the “clicking” between samples generated by the other routines.