[sdiy] saw vs ramp, audible?
brianw
brianw at audiobanshee.com
Tue Dec 10 00:47:00 CET 2024
It is impossible to remove aliasing with a filter after sampling. The filtering must be done before sampling. The reason it is impossible is that the desired harmonics of the saw/ramp are all around the undesired aliased frequencies. No filter can select only aliased frequencies without also removing desired harmonics.
In the analog domain, the signal and filter have "infinite" bandwidth, so the frequencies above Nyquist can be "removed" before sampling. Any time sample rate conversion reduces the rate, the filtering must be done at the higher sample rate, before conversion.
In your ideal sawtooth, there are infinite harmonics, so you're technically downsampling from an infinite rate to some finite rate. By filtering at 4400 Hz, you're removing both aliases and sawtooth harmonics above that, while there are still aliased frequencies before that - although they're really faint because each higher harmonic has a lower amplitude (1/N). When generating waveforms, the only way to avoid aliasing is to avoid generating any frequencies above Nyquist. For a sawtooth, a simple sum of sinusoid waveforms is the way to do it.
I have a macOS program that can synthesize bandlimited waveforms without aliasing, with controls for odd-even polarity, the number of harmonics, and the weight of the harmonics 1/1, 1/N, 1/(N^2). I need to update this for the latest macOS so I can upload a new version. For folks that have an old version of macOS, the latest version is at http://audiobanshee.com/software/Waves-1.2p.dmg
Brian Willoughby
p.s. An older version of my program would write waveshapes in Evolver format for uploading, but that code depended upon another library I wrote that isn't very portable.
On Dec 9, 2024, at 1:20 PM, Ben Stuyts wrote:
> On 9 Dec 2024, at 19:37, Jonatan Liljedahl wrote:
>> Yes, all but the 4th one is the same. I don’t think it’s interesting or important to know/hear if it’s up or down ramp, the interesting thing is that it’s a clear difference. I also perceive it as lower pitch. They are all aliasing a lot too :)
>
> Agreed about the aliasing. These were ideal sawtooth waveforms without any filtering. Here is a slightly improved version with an 8 pole low-pass Butterworth filter at 4.4 kHz. I have uploaded the resulting .wav to https://synth-diy.org/files/sawtooth_waves.wav to save bandwidth on the list.
>
> Attached is the Python script. There is a bit of a DC shift between the inverted and regular wave forms, so I have to look into that.
>
> The info about which is which is here: https://synth-diy.org/files/sawtooth_inversion_info.txt
>
> Ben
>
>> /Jonatan
>> http://kymatica.com
>>
>>
> mån 9 dec. 2024 kl. 19:14 skrev Ingo Debus via Synth-diy <synth-diy at synth-diy.org>:
>> Am 09.12.2024 um 17:44 schrieb Ben Stuyts via Synth-diy <synth-diy at synth-diy.org>:
>>> Here is a Python script to generate some random non-/inverted sawtooth waves after each other in a single wav file, plus a text file saying which is which. You can play with the parameters in the script to change the sample rate, length of each sample, etc.
>>
>> Thanks for sharing!
>> I listened to them several times (via Yamaha NS-10M speakers), and the 4th one sounds slightly lower in pitch to me than the first three. Any one else noticing this too?
>>
>> Ingo
More information about the Synth-diy
mailing list