News for hackers. Stuff that matters.
Re:Neural networks emulate any guitar pedal for $120 by andybak on Monday May 31, 2021 @07:38AM (#27342970)
any pedal? That seems far-fetched - one trivial counter-example would be a looper as that requires modal input and state. I also wonder if it can handle complex multi-tap delays.

Can anyone give a rough idea of the actual limitations? I would guess that there is a limit to how non-local the effects it can manage are.

Re:Neural networks emulate any guitar pedal for $120 by taneq on Monday May 31, 2021 @08:41AM (#27343455)
If you want to be pedantic it probably can't emulate a guitar pedal that you can tap a representation of a Turing machine into and it will only make a sound if the machine halts.
Re:Neural networks emulate any guitar pedal for $120 by gberger on Monday May 31, 2021 @07:50PM (#27349359)
I think I've read something about this in a story involving Achilles and a tortoise.
Re:Neural networks emulate any guitar pedal for $120 by shmageggy on Monday May 31, 2021 @09:50AM (#27344042)
You can't create such a pedal in the first place, so...
Re:Neural networks emulate any guitar pedal for $120 by marcodiego on Monday May 31, 2021 @10:33AM (#27344436)
You definitely can. You just cannot prove it will always make a sound.
Re:Neural networks emulate any guitar pedal for $120 by tiborsaas on Monday May 31, 2021 @10:15AM (#27344306)
The joke is that some pedals can be really complex with menu systems and all kinds of tricky jazz.
Re:Neural networks emulate any guitar pedal for $120 by jcelerier on Monday May 31, 2021 @01:09PM (#27346140)
why couldn't you ? the code would just be

    extern char* turing_machine;
    int main() {
      process_turing_machine(turing_machine);
      beep();
    }
Re:Neural networks emulate any guitar pedal for $120 by jdbernard on Monday May 31, 2021 @10:06AM (#27344214)
Yep. Disprove the sweeping generalization by counterexample.
Re:Neural networks emulate any guitar pedal for $120 by JD557 on Monday May 31, 2021 @08:11AM (#27343224)
They claim to be using a LSTM, and I believe that any RNN-like architecture should (in theory) be able to learn a loop pedal.

If you aren't familiar with RNNs, think about it like a NN that instead of learning a input -> output function, learns a (input, state) -> (output, newState) function

Re:Neural networks emulate any guitar pedal for $120 by lunixbochs on Monday May 31, 2021 @09:12AM (#27343728)
Only if the entire loop audio fits into the RNN's hidden state? Or if you use some kind of external memory mechanism that gives the network access to previous audio.
Re:Neural networks emulate any guitar pedal for $120 by jeeceebees on Monday May 31, 2021 @01:21PM (#27346257)
LSTM stands for Long Short Term Memory. It's a recurrent network that learns what and how long things should be kept in its internal state buffer. It doesn't have a fixed state size because it's just learning a nonlinear function that takes an input and a state to an output and a new state. Obviously it can't model all possible, infinite length recurrences, but it can definitely do a pretty good job of approximating long term recurrence relations in complex signals.
Re:Neural networks emulate any guitar pedal for $120 by lunixbochs on Monday May 31, 2021 @04:22PM (#27347729)
I don't think that assessment is quite right. The hidden size is fixed - the second argument to Pytorch's nn.LSTM constructor is "hidden_size – The number of features in the hidden state h".

A call to `y, hidden = layer.forward(x)` (where x has a batch size of 1, and an arbitrary length) produces two hidden states of dimensions `(1, 1, hidden_size)`, where hidden_size is the exact number you passed to the LSTM constructor. Those two states represent the long term and short term memory features.

You would need to have an LSTM with hidden_size large enough to store the samples (or a compressed representation) of your entire loop. Not to mention you'd run into other issues with handling the logic around variable length loops based on a pedal toggle.

Re:Neural networks emulate any guitar pedal for $120 by jeeceebees on Tuesday June 01, 2021 @01:09AM (#27350901)
The hidden state isn't storing the samples of your loop (or a compressed version of your loop). It's encoding a representation of how the output will change based on what the current state and input are. This might be strongly dependent on what the exact samples in the loop are, but it could also be more general. I think it's missing a bit of the representational power of an LSTM to see the state representation as just a buffer of the current input.

But, yeah, at some point your signal has such a complex behavior on long time scales that there isn't a good way to predict it based on a limited state size (or at least gradient descent can't find a function to predict it for you).

Re:Neural networks emulate any guitar pedal for $120 by lunixbochs on Wednesday June 02, 2021 @04:45AM (#27366403)
If you can reproduce the original information based only on a state input, you have stored it in the state (in an encoded form or not). If your state is smaller than the original information, you have compressed it. If your reproduction is not faithful to the original, you have created lossy compression.

If the future input samples have a meaningful impact during loop playback, then it hasn't learned the correct behavior of the original loop pedal.

Note that the linked project appears to use a hidden size of 20. Twenty floats. With that much space we're very much back to "sure, you might theoretically be able to loop if the information fits in the hidden size".

Increasing the hidden size beyond 20 still won't solve learning the complex state machine behavior of an original loop pedal, which can loop variable length audio. You'd need to provide the pedal state to the network in addition to the audio, and probably train need to train it on a bunch of different loop lengths (>thousands?).

This would mostly be an academic pursuit, as it's extremely impractical compared to the other uses of the device.

Re:Neural networks emulate any guitar pedal for $120 by titzer on Monday May 31, 2021 @10:33AM (#27344442)
This is the kind of thing where augmenting the NN with an actual raw audio buffer would allow it to mix in some of the signal from the past quite easily.
Re:Neural networks emulate any guitar pedal for $120 by ushakov on Monday May 31, 2021 @07:45AM (#27343041)
you could model amplifiers, distortion effects, phasers and flangers, according to CoreAudioML project, which makes this possible https://github.com/Alec-Wright/CoreAudioML
Re:Neural networks emulate any guitar pedal for $120 by duped on Monday May 31, 2021 @08:35AM (#27343411)
You can model most useful nonlinear functions with neural networks, this is unsurprising. You can also use Volterra series. You can even estimate/measure the Volterra kernel then train a NN to model it instead of dealing with the computational complexity of generalized convolution for nonlinear dynamic systems.

The hard part is that there are some fundamental limitations to deal with. The biggest is aliasing - distortion effects in particular deal with enormous amounts of distortion (> 100% THD) which creates spectrums far outside the range of hearing. Digital audio systems need to have high orders of oversampling to prevent audible aliasing (8-16x is not unheard of!).

After aliasing is memory. It's too early in the morning for me to do math but I'm almost certain you can't model a looper with a causal NN that has less internal state memory than the length of your loop. Doing so is dumb anyway, since loopers are pretty trivial and their biggest cost is memory. Same goes for digital delay and modulation effects, the algorithms are not expensive.

Re:Neural networks emulate any guitar pedal for $120 by marcan_42 on Monday May 31, 2021 @09:06AM (#27343675)
Now I wonder if a NN would be able to learn a nonlinear effect without aliasing, even if run at the original sample rate. Oversampling and filtering are, after all, things that could become part of the model too. Perhaps it can learn to approximate them with less CPU cost than doing it for real.
Re:Neural networks emulate any guitar pedal for $120 by duped on Monday May 31, 2021 @10:26AM (#27344370)
Oversampling requires producing more output information than input information. It would be incredible for a NN to realize a system that could do this without requiring more memory and CPU cycles than a good oversampling algorithm, which can be derived analytically with various definitions of "optimal."

A 3rd or 4th order polynomial interpolator is pretty darn good and doesn't need a NN to find the coefficients.

Re:Neural networks emulate any guitar pedal for $120 by marcan_42 on Monday May 31, 2021 @09:37PM (#27349934)
I'm not talking about using a NN for oversampling; I'm talking about whether an NN could learn to reduce aliasing when implementing nonlinear functions without any external oversampling.

Oversampled DSP algorithms work by oversampling, performing the nonlinear processing, then filtering to remove the higher harmonics, and finally downsampling again. We do it this way because it's convenient and easy to understand and based on proven mathematics. But nothing says these steps have to be distinct.

An oversampled DSP algorithm looks like a regular DSP algorithm from the outside, perhaps with some more state and latency required for it to perform the internal oversampling. You can also imolement such an oversampled algorithm entirely at the original sample rate clock; it just means the processing needs to internally process several samples per outer loop sample.

Since neural networks excel at modeling "black boxes" as one amorphous blob that we don't understand, I wonder if a NN could learn to model such an internally oversampled algorithm fairly accurately, and what the computational complexity would be.

Since you can model the oversampling/filtering/etc steps as linear convolutions with wider internal state at the original sample rate, I'm almost certain this will work with the right NN topology. It's obvious an NN can implement oversampling.

And so my question is: could treating the combined oversampled processing as one step, and training a NN on that, potentially result in a more efficient implementation than doing it naively? Especially for heavy distortion that needs high oversampling ratios.

Re:Neural networks emulate any guitar pedal for $120 by bottled_poe on Monday May 31, 2021 @07:56AM (#27343116)
You could.. but should you? I appreciate the ingenuity, but tuning this tech is time consuming. I prefer to just carrying on playing my guitar poorly.
Re:Neural networks emulate any guitar pedal for $120 by ushakov on Monday May 31, 2021 @08:04AM (#27343160)
you can download models online, no need to train yourself, which i agree is time consuming
Re:Neural networks emulate any guitar pedal for $120 by ratww on Monday May 31, 2021 @09:31AM (#27343877)
There's even some potential for a small market of those. Lots of guitar players I know but Kemper models, or convolution impulses.
Re:Neural networks emulate any guitar pedal for $120 by keyth72 on Monday May 31, 2021 @01:54PM (#27346571)
..any pedal

It can’t do time based effects such as delay, reverb, flange, chorus, etc. The LSTM can model distortion, overdrive, compression to an extent, and amp circuits (including vacuum tubes).

Re:Neural networks emulate any guitar pedal for $120 by keyth72 on Monday May 31, 2021 @01:58PM (#27346618)
But I will say that there is a project out there for time varying effects, but haven’t dug into it yet. I believe it’s a different method than the LSTM

https://github.com/Alec-Wright/NeuralTimeVaryFX