Audio Resampling
Resampling changes the number of audio sample positions per second while preserving the intended timeline.
A music track contains 44,100 sample frames for one second, but the output device consumes 48,000 per second. Sending the old frames faster would shorten the second. Resampling instead computes the signal at 48,000 new time positions, keeping its intended duration and pitch.
That makes sample-rate conversion a signal-processing problem, not a header edit.
Separate time from the array index
For input sample index n at 44.1 kHz, time is n/44,100 seconds. Output index m at 48 kHz refers to m/48,000 seconds. The desired output is the value of the same signal at that new time.
| Treatment of one second of 44.1 kHz input | Output sample frames | Playback duration |
|---|---|---|
| Retain 44.1 kHz | 44,100 | 1 second |
| Convert correctly to 48 kHz | 48,000 | 1 second |
| Relabel existing frames as 48 kHz | 44,100 | 0.91875 seconds |
Relabeling also multiplies every frequency by 48,000/44,100, approximately 1.0884. A 1 kHz tone becomes about 1,088.4 Hz. A correct converter supplies more values for the same original 1 kHz tone.
Work out a new value between two old ones
Consider a simpler rate doubling: the existing figure on the sampling page represents a 1 kHz sine sampled at 8 kHz. Its first two values are:
- At 0 ms: 0.
- At 0.125 ms: approximately +0.7071.
A 16 kHz output needs another sample at 0.0625 ms. Because we know the example's exact sine, its correct amplitude is sin(π/8), approximately +0.3827.
Simply averaging the neighbors gives (0 + 0.7071)/2 = +0.3536. That is an interpolation, but it does not give the correct sine value. The error becomes more consequential for frequencies closer to the sampling limit.
A high-quality resampler uses a suitable interpolation filter and a neighborhood of input samples. The values before and after the desired time jointly inform the result. Ideal bandlimited reconstruction uses sinc-shaped contributions from the whole sequence; practical filters approximate that operation using a finite number of samples.
The converter does not discover new information in the recording. It evaluates the available, bandlimited signal on another grid. Upsampling to 96 kHz can be useful for a processing or hardware stage without extending the original recording's captured frequency range.
Rate reduction needs a narrower signal first
Downsampling must satisfy the new sampling condition. Suppose 48 kHz input includes a 23 kHz component and is converted to 44.1 kHz output. The new Nyquist boundary is 22.05 kHz. Retaining that component while sampling at the lower rate can turn it into an alias at 44.1 − 23 = 21.1 kHz.
A low-pass filter attenuates such content before the reduced grid is taken. This preserves the wanted lower-frequency band and prevents unsuitable input frequencies from masquerading as different output frequencies.
Real filters need a transition region between a passband that they preserve and a stopband that they attenuate. The engineering tradeoff includes how close the passband approaches the limit, residual unwanted energy, computational work, and transient behavior. “Keeps every frequency right up to Nyquist” is not an adequate practical filter description.
Increasing the rate also needs filtering to avoid spectral images of the original sampled signal. In both directions, interpolation and filtering are parts of one conversion, rather than optional cleanup afterward.
How a converter implements a fractional ratio
48,000/44,100 simplifies to 160/147. A conceptual rational-rate converter can increase the internal grid by 160, filter, and keep every 147th position. This produces the correct relationship between input and output counts.
Inserting zeros during the conceptual increase is a way to prepare a sequence for filtering; those zeros are not supposed to become silent samples in the finished signal. Filtering fills in the values appropriate to the new time positions.
A practical polyphase implementation reorganizes the filter into phases so it computes the samples it actually needs. It does not have to construct an enormous intermediate array. That implementation detail explains how an apparently complicated fractional conversion can run efficiently during playback.
Account for filter delay and boundaries
A filter that uses neighboring samples needs stored input and may require future samples before it can produce the intended output. This creates latency. For illustration, a symmetric 64-tap linear-phase FIR filter has a group delay of (64−1)/2 = 31.5 sample intervals. At a 48 kHz filter rate that is about 0.656 ms. A complete resampler's buffering and boundary handling can add further delay.
At the start and end of a finite file, the implementation must handle missing neighbors and flush delayed results. Correct timestamps and output length keep this implementation delay from becoming a missing ending or a permanent audio/video offset.
A low-latency filter and one optimized for stronger rejection can therefore differ in more than CPU use. Their choices affect delay and transients as well as frequency response.
Pitch, aliasing, and delay during playback
For an Emby session that changes 44.1 kHz input to 48 kHz output, inspect the stages that require that change: server encoding, the player's decoder/output, or an operating-system mixer. An output fixed at 48 kHz naturally needs a conversion for a 44.1 kHz source.
Then distinguish three observed problems:
| Observation | Relevant part of the conversion |
|---|---|
| Pitch and duration both change | Samples may have been interpreted at a different rate instead of resampled |
| An unwanted high-frequency tone appears | Anti-alias filtering and rate interpretation deserve investigation |
| The sound is aligned differently from picture | Filter/buffer delay and timestamp handling are relevant |
Reducing integer precision during the same operation introduces quantization too. Dither addresses that amplitude-grid conversion; it is a separate operation from calculating the new time grid.