I think you may be misinterpreting how the FMOSC command works.

http://www.cs.cmu.edu/~rbd/doc/nyquist/ ... l#index394**(fmosc pitch modulation [table phase])** [LISP]

Returns a sound which is table oscillated at pitch plus modulation for the duration of the sound modulation. osc-table defaults to *table*, and phase is the starting phase (default 0.0 degrees) within osc-table. The modulation is expressed in hz, e.g. a sinusoid modulation signal with an amplitude of 1.0 (2.0 peak to peak), will cause a +/- 1.0 hz frequency deviation in sound. Negative frequencies are correctly handled. The sample rate is *sound-srate*.

By example:

The "pitch" parameter is the MIDI note number. It is easy to convert between MIDI note number (which Nyquist refers to as "steps") and frequency in Hz with the two functions "STEP-TO-HZ" and "HZ-TO-STEP". So in this first example I'll use (hz-to-step 440), which gives the "Pitch" (MIDI note number) for a frequency of 440 Hz.

Nyquist has a function "CONST" that produces a signal at a constant amplitude.

- Code: Select all
`(fmosc (hz-to-step 440) (const 0))`

This example returns a sound that oscillates at a frequency of 440 Hz + 0. In other words, it produces a sine wave at a frequency of 440 Hz. Try it for yourself and use "Plot Spectrum" to check the result.

- Code: Select all
`(fmosc (hz-to-step 440) (const 200))`

This example returns a sound that oscillates at a frequency of 440 Hz + 200. In other words, it produces a sine wave at a frequency of 640 Hz. Try it for yourself and use "Plot Spectrum" to check the result.

Nyquist has a function "RAMP" which creates a signal that gradually increases from 0 to 1.

By multiplying (ramp) by a fixed number, we can make a signal that rises from 0 to any value we like. For example (mult 440 (ramp)) will rise from 0 to 440.

- Code: Select all
`(fmosc (hz-to-step 440) (mult 440 (ramp)))`

Adding together the pitch [440 Hz] and the 'modulation' [ (mult 440 (ramp)) ], results in a signal that starts at 440 Hz and rises in pitch to 880 Hz.

The Nyquist function "HZOSC" creates a sine wave at a given frequency and an amplitude of +/- 1.

By multiplying a sine wave by a fixed number, we can change the amplitude. For example:

(hzosc 2) produces a sine wave with a frequency of 2 Hz and an amplitude of +/- 1.

(mult 100 (hzosc 2)) produces a sine wave with a frequency of 2 Hz and an amplitude of +/- 100.

- Code: Select all
`(fmosc (hz-to-step 440) (mult 100 (hzosc 2)))`

Adding together the pitch [440 Hz] and the 'modulation' [ (mult (100 (hzosc 2)) ], results in a signal that modulates at a frequency of 2 Hz, between 440 - 100 and 440 + 100. In other words, it creates a sound that 'wobbles' 2 times per second between 350 Hz and 540 Hz.

If the sum of the "pitch" parameter and the "modulation" parameter is negative, then FMOSC produces a frequency that has the absolute value of the sum, but is phase inverted. So

these two commands will both produce a sine wave at a frequency of 440 Hz, but one is "upside down" (phase inverted) from the other:

- Code: Select all
`(fmosc (hz-to-step 0) (const 440))`

- Code: Select all
`(fmosc (hz-to-step 0) (const -440))`

- Code: Select all
`(fmosc (hz-to-step 0.5)(mult 20 (hzosc 200)))`

Produces a sine wave that is modulated at a frequency of 200 Hz, between -19.5 Hz and 20 Hz.