You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-11Lines changed: 15 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,33 +11,30 @@ Among other uses, [window functions](http://en.wikipedia.org/wiki/Window_functio
11
11
12
12
## Usage
13
13
14
-
To require all window functions, include the top-level `window-function` module:
14
+
Apply window to a signal:
15
15
16
16
```javascript
17
-
var wfuncs =require('window-function')
17
+
var blackmanHarris =require('window-function/blackman-harris')
18
+
var applyWindow =require('window-function/apply')
18
19
19
20
var signal = [-1, 0, 1, 0, -1, 0]
20
21
21
-
var windowedSignal =wfuncs.applyWindow(signal, wfuncs.blackmanHarris)
22
+
var windowedSignal =applyWindow(signal, blackmanHarris)
22
23
```
23
24
24
-
You can also apply the window functions yourself:
25
+
Apply the window functions yourself:
25
26
26
27
```javascript
27
28
var wfuncs =require('window-function')
28
29
29
30
var value =wfuncs.blackmanHarris( 50, 101 )
30
31
```
31
32
32
-
You can also require a single window function:
33
+
## API
33
34
34
-
```javascript
35
-
var blackmanHarris =require('window-function/blackman-harris')
35
+
### `require('window-funciton/<type>')(i, total)`
36
36
37
-
var value =blackmanHarris( 50, 101 )
38
-
```
39
-
40
-
To calculate the value of a window function, pass the sample number and total number of samples to one of the window functions listed below, along with any additional parameters it may require. The plots below are calculated from the npm module and plotted with Fourier transform to illustrate the spectral leakage. See [the Wikipedia page on window functions](http://en.wikipedia.org/wiki/Window_function) for more details.
37
+
To calculate the value of a window function, pass the sample number `i` and `total` number of samples to one of the window functions listed below, along with any additional parameters it may require. The plots below are calculated from the npm module and plotted with Fourier transform to illustrate the spectral leakage. See [the Wikipedia page on window functions](http://en.wikipedia.org/wiki/Window_function) for more details.
41
38
42
39
-[Bartlett-Hann](#bartletthann-i-n-)
43
40
-[Bartlett](#bartlett-i-n-)
@@ -174,6 +171,13 @@ A tapered cosine window. Alpha controls the relative width of the flat section.
174
171
175
172

176
173
174
+
### `require('window-function/apply')(array, fn)`
175
+
176
+
Apply a windowing function to an array, modifies an array in-place.
177
+
178
+
### `require('window-function/generate')(fn, n)`
179
+
180
+
Generate an array of `n` samples of the window function `fn`.
0 commit comments