Signal Manipulations:
modulate
signal.modulate(isig) modulates the signal by the signal isig.
multiply
signal.multiply(f) multiplies every sample of the signal with f.
sampleHold
signal.sampleHold(p) samples and holds the signal with a periode of p.
The first periode starts with the first sample of the signal.
dft
signal.dft() calculates the discrete fourier transformation of the signal.
The original signal will be replaced by the transformation.
The size of the signal must be a power of 2.
falten
signal.falten(isig) folds the signal with the signal isig.
upsample
signal.upsample(p) upsamples the signal by the factor p.
The new signal size will be increased by the factor of p.
The samples between the original samples will be filled with zeros.
downsample
signal.downsample(g) downsamples the signal by the factor g.
The samples between k*g and (k+1)*g will be removed from the signal.
The parameter g must be greater than zero.
The size of the new signal will be reduced by the factor of g.
interleave
signal.interleave(isig) interleaves the signal with the signal isig.
magnitude and phase
signal.magnitudeAndPhase() calculates the magnitude and phase of the signal.
The magnitude is stored in the real part of the signal.
The phase is stored in the imaginary part of the signal
hanningWindow
signal.hanningWindow() multiplies the signal with a Hanning Window.
welchWindow
signal.welchWindow() multiplies the signal with a Welch Window.
iterator
iterator(function(n,real,imag){}) The iterator can be used to iterate a callback function over the signal.
Example for the use in firebug:
var a = 8;
sig.iterate(function(n,real,imag){
real[n] = a;
imag[n] = 2;
});
graph.draw();
Signal Forms:
random
signal.random(amplitude) replaces the samples of the signal by random samples with values between -amplitude and amplitude.
constant
signal.constant(amplitude) set the samples of the signal equal to amplitude.
unitSample
signal.unitSampleSequence(n) sets the sample with the position 'n' to one and sets all other samples to zero.
unitStep
signal.unitStep(n) set the samples with position greater or equal to n to one and sets all other samples to zero.
exponential
signal.exponential(amplitude) set the samples of the signal equal to 'amplitude^position'.
sinus
signal.sin(amplitude,omega,theta) sets the signal equal to a sinus wave with amplitude 'amplitude',rate 'omega' and phase 'theta'.
signal.addSin(amplitude,omega,theta) adds a sinus signal with amplitude 'amplitude',rate 'omega' and phase 'theta' to the current signal.
signal.sinusWelle(amplitude,number,theta) sets the signal equal to a sinus wave with 'number' periodes and an amplitude 'amplitude' and a starting phase of 'theta'.
si
signal.si(number,delay) sets the samples of the sinc function (sin(n)/n).
Number defines the number of zero values of the signal.
Delay defines the delay of the signal in samples.
linear
signal.linear(c,a) sets the samples of the signal equal to c+position*a.
rechtEckSignal
signal.rechtEckSignal(amplitude,number) sets the signal to a Rechtecksignal with amplitude 'amplitude'
and 'number' of periodes.
saegeZahn
signal.saegeZahn(amplitude,number) sets the signal to a Saegezahnsignal with amplitude 'amplitude'
and 'number' of periodes.
General Functions:
clone
signal.clone() returns a new signal with the same name,size and samples as the original signal.
Excample:
sig2 = sig.clone();
graph.draw();
transcript
signal1.transcript(signal2) sets the size of signal1 equal to the size of signal2 and
transcripts the signal2 into the signal1.
Excample:
sig1.transcript(sig2);
graph.draw();
clean
signal.clean() sets all samples of the signal to zero.
swap
signal.swap() excanges the real and the imaginary parts of the signal.
getFirstSample
signal.getFirstSample() sets the pointer "position" to zero and returns the first sample.
getNextSample
signal.getNextSample() increments the pointer "position" by one and returns the sample of the incremented pointer.
The function returns "undefined" if the position > length.
getSample
signal.getSample(pos) returns the sample of the position pos.
The function returns "undefined" if the position > length.
getReal
signal.getReal(pos) returns the real part of sample in the position pos.
The function returns "undefined" if the position > length.
getImag
signal.getImag(pos) returns the imag part of sample in the position pos.
The function returns "undefined" if the position > length.
setReal
signal.setReal(pos,value) sets the real part of sample in the position pos to the value.
setImag
signal.setImag(pos,value) sets the imag part of sample in the position pos to the value.
getLength
signal.length() returns the length of the signal.
getName
signal.getName returns the name of the signal.
signal.print() shows the signal samples in a alert window.
How to use this page:
1) Install the firefox plugin firebug.
2) Open firebug on this page.
3) Open the console in firebug.
4) Input "sig.clean(); sig.constant(9); graph.draw();" into the console.
5) Press "Run" in the console.
6) The graph will show a constant signal.
1) Install the firefox plugin firebug.
2) Open firebug on this page.
3) Open the console in firebug.
4) Input "sig.clean(); sig.constant(9); graph.draw();" into the console.
5) Press "Run" in the console.
6) The graph will show a constant signal.