Reply by mnentwig August 9, 20072007-08-09
Hi,

I may have a good answer, although I'm not sure if it still fits your
question anymore...

Using FFT to get a simple frequency response is a standard technique.
Divide FFT(out) by FFT(in) sample-by-sample (complex), and you'll get the
complex frequency response. IFFT gives you the impulse response, plug that
into a convolutional reverb and you'll get exactly the undistorted amp
sound (probaby with a huge delay but still).

But you seem to be after a model for the amplifier nonlinearity. 
That works even without FFT:

- Create a suitable test signal, record some low and high notes. The
better the statistics of your model match what's later encountered during
operation, the more accurate the model (in a least-squares sense).

- Play the signal, record the output, oversample as needed, time-align
input and output signal. Alignment accuracy is most critical.
- Build a set of base vectors [1; x; x^2; x^3; x^4; ...] where x is your
input signal
- Use the backslash operator in matlab to decompose your recorded signal
into the base vectors, least-squares sense. If you get warnings about
rank, use less terms.
- the result vector gives the polynomial coefficients for your amplifier
nonlinearity. Double precision arithmetics may allow using for example up
to 17th order.

- Evaluate the polynomial at 100 different points, straight line
interpolation in-between works OK. That's the model of your amplifier
nonlinearity.

If you want to take frequency response into account, include delayed
signals as your base vectors. This already goes towards simple Volterra
series modeling.

I've been wondering for a while whether this works for guitar, but it sure
does work for radio frequency amplifiers. I use this frequently in the lab,
a two-tap model usually leaves about 1/10000 of the received signal power
unexplained (-40 dBc).

If interested, search for AMAM/AMPM model for power amplifiers on the web.
The difference is that you use only real numbers, so there is no AMPM, and
your polynomial coefficients are real valued.
The method works for weakly nonlinear systems, you may be out of luck with
fuzz or heavy sounds

Cheers

Markus

PS: I might post some example code on a dsprelated.com blog in a while
(assuming it actually works with audio amps). Stay tuned...

Reply by Andor July 31, 20072007-07-31
Rock Lobster wrote:
> So, I guess this might not be really possible?
The above discussion was on the use of FFT as analysis tool for non- linear systems. Modeling non-linear systems is a different story, and has been done before.
> > My basic idea was just to spot the differences between input and output > after processing and applying them to another signal. The reason why I > thought the signal should gain in volume was that I'd have "difference > spectrums" for every possible input volume. Of course, this might be > tricky to do, but if the CPU power would be enough to do this in realtime, > wouldn't this "different volumes" thing eliminate some of the > "non-linearity" problems?
Somebody already cooked up (and patented, I believe) an algorithm that is similar to your ideas: http://www.sintefex.com/docs/appnotes/dynaconv.PDF It describes an alternative to the Volterra Series approach for modeling non-linearities. I don't know how well it works (never heard it), but Sintefex is using the algorithm in their pro-audio "vintage gear modelling" units (a guitar amp can also be described as "vintage gear" in these days of virtual guitars :-), and just received an award for their technology (details on their website).
> > (I'm not a good mathematican, so please understand if my stuff sounds a > bit silly :) but I was able to program a parametric equalizer, so at least > I understand the basic FFT stuff. But try to avoid answering with > mathematic formulas only :D )
The level of maths in that article doesn't exceed the usual convolution sums. The idea is to interpolate different filters, depending on the level of the input signal. Regards, Andor
Reply by Rock Lobster July 31, 20072007-07-31
So, I guess this might not be really possible?

My basic idea was just to spot the differences between input and output
after processing and applying them to another signal. The reason why I
thought the signal should gain in volume was that I'd have "difference
spectrums" for every possible input volume. Of course, this might be
tricky to do, but if the CPU power would be enough to do this in realtime,
wouldn't this "different volumes" thing eliminate some of the
"non-linearity" problems?

(I'm not a good mathematican, so please understand if my stuff sounds a
bit silly :) but I was able to program a parametric equalizer, so at least
I understand the basic FFT stuff. But try to avoid answering with
mathematic formulas only :D )
Reply by Rune Allnor July 30, 20072007-07-30
On 30 Jul, 18:26, Andor <andor.bari...@gmail.com> wrote:
> Tim Wescott wrote: > > Another way to put this is that the FFT is a mathematical tool that is > > handy for analyzing linear systems. Distortion in a guitar amp is a > > nonlinear phenomenon, so you can't use the FFT directly to analyze > > distortion. > > That's odd. I would have thought that FFT is the foremost tool for > detecting and analysing non-linearities. Put a sine through your > system and look at the spectrum of the output (to compute THD, for > example).
You don't use the DFT as such, but use coherence estimates which are computed by means of the FFT. Bendat wrote a book on nonlinear system analysis which gives all the details. Rune
Reply by Tim Wescott July 30, 20072007-07-30
Andor wrote:
> Tim Wescott wrote: > >> Another way to put this is that the FFT is a mathematical tool that is >> handy for analyzing linear systems. Distortion in a guitar amp is a >> nonlinear phenomenon, so you can't use the FFT directly to analyze >> distortion. > > That's odd. I would have thought that FFT is the foremost tool for > detecting and analysing non-linearities. Put a sine through your > system and look at the spectrum of the output (to compute THD, for > example). >
You're correct, of course. A stable, linear, time-invariant system will have an output signal who's spectral components are all in the spectrum of the input signal. A stable, linear, time-varying signal will have spectral components that aren't in the input signal, but if the time variation is periodic then the spectral components will be easy to predict and check against. A nonlinear system will, in general, add components to the spectrum of the input signal. So you can, indeed, use this as a test as you described. What I was _thinking_, is that you can make a system model with Fourier analysis (and to some extent numerically with the FFT) for a linear, time invariant system. With a bit more difficulty, you can model linear, time varying systems this way. But without bending over backwards (like, with Volterra series) you can't use Fourier analysis to analyze nonlinear systems. Even _with_ bending over backwards I don't think you could adequately simulate the distortion in a guitar amp this way. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" gives you just what it says. See details at http://www.wescottdesign.com/actfes/actfes.html
Reply by Andor July 30, 20072007-07-30
Tim Wescott wrote:

> Another way to put this is that the FFT is a mathematical tool that is > handy for analyzing linear systems. Distortion in a guitar amp is a > nonlinear phenomenon, so you can't use the FFT directly to analyze > distortion.
That's odd. I would have thought that FFT is the foremost tool for detecting and analysing non-linearities. Put a sine through your system and look at the spectrum of the output (to compute THD, for example).
Reply by Tim Wescott July 30, 20072007-07-30
Jon Slaughter wrote:
> "Rock Lobster" <email@christian-gleinser.de> wrote in message > news:etKdnem5FZVgHTDbnZ2dnUVZ_hOdnZ2d@giganews.com... >> Hello, >> >> so far I didn't read anything technical about analog modeling, but I >> thought about some very simple and straight-forward approach and I wonder >> if that would work (at least to a semi-satisfying level) or if this would >> result in a sonic catastrophy :) >> >> How about creating a white-noise sound, which gradually gains volume from >> 0 to 10 (or maybe to 11? :), and then running this sound through a guitar >> amplifier. The amp would be set to a good sounding distorted tone, but the >> equalizer should maybe left flat. >> >> Then the whole thing would be recorded and analyzed with FFT. The spectrum >> for each volume would be saved in RAM. >> >> Then, a random sound (preferably a guitar signal) would be played and also >> FFTed, and the stuff we saved in RAM would be applied to the signal, >> meaning that every frequency's volume would be changed according to the >> "recorded" sound. >> >> Would that work? The distortion level could then be altered just by >> changing the input volume, and an equalizer could be built on top. >> > > > There are methods that use white noise to model nonlinear devices but I > don't know much about it. I remember finding a pdf about how to do it a long > time ago but don't remember to much about it. Essentially because the device > doesn't follow the superposition law you cannot decompose a signal into > simpiler ones and then put them back together. > > For example, say you input f(t) = cos(wt) + cos(qt) then its not the same as > first inputing cos(wt) and then cos(qt) and then adding the results of the > device to get f(t). The reason is because the amplifier is not linear. > > Now, there was some heavy math in that paper that dealt with what they > called volterra kernels and how to use them to model such things > approximately using white noise. I'm sure if you google you'll be able to > find some more info. > > >
Another way to put this is that the FFT is a mathematical tool that is handy for analyzing linear systems. Distortion in a guitar amp is a nonlinear phenomenon, so you can't use the FFT directly to analyze distortion. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" gives you just what it says. See details at http://www.wescottdesign.com/actfes/actfes.html
Reply by Rune Allnor July 30, 20072007-07-30
On 30 Jul, 11:31, "Rock Lobster" <em...@christian-gleinser.de> wrote:
> Well my question was: > > >> I wonder if that would work (at least to a semi-satisfying level) > >> or if this would result in a sonic catastrophy :) > > So indeed, I already know that this would work from a technical view, > because it's just some multiplications. But the question is, would this > result in an acceptable sound, or better said, would the processed signal > sound at least somehow similar to the same signal run through the amp, or > would this sound completely different?
Ah. If you have access to matlab or somethind similar (octave or scilab), try to filter a recorded signal with a FIR filter consisting of white nois (i.e. random coefficients.) In matlab, the code would be something like N = 10000; % Number of coefficients in filter x = wavread('sound.wav'); % Fors simplicity, mono sound h = randn(N,1); % Filter consisting of white noise y = filter(h,1,x); and then play the sound y or store it to a .wav file. If that sounds bad, the added guitar amp will probably not improve on things. Rune
Reply by Jon Slaughter July 30, 20072007-07-30
BTW, heres a link

http://en.wikipedia.org/wiki/Volterra_series 


Reply by Jon Slaughter July 30, 20072007-07-30
"Rock Lobster" <email@christian-gleinser.de> wrote in message 
news:etKdnem5FZVgHTDbnZ2dnUVZ_hOdnZ2d@giganews.com...
> Hello, > > so far I didn't read anything technical about analog modeling, but I > thought about some very simple and straight-forward approach and I wonder > if that would work (at least to a semi-satisfying level) or if this would > result in a sonic catastrophy :) > > How about creating a white-noise sound, which gradually gains volume from > 0 to 10 (or maybe to 11? :), and then running this sound through a guitar > amplifier. The amp would be set to a good sounding distorted tone, but the > equalizer should maybe left flat. > > Then the whole thing would be recorded and analyzed with FFT. The spectrum > for each volume would be saved in RAM. > > Then, a random sound (preferably a guitar signal) would be played and also > FFTed, and the stuff we saved in RAM would be applied to the signal, > meaning that every frequency's volume would be changed according to the > "recorded" sound. > > Would that work? The distortion level could then be altered just by > changing the input volume, and an equalizer could be built on top. >
There are methods that use white noise to model nonlinear devices but I don't know much about it. I remember finding a pdf about how to do it a long time ago but don't remember to much about it. Essentially because the device doesn't follow the superposition law you cannot decompose a signal into simpiler ones and then put them back together. For example, say you input f(t) = cos(wt) + cos(qt) then its not the same as first inputing cos(wt) and then cos(qt) and then adding the results of the device to get f(t). The reason is because the amplifier is not linear. Now, there was some heavy math in that paper that dealt with what they called volterra kernels and how to use them to model such things approximately using white noise. I'm sure if you google you'll be able to find some more info.