Skip to content

Method fromStream bug when memoized stream. #2

@valerii15298

Description

@valerii15298

Hello @korbav. Thank you for such a great rewriting this library to typescript. Quite some time I see you active and even helping people with issues on original Wave.js :) The first time I looked at this rewritten lib a few months ago and it was really cool.

I have a few questions ant would be nice to talk(my discord nickname: Valerka#2430 , telegram: @valerii15298), because i really liked it and wanna start use it in my project.
There some things to improve:
Bug is that memoization isn't done, - it works just for one value. The same probem exist in original library but you seem to be active so I'm writing to your repo issues.
stream.toString() will always return the same string [object MediaStream], line 39, file from-stream.ts if (!sources[stream.toString()]) {. So better would be use stream.id as it is unique. Also using any in typescript is bad practice, if you see in this same file audioCtx is not initialised when (!sources[stream.toString()]) returns false. Then audioCtx.close().then() will throw error because of audioCtx will be undefined. This exactly what happend in my app using your lib, and thats why any from typescript coud avoid this bug if useing proper type. If disable memoization it will work good. Also when put correct types we typescript shows us that line analyser.fftsize = 32768; must be analyser.fftSize = 32768; and thus helping us with proper autocomplite, available properties, etc ...
Also using global properties on window object is not very good practice. I didnot dive in code fully but for now i can say it doesnt need memoization on global window. From user point of use i dont wanna side effects, so when I invoke deactivate all data must be cleaned. If we still need memizaition(though i think we dont) then we need change all stream.toString() to stream.id.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions