ChordWizard Software
13 years ago
Hi all,
I am working on a new project using PortAudio and testing it with a waveform stored in a buffer. This could be generated myself (sine, square, sawtooth, etc) or a more complex waveform loaded from a file.
I want to be able to render the waveform at different frequencies, but I can see that I will be limited by quantisation if I just play out the samples themselves.
For example, to generate a 440 Hz tone with sample rate 44100, I need 100.2272727 samples. This gets rounded to 100 samples, which then produces an actual tone of 441 Hz.
So it looks like I will be needing to interpolate between the samples in the wavetable. Can someone point me to some discussion or resources on this?
Simple linear interpolation looks easy enough to achieve, but does it introduce an unacceptable level of distortion? Is there a rule of thumb for minimum numer of samples per waveform to keep artifacts of this type undetectable?
Also, as an aside, is it general practice to calculate sample values with doubles (8 bytes) or are floats (4 bytes) generally adequate? I'm targeting CD-quality audio (shorts @ 2 bytes) so I'm not sure if the extra precision during calculations helps much.
Regards,
Stephen Clarke
Managing Director
ChordWizard Software Pty Ltd
***@chordwizard.com
http://www.chordwizard.com
ph: (+61) 2 4960 9520
fax: (+61) 2 4960 9580
I am working on a new project using PortAudio and testing it with a waveform stored in a buffer. This could be generated myself (sine, square, sawtooth, etc) or a more complex waveform loaded from a file.
I want to be able to render the waveform at different frequencies, but I can see that I will be limited by quantisation if I just play out the samples themselves.
For example, to generate a 440 Hz tone with sample rate 44100, I need 100.2272727 samples. This gets rounded to 100 samples, which then produces an actual tone of 441 Hz.
So it looks like I will be needing to interpolate between the samples in the wavetable. Can someone point me to some discussion or resources on this?
Simple linear interpolation looks easy enough to achieve, but does it introduce an unacceptable level of distortion? Is there a rule of thumb for minimum numer of samples per waveform to keep artifacts of this type undetectable?
Also, as an aside, is it general practice to calculate sample values with doubles (8 bytes) or are floats (4 bytes) generally adequate? I'm targeting CD-quality audio (shorts @ 2 bytes) so I'm not sure if the extra precision during calculations helps much.
Regards,
Stephen Clarke
Managing Director
ChordWizard Software Pty Ltd
***@chordwizard.com
http://www.chordwizard.com
ph: (+61) 2 4960 9520
fax: (+61) 2 4960 9580