Freeform band-limited waveforms
this paper was done long before i had MATLAB.  the drawings are poor, but the math (at least in this revision, which is what you should use) is spot on.

send me an email address (to my audioimagination.com, not the wavemechanics.com on the paper) and i will send you a very short C file that shows how to generate and crossfade the wavetables in the synthesis process.

about analyzing a sample of a note (like from a wav file), you need to have a good sliding pitch-detector and a good interpolator (like maybe a good Kaiser-windowed $\operatorname{sinc}(\cdot)$-based interpolator) to extract single-cycle waveforms out of the note and put them into wavetables.

or you can create wavetables in memory from the POV of additive synthesis, simply by adding up the sinusoids, but it might be easier with the inverse FFT (and this is when knowledge of the periodicity of the DFT can be used to advantage).  i think your life will be easiest that the active wavetables in memory that are being used in the real-time synthesizer, those wavetables should all be the same power of 2 (and a nice big power of 2, like 1024 or 2048 or 4096).  notes that are higher in pitch will have fewer harmonics than notes lower in pitch, but will have the same number of samples per wavetable.  (and if the number of samples greatly exceeds twice the number of harmonics, then you can get away with linear interpolation during synthesis.)

wavetables that are being stored and not active, need not have so many samples.  as long as the number of samples in the periodic wavetable is more than twice the highest harmonic number, then, at least theoretically, it is enough.  but when a wavetable is made "active" and loaded into memory, it should be expanded and interpolated out to be whatever the large power of 2 is.

oh, and Nigel Redmon has code somewhere.