tmhglnd / mercury-playground

The Mercury live coding environment running in the browser
GNU General Public License v3.0
63 stars 6 forks source link

Update `fx(reverb)` algorithm #54

Open tmhglnd opened 3 weeks ago

tmhglnd commented 3 weeks ago

The current reverb algorithm doesn't sound that good and doesn't seem to allow for long reverb times (like 6-7 seconds seems to be the max). On top of that it seems that memory usage slowly increases over time when evaluating multiple reverbs.

Maybe a custom reverb algorithm can be build through ToneJS objects, or with a custom processornode.

HighHarmonics2 commented 4 days ago

In my short time with Mercury, I have noticed the reverb. When the sound is fuller or with more voices playing it seems OK. Other times it seems limited, or the plate quality stands out too much as you extend the tail. I find myself wanting more options. I think we are also now very accustomed to flexible, high quality reverb capability. It seems to me that a custom solution is possible, but may be a fair amount of work. Maybe there is an open source JS solution out there?

tmhglnd commented 3 days ago

Hey, thanks for the comment. Are you now talking about the reverb in the Max version as well? Or specifically the reverb in the browser version?

The Max version is a plate reverb indeed, based on the [yafr2] object (which is based on the Dattorro Algorithm). While this could be upgraded as well I'm quite fine with the sound of it (and it is efficient, so using many reverbs is not a big deal).

The browser version uses a decaying noise convolution process, which does not sound so good in my opinion, and also I noticed that over a longer period of time the browser starts to use more RAM because of it.

I found some alternative reverbs in ToneJS but those didn't sound so good either. Other JS open source solutions could be nice, if there are any. I also looked at Strudel, thy implemented the same decaying-noise algorithm as in ToneJS (from https://github.com/adelespinasse/reverbGen?tab=readme-ov-file)

Giving the reverb more parameters could be possible (for example the Max version actually has a roomsize, decaytime, damping and diffusion parameters under the hood), but I notice that many users also struggle with the big lists of parameters for effects, especially to remember during performances (for example with the filter).

HighHarmonics2 commented 3 days ago

Thanks for the clarifications. I (incorrectly) assumed that the reverb would be the same or from the same source in both environments. I don't know much about the web audio API, but I did learn that it has a ConvolverNode. I also learned of Pizzicato.js which has a reverb function. A custom reverb in the web audio API might be the best route - using delay, filters, etc.

On the Max side - ah - yes [yafr2]. I'm familiar with it. I find it to be a good general purpose reverb but I like having more control. With Mercury, I too don't like lots of parameters - except when I want them! I started using the delay. I put a comment near it to remind me of what each parameter is. My experience is that with the reverb I spend a lot of time fussing. I would welcome having damping and diffusion as optional parameters with a default setting.

Max 9 has a set of reverb objects in the abl group. This might be a way to add some options without a lot of work.

tmhglnd commented 2 days ago

Ah thanks for pointing out pizzicato.js, haven't heard about it yet. I see that library also uses the exact same algorithm as Tonejs, Strudel and Mercury. This is indeed done with the ConvolverNode.

I tried making a custom design with delays/filters, but it turned out too heavy, but maybe with a custom AudioWorkletProcessor it can be made a bit more efficiently with less overhead (then loading class instances for every Delay/Filter in tonejs). For this I need to do some more research how to make it tho.

I have seen all the new abl objects in Max 9. Some great effects of course, and probably I could replace the whole mercury fx-chain with the ableton effects. For now I choose to not do this (or use them in any way) because not everyone is using Max9. Maybe in a year or so when most people switched over.

HighHarmonics2 commented 1 day ago

I have some additional thoughts on reverb and fx in Mercury4Max, including Max 9. But that seems to belong in the Issues section of the main mercury repository. I'll post there.