Skip to content

harmonic distortion when using 7th order interpolation #1483

Open
@mrbumpy409

Description

FluidSynth version

2.4.3

Describe the bug

FluidSynth allows changing the sample interpolation method to balance sound quality vs. CPU usage. This is usually done via FluidSynth's console, using the interp x command, where "x" is one of the following options:

x Type Description
0 None No interpolation: Fastest, but questionable audio quality.
1 Linear Straight-line interpolation: A bit slower, reasonable audio quality.
4 4th Order Fourth-order interpolation, good quality, the default.
7 7th Order Seventh-order interpolation.

In theory, 7th order interpolation should provide the best quality of these options. However, while FluidSynth's 7th order interpolation does provide cleaner interpolation of high frequency content, it also can introduce significant harmonic distortion. This is really noticeable on samples of low-pitched instruments such as electric bass. In these cases, 4th order interpolation provides a superior audio quality.

Steps to reproduce

  1. Download and extract sample interpolation test.zip.
  2. Load the SoundFont into bank 0 or 1 and play the MIDI file using FluidSynth's different interpolation settings. The MIDI file will play four different tests.

Included in the zip file are audio files of the test using FluidSynth's linear, 4th order, and 7th order resampling methods, as well as BASSMIDI set to linear and sinc interpolation (rendered at 48 KHz using FluidSynth Plugin and BassMidi VSTi). These files are time and volume matched so you can easily compare them in an audio editor. I recommend using Audacity with the waveform view set to "spectrogram".

Test 1: Sine Wave Sweep

The first test plays a descending sine wave sweep across most of the audible frequency range. With the ideal interpolation and sample, you should only see a singular, prominant frequency sweeping down. Here is a spectrogram view comparing BASSMIDI and FluidSynth's interpolation methods (the synthesizer and interpolation method are written at the top of each clip):
Image

The linear interpolation renderings look (and sound) almost identical between BASSMIDI and FluidSynth, with FluidSynth being a slight bit noisier. Both feature significant harmonic distortion that can be seen oscillating up and down in an arch-like pattern.

Comparing the next higher quality interpolation (BASSMIDI's "sinc" and FluidSynth's "4th order"), you can see the harmonic distortion is now barely audible, with BASSMIDI's algorithm once again being a bit cleaner.

Now observe FluidSynth's 7th order interpolation, which has the same harmonic distortion as the linear interpolation examples. This should not be happening with what is supposed to be a superior interpolation method.

Test 2: FM Electric Piano

The second test plays high samples of an FM electric piano moving up and down chromatically. With the ideal interpolation, all frequencies of the note should move together up and down with the notes. Here it is in the spectrogram view:
Image

Of these renderings, only BASSMIDI's sinc interpolation is perfectly clean. All of the other renderings feature varying levels of harmonic distortion. Here, FluidSynth's 7th order interpolation is notably cleaner-sounding than 4th order or linear, but is no match for BASSMIDI's sinc interpolation.

Test 3: Electric Bass

The third test plays an ascending scale of electric bass notes. Here is the spectrogram view:
Image

Here, something strange occurs. Both synthesizers' linear, sinc and 4th order examples sound pretty much the same and are free of artifacts. However, FluidSynth's 7th-order interpolation is creating clear high-frequency distortions which can be seen as horizontal lines sustained through most of the bass notes. These distortions create an audible whine in the sound that is not present using any of the other interpolation methods.

Test 4: Low Quality Timpani Sample

This test attempts to see how an interpolation method handles low-bitrate samples. Low quality interpolation methods will result in audible high-frequency aliasing noise. Here is the spectogram:
Image

Both linear results show the high frequency aliasing noise quite clearly, and this can be heard as a grainy, ringing sound. FluidSynth's 4th order interpolation cuts down on this noise quite a bit, but does not completely eliminate it. BASSMIDI's sinc interpolation completely eliminates the aliasing noise. FluidSynth's 7th-order interpolation seems to have cleaned up most of the aliasing noise, but once again features the same type of high frequency "whine" distortion we saw in the electric bass example.

Expected behavior

A high quality sample interpolation should not be producing these harmonic distortions. Unfortunately, this means that FluidSynth is not currently capable of truly high quality sample playback—at least in terms of what is expected out of a sampler used in professional music production. In many examples, the 7th order resampler sounds worse than 4th order and in some cases even worse than linear.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions