Skip to content

Commit 22faffc

Browse files
authored
Merge pull request #6 from bvanderdrift/master
Uncomment `applyWindow` helper
2 parents 04c9ce6 + a03c958 commit 22faffc

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ To require all window functions, include the top-level `window-function` module:
1616
```javascript
1717
var wfuncs = require('window-function')
1818

19+
var signal = [-1, 0, 1, 0, -1, 0]
20+
21+
var windowedSignal = wfuncs.applyWindow(signal, wfuncs.blackmanHarris)
22+
```
23+
24+
You can also apply the window functions yourself:
25+
26+
```javascript
27+
var wfuncs = require('window-function')
28+
1929
var value = wfuncs.blackmanHarris( 50, 101 )
2030
```
2131

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ module.exports = {
1717
flatTop: require('./flat-top'),
1818
cosine: require('./cosine'),
1919
gaussian: require('./gaussian'),
20-
tukey: require('./tukey')
20+
tukey: require('./tukey'),
21+
applyWindow: applyWindow
2122
}
2223

23-
/*
2424
function applyWindow(signal, func) {
2525
var i, n=signal.length, args=[0,n]
2626

@@ -36,7 +36,7 @@ function applyWindow(signal, func) {
3636
return signal;
3737
}
3838

39-
39+
/*
4040
function generate(func, N) {
4141
var i, args=[0,N]
4242
var signal = new Array(N);

test/test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('window functions return a finite number',function() {
4545
})
4646
})
4747

48-
/*describe('applies a window function',function() {
48+
describe('applies a window function',function() {
4949

5050
var x
5151

@@ -54,18 +54,19 @@ describe('window functions return a finite number',function() {
5454
})
5555

5656
it('applies a window to a signal',function() {
57-
wfunc.window( x, wfunc.hamming )
57+
var y = wfunc.applyWindow( x, wfunc.hamming )
58+
assert(y.length === x.length);
5859
})
5960

6061
it('passes extra arguments to a window function',function() {
61-
wfunc.window( x, wfunc.gaussian, 0.1 )
62+
wfunc.applyWindow( x, wfunc.gaussian, 0.1 )
6263
assert( isFinite(x[0]), 'samples are finite' )
6364
assert( x[0] < 1e-8, 'samples have been windowed' )
6465
})
6566
})
6667

6768

68-
69+
/*
6970
describe('generates a window function',function() {
7071
7172
it('constructs an window function array',function() {

0 commit comments

Comments
 (0)