FPGA and FFTs ... anyone here worked with this combo yet?

Started by Derringer, June 30, 2012, 11:53:48 AM

Previous topic - Next topic

Derringer

An EE friend and I have been talking and he has suggested this approach.

I know a little about programming, and have some of those fun higher math courses in my background (integral calc, diff EQ etc.).
I have an idea of what a Fast Fourier Transform is.
He knows plenty more than I do in these regards and we've been talking about some simpler learning projects to undertake using these concepts to program an overdrive/distortion.

Have any of you delved into this realm? (I did a search for FPGA and it did not come up in the topic of any thread so I decided to make one.)

Any tips? Any good links to check out?

Thanks!

cloudscapes

FFT is something I've heard about a lot and occasionally tried to read about. But I'm not terribly good at maths and haven't been able to understand how exactly it can be applied to audio.  :-[ Practical uses, I mean.

I see it brought up in pitch-shifting, occasionally.
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

Derringer

the way I understand it, with the right algorithms, you can design basically any effect you want be it pitch shift, or distortion, emulation, time-based stuff etc.

but i suppose that's the greatest challenge ... what are the right algorithms to use

cloudscapes

But you can design any kind of effect using raw data stream from the ADC as well. Numbers between 0 and 65k, 44k times a second, then with the right algorithm. For tiem based stuff, you hardly need any (unless you're simulating tape wear). And I can create a digital distortion easily enough with raw ADC data.

Where does FFT come in? I'm not being confrontational BTW  ;D I'm just generally clueless.
~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

Derringer

and i am kind of grasping at straws here too ...  ;D

this is from wikipedia:
In mathematics, Fourier analysis is a subject area which grew from the study of Fourier series. The subject began with the study of the way general functions may be represented by sums of simpler trigonometric functions. Fourier analysis is named after Joseph Fourier, who showed that representing a function by a trigonometric series greatly simplifies the study of heat propagation.

Today, the subject of Fourier analysis encompasses a vast spectrum of mathematics. In the sciences and engineering, the process of decomposing a function into simpler pieces is often called Fourier analysis, while the operation of rebuilding the function from these pieces is known as Fourier synthesis. In mathematics, the term Fourier analysis often refers to the study of both operations.

The decomposition process itself is called a Fourier transform. The transform is often given a more specific name which depends upon the domain and other properties of the function being transformed. Moreover, the original concept of Fourier analysis has been extended over time to apply to more and more abstract and general situations, and the general field is often known as harmonic analysis. Each transform used for analysis (see list of Fourier-related transforms) has a corresponding inverse transform that can be used for synthesis.


...

A DFT (discrete Fourier transform) decomposes a sequence of values into components of different frequencies. This operation is useful in many fields but computing it directly from the definition is often too slow to be practical. An FFT (Fast Fourier transform) is a way to compute the same result more quickly: computing a DFT of N points in the naive way, using the definition, takes O(N2) arithmetical operations, while an FFT can compute the same result in only O(N log N) operations. The difference in speed can be substantial, especially for long data sets where N may be in the thousands or millions—in practice, the computation time can be reduced by several orders of magnitude in such cases, and the improvement is roughly proportional to N / log(N). This huge improvement made many DFT-based algorithms practical; FFTs are of great importance to a wide variety of applications, from digital signal processing and solving partial differential equations to algorithms for quick multiplication of large integers.


The first four Fourier series approximations for a square wave.

I hope that helps to make some sense ... I'm mostly only able to understand it conceptually


So what method are you using? Am i correct to assume that ADC = Analog to Digital Converter?
How are you defining/programing/etc your digital distortion?

thanks!

harmless

My basic understanding is that the FFT lets you transform something from one domain to another.  What is interesting for audio is usually from the time domain to the frequency domain.  Specifically, you can take a buffer of raw ADC samples, run it through an FFT, and end up with all of the individual frequencies of all the notes contained in that sample.  There are lots of constraints and tuning involved (how long do you sample, how big are the frequency buckets (ie how precise are you trying to be), etc).  A silly example is a graphic equalizer like on the front of a stereo.  If there are only 8 little bars that move up and down, then you only have 8 buckets to chop the whole frequency range up into.  Take a sample of the audio for some amount of time, run it through FFT and end up with how high to draw each bar on the EQ.

I'm guessing a naive pitch shifting algorithm could basically be sample -> FFT -> shift the values of each of the buckets up or down -> run an inverse FFT to convert from frequency buckets back into the time domain -> output the resulting samples.

CynicalMan

An FFT distortion would be quite complicated, actually. You'd need to calculate harmonics and add them on in the frequency domain. Distortion is much easier in the time domain, as you can basically apply any waveshaping function you want. Simple filters are also much easier in the time domain, although long, complex filters can be done with FFT convolution. I've done a few DSP distortion plugins, and I've never used FFTs. They are an important DSP tool, but they're not necessary for most guitar effects.

Derringer

I would think that working with the specific harmonics would be key though to getting distortion/overdrive sounds.
Like I look at a graph like this and think that an approach where you could dictate what harmonics are produced, to "x" amplitude relative to the fundamental, for "y" duration etc would lead to some really natural sounding sounds.



Does a wave-shaping function basically do that though?
i know that certain wave shapes do dictate certain harmonic tendencies
but I also know from playing with my scope and analog circuits that not all square waves (for instance) sound the same

CynicalMan

#8
The issue there is that the distortion changes depending on the amplitude. For example, consider this clipping function:


If the output amplitude is less than 0.6, there is very little harmonic distortion. If the output amplitude is 0.65, there is some hard clipping on the positive side, with the harmonics associated with that. And if the output amplitude is above 0.8 or so, there's some soft clipping on the negative side. At each of these locations, the harmonic characteristics will be different. A constant harmonic distortion wouldn't sound at all normal to us. There would also be no compression or clipping in the distortion.

Emulating this with an FFT-based approach would be possible, but it would be quite complicated compared to a waveshaper approach. Tubes themselves can be adequately emulated using a series of waveshaping functions and filters. In more complex models, the functions and filters are changed based on the input characteristics, but using FFTs to do that would be overcomplicating things. FFTs are good for pitch shifting, spectrum analysis, complex filters, etc., but they aren't really useful for distortion.

Waveshaping is the closest DSP analogue to electronic clipping. It will usually add harmonics to a signal, but that depends on the input signal and the waveshaping function. Usually clipping functions like tanh(x) are used to add harmonics, just like diode or tube clipping.

puretube

Quote from: cloudscapes on July 01, 2012, 11:16:03 AM
FFT is something I've heard about a lot and occasionally tried to read about. But I'm not terribly good at maths and haven't been able to understand how exactly it can be applied to audio.  :-[ Practical uses, I mean.

I see it brought up in pitch-shifting, occasionally.

FFT this...
or
this...

:icon_smile:

Derringer

Quote from: CynicalMan on July 02, 2012, 04:21:45 PM
The issue there is that the distortion changes depending on the amplitude. For example, consider this clipping function:


If the output amplitude is less than 0.6, there is very little harmonic distortion. If the output amplitude is 0.65, there is some hard clipping on the positive side, with the harmonics associated with that. And if the output amplitude is above 0.8 or so, there's some soft clipping on the negative side. At each of these locations, the harmonic characteristics will be different. A constant harmonic distortion wouldn't sound at all normal to us. There would also be no compression or clipping in the distortion.

Emulating this with an FFT-based approach would be possible, but it would be quite complicated compared to a waveshaper approach. Tubes themselves can be adequately emulated using a series of waveshaping functions and filters. In more complex models, the functions and filters are changed based on the input characteristics, but using FFTs to do that would be overcomplicating things. FFTs are good for pitch shifting, spectrum analysis, complex filters, etc., but they aren't really useful for distortion.

Waveshaping is the closest DSP analogue to electronic clipping. It will usually add harmonics to a signal, but that depends on the input signal and the waveshaping function. Usually clipping functions like tanh(x) are used to add harmonics, just like diode or tube clipping.

that makes a lot of sense, thank you


puretube

Quote from: puretube on July 02, 2012, 05:23:19 PM
Quote from: cloudscapes on July 01, 2012, 11:16:03 AM
FFT is something I've heard about a lot and occasionally tried to read about. But I'm not terribly good at maths and haven't been able to understand how exactly it can be applied to audio.  :-[ Practical uses, I mean.

I see it brought up in pitch-shifting, occasionally.

FFT this...
or
this...



:icon_smile:

or http://www.pat2pdf.org/patents/pat3851162.pdf

earthtonesaudio

I have a little microcontroller based scope that will display an FFT on-screen, without any noticeable lag.  Presumably that means it's fast enough that you could use the frequency outputs to synthesize a new waveform (particularly if your waveform generators were on the same chip).
This would be quite amazing power for an audio effect.  For example you could mix in the first two harmonics as sawtooth waves, plus a bit of third harmonic sine shifted down ten hz.  Or maybe normalize the level of the second through fifth harmonics, nulling the rest.  Or swap the amplitudes of the even harmonics for those of the next lower odd harmonics.  Or shift the even harmonics up five hertz while shifting the odd harmonics down two hertz.  The possibilities are endless.

Also, in my opinion this technology would be utterly wasted on a simple dirt box.

Derringer

Quote from: earthtonesaudio on July 03, 2012, 09:25:41 PM
I have a little microcontroller based scope that will display an FFT on-screen, without any noticeable lag.  Presumably that means it's fast enough that you could use the frequency outputs to synthesize a new waveform (particularly if your waveform generators were on the same chip).
This would be quite amazing power for an audio effect.  For example you could mix in the first two harmonics as sawtooth waves, plus a bit of third harmonic sine shifted down ten hz.  Or maybe normalize the level of the second through fifth harmonics, nulling the rest.  Or swap the amplitudes of the even harmonics for those of the next lower odd harmonics.  Or shift the even harmonics up five hertz while shifting the odd harmonics down two hertz.  The possibilities are endless.
which to me, at least, sounds awesome
control over all parameters to tweak away!


QuoteAlso, in my opinion this technology would be utterly wasted on a simple dirt box.
perhaps, but why the heck not? need to start somewhere right?

earthtonesaudio

why the heck not? need to start somewhere right?

True enough!

ioseph

Have a look at this project: http://opencores.org/project,pipelined_fft_256

I'm currently investigating using this to do basic pitch shifting, will post results as I progress

SISKO

These days, real time pitch-shifiting its done via sample rate variation rather than FFT.
Obviously, FFT (and its relatives) sound better than SR variation
--Is there any body out there??--

potul

Quote from: SISKO on November 22, 2013, 10:42:19 AM
These days, real time pitch-shifiting its done via sample rate variation rather than FFT.
Obviously, FFT (and its relatives) sound better than SR variation

By SR variation do you talk about the typical rotating head approach? So a delay line and a reading pointer that moves to a different speed than the write pointer? PSOLA and similar approach I guess...

I thought that with the increasing power of the microprocessors availabe, FFT methods (meaning phase vocoder and similar) would become more and more standard.

Do you know what kind of method are using the EHX pedals like HOG / POG?

SISKO

Fisrt, sorry for the late reply, didnt see this

Heres a link on the other forum  that might be of interest of you   .....org/viewtopic.php?f=29&t=16882
--Is there any body out there??--