3 deleted 21 characters in body
source | link

Let us say your sample rate is 48kHz.

You are generating a sawtooth wave at a fundamental frequency of 10kHz, using your code.

First harmonic is at 10kHz. Second harmonic at 20kHz. Third harmonic at 30kHz. But since your signal is inherently sampled at 48kHz, anything above Nyquist gets aliased back into the 0..24kHz band. The 30kHz harmonic is 6kHz above Nyquist, so it gets folded back to 24-6 = 18kHz. Fourth harmonic at 40kHz, 16kHz above Nyquist, folded back to 8kHz which is below your fundamental! Next harmonic at 50kHz, 26kHz above Nyquist, folded back to 2kHz.

I recommend you to use Sonic Visualizer or any other audio analysis tool, and monitor the spectra of the signals coming out of your code. You'll see the undertones created by your code.

Since you are already working with a 48kHz sample rate / 24kHz Nyquist frequency, everything your algorithm generates will be folded into this band; and obviously no simple filter shape - low-pass, high-pass could filter the spurious 18kHz, 8kHz, 2kHz and so on tones.

The only filter that could possibly work would be the complementary of a comb-filter with a cutoff frequency equal to your fundamental - but it is tricky to design, and still won't handle the case where the fundamental divides the sample rate.

Thus, you need to use a technique which directly synthesize (approximately) band-limited data - additive synthesis, band-limited wavetables, or minBLEP.

OR:

You generate your data as a ridiculously high sample rate - to the point that you can consider that aliasing will be negligible; and then low-pass filter.

For example, let us say that you request that no alias image should be above -48dB (which is still very lax!). This means that only the 252th harmonic of your sawtooth wave can be aliased (its amplitude will be 0.004, or -48dB). So your Nyquist frequency has to be above the frequency of the 252th harmonics of the highest pitched note. Let us say 4kHz is the highest fundamental frequency you want to synthesize. This means a sample rate of 2 x 4000 x 252 = 2 MHz.

So if you have lots of computational resources to waste, you can run your synthesis code at 2 MHz, then apply a brickwall low-pass filter at 24kHz, and resample at 48kHz. But this would be a very stupid thing to do...

Let us say your sample rate is 48kHz.

You are generating a sawtooth wave at a fundamental frequency of 10kHz, using your code.

First harmonic is at 10kHz. Second harmonic at 20kHz. Third harmonic at 30kHz. But since your signal is inherently sampled at 48kHz, anything above Nyquist gets aliased back into the 0..24kHz band. The 30kHz harmonic is 6kHz above Nyquist, so it gets folded back to 24-6 = 18kHz. Fourth harmonic at 40kHz, 16kHz above Nyquist, folded back to 8kHz which is below your fundamental! Next harmonic at 50kHz, 26kHz above Nyquist, folded back to 2kHz.

I recommend you to use Sonic Visualizer or any other audio analysis tool, and monitor the spectra of the signals coming out of your code. You'll see the undertones created by your code.

Since you are already working with a 48kHz sample rate / 24kHz Nyquist frequency, everything your algorithm generates will be folded into this band; and obviously no simple filter shape - low-pass, high-pass could filter the spurious 18kHz, 8kHz, 2kHz and so on tones.

The only filter that could possibly work would be the complementary of a comb-filter with a cutoff frequency equal to your fundamental - but it is tricky to design, and still won't handle the case where the fundamental divides the sample rate.

Thus, you need to use a technique which directly synthesize (approximately) band-limited data - additive synthesis, band-limited wavetables, or minBLEP.

OR:

You generate your data as a ridiculously high sample rate - to the point that you can consider that aliasing will be negligible; and then low-pass filter.

For example, let us say that you request that no alias image should be above -48dB (which is still very lax!). This means that only the 252th harmonic of your sawtooth wave can be aliased (its amplitude will be 0.004, or -48dB). So your Nyquist frequency has to be above the frequency of the 252th harmonics of the highest pitched note. Let us say 4kHz is the highest fundamental frequency you want to synthesize. This means a sample rate of 2 x 4000 x 252 = 2 MHz.

So if you have lots of computational resources to waste, you can run your synthesis code at 2 MHz, then apply a brickwall low-pass filter at 24kHz, and resample at 48kHz. But this would be a very stupid thing to do...

Let us say your sample rate is 48kHz.

You are generating a sawtooth wave at a fundamental frequency of 10kHz, using your code.

First harmonic is at 10kHz. Second harmonic at 20kHz. Third harmonic at 30kHz. But since your signal is inherently sampled at 48kHz, anything above Nyquist gets aliased back into the 0..24kHz band. The 30kHz harmonic is 6kHz above Nyquist, so it gets folded back to 24-6 = 18kHz. Fourth harmonic at 40kHz, 16kHz above Nyquist, folded back to 8kHz which is below your fundamental! Next harmonic at 50kHz, 26kHz above Nyquist, folded back to 2kHz.

I recommend you to use Sonic Visualizer or any other audio analysis tool, and monitor the spectra of the signals coming out of your code. You'll see the undertones created by your code.

Since you are already working with a 48kHz sample rate / 24kHz Nyquist frequency, everything your algorithm generates will be folded into this band; and obviously no simple filter shape - low-pass, high-pass could filter the spurious 18kHz, 8kHz, 2kHz and so on tones.

The only filter that could possibly work would be a comb-filter with a cutoff frequency equal to your fundamental - but it is tricky to design, and still won't handle the case where the fundamental divides the sample rate.

Thus, you need to use a technique which directly synthesize (approximately) band-limited data - additive synthesis, band-limited wavetables, or minBLEP.

OR:

You generate your data as a ridiculously high sample rate - to the point that you can consider that aliasing will be negligible; and then low-pass filter.

For example, let us say that you request that no alias image should be above -48dB (which is still very lax!). This means that only the 252th harmonic of your sawtooth wave can be aliased (its amplitude will be 0.004, or -48dB). So your Nyquist frequency has to be above the frequency of the 252th harmonics of the highest pitched note. Let us say 4kHz is the highest fundamental frequency you want to synthesize. This means a sample rate of 2 x 4000 x 252 = 2 MHz.

So if you have lots of computational resources to waste, you can run your synthesis code at 2 MHz, then apply a brickwall low-pass filter at 24kHz, and resample at 48kHz. But this would be a very stupid thing to do...

2 added 783 characters in body
source | link

Let us say your sample rate is 48kHz.

You are generating a sawtooth wave at a fundamental frequency of 10kHz, using your code.

First harmonic is at 10kHz. Second harmonic at 20kHz. Third harmonic at 30kHz. But since your signal is inherently sampled at 48kHz, anything above Nyquist gets aliased back into the 0.. which24kHz band. The 30kHz harmonic is 6kHz above Nyquist frequency -, so it'll beit gets folded back atto 24-6 = 18kHz. Fourth harmonic at 40kHz, 16kHz above Nyquist, folded back to 8kHz which is below your fundamental! Next harmonic at 50kHz, 26kHz above Nyquist, folded back to 2kHz.

I recommend you to use Sonic Visualizer or any other audio analysis tool, and monitor the spectra of the signals coming out of your code. You'll see the undertones created by your code.

Since you are already working with a 48kHz sample rate / 24kHz Nyquist frequency, everything your algorithm generates will be folded into this band; and obviously no simple filter shape - low-pass, high-pass could filter the spurious 18kHz, 8kHz, 2kHz and so on tones.

The only filter that could possibly work would be the complementary of a comb-filter with a cutoff frequency equal to your fundamental - but it is tricky to design, and still won't handle the case where the fundamental divides the sample rate.

Thus, you need to use a technique which directly synthesize (approximately) band-limited data - additive synthesis, band-limited wavetables, or minBLEP.

OR:

You generate your data as a ridiculously high sample rate - to the point that you can consider that aliasing will be negligible; and then low-pass filter.

For example, let us say that you request that no alias image should be above -48dB (which is still very lax!). This means that only the 252th harmonic of your sawtooth wave can be aliased (its amplitude will be 0.004, or -48dB). So your Nyquist frequency has to be above the frequency of the 252th harmonics of the highest pitched note. Let us say 4kHz is the highest fundamental frequency you want to synthesize. This means a sample rate of 2 x 4000 x 252 = 2 MHz.

So if you have lots of computational resources to waste, you can run your synthesis code at 2 MHz, then apply a brickwall low-pass filter at 24kHz, and resample at 48kHz. But this would be a very stupid thing to do...

Let us say your sample rate is 48kHz.

You are generating a sawtooth wave at 10kHz using your code.

First harmonic is at 10kHz. Second harmonic at 20kHz. Third harmonic at 30kHz... which is 6kHz above Nyquist frequency - so it'll be folded back at 18kHz. Fourth harmonic at 40kHz, 16kHz above Nyquist, folded back to 8kHz which is below your fundamental! Next harmonic at 50kHz, 26kHz above Nyquist, folded back to 2kHz.

I recommend you to use Sonic Visualizer or any other audio analysis tool, and monitor the spectra of the signals coming out of your code. You'll see the undertones created by your code.

Since you are already working with a 48kHz sample rate / 24kHz Nyquist frequency, everything your algorithm generates will be folded into this band; and obviously no simple filter shape - low-pass, high-pass could filter the spurious 18kHz, 8kHz, 2kHz and so on tones.

The only filter that could possibly work would be the complementary of a comb-filter with a cutoff frequency equal to your fundamental - but it is tricky to design, and still won't handle the case where the fundamental divides the sample rate.

Thus, you need to use a technique which directly synthesize (approximately) band-limited data - additive synthesis, band-limited wavetables, or minBLEP.

Let us say your sample rate is 48kHz.

You are generating a sawtooth wave at a fundamental frequency of 10kHz, using your code.

First harmonic is at 10kHz. Second harmonic at 20kHz. Third harmonic at 30kHz. But since your signal is inherently sampled at 48kHz, anything above Nyquist gets aliased back into the 0..24kHz band. The 30kHz harmonic is 6kHz above Nyquist, so it gets folded back to 24-6 = 18kHz. Fourth harmonic at 40kHz, 16kHz above Nyquist, folded back to 8kHz which is below your fundamental! Next harmonic at 50kHz, 26kHz above Nyquist, folded back to 2kHz.

I recommend you to use Sonic Visualizer or any other audio analysis tool, and monitor the spectra of the signals coming out of your code. You'll see the undertones created by your code.

Since you are already working with a 48kHz sample rate / 24kHz Nyquist frequency, everything your algorithm generates will be folded into this band; and obviously no simple filter shape - low-pass, high-pass could filter the spurious 18kHz, 8kHz, 2kHz and so on tones.

The only filter that could possibly work would be the complementary of a comb-filter with a cutoff frequency equal to your fundamental - but it is tricky to design, and still won't handle the case where the fundamental divides the sample rate.

Thus, you need to use a technique which directly synthesize (approximately) band-limited data - additive synthesis, band-limited wavetables, or minBLEP.

OR:

You generate your data as a ridiculously high sample rate - to the point that you can consider that aliasing will be negligible; and then low-pass filter.

For example, let us say that you request that no alias image should be above -48dB (which is still very lax!). This means that only the 252th harmonic of your sawtooth wave can be aliased (its amplitude will be 0.004, or -48dB). So your Nyquist frequency has to be above the frequency of the 252th harmonics of the highest pitched note. Let us say 4kHz is the highest fundamental frequency you want to synthesize. This means a sample rate of 2 x 4000 x 252 = 2 MHz.

So if you have lots of computational resources to waste, you can run your synthesis code at 2 MHz, then apply a brickwall low-pass filter at 24kHz, and resample at 48kHz. But this would be a very stupid thing to do...

1
source | link

Let us say your sample rate is 48kHz.

You are generating a sawtooth wave at 10kHz using your code.

First harmonic is at 10kHz. Second harmonic at 20kHz. Third harmonic at 30kHz... which is 6kHz above Nyquist frequency - so it'll be folded back at 18kHz. Fourth harmonic at 40kHz, 16kHz above Nyquist, folded back to 8kHz which is below your fundamental! Next harmonic at 50kHz, 26kHz above Nyquist, folded back to 2kHz.

I recommend you to use Sonic Visualizer or any other audio analysis tool, and monitor the spectra of the signals coming out of your code. You'll see the undertones created by your code.

Since you are already working with a 48kHz sample rate / 24kHz Nyquist frequency, everything your algorithm generates will be folded into this band; and obviously no simple filter shape - low-pass, high-pass could filter the spurious 18kHz, 8kHz, 2kHz and so on tones.

The only filter that could possibly work would be the complementary of a comb-filter with a cutoff frequency equal to your fundamental - but it is tricky to design, and still won't handle the case where the fundamental divides the sample rate.

Thus, you need to use a technique which directly synthesize (approximately) band-limited data - additive synthesis, band-limited wavetables, or minBLEP.