fix(streamer): db-scaled spectrum so bars match frontend visibility
This commit is contained in:
parent
9eaa16d818
commit
1c4c875c10
2 changed files with 11 additions and 5 deletions
|
|
@ -23,13 +23,14 @@ describe("SpectrumAnalyzer", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("a 1khz sine puts most energy in low bars (logarithmic binning)", () => {
|
||||
it("a 200hz sine puts most energy in low bars (logarithmic binning)", () => {
|
||||
const a = new SpectrumAnalyzer({ bars: 48, sampleRate: 48000 });
|
||||
a.feed(sineFrame(1000));
|
||||
for (let n = 0; n < 4; n++) a.feed(sineFrame(200));
|
||||
const bars = a.bars();
|
||||
const lowSum = bars.slice(0, 16).reduce((s, v) => s + v, 0);
|
||||
const highSum = bars.slice(32).reduce((s, v) => s + v, 0);
|
||||
expect(lowSum).toBeGreaterThan(highSum * 5);
|
||||
expect(lowSum).toBeGreaterThan(0.1);
|
||||
expect(lowSum).toBeGreaterThan(highSum + 0.1);
|
||||
});
|
||||
|
||||
it("silence produces all-near-zero bars", () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue