Re: [LAD] Wavetable synthesis : Creating fat wavetables

2012-08-25 Thread Fons Adriaensen
On Sat, Aug 25, 2012 at 12:44:12AM +0100, Harry van Haaren wrote:
 On Fri, Aug 24, 2012 at 11:48 PM, Fons Adriaensen f...@linuxaudio.orgwrote:
 
  The easiest way in the case of wavetable synthesis is to upsample
  your waves by a factor of say 8, then use linear interpolation.
 
 
 So the preparation process is:
 -record the sounds
 -upsample x8
 
 Live playing:
 -downsample the wavetable  to the size needed for the frequency that is
 played
 
 Do I understand the steps correctly?

Basically just multiply all samples indices by 8. For example if
when using the original you would need the value at 3.4, and 
interpolate between samples 3 and 4, in the upsampled table that
becomes 3.4 * 8 = 27.2 and you interpolate between samples 27 and
28. The run-time CPU load is just the same, you only need more
memory. But since now you can interpolate witout artefacts, you
don't need a perfect fit of K cycles in N samples, and that allows
the waves to be shorter. 

Ciao,


-- 
FA

A world of exhaustive, reliable metadata would be an utopia.
It's also a pipe-dream, founded on self-delusion, nerd hubris
and hysterically inflated market opportunities. (Cory Doctorow)

___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


Re: [LAD] Wavetable synthesis : Creating fat wavetables

2012-08-25 Thread Gabriel M. Beddingfield

On 08/24/2012 02:21 PM, harryhaa...@gmail.com wrote:

Hi everybody!

I'm interested in wavetable synthesis, so read around a bit on how they
work, best used etc, but I can find preciously little information that


You probably know this, but wavetable synthesis is different from a 
table-lookup oscillator.  It sounds like you're doing a table look-up 
oscillator.



describes how to best create a wavetable.
Pre-recorded material seems a pretty go-to choice rather than using
csound or freinds to generate wavetables.

The issue of tuning is where I currently struggle the most: How should
that be approached?


I wrote a table-lookup oscillator that is currently being used in 
omap-audio-tool[1] for the tone generator.  See [2] for the header.  I 
originally wrote it for fun, with the intention of using it on platforms 
with weak floating point.


Like Fons mentioned in the e-mail, I made my tables a length of N^2 and 
large enough so that they would not need interpolation for frequencies 
over about 100Hz (IIRC).  Below this cut-off frequency it does linear 
interpolation.


When calculating offsets within your table, it's important to be wary of 
truncation error (i.e. don't convert your frequency to play every kth 
sample in the table).  This will cause your output frequencies to be 
different from what you input (quantization error).


For generating the tables for sine, triangle, etc., audio-tool has a 
program generate-wave-table.c[3] that generates the look-up tables in a 
format suitable for inclusion in a C source file.  However, you can 
easily change the output by changing the 'out()' implementation in main().


-gabriel

[1] http://gitorious.org/omap-audio/omap-audio-tool
[2] 
http://gitorious.org/omap-audio/omap-audio-tool/blobs/master/oscillator-table.h
[3] I started off calling everything wavetable by mistake, this is one 
was overlooked in the renaming of thing.


___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


Re: [LAD] Wavetable synthesis : Creating fat wavetables

2012-08-24 Thread Robin Gareus
On 08/24/2012 10:35 PM, harryhaa...@gmail.com wrote:
 I record a C3 note, 10 seconds of it. Then I want to create a wavetable.
 Search for a zero crossing after 1 second, chop. Looped playback = C3.
 Now I want to have a C#3, so 1/12 of the double of the frequency,
 playing back at that rate will NOT always provide a C#3.

Hi Harry,

You may mean the right thing and even have implemented it correctly but

  a halftone step over base_freq  =  base_freq * 2^(1/12)

Even if you implemented it correctly, overtones or undertones can
mislead ones perception quite easily. Looping can warp things back, too.
-- I suggest to play the wavetable in a loop and check with a spectrum
analyzer if you really have the fundamental.

ciao,
robin
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


Re: [LAD] Wavetable synthesis : Creating fat wavetables

2012-08-24 Thread Fons Adriaensen
On Fri, Aug 24, 2012 at 08:35:29PM +, harryhaa...@gmail.com wrote:

 My intention is indeed to do waldorf style cascaded wavetables
 which are interpolated between. I have a program that I can use to
 test the wavetables, but the issue of tuning remains a problem for
 me.

A few things to consider.

You need an interpolation method that doesn't create artefacts, in
this case aliasing. You'll also want it to be fast and efficient.
The easiest way in the case of wavetable synthesis is to upsample
your waves by a factor of say 8, then use linear interpolation.
Takes more memory, but memory is cheap these days. Aeolus does this
for pipes that contain significant energy above 1/8 of the sample
rate.

Provided you have a *good* interpolation method, two things follow.

* Your wavetable doesn't need exactly K cycles in N samples, K,N
integer. If for example you know you have an integer number of cycles
in say 123.4 samples, create a wavetable with 124 samples. On the first
iteration, use samples 0...123, then when you reach 124 (beyond the end
of the table), jump back 123.4 samples, so interpolate at 0.6, 1.6, 2.6
etc. Similar for all iterations through the loop, the third will be 0.2,
1.2, 2.2 etc.

* If you are prepared to e.g. turn a C into a C# by interpolation,
then you could as well interpolate to obtain the C. In other words,
the wavetable doesn't need to be exactly C in the first place. You
just need to know its exact pitch.

Picking loop entry/exit points by looking for zero crossings can
sometimes provide a reasonable result, but it's pure chance. First,
the zero crossings could be everywhere between the samples. Second,
the distance between two zero crossings doesn't need to be an exact
number of cycles.

The easiest way to obtain good loops of natural sounds is to have
a playback engine that works as described above, and that allows
you to modify the supposed lenght of the loop (the 123.4 in the
example) in real time while listening to the result. The alternative
is to compute the phase trajectory of the entire waveform, which will
tell you the exact pitch with much more precision than looking at the
waveform.

Whatever the method, the result could be that you have a discon-
tinuity between the start and end of the loop. There can be many
causes for that. With recorded samples LF noise is one, or the
harmonics could simply be not exactly harmonic. In such cases you
need to test a different start and end points, until you find some
that work well, or to 'bend' the waveform so the ends meet. 

Ciao,

-- 
FA

A world of exhaustive, reliable metadata would be an utopia.
It's also a pipe-dream, founded on self-delusion, nerd hubris
and hysterically inflated market opportunities. (Cory Doctorow)

___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


Re: [LAD] Wavetable synthesis : Creating fat wavetables

2012-08-24 Thread Harry van Haaren
On Fri, Aug 24, 2012 at 11:18 PM, Robin Gareus ro...@gareus.org wrote:

 Even if you implemented it correctly, overtones or undertones can
 mislead ones perception quite easily.


Indeed: I've not taken a spectrum analyzer to the signal yet: but something
feels wierd with it.
Will look at the spectrum and see if the fundamental is present.
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev


Re: [LAD] Wavetable synthesis : Creating fat wavetables

2012-08-24 Thread Harry van Haaren
On Fri, Aug 24, 2012 at 11:48 PM, Fons Adriaensen f...@linuxaudio.orgwrote:

 The easiest way in the case of wavetable synthesis is to upsample
 your waves by a factor of say 8, then use linear interpolation.


So the preparation process is:
-record the sounds
-upsample x8

Live playing:
-downsample the wavetable  to the size needed for the frequency that is
played

Do I understand the steps correctly?


 Provided you have a *good* interpolation method, two things follow.

You mentioned linear interpolation, I think that will be sufficient
considering its an instrument not an emulator, crunchy aliasing? Thats
meant to be there :)


The alternative
 is to compute the phase trajectory of the entire waveform, which will
 tell you the exact pitch with much more precision than looking at the
 waveform.

I don't know how to compute the phase trajectory or that, but it sounds
like its not strictly necessary so I'll leave that for the time being.
The loop points on the wavetables I'm currently using are just ear
picked, and slightly visually tuned.

Other concepts I've read about and would be interested in experimenting
with after a working prototype is done:
-2d interpolation between wavetables and linear interpolation between the
wavetables values. Time and phase of wavetables must be exact.
-Randomizing phases and loop positions within wavetable for different
timbres

-Harry

PS: Random idea: Create a program which scans trough a short recorded
frament, and analyzes the number of samples per cycle. Some sort of take
sample, check sample loop should do the trick really, and then output the
largest repeated period. That with a sensitivity control is essentially all
that's needed to create perfectly looped synthesized recorded wavetables
right?
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev