phaze icon indicating copy to clipboard operation
phaze copied to clipboard

Output volume

Open mdabbs opened this issue 1 year ago • 6 comments
trafficstars

It appears that the output volume is significantly less that the original volume? Is this by design? I don't understand the math enough to know if this is by design or if the volume is being lost somewhere in the computations.

mdabbs avatar Feb 13 '24 05:02 mdabbs

Yeah it seems to be a consequence of the processing, what I have unscientifically found to work best is to boost the volume using pre- and post-GainNodes both set to a value of 1.6.

marcelblum avatar Feb 14 '24 03:02 marcelblum

I can understand why it's there in the handleOutputBuffersToRetrieve function where it divides by the number of overlaps. Logically, the same signal added to itself nbOverlap times should be divided back down. But from my experience with digital audio, mixing signals usually doesn't require a shift down.

I'm not scientifically or mathematically inclined, but from a logical standpoint, would it makes sense to maybe keep something like an RMS value for each WEBAUDIO_BLOCK_SIZE window, and then normalize each block as it goes out to about what it was when it came in? I may give that a try, but I wonder if the perceived volume would jump too much and be too perceptible to the human ear?

mdabbs avatar Feb 14 '24 04:02 mdabbs

Honestly crunching all these numbers in pure JS is so cpu intensive as it is, I wouldn't want to pile on any further computation, which is why I settled on using a simple pregain/postgain to compensate.

marcelblum avatar Feb 14 '24 04:02 marcelblum

Sorry, one more question if you don't mind. The fft and ifft, are those standard? I'm porting this to c++. Could I substitute something like fftw instead? From some basic profiling, it looks like transform4 and realTransform4 are really taking the bulk of the time.

mdabbs avatar Feb 16 '24 22:02 mdabbs

Full disclosure, I'm not a maintainer of this project just a tinkerer who forked it. I'm not sure why you would want to port this to c++ as there are surely better existing implementations (Rubber Band comes to mind), this is just a rough implementation using web standards within the limits of current browsers. But yeah, in theory you should be able to use a better/faster existing FFT library, not sure how much of a drop in replacement it would be.

marcelblum avatar Feb 17 '24 03:02 marcelblum

Yea, I've looked at Rubber Band but it has commercial licensing restrictions. I just need something for a media player/karaoke app, but since I might make mine commercial also, I need something less restrictive with licensing. Also, I really just want to understand more of how it all works, so I'm a fellow tinkerer as well. I appreciate the discourse though.

mdabbs avatar Feb 17 '24 05:02 mdabbs