Best WaveTable sample size


#1

I know this is subjective but I’m trying to gauge a good number of samples for a wavetable synth. I feel like it should be a power of 2.

256 samples per wavetable row feels too small even though I know with simple interpolation you wouldn’t perceive any stepping and it has the ability to abuse a single byte overflow as apposed to using a modulus operation. But I feel I would loose a little bit of harmonic richness

I feel like going any higher than 1024 samples is overkill especially with interpolation and if the wavetable itself has a depth of 256 then that’s going to be quite large for saving presets e.t.c.

I feel that 512 samples is on paper the correct number to use but it kind of feels like punching for mediocrity.

I don’t want to use dynamic WT sample length as this would introduce unnecessary calculations and I want stability as this is for a pet project that could run on ARM processors like an RPi.

As stated I know this is all subjective but I was wondering if there’s any strong consensus going into 2019.


#2

The number of samples in a looping wavetable will determine the highest frequency that can be reproduced. i.e. the more samples, the more “high-end” frequencies you will hear.

A 256 sample loop can represent 7 octaves worth of harmonics (number-of-bits minus one) so in terms of human perception (which can detect frequencies up to approx 20kHz), the lowest frequency you can play without missing harmonics is 156Hz, which is MIDI note 51 D#3.
So, as you suspected, a 256 sample wavetable would not be considered “pro audio”, but might be acceptable in some other applications.
You can use the above method to compare different table sizes, and pick one that’s suitable for you. There is a trade-off between quality and memory consumption, use too much memory and you may cause “cache-thrashing” which will degrade your system performance.
PS: I use a range of wavetable sizes in my best Oscillator, less for high frequencies, more for low frequencies.


#3

It depends what’s in the wavetable, what frequency you read through it, how much aliasing you can tolerate, and how much memory is available. It’s difficult to quantify that, so you’ll need to figure it out empirically (Octave or MATLAB are great for that).

There is an ideal size. If your wave’s frequency is F Hz, then its period is going to be Fs / F samples (eg 440 Hz at 48k sample rate has a period of 110 samples). If you use a table smaller than the ideal, interpolation is equivalent to a lowpass filter and you lose high end. If you use a table larger than the ideal, you get aliasing. That’s why when you want to minimize aliasing you need to use multiple wavetables for a single waveform, shrinking in size as you go up the spectrum. Old rule of thumb is a new wavetable for each minor 3rd up the scale.

You shouldn’t really care about power of 2 sized wavetables, my gut is the performance benefit doesn’t matter nearly as much as keeping the lookups on the same cache line.


#4

I have been thinking about this one today too …
It’s always a fudge isn’t it.
I was wondering if most of the soft synths I like to use like Dune2 or Reaktor or Dexed just calculate the waveforms or look stuff up … If you use wavetables I was thinking you really want a variable sample rate and a DAC for each voice. Something which probably can’t be achieved in JUCE and Cubase!


#5

If you use wavetables I was thinking you really want a variable sample rate and a DAC for each voice

That’s exactly what wavetable oscillators do. They resample by stepping through at different increments and filter with interpolation (which is what a DAC is, just a lowpass filter).


#6

@ JeffMcClintock … I think you make a strong point. I realised that lower number of samples would suppress harmonics and cause aliasing issues. As it’s just an idea at the moment that I’m sketching out a prototype for I didn’t think to put pen to paper on the actual frequency range and was a bit narrow minded on performance.

@Holy_City I hear you on wavetable size but there are lots of performance tricks that can be done to track sample and inter sample position in the wavetable so I may as well utilise that. I had thought of using several small wavetables to represent the full spectrum with different types of interpolation - it’s food thought. I want to have the ability to hand wavetables which makes that idea a little tricky to calculate on the fly. I suppose you can have a control table and sub tables that are filtered accordingly…

Gut feeling at the moment is that 512 samples is a good bet. Does anyone know what the main WT synths use?


#7

I’m currently going with 2048 samples for all frequency octaves, with linear Interpolation. Although 1024 might do, but I’ve seen some aliasing with that, so I’m sticking with 2048 :smiley:
I don’t save all of them, because they’re all really easy to calculate from the base waveform.