34 ms·
Let's Write a Reverb (2021)
- prashp 2y agoIs it possible to model reverb using a neural network (e.g. wavenet or LSTMs) for real-time use? Is this what something like Neural DSP is doing under the hood?
- landonxjames 2y agoNot sure about Neural DSP or reverbs in general, but real-time neural network based DSP seems very possible. The open source Neural amp modeler[1] would be a good place to start diving in. [1] https://www.neuralampmodeler.com/the-code https://www.neuralampmodeler.com/the-code
- prashp 2y agoI have tried NAM but with limited success in modeling some time-based effects (e.g. octave shifting). However, I have not tried to model reverb effects.
- intalentive 2y agoTo handle time-based effects you need a custom architecture. https://www.research.ed.ac.uk/en/publications/neural-modelling-of-periodically-modulated-time-varying-effects https://www.research.ed.ac.uk/en/publications/neural-modelli... Don’t use NAM. Learn PyTorch.
- prashp 2y agoNAM uses pytorch for its NN implementation?
- intalentive 2y agoIt is 100% possible and there are a slew of tricks you can use to get big performance boosts with negligible cost to accuracy.
- prashp 2y agoDo you know what the tricks are?
- intalentive 2y ago1. Don’t use LSTMs (4 vector-matrix multiplies) or GRUs (3 multiplies). Use a fixed Hippo matrix to update state. Just 1 multiply and since it’s fixed you can unroll during training, much faster than backprop through time. 2. Write SIMD intrinsics by hand. None of the libraries are as fast. 3. Don’t use sigmoid or tanh functions as your nonlinear activation. Instead approximate them with the softsign function which is much cheaper. Depends on exact architecture, but these optimizations have yielded 10-30x improvement for single threaded CPU real time audio applications. When GPU audio matures all this may be unnecessary.
- duped 2y agoThe trick is not to use NNs for DSP but to discover the parameters for the DSP. In other words you hardcode the signal flow architecture using a common technique like an FDN but then train a NN to find "good" sounding parameters, like comparing to a convolution reverb or recordings. The thing about reverb is they require a lot of state and nonlinearity is undesirable.
- squeaky-clean 2y agoFor reverb I don't see much practical use, mainly because you can capture a pretty-much-perfect recreation of a real space with an impulse response. No need for thousands or millions of rounds of training a network. For unrealistic reverbs, you have the problem that to get training data you'd have to invent several unrealistic reverb effects to apply to sounds. And once you've made those effects, there's not really any reason to neural-netify them. For NeuralDSP it's a bit different because they use NN's to simulate a guitar amp circuit which is a nonlinear system and so there's no simple way to "capture" the effect the way that you can for reverb sims or speaker sims. And while you can make a very accurate model using something like SPICE, that won't run in realtime. With traditional amp modeling you basically take the SPICE version and try to optimize and cheat as much as you can so it can run in realtime, at the cost of accuracy. So that's what NeuralDSP's goal is, a system that approximates the amplifier but can also be computed in real-time, except done using a trained NN instead of a human-optimized variant of the SPICE circuit. They have a couple whitepapers on their website, though none of them go deep enough to really give away their secret sauce. But basically according to them, making a NN model of an amplifier at a fixed setting is fairly simple. Where they had to get novel with it is adjustable settings/parameters. E.g. turning the drive up, or turning the treble down. Just capturing a few hundred or thousand models based on adjusting parameters and cross-fading between them doesn't sound realistic. So they had to come up with a larger model architecture that can "learn" those parameter changes. https://arxiv.org/pdf/2403.08559 https://arxiv.org/pdf/2403.08559
- intalentive 2y agoIt’s not that hard, you just collect a lot of data. Much easier with a robot turning the knobs. Predict the next sample based on input and knob settings.
- pierrec 2y agoEasily the most approachable yet complete writeup I've seen on the topic. I've always noticed an aura of esoteric dark magic around writing good algorithmic reverbs, this makes it seems less daunting. Since the author does a quick comparison between convolution and algorithmic reverbs, I'll mention how I often combine them: a small/medium convolution reverb, plus a long algorithmic reverb. The convolution can perfectly diffuse the signal and it can also give a precise character to the sound, depending on the impulse response. It's great for adding a "body" to a raw sound generator. The algorithmic layer then adds a subtle ambience that can be extra long if desired.
- joshka 2y agoTake a look at the articles on Valhalla's site. They're another goldmine https://valhalladsp.com/learn/ https://valhalladsp.com/learn/
- cyco130 2y agoCame to write this. The guy not only makes the best algorithmic reverb plugins out there and sells them very cheap, he also shares his obsessively deep and broad knowledge on the subject. Big fan.
- fuhsnn 2y ago>throw a random-number generator at all the delay times Reverb algorithms are indeed random enough, a leading audio plugin brand once came up with a randomizing reverb freeware[0] embedded with a "submit when it sounds cool" button. https://www.kvraudio.com/forum/viewtopic.php?t=453229 https://www.kvraudio.com/forum/viewtopic.php?t=453229
- NikkiA 2y agou-he weren't the only ones either: https://bedroomproducersblog.com/2021/11/17/baby-audio-magic-dice/ https://bedroomproducersblog.com/2021/11/17/baby-audio-magic... And while it's not a one-button random reverb, MCharmVerb also heavily relies on randomizing: https://www.meldaproduction.com/MCharmVerb https://www.meldaproduction.com/MCharmVerb
- peterburkimsher 2y agoOn my personal laptop (Mac), I used AU Lab to apply effects to the music I listened to, and discovered that I like the ambience provided by adding a little reverb. I'm interested in doing the same at work, but the office PCs run Windows and I'm somewhat limited in what I can install. The Arduino Audio Tools library seemed like it would work, but it only applies effects on one channel. https://github.com/pschatzmann/arduino-audio-tools/wiki/Audio-Effects#limitations https://github.com/pschatzmann/arduino-audio-tools/wiki/Audi... I discovered the Wishing Well stereo reverb pedal, and am wondering whether building one will allow me to apply the effect to music from an iPod, rather than a guitar. https://scientificguitarist.wixsite.com/home/wishing-well https://scientificguitarist.wixsite.com/home/wishing-well If anybody would like to group-buy the Wishing Well, please let me know - if I order PCBs and parts, I'll have spares.
- deleted 2y ago[deleted]
- parentheses 2y agoI came expecting DSP code but was pleasantly surprised by this! If anyone has any other interesting ones to share about how audio hardware and software are built, I'd love to see them!
- Slow_Hand 2y agoSean Costello of Valhalla DSP is doing excellent work with his designs. He's got a series of blog posts that delve into various approaches for designing reverb algorithms: https://valhalladsp.com/2021/09/20/getting-started-with-reverb-design-part-1-dev-environments/ https://valhalladsp.com/2021/09/20/getting-started-with-reve... https://valhalladsp.com/2021/09/22/getting-started-with-reverb-design-part-2-the-foundations/ https://valhalladsp.com/2021/09/22/getting-started-with-reve...
- deleted 2y ago[deleted]
- djmips 2y agoHere's a video that just dropped that's starting at very approachable first principles, coding as they go. It's is also entertaining and they promise to continue with the series which I look forward too. The code will be shared as well. https://youtube.com/watch?v=iA6wRgwl7k0 https://youtube.com/watch?v=iA6wRgwl7k0
- squeaky-clean 2y agoFantastic article from start to finish. Great explanation, great audio samples, and from a first skim the C++ example looks very readable. > I haven't found any good resources on this particular diffuser design. I found a couple of forum posts and a paragraph from a book When I read this my first thought was "this is a link to a comment by mystran on KVR, isn't it?" And yep. If you're looking for some obscure DSP knowledge, all Google searches eventually lead to a comment by mystran.
- signalsmith 2y agoHaha, yeah - although their comment was only considering the 2D case, same as the book. You can make a (very efficient!) diffuser from 2-channel rotations, but you have to tune it a bit to get it smooth without having a slow attack. With more channels, it's much easier to get right.
- Optimal_Persona 2y agoI hang around the KVR DSP forums and indeed, it's always impressive to see mystran answer questions posed by world-class commercial plugin devs who are stumped or stuck somewhere. mystran appears to have one of the best understanding of both DSP theory and the tricks required to implement efficient C++ algorithms.
- chilling 2y agoVery nice tutorial, and extremally nicely done! It's worth knowing that some of those effects can also be achived (of course much much more simplified) in all modern browsers using the Web Audio API. I created mobbler[0] using that, and I also wrote a small tutorial on how some of the effects can be achieved using simple modules (it might seem too complex at first glance, but you can just look at the pictures)[1]. [0]: https://github.com/Megaemce/mobbler https://github.com/Megaemce/mobbler [1]: https://github.com/Megaemce/mobbler/wiki/Tutorials https://github.com/Megaemce/mobbler/wiki/Tutorials
- signalsmith 2y agoGiven the number of connections/nodes in my design, I'd be interested to know what the performance is. For Web Audio, there's an increasing trend of compiling WASM and running it in an AudioWorkletProcessor, which is maybe 2-3x slower than native. It's actually how I do a lot of my prototyping now, because the Emscripten build times are faster than a full plugin, and I can send it to people without them having to install anything.
- chaosprint 2y agoSignalsmith Audio always has great posts. Their article on pitch shift is also worth a look! I have also posted before: https://news.ycombinator.com/item?id=36706588 https://news.ycombinator.com/item?id=36706588 Speaking of reverb, I implemented a Dattorro reverb (https://ccrma.stanford.edu/~dattorro/EffectDesignPart1.pdf https://ccrma.stanford.edu/~dattorro/EffectDesignPart1.pdf) in Rust before. https://github.com/chaosprint/dattorro-vst-rs https://github.com/chaosprint/dattorro-vst-rs It's based on Glicol source code here: https://github.com/chaosprint/glicol/blob/main/rs/synth/src/node/effect/plate.rs https://github.com/chaosprint/glicol/blob/main/rs/synth/src/... You can play with it here: https://glicol.org/demo#handmadedattorroreverb https://glicol.org/demo#handmadedattorroreverb Also you don't want to miss the Tom Erbe's reverb patches in Pure Data. Patches demonstrating several types of reverb (Schroeder, Moorer, Moore, Gerzon, Dattorro): https://tre.ucsd.edu/wordpress/?p=625 https://tre.ucsd.edu/wordpress/?p=625
- signalsmith 2y agoWhoah - the author (Signalsmith) here! This was a fun way to wake up, and I'm happy to answer any questions.
- 127 2y agoNothing to ask, really. Just saying thanks for a fantastic intro to reverb, that I used as one of the sources to implement my own. Hope to see more audio processing educational material.
- 22c 2y agoThanks for the enjoyable article! Possibly off-topic, but I am coder with hobbyist interest in the DSP space. I have never really had a "penny drop" moment when it comes to starting from nothing and generating sound. Even generating simple sine wave seems like either a big chore or a completely abstract concept (depending on the tools/libraries/environment), I have not been able to find a middle-ground where I feel like I am learning but not getting completely lost in trigonometry or calculus. I am not sure if I'm not using the right tools or if I need to start even simpler and build up. GNU Radio comes close to scratching an itch for me of generating signal processing pipelines and a bit of intuition, but ultimately it becomes pretty easy to get lost in that as well (and it seems mostly focused on actual radio use-cases). Do you have any advice for someone looking to build more familiarity or intuition on this front?
- signalsmith 2y agoFirst, join a good community! If you're on Discord, TAP is great: https://discord.gg/aBghGGcfYs https://discord.gg/aBghGGcfYs - it's beginner-friendly while also having some heavy-hitters in there, and it's generally wholesome. You're not the only hobbyist learner, and it's important to have a place you can ask questions without feeling awkward. If you swap language/environment later, you'll carry your understanding/intuition with you, so you don't have to start with C++ if that's not your bag (even though it's still the industry standard). There are audio-specific languages with JIT runtimes (which can be used in Logic/Reaper/GarageBand/etc.), Rust/JS frameworks, etc. so find the one that feels good to tinker with, and keep that momentum/motivation going. :)
- codedokode 2y agoInteresting article, however in drums demo the reverb sound increases after the drum is hit, and this doesn't seem natural. I would expect the reverb to have only decay phase, but here the reverb has a slow attack as well.
- signalsmith 2y ago*EDIT*: I just realised that the demo you're talking about doesn't include the "early reflections"! So that demo only includes echoes which have gone through the main feedback delays at least once. If you mix in some of the diffused signal directly, it bridges the gap between the initial sound and the feedback echoes: https://signalsmith-audio.co.uk/writing/2021/lets-write-a-reverb/#putting-it-together-next-steps-early-reflections https://signalsmith-audio.co.uk/writing/2021/lets-write-a-re... --- You can tune the diffuser to have an almost-instant onset. I can't remember what I did last time, but at a guess, having the largest diffuser stage increase by a factor of N (number of channels) instead of 2 might do it. But also, if you're playing acoustic drums in a big space like a concert hall (instead of a long one like a staircase), the first echoes coming back from the walls are actually a bit delayed (1 foot ~= 1ms, at the speed of sound). So if your nearest wall is 10ft away, the first wall-echoes will come 10-20ms after the initial direct sound.
- codedokode 2y agoI wonder where do you find information like this? E.g. how a reverd is made, how those electronic drum sounds from classic drum machines are made and so on? Is there something like a big catalogue of different tricks and algorithms?
- signalsmith 2y agoSome stuff is around the web, some is from other people. Particularly for classic kit, someone's usually analysed it before, but it's not always in a good tutorial kind of form. Personally, I did a lot of messing around with audio/programming from my early teens onwards, and built my intuition about how the maths and sound link up from years of tinkering without many reference resources. A lot of this stuff can be made from relatively simple building-blocks though, and you don't have to copy a previous configuration. My thought process was pretty much exactly as written in the blog-post! I just wanted to make something which didn't require any special tuning skills.
- ovi256 2y agoThis one, making reverbs, at least is taught in signal processing classes in EE courses
- bravura 2y agoIs there a way to get "realistic" reverb using GPU computation?
- thinkingtoilet 2y agoI think a GPU is overkill. In the guitar world, there are dozens of insanely high quality reverb pedals and they all only have some basic chips in them, no GPU necessary.
- Underphil 2y agoNo, but the question bears discussion. Many of us have high powered GPUs in our machines that sit idle during audio production. Could they be leveraged? Not just for reverb.
- hatthew 2y agoMy understanding is that latency is usually a much bigger concern than raw computing power when doing audio processing. GPUs are great at doing large batches of computation, but aren't as good at doing lots of small batches with low latency, which is what audio processing tends to be.
- beardyw 2y agoUsing convolution I found that applying some random variation between the stereo channels made a much more satisfying stereo result, though only on later reflections, earlier it makes for unhelpful stereo effects. Is that something you have tried?
- DoesntMatter22 2y agoI wrote a synthesizer last year. It was a lot of fun. Just through trial and error I learned how sound waves work. It's really enjoyable to build things that aren't websites
- Someone 2y agoFTA: There are some interesting designs here - and they work, but they often require careful tuning. As well as finding a good compromise for the delay time, using too much inter-channel mixing can lock the delays together so they act like a cohesive unit, which isn't great for longer tails. Made me wonder whether there’s a connection with linear feedback shift registers (https://en.wikipedia.org/wiki/Linear-feedback_shift_register https://en.wikipedia.org/wiki/Linear-feedback_shift_register) If you have a LFSR that produces a decent but not too good pseudo-random signal, can you use its parameters to create a decent reverb?
- kazinator 2y agoI have a Yamaha FX-500 multi-effects processor from 1989. Original owner; got it in 1989. I was fiddling with it recently to try to get a decent reverb. The main algorithms don't sound good; they have not aged well. These algorithms have a delay parameter, but it doesn't produce enough of a separation somehow. Instead of a reverb-only block you can choose a combined delay with reverb (R->D, D->R or D+R). The delay block takes its own resources, leaving fewer for the reverb, which is simplified. You cannot choose the type of reverb (plate, hall, ...) and there are fewer parameters. The interesting thing is that with the D->R and R->D, I can get much better sounds. The D->R can produce a pretty lush/deep long reverb, where the main signal stands out clearly. (I should mention that I'm using an external analog mixer for mixing the dry signal: the FX-500 is 100% wet. Thus, in general, I can get the best possible sound out of it: the full resolution is allocated to the effect, not to propagating the dry signal.) Less can be more; a simpler reverb can sound better. A completely separate delay before the reverb can be better than playing games with built-in pre-delay. Basically, in combining the resources of the delay and reverb into a more complicated reverb effect, Yamaha somehow made a mess.