• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

Convolution & sample rate

daftcombo

Major Contributor
Forum Donor
Joined
Feb 5, 2019
Messages
3,687
Likes
4,068
Hi,

I have mostly 44.1kHz/16bit music files (MP3 & FLAC).

Is it better to run convolution with a 44.1 kHz impulse, or to upsample the files at 88.2 kHz and run convolution at 88.2 kHz?
And in the last case, is it better (for example to avoid IMD products) to downsample back to 44.1 kHz?

Cheers.
 
OP
daftcombo

daftcombo

Major Contributor
Forum Donor
Joined
Feb 5, 2019
Messages
3,687
Likes
4,068
Additional question: how transparent are Resampler (SoX) in Foobar? the resampler in JRiver?
 
OP
daftcombo

daftcombo

Major Contributor
Forum Donor
Joined
Feb 5, 2019
Messages
3,687
Likes
4,068
You can prepare several DSP presets ( 44, 88,176) and test passing between them. DSP switcher for Foobar.
https://cdpos.biz/showthread.php?1034-DSP-Switcher-(Переключатель-DSP)

Yes, I couldn't just prepare several configurations and listen. But experience taught me that differences sometimes are difficult to spot in a short time, and I would like some help, at least to tell me what to focus on: treble, bass, soundstage...
It is easier when a problem is already spotted (like harshness) and you try several solutions to see if there's an improvement.
If somebody hints me, I'll take an ABX to check.
 

Jim777

Active Member
Forum Donor
Joined
May 28, 2019
Messages
124
Likes
203
Location
Greater Boston
I'd run it without resampling. Few reasons, the 88.2k impulse is kind of just a resampled filter (it will be the same length in time, or twice as long in sample length). Also, not that it matters, but this filter is probably only doing stuff to lower frequencies. And finally, if well done, both should sound identical so why do extra processing if you have IR's for your source material's sample rate?
I even suspect that some room correction systems downsamples, processes that (less complex), then upsamples and adds back the high frequencies of the input with the appropriate delay. There is just no reason to process at a higher rate.
 

Jose Hidalgo

Addicted to Fun and Learning
Joined
Aug 15, 2020
Messages
961
Likes
1,032
Location
France
Hi guys, sorry to chime in, but you seem quite proficient in convolution and I'm still learning to use it. :)

Currently I'm using a basic impulse (wav 32-bit float @44.1 KHz) consisting of 4096 samples : all zeroes, and sample #2048 is the impulse.
Then I apply a PEQ to the impulse, I save the corresponding impulse response (wav 32-bit float @ 44.1 KHz), and I feed foobar2000's convolver with it. It works, but I have a couple questions :
  1. I'm using a 4096-sample basic impulse because somebody told me that it would be "enough". But I'd like to understand. How do we calculate the basic impulse length? Is it related to the sample rate? (what if I needed to create another basic impulse for 48 KHz, or even for 192 KHz ?).

  2. Generally speaking, applying a PEQ requires that we reduce the global gain to avoid clipping. But since we're talking about an impulse here, do I still need to reduce the global gain when applying the PEQ ? For example here's how the 44.1 KHz pulse looks after a PEQ with a global gain of -5.5 dB. Do you see my point ?

2020-09-18_000800.png
 

NTK

Major Contributor
Forum Donor
Joined
Aug 11, 2019
Messages
2,660
Likes
5,820
Location
US East
Hi guys, sorry to chime in, but you seem quite proficient in convolution and I'm still learning to use it. :)

Currently I'm using a basic impulse (wav 32-bit float @44.1 KHz) consisting of 4096 samples : all zeroes, and sample #2048 is the impulse.
Then I apply a PEQ to the impulse, I save the corresponding impulse response (wav 32-bit float @ 44.1 KHz), and I feed foobar2000's convolver with it. It works, but I have a couple questions :
  1. I'm using a 4096-sample basic impulse because somebody told me that it would be "enough". But I'd like to understand. How do we calculate the basic impulse length? Is it related to the sample rate? (what if I needed to create another basic impulse for 48 KHz, or even for 192 KHz ?).

  2. Generally speaking, applying a PEQ requires that we reduce the global gain to avoid clipping. But since we're talking about an impulse here, do I still need to reduce the global gain when applying the PEQ ? For example here's how the 44.1 KHz pulse looks after a PEQ with a global gain of -5.5 dB. Do you see my point ?
  1. The leading and trailing zeros in the impulse response do nothing. You can safely truncate them to shorten the length of the impulse response to reduce the number of taps required in your FIR filter.

    The required length of the impulse depends on how quickly/slowly the impulse response decays to zero (or close enough to zero). For non-causal filters, you also need to include the "pre-ringings". To correct for phase at low frequencies, because of the periods of the full oscillations are long, the filter impulse response will be very long, and will therefore require a lot of samples/taps.

  2. It is no different than ordinary PEQ (implemented using IIR filters). If the filter calls for a boost at a certain frequency to correct for a dip, then you can run into the possibility of digital clipping when your source signal contains contents close to full scale at that frequency.

    It is difficult to tell the frequency response of the filter (to see if there is any and where the boosts are) from its impulse response. Even a simple FR curve may not tell the full story. By shifting phase, you can easily increase the crest factor of the signal. So some amount of global gain reduction is often a good idea
 

johnvictor

New Member
Joined
Sep 8, 2020
Messages
2
Likes
2
Mostly true. There are audible (albeit subtle) differences in sample rate conversion of impulses, so if you use impulses at a different sample rate to your session, sometimes they will sound slightly darker (which is not necessarily a bad thing). There are also differences in the way you can manipulate the impulses, but functionally they are all quite similar, but an easy to use interface that allows you to audition impulses quickly is probably more important than the other differences. For instance, Waves IR is flexible in terms of impulse manipulation, but clunky to audition different impulses quickly (it also was quite easy to clip. I don't know if they fixed that in newer versions).
 

Jose Hidalgo

Addicted to Fun and Learning
Joined
Aug 15, 2020
Messages
961
Likes
1,032
Location
France
Thanks guys, I'm starting to understand.

I'm currently creating impulse responses for the purpose of EQing my headphones. So once a given headphone is connected, I just have to load the appropriate impulse response into foobar's Convolver. To create an impulse response, I'm currently using Audacity with the nice QRange PEQ VST (linear phase, up to 12 bands) and Oratory presets. I enter a given preset into the PEQ, I apply it once to the basic impulse, and then I save the impulse response. Seems to work pretty well.

I understand that the leading and trailing part only matter on the impulse response. However, I still don't know what number would be "enough" without being "too much", and what parameters may affect that number. Is it the PEQ presets ? (some of them are pretty complicated with 10 bands, some very close to 20 Hz). Is it the sampling frequency ? Plus besides, sometimes the oscillations in the impulse response are so tiny that I can't see them with the naked eye.

Maybe there is a better way of generating those impulse responses and saving them in wav32 format?
 

NTK

Major Contributor
Forum Donor
Joined
Aug 11, 2019
Messages
2,660
Likes
5,820
Location
US East
Thanks guys, I'm starting to understand.

I'm currently creating impulse responses for the purpose of EQing my headphones. So once a given headphone is connected, I just have to load the appropriate impulse response into foobar's Convolver. To create an impulse response, I'm currently using Audacity with the nice QRange PEQ VST (linear phase, up to 12 bands) and Oratory presets. I enter a given preset into the PEQ, I apply it once to the basic impulse, and then I save the impulse response. Seems to work pretty well.

I understand that the leading and trailing part only matter on the impulse response. However, I still don't know what number would be "enough" without being "too much", and what parameters may affect that number. Is it the PEQ presets ? (some of them are pretty complicated with 10 bands, some very close to 20 Hz). Is it the sampling frequency ? Plus besides, sometimes the oscillations in the impulse response are so tiny that I can't see them with the naked eye.

Maybe there is a better way of generating those impulse responses and saving them in wav32 format?
I think it is much easier to judge the filter impulse response length using the spectrogram view.

Filt.JPG


The length of the filter impulse response (which I think equals to the filter order + 1 sample for FIR filters) is determined by the filter parameters. Below is the Kaiser's formula for estimating filter order I found in Stack Exchange DSP for a low-pass filter.
https://dsp.stackexchange.com/questions/37646/filter-order-rule-of-thumb

jjQn3.png


Ideally, the program generating the filter can also generate the impulse response and/or provide the filter coefficients to generate the impulse response, so we won't have leading and trailing zeros in the impulse response.
 

Jose Hidalgo

Addicted to Fun and Learning
Joined
Aug 15, 2020
Messages
961
Likes
1,032
Location
France
The spectrogram view! That's exactly what I was looking for! It allows me to really see the "non-null" extent of the impulse response (which was much bigger than I suspected for one of my headphones : nearly 85% of all the 4096 samples :oops:). Thank you! :D

As for the leading/trailing zeros in the impulse response, maybe I'm being naive, but I guess the convolver should be able to take care of them: analyze the impulse response once, discard all the leading/trailing zeros. Should be easy.
 

NTK

Major Contributor
Forum Donor
Joined
Aug 11, 2019
Messages
2,660
Likes
5,820
Location
US East
...
As for the leading/trailing zeros in the impulse response, maybe I'm being naive, but I guess the convolver should be able to take care of them: analyze the impulse response once, discard all the leading/trailing zeros. Should be easy.
Don't know how smart the algorithm is. But FFT convolutions are fast on modern computers. Shouldn't be a problem.

Note that FFT lengths in powers of 2 can often be faster than shorter ones (depending on how divisible the number of samples is).
 

Jose Hidalgo

Addicted to Fun and Learning
Joined
Aug 15, 2020
Messages
961
Likes
1,032
Location
France
Great! Plus I'll be changing my 10-y.o. audio PC in a few months anyway for a brand new Zen3 based one, so I'll be able to throw just about anything at it without issues.

I'll just check with the spectrogram view if 4096 is enough for all my cans, and if not I'll just try 8192. Problem solved I guess. :)
 
Last edited:
  • Like
Reactions: NTK
Top Bottom