[Fpga-synth] Signals and Sample Rates
Eric Brombaugh
ebrombaugh at earthlink.net
Sat May 17 17:11:08 CEST 2008
On May 17, 2008, at 7:14 AM, Scott Gravenhorst wrote:
> I am trying to understand how to deal with signals and sample rates.
>
> For example, when a limit is given, such as for a digital state
> variable filter being 1/6 of the sample rate, higher frequencies
> causing instability, I think that this means a sine wave at 1/6 the
> sample rate. But most of our synth signals are not sinewaves and
> thus can have frequency components much higher than the fundamental.
>
> How does one deal with the transients in sawtooth or rectangular
> waves?
>
> Is it "OK" to use such a filter because the energy in the highest
> harmonics tends to be diminished?
>
> I like the sound I get out of a digital SVF, but that's in a synth
> with a sample rate of 1 MHz. Seems to be enough headroom there.
> However, I'm working on a synth that currently has a sample rate of
> 125KHz. That sets the limit much lower at 20.833 KHz. Is that my
> magic number (being just above what most of us can hear) ? I.e., is
> 125 KHz too low?
>
> What sorts of things will I need to look for to judge the quality of
> my SVF at that sample rate?
The first thing you need to ask is "what is the effect of violating
the 1/6 spec on the SVF?"
With most DSP the foremost issue is to avoid aliasing caused by
violating the Nyquist criterion. That means you don't do anything that
would generate frequency content beyond Fs/2. The consequence of
violating Nyquist is that the signals beyond Fs/2 will fold back into
the lower frequency range and more often than not will be
anharmonically related to the signal you actually want to hear,
resulting in noise and distortion.
Square, saw and triangle waves all have the potential to violate
Nyquist - they are essentially infinite series of summed sinusoids
with harmonic content that extends far beyond human hearing range.
Using very high sample rates can mitigate aliasing when these
waveforms are generated naively (using simple math that models the
instantaneous voltage changes found in ideal waveforms). This works
primarily because the ratio of sample rate to fundamental frequency is
so high that the aliases which are created are at such a low level
that they are not bothersome. But don't be fooled - they are still
there!
So, getting back to the question at hand, what happens when you drive
a signal beyond Fs/6 into your SVF model? The only real way to tell
is to do a full sweep of frequency (0 - Fs/2) and analyze the results.
Chances are it will fall into one of the following categories:
1) The filter's outputs (HP, LP, BP, Notch) fail to perform as
desired. Mainly this means that as frequency increases, the LP and BP
states begin to exhibit less attenuation than at lower frequencies.
2) The filter becomes unstable. Perhaps stimulating the SVF with
inputs beyond Fs/6 excites some undesirable behavior resulting in
chaotic outputs.
3) Perhaps the Fs/6 limit applies not to the input frequency but to
the corner frequency setting. It could be that you shouldn't attempt
to configure a corner frequency > Fs/6, but input frequencies > Fs/6
are OK and the filter action is still sane beyond that limit.
As you can see, there are a lot of potential answers to what happens -
probably even more than listed above. If the answer turns out to be
something like 1) or 2), then your only solution is to avoid
generating any frequency content > Fs/6. You can either do this with
band-limited waveform generation techniques, or by applying some sort
of pre-filtering. If the answer is like 3) then the solution is simply
to avoid setting the corner frequency too high.
For your present project with Fs = 125kHz, the 1/6 limit is not much
of a constraint, especially considering that most musical content will
be confined to fundamentals less than 8kHz or so. If your filter has
problems 1) or 3) then you should be OK with this. If your filter's
problem is 2) (chaotic behavior with inputs > Fs/6) then you'll need
some more signal processing to protect it though.
You will find that with such a low Fs that naively generating
waveforms with sharp transitions will result in noticeable aliasing in
the higher registers. Beyond about 2kHz or so your square and sawtooth
waves will begin to sound a little dirtier, and beyond 6kHz you can
really hear those little birdies chirping in the background when you
sweep the frequency around.
Eric
More information about the Fpga-synth
mailing list