[sdiy] saw vs ramp, audible?
brianw
brianw at audiobanshee.com
Tue Dec 10 06:34:11 CET 2024
I updated the macOS program to run on more modern macOS releases. Some of you might want to check it out because you can explore waveshapes created by summing weighted sinusoid harmonics, with various options to flip the polarity of harmonics.
Turn down your main output volume before running the following.
http://audiobanshee.com/software/Waves-2.dmg
Not sure how many systems this will run on, but it runs on my Monterey laptop.
It starts with a sine wave with no harmonics. The higher the sample rate, the higher the pitch. The unlabeled slider on the right hand side adds one harmonic per tick. By default, it will create a sawtooth if you raise that slider, because all harmonics are included with an amplitude weighting of 1/N. You can choose Odd harmonics, Even harmonics, or All harmonics. There's a checkbox to Flip the polarity of harmonics. At the bottom, you can choose a Ratio for the harmonics' amplitude weighting, from 1/1, 1/N and 1/(N*N).
Triangle is generated with Odd harmonics, polarity Flip, and 1/(N*N) weighting. What's interesting is that if you turn off Flip, you see a waveform that looks like a sine, but even more circular, and the tone is exactly the same as triangle. The catch is that the harmonics line up in a way that you hear a louder intensity for the same peak-to-peak level. Hit the Reset Peak button to boost any generated waveform to the maximum peak-to-peak level (this counters the automatic peak limited that goes on while parameters are changed).
Note that the 1/1 Ratio just generates various types of impulses. These don't correspond to any analog synth waveforms.
Of course, Odd harmonics with 1/N amplitude Ratio generates a band-limited square. If you slowly vary the number of harmonics, it sounds a bit like a filter sweep - but one that jumps (and has no resonance). In this setting, turning on Flip will create a very spiky waveform that sounds exactly like a square, but is terribly quiet because of the extreme peak-to-peak amplitude. Try turning Flip on and off without Reset Peak to note the similar sound of two very different looking shapes. This is because the only change is the polarity of harmonics, not the number or relative amplitude of those harmonics.
Brian Willoughby
p.s. I realize that some of you don't have macOS and can't run this. I wrote the program back in 2007, and it was much quicker to just recompile it today than try to port to another OS.
On Dec 9, 2024, at 3:47 PM, brianw <brianw at audiobanshee.com> wrote:
> 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