GenerateTone - Maple Help

SignalProcessing

 GenerateTone
 generate a tone

 Calling Sequence GenerateTone( n, magnitude, frequency, phase )

Parameters

 n - posint, number of samples to generate magnitude - realcons, magnitude of the signal frequency - realcons, the frequency relative to the sampling frequency; with value 0 <= frequency < 1/2 (Nyquist sampling frequency) phase - realcons, the phase of the signal (0 <= phase < 2Pi)

Options

 • container : Array, predefined Array for holding results

Description

 • The GenerateTone(n, magnitude, frequency, phase ) command generates n samples for a tone (sinusoidal) signal with the indicated values for the magnitude, frequency and phase. The result is returned in an Array with datatype float[8].
 • If the container=c option is provided, then the results are put into c and c is returned. With this option, no additional memory is allocated to store the result. The container must be an Array of size n having datatype float[8].

 • The SignalProcessing[GenerateTone] command is thread-safe as of Maple 17.

Examples

 > $\mathrm{with}\left(\mathrm{SignalProcessing}\right):$
 > $\mathrm{GenerateTone}\left(10,1,\frac{1}{\mathrm{\pi }},\mathrm{\pi }\right)$
 $\left[\begin{array}{cccccccccc}{-1.}& {0.416146836441423}& {0.653643621350037}& {-0.960170286323670}& {0.145500032130977}& {0.839071530285352}& {-0.843853957257653}& {-0.136737221452173}& {0.957659481417869}& {-0.660316704993774}\end{array}\right]$ (1)

The container option can be used to put generated values into a predefined Array.

 > $c≔\mathrm{Array}\left(1..10,\mathrm{datatype}=\mathrm{float}\left[8\right],\mathrm{order}=\mathrm{C_order}\right):$
 > $\mathrm{GenerateTone}\left(10,1,\frac{1}{\mathrm{\pi }},\mathrm{\pi },\mathrm{container}=c\right)$
 $\left[\begin{array}{cccccccccc}{-1.}& {0.416146836441423}& {0.653643621350037}& {-0.960170286323670}& {0.145500032130977}& {0.839071530285352}& {-0.843853957257653}& {-0.136737221452173}& {0.957659481417869}& {-0.660316704993774}\end{array}\right]$ (2)
 > $c$
 $\left[\begin{array}{cccccccccc}{-1.}& {0.416146836441423}& {0.653643621350037}& {-0.960170286323670}& {0.145500032130977}& {0.839071530285352}& {-0.843853957257653}& {-0.136737221452173}& {0.957659481417869}& {-0.660316704993774}\end{array}\right]$ (3)
 > $\mathrm{SignalPlot}\left(\mathrm{GenerateTone}\left(100,1,\frac{1}{\mathrm{\pi }},\mathrm{\pi }\right)\right)$

 > $\mathrm{nSamples}≔200:$
 > $\mathrm{RelativeFrequency}≔0.02:$
 > $\mathrm{signal}≔\mathrm{Array}\left(\mathrm{GenerateTone}\left(\mathrm{nSamples},1,\mathrm{RelativeFrequency},0\right)\right)$
 ${\mathrm{signal}}{≔}\left[{1.}{,}{0.992114701314478}{,}{0.968583161128631}{,}{0.929776485888251}{,}{0.876306680043864}{,}{0.809016994374947}{,}{0.728968627421412}{,}{0.637423989748690}{,}{0.535826794978997}{,}{0.425779291565073}{,}{0.309016994374947}{,}{0.187381314585725}{,}{0.0627905195293133}{,}{-0.0627905195293134}{,}{-0.187381314585725}{,}{-0.309016994374947}{,}{-0.425779291565073}{,}{-0.535826794978997}{,}{-0.637423989748690}{,}{-0.728968627421411}{,}{-0.809016994374947}{,}{-0.876306680043864}{,}{-0.929776485888251}{,}{-0.968583161128631}{,}{-0.992114701314478}{,}{-1.}{,}{-0.992114701314478}{,}{-0.968583161128631}{,}{-0.929776485888251}{,}{-0.876306680043863}{,}{-0.809016994374948}{,}{-0.728968627421412}{,}{-0.637423989748690}{,}{-0.535826794978996}{,}{-0.425779291565072}{,}{-0.309016994374948}{,}{-0.187381314585725}{,}{-0.0627905195293132}{,}{0.0627905195293128}{,}{0.187381314585724}{,}{0.309016994374947}{,}{0.425779291565072}{,}{0.535826794978997}{,}{0.637423989748689}{,}{0.728968627421411}{,}{0.809016994374947}{,}{0.876306680043864}{,}{0.929776485888251}{,}{0.968583161128631}{,}{0.992114701314478}{,}{1.}{,}{0.992114701314478}{,}{0.968583161128631}{,}{0.929776485888251}{,}{0.876306680043864}{,}{0.809016994374947}{,}{0.728968627421412}{,}{0.637423989748690}{,}{0.535826794978996}{,}{0.425779291565073}{,}{0.309016994374948}{,}{0.187381314585725}{,}{0.0627905195293142}{,}{-0.0627905195293136}{,}{-0.187381314585725}{,}{-0.309016994374947}{,}{-0.425779291565073}{,}{-0.535826794978997}{,}{-0.637423989748691}{,}{-0.728968627421412}{,}{-0.809016994374947}{,}{-0.876306680043864}{,}{-0.929776485888251}{,}{-0.968583161128631}{,}{-0.992114701314478}{,}{-1.}{,}{-0.992114701314478}{,}{-0.968583161128631}{,}{-0.929776485888252}{,}{-0.876306680043863}{,}{-0.809016994374948}{,}{-0.728968627421412}{,}{-0.637423989748691}{,}{-0.535826794978996}{,}{-0.425779291565072}{,}{-0.309016994374948}{,}{-0.187381314585726}{,}{-0.0627905195293134}{,}{0.0627905195293126}{,}{0.187381314585725}{,}{0.309016994374947}{,}{0.425779291565072}{,}{0.535826794978997}{,}{0.637423989748689}{,}{0.728968627421412}{,}{0.809016994374947}{,}{0.876306680043864}{,}{0.929776485888251}{,}{0.968583161128631}{,}{0.992114701314478}{,}{\dots }{,}{\text{⋯ 100 Array entries not shown}}\right]$ (4)

A plot of the signal vs the index position (note that this is not equal to time):

 > $\mathrm{SignalPlot}\left(\mathrm{signal}\right)$

To plot the signal vs time, the sampling rate and signal frequency are required:

 > $\mathrm{SamplingRate}≔1000:$
 > $\mathrm{SignalPlot}\left(\mathrm{signal},\mathrm{samplerate}=\mathrm{SamplingRate}\mathrm{RelativeFrequency}\right)$

Compatibility

 • The SignalProcessing[GenerateTone] command was introduced in Maple 17.