Skip to main content

High-Pass Filter

What is a high-pass filter?​

A high-pass filter (HPF, also called a low-cut filter or bass-cut filter) is a filter that lets frequencies above a chosen cutoff frequency pass and weakens those below it. In practice it removes slow changes, such as a DC offset, drift or rumble, and keeps the faster detail.

A drifting ECG-like trace in orange and the same trace after a high-pass filter in blue, flat on zero, with a frequency response plot below it, in a dark navy theme

An ECG-like signal with baseline drift (orange) and after a 0.5 Hz high-pass filter (blue), with the filter's frequency response below (sample data). Try the interactive version.

Key takeaways
  • A high-pass filter keeps fast changes and removes slow ones: offsets, drift, baseline wander, rumble and hum below the cutoff.
  • The cutoff frequency is usually where the output is 3 dB down (half the power, about 71% of the amplitude). Below it the gain rolls off at 20 dB per decade for each order of the filter.
  • An RC high-pass filter has a cutoff of fc=1/(2πRC)f_c = 1/(2\pi RC).
  • In code, use a first-order IIR (a DC blocker) for speed, or a windowed-sinc FIR for a sharp cutoff with no phase distortion.
  • Set the cutoff just below the lowest frequency you need. Too high, and the filter removes part of the signal and adds ringing.

Anything steady or slowly wandering counts as low frequency, so the filter pulls it to zero. Anything that changes fast, such as a voice, a vibration or the sharp peak of a heartbeat, passes through.

Common uses:

FieldWhat the high-pass filter removesTypical cutoff
Audio recording and mixingMicrophone handling noise, rumble from floors, traffic and air conditioning, wind and breath popsOften 75 to 100 Hz on vocals
LoudspeakersBass that would damage a tweeter (one half of a crossover)A few kHz
ECG and other biosignalsBaseline wander from breathing and electrode movement0.05 Hz for diagnosis, up to 0.67 Hz with zero-phase filters
Sensors and measurementTemperature drift, a DC offset, or gravity in an accelerometer when you want only the motionWell under 1 Hz
ElectronicsDC bias between amplifier stages (a coupling capacitor is a high-pass filter)Below the lowest signal frequency
ImagesSmooth areas, keeping edges and fine texture (the basis of sharpening and edge detection)Set by the kernel size

The image case works on space rather than time: a high-pass filter applied across the pixels keeps sharp changes in brightness, which are the edges. Photo editors' "high pass" sharpening is the same idea.

How a high-pass filter works​

A high-pass filter is described by its frequency response: how much it scales each frequency, usually shown as a Bode plot of gain in decibels (dB) against frequency on a log scale.

On the left, a first-order RC high-pass circuit: a capacitor C in series from input to output and a resistor R from output to ground, with fc = 1 / (2 pi R C). On the right, its frequency response: the gain rises at 20 dB per decade up to the cutoff, is 3 dB down at the cutoff, and is flat at 0 dB above it

Three properties describe it:

  • Cutoff frequency (fcf_c). The boundary between the frequencies the filter blocks (the stopband) and those it passes (the passband). For most analogue and IIR filters it's the −3 dB point, where the output power is half the input power and the amplitude is 1/21/\sqrt{2}, about 71%. Windowed-sinc FIR filters are usually specified at the −6 dB point (half amplitude) instead.
  • Roll-off. How fast the gain falls below the cutoff. A first-order filter falls by 20 dB per decade (6 dB per octave): every tenfold drop in frequency cuts the amplitude tenfold.
  • Order. Each extra order adds another 20 dB per decade. A second-order filter falls at 40 dB per decade, a fourth-order at 80. Higher orders give a sharper boundary, at the cost of more components or computation and more ringing.
OrderRoll-off below the cutoffGain one decade below the cutoff (ideal)Built with
1st20 dB per decade−20 dB (10% amplitude)One capacitor and one resistor
2nd40 dB per decade−40 dB (1%)RLC circuit, or an op-amp stage such as Sallen–Key
4th80 dB per decade−80 dB (0.01%)Two second-order stages in a row

High-pass filter transfer function​

For a first-order high-pass filter with cutoff angular frequency ωc=2πfc=1/RC\omega_c = 2\pi f_c = 1/RC:

H(s)=ss+ωc,∣H(f)∣=f/fc1+(f/fc)2H(s) = \frac{s}{s + \omega_c}, \qquad |H(f)| = \frac{f/f_c}{\sqrt{1 + (f/f_c)^2}}

At f=fcf = f_c the gain is 1/21/\sqrt{2} (−3 dB). Far below the cutoff, ∣H∣≈f/fc|H| \approx f/f_c, which is the 20 dB per decade slope. Far above it, ∣H∣≈1|H| \approx 1.

A high-pass filter also shifts the phase (timing) of each frequency. A first-order filter moves the phase forward by 90∘−arctan⁡(f/fc)90^\circ - \arctan(f/f_c): nearly 90° far below the cutoff, 45° at the cutoff, and close to zero far above it. That shift changes the shape of a waveform even where its amplitude passes almost untouched (see common mistakes).

RC high-pass filter circuit​

The simplest passive high-pass filter is a capacitor in series with the signal and a resistor to ground, as in the diagram above. A capacitor blocks a steady voltage completely but lets a changing one through, more easily the faster it changes (its impedance is 1/(2πfC)1/(2\pi f C)). So the faster the input changes, the more of it reaches the resistor and the output.

fc=12πRCf_c = \frac{1}{2\pi RC}

The product RCRC is the time constant τ\tau, in seconds. After a sudden step at the input, the output jumps with it, then decays back to zero, falling to about 37% after one time constant.

Worked example: an 80 Hz high-pass filter for a voice microphone​

You want to remove rumble below about 80 Hz, and you have a 100 nF capacitor.

  1. Rearrange the formula for R: R=1/(2πfcC)=1/(2π×80×100×10−9)≈19,900 ΩR = 1/(2\pi f_c C) = 1/(2\pi \times 80 \times 100 \times 10^{-9}) \approx 19{,}900\ \Omega.
  2. The nearest standard value is 20 kΩ, which gives fc=1/(2π×20,000×100×10−9)≈79.6f_c = 1/(2\pi \times 20{,}000 \times 100 \times 10^{-9}) \approx 79.6 Hz.
  3. The time constant is τ=RC=2\tau = RC = 2 ms.

How much of each frequency gets through:

FrequencyRatio f/fcf/f_cGainAmplitude passedPhase lead
8 Hz (rumble)0.1−20.0 dB10%84°
20 Hz0.25−12.3 dB24%76°
40 Hz0.5−7.0 dB45%63°
80 Hz (cutoff)1−3.0 dB71%45°
160 Hz2−1.0 dB89%26°
1,000 Hz (voice)12.6−0.03 dB99.7%4.5°

40 Hz still gets through at 45%. For a sharper cut, use a higher-order filter.

Active, RL and higher-order high-pass filters​

  • Active high-pass filter. Adds an op-amp to the RC network, so the filter can have gain, drive a load without changing its cutoff, and be cascaded. The Sallen–Key circuit is a common second-order active design, and choosing its components for a Butterworth response gives the flattest possible passband.
  • RL high-pass filter. A resistor in series and an inductor to ground, with fc=R/(2πL)f_c = R/(2\pi L). Inductors are bulky at low frequencies, so RL and LC high-pass filters appear mainly in radio-frequency circuits and loudspeaker crossovers.
  • Second-order RLC or LC high-pass filter. Combines a capacitor and an inductor for 40 dB per decade. Near the cutoff, its response can peak, depending on the damping.

Digital high-pass filters​

In software, a filter is a rule for computing each output sample from input samples. There are three common ways to build a digital high-pass filter (for how FIR and IIR designs compare in general, see FIR vs IIR filters). The live demo below runs the first-order IIR and the windowed-sinc FIR, and its code includes both.

First-order IIR high-pass filter (DC blocker)​

This is the digital version of the RC circuit. Each output depends on the previous output, which makes it an infinite impulse response (IIR) filter:

y[n]=α (y[n−1]+x[n]−x[n−1]),α=RCRC+Δt,RC=12πfcy[n] = \alpha\,\big(y[n-1] + x[n] - x[n-1]\big), \qquad \alpha = \frac{RC}{RC + \Delta t}, \quad RC = \frac{1}{2\pi f_c}

where Δt\Delta t is the time between samples. Written this way, it takes one multiplication per sample and almost no memory, so it runs on any microcontroller and in real time. With α\alpha close to 1, it's the classic DC blocker used in audio code. Its trade-offs are the gentle 20 dB per decade roll-off and the phase shift near the cutoff. Its cutoff is accurate when fcf_c is well below the sample rate.

Subtracting a low-pass filter from the original​

Whatever a low-pass filter keeps, the original signal minus it is the rest: high-pass=x−low-pass(x)\text{high-pass} = x - \text{low-pass}(x). Subtracting a moving average is the simplest example, and a quick way to remove drift from a sensor log. It works exactly when the low-pass filter doesn't delay the signal; otherwise, line the two up first.

Windowed-sinc FIR high-pass filter (spectral inversion)​

A finite impulse response (FIR) filter is a list of weights, its kernel, that you slide along the signal with convolution. To make a high-pass kernel:

  1. Design a low-pass kernel: a sinc function, sin⁡(2πfck)/(πk)\sin(2\pi f_c k)/(\pi k), shaped by a window such as Blackman.
  2. Scale it so its taps add up to 1 (a gain of 1 at 0 Hz).
  3. Spectral inversion: negate every tap, then add 1 to the centre tap. The new kernel is "an impulse minus the low-pass", which is the subtraction method written as one kernel.

A symmetric FIR kernel has linear phase: every frequency is delayed by the same amount, so waveform shapes are kept. Applied centred on each sample, offline, it has no delay at all. The cost is length: the transition from stopband to passband is roughly 4/N4/N of the sample rate wide for a Blackman window of NN taps, so a sharp cutoff at a very low frequency needs a very long kernel. For speed on long kernels, do the convolution with an FFT.

MethodRoll-offPhaseCost per sampleGood for
First-order IIR (DC blocker)20 dB per decadeShifts near the cutoff1 multiplicationReal time, removing DC and slow drift
Original minus low-passDepends on the low-passZero if the low-pass has no delayThat of the low-passQuick drift removal, sensor logs
Windowed-sinc FIRSharp, set by the kernel lengthLinear (zero when centred)One multiplication per tapPrecise cutoffs, keeping waveform shape
Higher-order IIR (e.g. Butterworth)20 dB per decade per orderShifts more with each orderA few multiplications per stageSharp cutoffs on a small budget

To check any of these, look at its frequency response, or take the FFT of the signal before and after: the energy below the cutoff should be gone.

High-pass vs low-pass vs band-pass vs band-stop filters​

The four basic filter types differ only in which frequencies they keep:

FilterKeepsRemovesUse it when you want to…Example
High-passAbove the cutoffBelow the cutoffRemove offset, drift, rumble or slow trendsECG baseline wander, vocal low cut
Low-passBelow the cutoffAbove the cutoffSmooth out fast noise, or stop aliasing before samplingSensor smoothing, anti-aliasing
Band-passBetween two cutoffsBelow and above the bandKeep one range of frequenciesA radio channel, or one band of a vibration signal
Band-stop (notch)Below and above the bandBetween two cutoffsRemove one narrow interference50 or 60 Hz mains hum

A band-pass filter is a high-pass and a low-pass in a row. A band-stop filter is the original minus a band-pass. A high-shelf or low-shelf EQ turns the frequencies above or below a set point up or down by a fixed amount instead of removing them.

Common high-pass filter mistakes​

A high-pass filter goes wrong most often through a cutoff set too high, or through side effects that look like real features.

  • Setting the cutoff too high. The filter removes part of the signal you need. On an ECG, a cutoff of a few hertz flattens and distorts the slow ST segment and T wave; on a voice, it thins out the sound. Set the cutoff just below the lowest frequency you care about.
  • Ignoring phase shift. An IIR high-pass filter shifts frequencies near the cutoff by different amounts, so pulses and slow waves change shape even when their size is kept. ECG recommendations therefore allow a higher cutoff only for zero-phase (linear-phase) digital filters. Use a centred FIR filter, or run an IIR filter forwards then backwards, when shape matters.
  • Mistaking ringing and undershoot for real events. A high-pass filter turns a step into a spike that decays, and a sharp filter adds ripples (ringing) on either side of fast edges. A flat-topped pulse sags, then dips below zero after it ends.
  • Ignoring start-up and edge transients. If the signal starts far from zero, an IIR filter's output jumps at the start and takes several time constants to settle, and an FIR filter needs data beyond the ends. Start the filter from the first sample's value, or extend the ends, and discard the settling period.
  • Using a short FIR kernel for a very low cutoff. A kernel that is short compared with one period of the cutoff can't separate frequencies that close to zero. Use a longer kernel, an IIR filter, or downsample first.
  • Choosing the cutoff without knowing the sample rate. Digital cutoffs are relative to the sample rate. The same coefficients give a different cutoff at a different rate, and the cutoff must be well below half the sample rate (the Nyquist frequency).
  • Filtering unevenly spaced data as if it were even. These formulas assume a fixed time between samples. Resample first, or use Δt\Delta t for each step in the IIR filter.

How to apply a high-pass filter in JavaScript, React or Angular​

Each time you move a control, the demo filters 8 seconds of signal at 250 samples per second (2,000 samples) with either a one-line IIR filter or a 1,001-tap FIR kernel, and redraws both charts. In the demo below, the orange line is an ECG-like signal with baseline drift, and the blue line is the high-pass filtered copy; the bottom chart is the filter's frequency response, with the cutoff marked. Move the cutoff slider, or switch between the first-order IIR and the windowed-sinc FIR filter. Try a cutoff above 2 Hz to see the filter start to distort the beats. Hover to compare the two lines at any moment; scroll, drag and double-click to zoom, pan and reset.

Here is the code for this chart. The filter design helpers are plain JavaScript, and SciChart.js applies the filter to the chart's data with an XyCustomFilter.

// Remove drift with a high-pass filter, and chart the result with SciChart.js
const {
SciChartSurface,
NumericAxis,
LogarithmicAxis,
NumberRange,
EAutoRange,
ENumericFormat,
FastLineRenderableSeries,
XyDataSeries,
XyCustomFilter,
VerticalLineAnnotation,
HorizontalLineAnnotation,
ELabelPlacement,
SciChartJsNavyTheme,
CursorModifier,
LegendModifier,
MouseWheelZoomModifier,
ZoomPanModifier,
ZoomExtentsModifier
} = SciChart;
// or, for npm, import { SciChartSurface, ... } from "scichart"

// --- High-pass filter helpers (plain JavaScript, no library needed) ---

// First-order IIR high-pass: the digital version of an RC circuit, often called a DC blocker.
// y[n] = alpha * (y[n-1] + x[n] - x[n-1]), with alpha = RC / (RC + dt) and RC = 1 / (2 * pi * cutoff).
function firstOrderAlpha(cutoffHz, sampleRate) {
const rc = 1 / (2 * Math.PI * cutoffHz);
return rc / (rc + 1 / sampleRate);
}

// Windowed-sinc FIR high-pass: design a low-pass kernel (a sinc shaped by a Blackman window), scale it to a
// gain of 1 at 0 Hz, then use spectral inversion: negate every tap and add 1 to the centre tap. The result
// passes what the low-pass would remove. Its cutoff is where the gain is 0.5 (-6 dB).
function designHighPassFir(cutoffHz, sampleRate, numTaps) {
const fc = cutoffHz / sampleRate; // cutoff as a fraction of the sample rate
const M = numTaps - 1;
const h = [];
let sum = 0;
for (let i = 0; i <= M; i++) {
const k = i - M / 2;
const sinc = k === 0 ? 2 * Math.PI * fc : Math.sin(2 * Math.PI * fc * k) / k;
const blackman = 0.42 - 0.5 * Math.cos((2 * Math.PI * i) / M) + 0.08 * Math.cos((4 * Math.PI * i) / M);
h.push(sinc * blackman);
sum += sinc * blackman;
}
for (let i = 0; i <= M; i++) h[i] = -h[i] / sum; // normalise the low-pass, and negate it
h[M / 2] += 1; // ...then add an impulse: high-pass = original - low-pass
return h;
}

// Gain in decibels of a filter with coefficients b and a at frequency f:
// |H| = |sum(b[k] e^(-jwk))| / |sum(a[k] e^(-jwk))|, with w = 2 * pi * f / sampleRate.
function gainDb(b, a, f, sampleRate) {
const w = (2 * Math.PI * f) / sampleRate;
const sumAt = (c) => {
let re = 0;
let im = 0;
c.forEach((value, k) => {
re += value * Math.cos(w * k);
im -= value * Math.sin(w * k);
});
return re * re + im * im;
};
return 10 * Math.log10(Math.max(sumAt(b) / sumAt(a), 1e-12));
}

// --- Chart 1: the raw signal and the high-passed signal over time ---
const time = await SciChartSurface.create(timeDiv, { theme: new SciChartJsNavyTheme() });
time.sciChartSurface.xAxes.add(new NumericAxis(time.wasmContext, { axisTitle: "Time (s)" }));
time.sciChartSurface.yAxes.add(
new NumericAxis(time.wasmContext, {
axisTitle: "Signal (mV)",
autoRange: EAutoRange.Always,
growBy: new NumberRange(0.05, 0.05)
})
);

const { x, y } = makeEcgWithDrift(); // your data: evenly spaced samples
const rawSeries = new XyDataSeries(time.wasmContext, {
xValues: x,
yValues: y,
dataSeriesName: "Raw: ECG with baseline drift",
dataIsSortedInX: true,
dataEvenlySpacedInX: true
});
// --- The high-pass filter, applied by SciChart.js with an XyCustomFilter ---
// XyCustomFilter calls filterFunction(index, y) once per sample, in index order: from index 0 on a full
// recompute (when the filter is created or its function is set), and from the first new index when data
// is appended. Because it gets the index, the function can read neighbouring samples from the source
// series, and it keeps the IIR's previous output between calls.
let filterType = "iir";
let alpha = 1; // IIR coefficient
let kernel = [1]; // FIR taps
let coefficients = { b: [1], a: [1] }; // b: feed-forward, a: feedback, for the frequency response
let source = []; // the raw values, read from the source series once per pass
let previousOutput = 0; // IIR state: y[n-1]

function highPassAt(index, value) {
// Read the raw values on a full recompute (index 0), or when new samples have been appended
if (index === 0 || index >= source.length) {
const values = rawSeries.getNativeYValues();
source = [];
for (let i = 0; i < rawSeries.count(); i++) source.push(values.get(i));
}
if (filterType === "fir") {
// Convolution centred on this sample, so the output isn't delayed. Past the ends of the data,
// repeat the first and last samples, so a DC offset doesn't cause a jump. (With live data, the
// last few outputs are computed before the samples after them arrive.)
const half = (kernel.length - 1) / 2;
let acc = 0;
for (let k = 0; k < kernel.length; k++) {
const i = Math.min(source.length - 1, Math.max(0, index + half - k));
acc += kernel[k] * source[i];
}
return acc;
}
// First-order IIR. Start at 0, as if the input had always been at its first value (no start-up jump)
previousOutput = index === 0 ? 0 : alpha * (previousOutput + value - source[index - 1]);
return previousOutput;
}

// Sets the filter type and cutoff, and the coefficients for the frequency response chart
function configureFilter(cutoffHz, type) {
filterType = type;
if (type === "fir") {
kernel = designHighPassFir(cutoffHz, SAMPLE_RATE, FIR_TAPS);
coefficients = { b: kernel, a: [1] };
} else {
alpha = firstOrderAlpha(cutoffHz, SAMPLE_RATE);
coefficients = { b: [alpha, -alpha], a: [1, -alpha] };
}
}
configureFilter(0.5, "iir");

// The filtered series: SciChart.js keeps it in step with rawSeries
const highPassed = new XyCustomFilter(rawSeries, {
dataSeriesName: "High-pass filtered",
filterFunction: highPassAt
});

time.sciChartSurface.renderableSeries.add(
new FastLineRenderableSeries(time.wasmContext, { dataSeries: rawSeries, stroke: "#F48420", strokeThickness: 1.5 }),
new FastLineRenderableSeries(time.wasmContext, { dataSeries: highPassed, stroke: "#50C7E0", strokeThickness: 2 })
);
time.sciChartSurface.chartModifiers.add(
new CursorModifier({ showTooltip: true, showAxisLabels: false }),
new LegendModifier({ showCheckboxes: true }),
new MouseWheelZoomModifier(),
new ZoomPanModifier(),
new ZoomExtentsModifier()
);

// --- Chart 2: the filter's frequency response (a Bode magnitude plot), log frequency vs gain in dB ---
const response = await SciChartSurface.create(responseDiv, { theme: new SciChartJsNavyTheme() });
response.sciChartSurface.xAxes.add(
new LogarithmicAxis(response.wasmContext, {
axisTitle: "Frequency (Hz)",
logBase: 10,
maxAutoTicks: 6, // one label per decade: 0.01, 0.1, 1, 10, 100
labelFormat: ENumericFormat.SignificantFigures,
labelPrecision: 2,
visibleRange: new NumberRange(0.01, 100)
})
);
response.sciChartSurface.yAxes.add(
new NumericAxis(response.wasmContext, {
axisTitle: "Gain (dB)",
visibleRange: new NumberRange(-60, 6),
labelPrecision: 0
})
);
const responseSeries = new XyDataSeries(response.wasmContext, { dataSeriesName: "Gain" });
response.sciChartSurface.renderableSeries.add(
new FastLineRenderableSeries(response.wasmContext, {
dataSeries: responseSeries,
stroke: "#50C7E0",
strokeThickness: 2
})
);
// Mark the cutoff frequency and the -3 dB level
const cutoffLine = new VerticalLineAnnotation({
x1: 0.5,
stroke: "#F48420",
strokeDashArray: [6, 4],
showLabel: true,
labelPlacement: ELabelPlacement.TopRight,
axisLabelFill: "#F48420"
});
response.sciChartSurface.annotations.add(
cutoffLine,
new HorizontalLineAnnotation({
y1: -3,
stroke: "#FFFFFF88",
strokeDashArray: [2, 4],
showLabel: true,
labelValue: "-3 dB",
labelPlacement: ELabelPlacement.TopLeft
})
);
response.sciChartSurface.chartModifiers.add(
new CursorModifier({ showTooltip: true, showAxisLabels: false }),
new MouseWheelZoomModifier(),
new ZoomPanModifier(),
new ZoomExtentsModifier()
);

// Redraw the frequency response from the filter's coefficients: 300 frequencies, evenly spaced on a log scale
function updateResponse(cutoffHz) {
const freqs = [];
const gains = [];
for (let i = 0; i < 300; i++) {
const f = 0.01 * Math.pow(100 / 0.01, i / 299); // 0.01 Hz to 100 Hz
freqs.push(f);
gains.push(gainDb(coefficients.b, coefficients.a, f, SAMPLE_RATE));
}
responseSeries.clear();
responseSeries.appendRange(freqs, gains);
cutoffLine.x1 = cutoffHz;
cutoffLine.labelValue = `cutoff ${cutoffHz.toFixed(2)} Hz`;
}

// --- The controls: the slider sets the cutoff from 0.05 Hz to 5 Hz on a log scale ---
function onControlsChanged() {
const cutoffHz = 0.05 * Math.pow(100, Number(cutoffInput.value) / 100);
cutoffOutput.textContent = `${cutoffHz.toFixed(2)} Hz`;
configureFilter(cutoffHz, typeSelect.value);
highPassed.filterFunction = highPassAt; // setting the function reruns the filter over all the data
updateResponse(cutoffHz);
}
cutoffInput.addEventListener("input", onControlsChanged);
typeSelect.addEventListener("change", onControlsChanged);
onControlsChanged();

Key points:

  • XyCustomFilter is a data series computed from another series by a filterFunction(index, y). SciChart.js calls it for each sample in index order: from index 0 when the filter is created or its function is set, and from the first new index when data is appended. So the filtered line stays in step with live data.
  • Because the function gets the index, it can read neighbouring samples from the source series (the FIR's convolution) and carry state between calls (the IIR's previous output, reset at index 0).
  • Setting filterFunction again reruns the filter over all the data; the demo does this whenever a control moves.
  • The frequency response chart uses a LogarithmicAxis for frequency, as a Bode plot does, with a VerticalLineAnnotation at the cutoff and a HorizontalLineAnnotation at −3 dB.

See it in the demo app: JavaScript trendline and moving average filters · React trendline and moving average filters · Angular trendline and moving average filters, where the moving average is the low-pass you would subtract to remove a trend. For a biosignal example, see the JavaScript vital signs ECG/EKG medical demo.

Go deeper: SciChart.js custom filter documentation, and the Filters API overview, including the built-in moving average filter, a simple low-pass you can subtract from the original.

Frequently asked questions​

What does a high-pass filter do?​

A high-pass filter lets fast changes through and removes slow ones. It blocks a steady DC offset, slow drift and low-frequency noise such as rumble or hum below its cutoff frequency, and keeps the higher-frequency detail above it, such as speech, vibration or the sharp parts of a heartbeat.

How do you calculate the cutoff frequency of a high-pass filter?​

For a first-order RC high-pass filter, the cutoff frequency is fc = 1 / (2 pi R C), with R in ohms and C in farads. For example, R = 20 kilohms and C = 100 nanofarads give a cutoff of about 80 Hz. At the cutoff, the output is 3 dB down, about 71% of the input amplitude.

What is the difference between a high-pass and a low-pass filter?​

A high-pass filter keeps frequencies above its cutoff and removes those below it, so it strips out offsets, drift and rumble. A low-pass filter does the opposite: it keeps frequencies below its cutoff and removes those above, so it smooths out fast noise. Subtracting a low-pass output from the original signal gives a high-pass output.

What should I set my high-pass filter to?​

Set the cutoff just below the lowest frequency you need to keep. For voice recordings that is often around 75 to 100 Hz; for removing sensor drift it may be well under 1 Hz; diagnostic ECGs use about 0.05 Hz, or up to 0.67 Hz with zero-phase digital filters. Too high a cutoff removes part of the signal you wanted.

What is a high-pass filter in audio?​

In audio, a high-pass filter (also called a low-cut filter) removes low frequencies that add muddiness rather than music: microphone handling noise, stage and traffic rumble, wind and breath pops. It is commonly used on vocals and many instruments that have little useful low end, and in loudspeaker crossovers to keep bass out of tweeters.

How do I apply a high-pass filter in JavaScript?​

For a quick filter, loop over your samples with the first-order recurrence y[n] = alpha * (y[n-1] + x[n] - x[n-1]), where alpha = RC / (RC + dt). For a sharper cutoff, convolve the samples with a windowed-sinc high-pass kernel. To chart the result with SciChart.js, apply it with an XyCustomFilter, whose filter function is called for each sample in order, so the filtered line updates whenever the data changes.

Sources​