Skip to content

Commit 76f5cfe

Browse files
committed
Correctly return the sampleRate from the sample dropper
1 parent fcbf1b0 commit 76f5cfe

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/lib/audio/audio-util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const dropEveryOtherSample = buffer => {
102102
}
103103
return {
104104
samples: newSamples,
105-
sampleRate: buffer.rate / 2
105+
sampleRate: buffer.sampleRate / 2
106106
};
107107
};
108108

test/unit/util/audio-util.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,15 @@ describe('dropEveryOtherSample', () => {
8787
sampleRate: 2
8888
};
8989
test('result is half the length', () => {
90-
const {samples} = dropEveryOtherSample(buffer, 1);
90+
const {samples} = dropEveryOtherSample(buffer);
9191
expect(samples.length).toEqual(Math.floor(buffer.samples.length / 2));
9292
});
9393
test('result contains only even-index items', () => {
94-
const {samples} = dropEveryOtherSample(buffer, 1);
94+
const {samples} = dropEveryOtherSample(buffer);
9595
expect(samples).toEqual(new Float32Array([1, 2, 3]));
9696
});
97+
test('result sampleRate is given sampleRate / 2', () => {
98+
const {sampleRate} = dropEveryOtherSample(buffer);
99+
expect(sampleRate).toEqual(buffer.sampleRate / 2);
100+
});
97101
});

0 commit comments

Comments
 (0)