ZPlane:
Filter:
Classes (extension) | DSP

ZPlane
ExtensionExtension

a Z-plane object for SC with graphical interface
Location: NOT INSTALLED!

Description

A class for graphing poles and zeros on the Z-plane. Filters of arbitrary order can be designed by specifying the location of the desired poles and zeros on the Z-plane and feeding these polar coordinates to FilterCoef. ZPlane can also calculate the frequency and phase response of the desired filter. A number of convenience methods are also implemented for easier use, like automatic detection of identical pole/zero pairs and autmatic conjugate adding when specifying a pole/zero (thus resulting in real-valued filter coefficients).

Class Methods

.new

Create a new instance of ZPlane.

Arguments:

poles

An Array containing a number of poles of type Polar.

zeros

An Array containing a number of poles of type Polar.

function

A Function evaluated each time the mouse is moved in the gui. Can be used to update specific settings when a pole or zero is dragged to another location on the Z-plane.

real

A Boolean indicating whether the filter should be real or complex. When set to true, the conjugates of any specified poles and zeros are added automatically.

Returns:

A new instance of ZPlane.

DISCUSSION:


Z-plane

Inherited class methods

Instance Methods

.addPole

Add a pole to the Z-plane. Index must be a valid Integer index into the poles array. Alternatively, index can be specified as nil, which means the pole will be added to the tail of the poles array. Poles can also be added by calling -gui on an instance of ZPlane, clicking somewhere inside the graphical representation of the Z-plane and pressing 'ctr-p'.

Arguments:

index

An instance of Integer or nil.

loc

An instance of Polar.

.addZero

Add a zero to the Z-plane. Index must be a valid Integer index into the zeros array. Alternatively, index can be specified as nil, which means the zero will be added to the tail of the zeros array. Zeros can also be added by calling -gui on an instance of ZPlane, clicking somewhere inside the graphical representation of the Z-plane and pressing 'ctr-z'.

Arguments:

index

An instance of Integer or nil.

loc

An instance of Polar.

.removePole

Removes the pole specified by index. If there is a conjugate, this is removed too.

Arguments:

index

An instance of Integer.

Returns:

The (possibly modified) index in response to a method call.

.removeZero

Removes the zero specified by index. If there is a conjugate, this is removed too.

Arguments:

index

An instance of Integer.

Returns:

The (possibly modified) index in response to a method call.

.setPole

Change the location of a particular pole specified by index. If there is a conjugate this will be moved too.

Arguments:

index

An instance of Integer or nil.

newLoc

An instance of Polar.

.setPole

Change the location of a particular pole specified by index. If there is a conjugate this will be moved too.

Arguments:

index

An instance of Integer or nil.

newLoc

An instance of Polar.

.setZero

Change the location of a particular zero specified by index. If there is a conjugate this will be moved too.

Arguments:

index

An instance of Integer or nil.

newLoc

An instance of Polar.

.removeAllPoles

Removes all poles associated with this instance of ZPlane.

NOTE: poles might be added at \left(0,0\right) however, to keep the nr. of poles and zeros equal.

.removeAllZeros

Removes all zeros associated with this instance of ZPlane.

NOTE: zeros might be added at \left(0,0\right) however, to keep the nr. of poles and zeros equal.

.calcAmpResp

Calculate the amplitude response of the filter.

Arguments:

res

An Integer denoting the resolution of the amplitude response.

norm

A Boolean indicating whether the peak value of the amplitude response should be normalized to unity.

Returns:

An Array holding the amplitude response of size res.

.calcPhaseResp

Calculate the amplitude response of the filter.

Arguments:

res

An Integer denoting the resolution of the phase response.

unwrap

A Boolean indicating whether the phase response should be unwrapped.

derivative

A Boolean indicating whether the negative derivative of the phase response (group delay) should be calculated too.

Returns:

An Array (of arrays) holding the phase response and possibly the group delay of size res.

.calcAmpAndPhaseResp

Calculate the amplitude and phase response of the filter.

NOTE: If one requires the amplitude response and the phase response of the filter simultaneously, this method is slightly more efficient than calling -calcAmpResp and -calcPhaseResp separately.

Arguments:

res

An Integer denoting the resolution of the frequency response.

norm

A Boolean indicating whether the peak value of the amplitude response should be normalized to unity.

unwrap

A Boolean indicating whether the phase response should be unwrapped.

derivative

A Boolean indicating whether the negative derivative of the phase response (group delay) should be calculated too.

Returns:

An Array of arrays holding the amplitude and phase response and possibly the group delay, all of size res.

.gui

Make a window with a graphical interface for an instance of ZPlane.

Arguments:

bounds

A Rect indicating the bounds of the window holding the graphical interface.

.close

Close the gui associated with a particular instance of ZPlane.

Inherited instance methods

Examples