Help me learn the mathematical formulas behind wavetables

anomandaris1
 KVRist
 271 posts since 26 Nov, 2009
Help me learn the mathematical formulas behind wavetables
I know that you can that you can input a mathematical expression in some programs like Serums (and some free/shareware wavetable generators) and it will generate a waveform.
I'm interested in making inharmonic waves, but I thought it would be faster just to learn the formulas behind them instead of detuning the partials of an additive synthesizer one by one.
Can you recommend a good book on this?
I'm interested in making inharmonic waves, but I thought it would be faster just to learn the formulas behind them instead of detuning the partials of an additive synthesizer one by one.
Can you recommend a good book on this?

Andrew Souter
 KVRAF
 2417 posts since 12 Sep, 2008
Re: Help me learn the mathematical formulas behind wavetables
Assuming your waveform is of (relatively short) fixed length, it can NOT be inharmonic. Anything that repeats is harmonic. The number of potential harmonics in a waveform is 1/2 the length of the waveform. 2048 is a common length to use, and thus has 1024 potential harmonics. It can not be inharmonic. It could have very complex relationships between partials, generally simply meaning larger numbers (higher harmonics), but it will not be inharmonic. All partials in a repeating waveform have integer relationships. Look into DFT/iDFT to understand the relationship between timedomain (waveform) and its harmonic content (spectral domain).
my past work on this (which is in many synths from various companies) may provide some insights:
http://www.galbanum.com/content/product ... Manual.pdf
http://www.galbanum.com/products/archit ... eforms2010
If you want inharmonic spectra, the frequency relationship between partials (note we now call them partials instead of harmonics) must be irrational.... but you can't achieve it with a waveform of fixed/finite length...
(well OK, that is true in the absolute theoretical mathematics sense... in the real world, you just need a period length that is sufficiently long and spectrum that is sufficiently complex as to behave that way perceptually... how long exactly is a matter of semantics, but certainly things as short as the common 2048 sample length for wavetable synths can not really be considered inharmonic. You really need several seconds at whatever sample rate you are using at the very least...)
additive synths with freely tunable partials can do it, as you point out... as well as pseudo/supra additive things such as:
http://www.2caudio.com/products/kaleidoscope#_overview
my past work on this (which is in many synths from various companies) may provide some insights:
http://www.galbanum.com/content/product ... Manual.pdf
http://www.galbanum.com/products/archit ... eforms2010
If you want inharmonic spectra, the frequency relationship between partials (note we now call them partials instead of harmonics) must be irrational.... but you can't achieve it with a waveform of fixed/finite length...
(well OK, that is true in the absolute theoretical mathematics sense... in the real world, you just need a period length that is sufficiently long and spectrum that is sufficiently complex as to behave that way perceptually... how long exactly is a matter of semantics, but certainly things as short as the common 2048 sample length for wavetable synths can not really be considered inharmonic. You really need several seconds at whatever sample rate you are using at the very least...)
additive synths with freely tunable partials can do it, as you point out... as well as pseudo/supra additive things such as:
http://www.2caudio.com/products/kaleidoscope#_overview

anomandaris1
 KVRist
 271 posts since 26 Nov, 2009
Re: Help me learn the mathematical formulas behind wavetables
Thank you for your answer. I was reading this.
http://sethares.engr.wisc.edu/paperspdf/cmj98.pdf
But I was looking for a recommendation on some audiomathematical literature that will help me better understand all this (wavetables, fft etc ).
Professional literature is not exactly cheap and I was hoping that someone can point the right things (a book on audio synthesis and a book on the required math, or one book that explains both topics) to buy.
http://sethares.engr.wisc.edu/paperspdf/cmj98.pdf
But I was looking for a recommendation on some audiomathematical literature that will help me better understand all this (wavetables, fft etc ).
Professional literature is not exactly cheap and I was hoping that someone can point the right things (a book on audio synthesis and a book on the required math, or one book that explains both topics) to buy.

stratum
 KVRAF
 2120 posts since 29 May, 2012
Re: Help me learn the mathematical formulas behind wavetables
A wavetable synth is not a good way to create inharmonic spectra if the only feature you use is the wavetable itself.
Simplest way to create 'interesting' inharmonic spectra is to use effects like ring modulation and that requires more than one signal source and the sources must be inharmonic with respect to each other. Even with distortion the result is inharmonic only if the source contains "inharmonic" partials (like a chord, even if a chord sounds consonant the partials are not integer multiples of each other, therefore 'inharmonic').
p.s. you may like this one http://www.kvraudio.com/forum/viewtopic ... 1&t=478136
Simplest way to create 'interesting' inharmonic spectra is to use effects like ring modulation and that requires more than one signal source and the sources must be inharmonic with respect to each other. Even with distortion the result is inharmonic only if the source contains "inharmonic" partials (like a chord, even if a chord sounds consonant the partials are not integer multiples of each other, therefore 'inharmonic').
p.s. you may like this one http://www.kvraudio.com/forum/viewtopic ... 1&t=478136
~stratum~

Andrew Souter
 KVRAF
 2417 posts since 12 Sep, 2008
Re: Help me learn the mathematical formulas behind wavetables
See the "Online Books" section here:
https://ccrma.stanford.edu/~jos/
not exactly "easy reading" though IMHO...
https://ccrma.stanford.edu/~jos/
not exactly "easy reading" though IMHO...

Andrew Souter
 KVRAF
 2417 posts since 12 Sep, 2008
Re: Help me learn the mathematical formulas behind wavetables
but like Stratum and I said, wavetable/waveformbased synth methods by themselves are not well suited to achieve "inharmonic" things. Various DSP processes can be applied post wavetable/waveform/oscillator playback to transform the spectrum to make it inharmonic, but a short waveform itself can not really produce this by itself...
the best you could hope for using only pure waveform/wavetable playback is to use a bunch of very high harmonics in the waveform, and then transpose playback down many octaves... which would effectively give a longer period... it's still not mathematically inharmonic, but the harmonic relationships might be complex enough to be perceived as such... (The UHF waveforms in the original links I gave, are designed for this kind of trick...)
the best you could hope for using only pure waveform/wavetable playback is to use a bunch of very high harmonics in the waveform, and then transpose playback down many octaves... which would effectively give a longer period... it's still not mathematically inharmonic, but the harmonic relationships might be complex enough to be perceived as such... (The UHF waveforms in the original links I gave, are designed for this kind of trick...)

anomandaris1
 KVRist
 271 posts since 26 Nov, 2009
Re: Help me learn the mathematical formulas behind wavetables
Thank you, guys.

kryptonaut
 KVRian
 728 posts since 25 Apr, 2011
Re: Help me learn the mathematical formulas behind wavetables
For generating bandlimited sounds with 'stretched' (or compressed) harmonics, you can experiment with the formula given on the first page of http://www.jamminpower.com/PDF/Sine%20Summation.pdf  these waves can't be put in a wavetable as they aren't periodic, but they can generate some interesting sounds.

kamalmanzukie
 KVRist
 145 posts since 12 May, 2012
Re: Help me learn the mathematical formulas behind wavetables
i was looking at google trends the other day, all the time series data. a lot of them are clearly periodic and i have wondered how some of them might sound as a wavetable.
the thing that i really can't get my head around though, is a lot of these google 'waveforms' clearly have a good bit of harmonic content. i mean, its one thing to have a year long periodicity for the word 'flowers', but what about the overtones?
i can't conceptualize it without getting a bit metaphysical. of course, i've played around in a spectrogram, loop a column of noise burst and it becomes rows of harmonics, but even that still kind of mystifies me
the thing that i really can't get my head around though, is a lot of these google 'waveforms' clearly have a good bit of harmonic content. i mean, its one thing to have a year long periodicity for the word 'flowers', but what about the overtones?
i can't conceptualize it without getting a bit metaphysical. of course, i've played around in a spectrogram, loop a column of noise burst and it becomes rows of harmonics, but even that still kind of mystifies me

Z1202
 KVRian
 978 posts since 12 Apr, 2002
Re: Help me learn the mathematical formulas behind wavetables
The idea of Fourier series states that a periodic signal has only harmonic content. What Andrew was referring to is that if the lower harmonics are missing from the series (that is having very low or zero amplitude) then the harmonic relationship between higher harmonics becomes less and less obvious (e.g. you might not realize that 1.15267175573 is 151/131 ) and the whole signal might sound inharmonic. In order for these higher partials to be in the audible range one generaly needs a large signal period, which also means that lower harmonic frequencies might be even below the audible range anyway.kamalmanzukie wrote:i was looking at google trends the other day, all the time series data. a lot of them are clearly periodic and i have wondered how some of them might sound as a wavetable.
the thing that i really can't get my head around though, is a lot of these google 'waveforms' clearly have a good bit of harmonic content. i mean, its one thing to have a year long periodicity for the word 'flowers', but what about the overtones?
i can't conceptualize it without getting a bit metaphysical. of course, i've played around in a spectrogram, loop a column of noise burst and it becomes rows of harmonics, but even that still kind of mystifies me

kamalmanzukie
 KVRist
 145 posts since 12 May, 2012
Re: Help me learn the mathematical formulas behind wavetables
the part you explained makes perfect sense, what i was wondering was more to do with the idea that human behavior, on a macro level, follows these same patterns, and what this would mean from a metaphysical perspective. like, what would it mean for google trends data to show a strong, lets say, 3rd harmonic?
probably the wrong place to talk about a thing like this. i tried asking about this on quora, but got no hits
probably the wrong place to talk about a thing like this. i tried asking about this on quora, but got no hits

BertKoor
 KVRAF
 10792 posts since 8 Mar, 2005 from Utrecht, Holland
Re: Help me learn the mathematical formulas behind wavetables
https://trends.google.com/trends/explor ... &q=flowers
There are some clear spikes around Valentines Day (feb 14) and the first week of May, and less interest in the winter months. I wouldn't call those spikes "harmonics", although you could probably build a similar waveform with FFT.
The meaning of this is just that there is a correlation between the time of year, and our interest in flowers. That makes common sense...
There are some clear spikes around Valentines Day (feb 14) and the first week of May, and less interest in the winter months. I wouldn't call those spikes "harmonics", although you could probably build a similar waveform with FFT.
The meaning of this is just that there is a correlation between the time of year, and our interest in flowers. That makes common sense...
We are the KVR collective. Resistance is futile. You will be assimilated.
My MusicCalc is back online!!
My MusicCalc is back online!!

kamalmanzukie
 KVRist
 145 posts since 12 May, 2012
Re: Help me learn the mathematical formulas behind wavetables
i'm sure you're right. what i was thinking was going on a lot of assumptions, i've never taken the fft of one myself, though i know people do autocorrelations on them somehow. there must be a way to export the data to a text file or xml or something?BertKoor wrote:https://trends.google.com/trends/explor ... &q=flowers
There are some clear spikes around Valentines Day (feb 14) and the first week of May, and less interest in the winter months. I wouldn't call those spikes "harmonics", although you could probably build a similar waveform with FFT.
The meaning of this is just that there is a correlation between the time of year, and our interest in flowers. That makes common sense...

mystran
 KVRAF
 5036 posts since 12 Feb, 2006 from Helsinki, Finland
Re: Help me learn the mathematical formulas behind wavetables
I know this thread is a bit old by now, but you can put these into wavetables  or rather, you can play any wavetable with stretched or compressed harmonics. It's actually fairly simple (and only slightly more expensive computationally when compared to regular wavetable playback):kryptonaut wrote:For generating bandlimited sounds with 'stretched' (or compressed) harmonics, you can experiment with the formula given on the first page of http://www.jamminpower.com/PDF/Sine%20Summation.pdf  these waves can't be put in a wavetable as they aren't periodic, but they can generate some interesting sounds.
First preprocess the wavetables (eg. using FFT) into analytic (complex valued) wavetables by filtering out the negative frequencies. Then at realtime figure out the desired harmonic spacing (as a linear frequency) and play the wavetable at this frequency to generate a complex temporary signal. Now the fundamental will be in the wrong place, so calculate the frequency difference to the desired fundamental and generate a complex sinusoid at this frequency (positive or negative, depending on whether you are compressing or stretching). Then apply frequency shifting by multiplying the complex wavetable output with the complex sinusoid to shift all the harmonics to where they should be. Finally you can throw away the imaginary part to get a normal realonly signal.
It is also possible to do this with realtime Hilbert transform (eg. using arbitrary DSP oscillators instead of wavetables) instead of precalculation, but preprocessing has some advantages. Besides a perfect transform (something that you never quite get with HTfilters), we can generate complex signal right from the start. This is nice for bandlimiting, because it's then sufficient to ensure that the final (frequency shifted) signal fits below Nyquist (ie. fs/2), since the bandwidth available for analytic signals known to only contain positive (or negative) frequencies is twice that of a realsignal, so it's perfectly fine if the initial wavetable output (before shifting in place) violates the fs/2 condition temporarily.
The end result sounds like frequency shifting usually does, but if the harmonic spacing is kept relative to the pitch, the result is consistent across the keyboard and much more musical than a fixedfrequency postprocess shift. Depending on the contents of the wavetable, keeping the fundamental in place doesn't necessarily mean that the perceived pitch stays in place, but you can easily compensate by adjusting the overall tuning, since intervals (and chords, etc) still sound more or less the same (depending a bit on the actual amount of stretch/compress) as you go up and down in pitch.
That said, as long as the harmonics spacing is constant (even if we shift it such that it's no longer "harmonic" as such), the result still tends to sound a bit "static" the way single cycle waveforms do with some cyclic variation, so it's not really something that can reproduce the type of inharmonicity you'd hear on dispersive strings or similar. For that type of stuff your best bet is probably to just go additive (ie. FFT the wavetables, then use the spectrum to scale the harmonics of an additive synth while detuning the partials using some nonlinear curve).
If you'd like Signaldust to return, please ask Katinka Tuisku to resign.

Tj Shredder
 KVRAF
 1611 posts since 6 Jan, 2017 from Outer Space
Re: Help me learn the mathematical formulas behind wavetables
The best book probably that is affordable for anybody is Miller Puckettes "The theory and technique of electronic music" from the creator of Max and Pd or pure data. If you start with Pd, you might not only get a deeper understanding of DSP methods, you might also start into a world way beyond readymade VSTs...
http://msp.ucsd.edu/techniques.htm
http://msp.ucsd.edu/techniques.htm