Filter

Filter

new Filter(optionsopt)

Source:
Properties:
Name Type Attributes Default Description
options.type String | function <optional>
"parametric"

The type of filter. This can either be a function which implements the Filter~filter_factory interface or a string naming one of the standard filters in StandardBiquadFilters.

options.freq Number <optional>
1000

The initial frequency.

options.gain Number <optional>
0

The initial gain.

options.q Number <optional>
1

The initial Q of the filter.

options.sample_rate Number <optional>
44100

The sample rate.

Filter provides the math for calculating a gain from a given frequency for different types of biquad filters.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{ }

An object containing initial options.

Extends

Methods

addEventListener(event, func)

Source:
Inherited From:

Register an event handler.

Parameters:
Name Type Description
event string

The event descriptor.

func function

The function to call when the event happens.

delegateEvents(element) → {HTMLElement}

Source:
Inherited From:

Delegates all occuring DOM events of a specific DOM node to the widget. This way the widget fires e.g. a click event if someone clicks on the given DOM node.

Parameters:
Name Type Description
element HTMLElement

The element all native events of the widget should be bound to.

Fires:
Returns:

The element

Type
HTMLElement

destroy()

Source:
Inherited From:

Destroys all event handlers and the options object.

dispatchEvent(event, …args)

Source:
Inherited From:

Fires an event.

Parameters:
Name Type Attributes Description
event string

The event descriptor.

args * <repeatable>

Event arguments.

frequencyToGain(frequency) → {number}

Source:

Returns the gain for a given frequency

Parameters:
Name Type Description
frequency number

The frequency to calculate the gain for.

Returns:

gain - The gain at the given frequency.

Type
number

get(key)

Source:
Inherited From:

Get the value of an option.

Parameters:
Name Type Description
key string

The option name.

getDefault()

Source:
Inherited From:

Returns the default value of a given option. If the option does not exist, an exception is thrown.

getOptionType()

Source:
Inherited From:

Returns the type of an option. If the given option does not exist, 'undefined' is returned.

hasEventListeners(event) → {boolean}

Source:
Inherited From:

Test if the event descriptor has some handler functions in the queue.

Parameters:
Name Type Description
event string

The event desriptor.

Returns:

True if the event has some handler functions in the queue, false if not.

Type
boolean

off(event, fun)

Source:
Inherited From:

Removes the given function from the event queue. If it is a native DOM event, it removes the DOM event listener as well.

Parameters:
Name Type Description
event string

The event descriptor.

fun function

The function to remove.

reset(key)

Source:
Overrides:

Resets an option to its default value.

Parameters:
Name Type Description
key string

The option name.

set(key, value)

Source:
Inherited From:

Sets an option. Fires both the events set with arguments key and value; and the event 'set_'+key with arguments value and key.

Parameters:
Name Type Description
key string

The name of the option.

value mixed

The value of the option.

Fires:

update(key, value)

Source:
Inherited From:

Conditionally sets an option unless it already has the requested value.

Parameters:
Name Type Description
key string

The name of the option.

value mixed

The value of the option.

Fires:

userset(key, value)

Source:
Inherited From:

Sets an option by user interaction. Emits the userset event. The userset event can be cancelled (if an event handler returns false), in which case the option is not set. Returns true if the option was set, false otherwise. If the option was set, it will emit a useraction event.

Parameters:
Name Type Description
key string

The name of the option.

value mixed

The value of the option.

Fires:
  • Base#event:userset
  • Base#event:useraction

Type Definitions

filter_factory(options) → {EqFilter}

Source:
Parameters:
Name Type Description
options Object

The filter parameters.

Properties
Name Type Description
freq number

The current frequency, i.e. the x position in the equalizer graph.

gain number

The current gain, i.e. the y position in the equalizer graph.

q number

The Q of the filter, i.e. the z position in the equalizer graph.

sample_rate number

The sample rate.

Returns:
Type
EqFilter

Events

delegated

Source:
Inherited From:

Is fired when an element is delegated.

Parameters:
Name Type Description
element HTMLElement | Array

The element which receives all native DOM events.

old_element HTMLElement | Array

The element which previously received all native DOM events.

initialized

Source:
Inherited From:

Is fired when an instance is initialized.

reset

Source:

Is fired when a filters drawing function is reset.

set

Source:
Inherited From:

Is fired when an option is set.

Parameters:
Name Type Description
name string

The name of the option.

value mixed

The value of the option.

set_[option]

Source:
Inherited From:

Is fired when an option is set.

Parameters:
Name Type Description
value mixed

The value of the option.