Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notch filter support #122

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ logos
*.sublime-project
*.sublime-workspace
*.pem
npm-debug.log
npm-debug.log
.package-lock.json
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
logos
*.sublime-project
*.sublime-workspace
site
site
.package-lock.json
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Pizzicato aims to simplify the way you create and manipulate sounds via the Web
- [Compressor](#compressor)
- [Low-pass filter](#low-pass-filter)
- [High-pass filter](#high-pass-filter)
- [Notch filter](#notch-filter)
- [Stereo Panner](#stereo-panner)
- [Convolver](#convolver)
- [Reverb](#reverb)
Expand Down Expand Up @@ -853,6 +854,25 @@ sound.addEffect(highPassFilter);
sound.play();
```

<a name="notch-filter"/>

### Notch filter ([example](https://alemangui.github.io/pizzicato/#notch-filter))
Standard notch filter, also called a band-stop or band-rejection filter. It is the opposite of a bandpass filter: frequencies outside the give range of frequencies pass through; frequencies inside it are attenuated.

* ```frequency``` _(min: 10, max: 22050, defaults to 350)_: The center of the range of frequencies.
* ```peak``` _(min: 0.0001, max: 1000, defaults to 1)_: Controls the width of the frequency band. The greater peak value - the smaller frequency band.

Example:
```javascript
var notchFilter = new Pizzicato.Effects.NotchFilter({
frequency: 1000,
peak: 3.0
});

sound.addEffect(notchFilter);
sound.play();
```

<a name="stereo-panner"/>

### Stereo panner ([example](https://alemangui.github.io/pizzicato/#stereo-panner))
Expand Down
34 changes: 33 additions & 1 deletion distr/Pizzicato.js
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,16 @@
Filter.call(this, options, 'highpass');
};

/**
* Frequencies outside the give range of
* frequencies pass through;
*
* frequencies inside it are attenuated.
*/
Pizzicato.Effects.NotchFilter = function(options) {
Filter.call(this, options, 'notch');
};

/**
* Filters used by Pizzicato stem from the biquad filter node. This
* function acts as a common constructor. The only thing that changes
Expand All @@ -1328,7 +1338,8 @@

var defaults = {
frequency: 350,
peak: 1
peak: 1,
gain: 0,
};

this.inputNode = this.filterNode = Pz.context.createBiquadFilter();
Expand Down Expand Up @@ -1380,11 +1391,32 @@
if (Pizzicato.Util.isInRange(value, 0.0001, 1000))
this.filterNode.Q.value = value;
}
},

/**
* The boost, in dB, to be applied;
* if negative, it will be an attenuation.
* MIN: -15.0
* MAX: 15.0
*/
gain: {
enumerable: true,

get: function () {
return this.filterNode.gain.value;
},
set: function(value) {
// 15db used as common limit referenced from Ableton Live EQ8
if (Pizzicato.Util.isInRange(value, -15.0, 15.0))
this.filterNode.gain.value = value;
}
}
});

Pizzicato.Effects.LowPassFilter.prototype = filterPrototype;
Pizzicato.Effects.HighPassFilter.prototype = filterPrototype;
Pizzicato.Effects.NotchFilter.prototype = filterPrototype;

Pizzicato.Effects.Distortion = function(options) {

this.options = {};
Expand Down
4 changes: 2 additions & 2 deletions distr/Pizzicato.min.js

Large diffs are not rendered by default.

Loading