Learn · 01 of 02

How it works

From a heart sound to a decision, in two halves.

The electronics that turn a sound into numbers, and the software that turns those numbers into an answer. Choose a half with the tabs below.

Hardware · The circuit

From two microphones to the PCM1808 input.

The analog front end between the microphones and the converter, as designed and analysed by Patrick De Leo. Below, the whole circuit in one drawing, then each stage with its circuit, its values, its derivation and its response.

Circuit design and analysis by Patrick De Leo.

Design and analysis · simulated, awaiting parts

FIG. 1 · The whole front end · microphones to the PCM1808 input

Scrolls sideways

Full signal chainBoth microphones, input stage, instrumentation amplifier, high-pass and low-pass filters, notch, variable gain, C_ADC and R_Bias into the PCM1808 analog input, in stage boxes 1 to 5 and ADC.S1.M_NCCMB-6544PF+−V_MNCS1.RL_NC1 kΩ+V_sS1.CL_NC1 µFS1.Rin_NC14915.49 ΩAS1.M_HCMB-6544PF+−V_MHS1.RL_H1 kΩ+V_sS1.CL_H1 µFS1.Rin_H14915.49 ΩD+−S2.M1OPA2141 or OPA4141+−S2.M2OPA2141 or OPA4141BCS2.R1100 ΩS2.R210 kΩS2.R310 kΩV_o1 − V_o2V_o1V_o2+−S2.M3OPA2141 or OPA4141S2.R4R4 = R5 = R6 = R7S2.R5R4 = R5 = R6 = R7S2.R7R4 = R5 = R6 = R7S2.R6R4 = R5 = R6 = R7S3a.C11 µFS3a.C21 µFAB+−S3a.U1OPA4141 or OPA4197S3a.R211.252 kΩS3a.R15.628 kΩn_inaS3b.R122.508 kΩS3b.R222.508 kΩAB+−S3b.U1OPA4141 or OPA4197S3b.C110 nFS3b.C220 nFn_hpfS4.R310 kΩS4.R510 kΩS4.R112.1 kΩS4.R212.1 kΩS4.C10.22 µFS4.C20.22 µFS4.R424.3 kΩ+−S4.U1OPA4141 or OPA4197S4.R610 kΩ+−S4.U2OPA4141 or OPA4197n_lpf+−S5.U1OPA2141 or OPA4141S5.Rin1 kΩAS5.Rf0 to 100 kΩn_notchADC.C_ADC1 µFADC.R_Bias100 kΩV_ref (PCM1808)ADC.PCM1808PCM1808analog inputn_gainStage 1 Input stageStage 2 Instrumentation amplifierStage 3 Band-pass filterStage 4 Notch filterStage 5 Variable gainADC PCM1808 interface3a High-pass, Sallen-Key Butterworth3b Low-pass, Sallen-KeyPWR.CP inverted rail: low-noise charge pump inverter, TC7660H or LM27762 (analysis p.9)Circuit design and analysis by Patrick De LeoPhonocardiogram analog front end: microphones to PCM1808 input
The complete front end in one drawing: both microphones, the input stage, the instrumentation amplifier, the high-pass and low-pass filters, the notch, the variable gain and the coupling into the PCM1808 analog input, in stage boxes 1 to 5 and the ADC.Circuit design and analysis by Patrick De Leo. Drawing: hardware/svg/full_chain.svg.

Stage 1 · Input stage

Microphones and input coupling

Two electret microphones, MNC and MH (CMB-6544PF), each feed an amplifier input through a coupling capacitor.

Each microphone's output is a voltage on a node (VMNC and VMH) that RL ties to the supply +Vs. The capacitor CL passes the signal on to nodes A and D, where Rin goes to ground.

CL, RL and Rin together form a first-order high-pass filter. A high-pass filter passes frequencies above its cutoff and weakens those below it. The analysis derives the cutoff fc and sets it to 10 Hz, which fixes Rin.

FIG. 2 · Input stage · circuit

As designed

Input stageTwo CMB-6544PF electret microphones M_NC and M_H, each with an R_L to +V_s, a C_L coupling capacitor and an R_in to ground.S1.M_NCCMB-6544PF+−V_MNCS1.RL_NC1 kΩ+V_sS1.CL_NC1 µFS1.Rin_NC14915.49 ΩAS1.M_HCMB-6544PF+−V_MHS1.RL_H1 kΩ+V_sS1.CL_H1 µFS1.Rin_H14915.49 ΩDStage 1: input stage (analysis p.1, p.2)to M1 (+ input)to M2 (+ input)
Input stage (analysis p.1): two microphones MNCM_{NC} and MHM_H, each with RLR_L to +Vs+V_s, CLC_L and RinR_{in}.Drawing: hardware/svg/input_stage.svg.

Design targets

Zout = ro || RL, ro >> RL, so Zout ~ RL
1 kΩ p.1
Vs (DC)
4.5 to 10 V p.1
Input coupling cutoff fc
10 Hz p.2

Components

Input stage: component values from hardware/values.json, with the page of the analysis each comes from
ComponentValueRole in the circuitPage
S1.RL_NCRL (MNC)1 kΩLoad resistor from the MNC capsule output (node VMNC) to +Vsp.1
S1.RL_HRL (MH)1 kΩLoad resistor from the MH capsule output (node VMH) to +Vsp.1
S1.CL_NCCL (MNC)1 µFCoupling capacitor from node VMNC to node Ap.1
S1.CL_HCL (MH)1 µFCoupling capacitor from node VMH to node Dp.1
S1.Rin_NCRin (MNC)14915.49 Ω (about 15 kΩ)Resistor from node A to ground; fc = 10 Hzp.2
S1.Rin_HRin (MH)14915.49 Ω (about 15 kΩ)Resistor from node D to ground; fc = 10 Hzp.2

Parts

S1.M_NCElectret microphone, voltage VMNC
CMB-6544PF p.1
S1.M_HElectret microphone, voltage VMH
CMB-6544PF p.1

Derivation

On a narrow screen, scroll an equation sideways to see all of it.

The page is headed “Circuits – Phonocardiogram”. Microphone: CMB-6544PF.

Zout=ro∥RL  →  ro≫RL  →  Zout≃RL=1 kΩZ_{out} = r_o \parallel R_L \;\to\; r_o \gg R_L \;\to\; Z_{out} \simeq R_L = 1\,\mathrm{k}\Omega
RL=1 kΩCL=1 μFVs=[4.5,10] VDC\begin{align*}R_L &= 1\,\mathrm{k}\Omega \\ C_L &= 1\,\mu\mathrm{F} \\ V_s &= [4.5, 10]\ \mathrm{V_{DC}}\end{align*}

VA→V_A \to voltage divider

VA=RinRL+Rin+1/sCL VNC  →  VAVNC=RinRL+Rin+1/sCLH(s)=sCLRinsCL(RL+Rin)+1,s=jωH(jω)=jωCLRinjωCL(RL+Rin)+1  →  ∣H(jω)∣=ωCLRinω2CL2(RL+Rin)2+1∣H(jω)∣2=ω2CL2Rin2ω2CL2(RL+Rin2)+1\begin{align*}V_A &= \frac{R_{in}}{R_L + R_{in} + 1/sC_L}\, V_{NC} \;\to\; \frac{V_A}{V_{NC}} = \frac{R_{in}}{R_L + R_{in} + 1/sC_L} \\[4pt] H(s) &= \frac{sC_L R_{in}}{sC_L(R_L + R_{in}) + 1}, \qquad s = j\omega \\[4pt] H(j\omega) &= \frac{j\omega C_L R_{in}}{j\omega C_L (R_L + R_{in}) + 1} \;\to\; |H(j\omega)| = \frac{\omega C_L R_{in}}{\sqrt{\omega^2 C_L^2 (R_L + R_{in})^2 + 1}} \\[4pt] |H(j\omega)|^2 &= \frac{\omega^2 C_L^2 R_{in}^2}{\omega^2 C_L^2 (R_L + R_{in}^2) + 1}\end{align*}
∣H(jω)∣2=ω2CL2Rin2ω2CL2(RL+Rin2)+1|H(j\omega)|^2 = \frac{\omega^2 C_L^2 R_{in}^2}{\omega^2 C_L^2 (R_L + R_{in}^2) + 1}

Since this is a HPF, we take the limit ω→∞\omega \to \infty to find max power.

lim⁡ω→∞∣H(jω)∣2=lim⁡ω→∞ω2CL2Rin2ω2CL2(RL+Rin)2+1divide every term by ω2CL2=lim⁡ω→∞Rin2(RL+Rin)2+1ω2CL2=Rin2(RL+Rin)2\begin{align*}\lim_{\omega \to \infty} |H(j\omega)|^2 &= \lim_{\omega \to \infty} \frac{\omega^2 C_L^2 R_{in}^2}{\omega^2 C_L^2 (R_L + R_{in})^2 + 1} \qquad \text{divide every term by } \omega^2 C_L^2 \\ &= \lim_{\omega \to \infty} \frac{R_{in}^2}{(R_L + R_{in})^2 + \frac{1}{\omega^2 C_L^2}} = \frac{R_{in}^2}{(R_L + R_{in})^2}\end{align*}

The −3-3 dB is half power and ∣H(jω)∣2|H(j\omega)|^2 is power @ ωc\omega_c.

∣H(jωc)∣2=12lim⁡ω→∞∣H(jω)∣2ωc2CL2Rin2ωc2CL2(RL+Rin)2+1=12 Rin2(RL+Rin)22ωc2CL2(RL+Rin)2=ωc2CL2(RL+Rin)2+1ωc2CL2(RL+Rin)2=1ωc2=1CL2(RL+Rin)2  →  ωc=1CL(RL+Rin)ωc=2πfc∴  fc=12πCL(RL+Rin)\begin{align*}|H(j\omega_c)|^2 &= \frac{1}{2} \lim_{\omega \to \infty} |H(j\omega)|^2 \\ \frac{\omega_c^2 C_L^2 \cancel{R_{in}^2}}{\omega_c^2 C_L^2 (R_L + R_{in})^2 + 1} &= \frac{1}{2}\, \frac{\cancel{R_{in}^2}}{(R_L + R_{in})^2} \\ 2\omega_c^2 C_L^2 (R_L + R_{in})^2 &= \omega_c^2 C_L^2 (R_L + R_{in})^2 + 1 \\ \omega_c^2 C_L^2 (R_L + R_{in})^2 &= 1 \\ \omega_c^2 = \frac{1}{C_L^2 (R_L + R_{in})^2} &\;\to\; \omega_c = \frac{1}{C_L (R_L + R_{in})} \\ \omega_c = 2\pi f_c \qquad \therefore\; f_c &= \frac{1}{2\pi C_L (R_L + R_{in})}\end{align*}
CL=1 μFRL=1 kΩfc→10 Hz\begin{align*}C_L &= 1\,\mu\mathrm{F} \\ R_L &= 1\,\mathrm{k}\Omega \\ f_c &\to 10\,\mathrm{Hz}\end{align*}
10 (2π)  1⋅10−6 (1⋅103+Rin)=120π⋅1⋅10−3+20π⋅10−6Rin=1Rin=1−20π⋅10−320π⋅10−6=14915.49 Ω≃15 kΩ\begin{align*}10\,(2\pi)\; 1 \cdot 10^{-6}\, (1 \cdot 10^{3} + R_{in}) &= 1 \\ 20\pi \cdot 1 \cdot 10^{-3} + 20\pi \cdot 10^{-6} R_{in} &= 1 \\ R_{in} = \frac{1 - 20\pi \cdot 10^{-3}}{20\pi \cdot 10^{-6}} &= 14915.49\,\Omega \simeq 15\,\mathrm{k}\Omega\end{align*}

FIG. 3 · input coupling · gain against frequency

1–2000 Hz

-25-20-15-10-5051101001000Frequency (Hz, log scale)Gain (dB)

Point at the chart, or focus it and use the arrow keys, to read the gain at one frequency.

Gain of the input coupling in dB on a log frequency axis, computed from the design (hardware/response.json, ideal op-amps). It is a calculation, not a measurement.

Stage 2 · Instrumentation amplifier

Instrumentation amplifier

Three op-amps: M1 and M2 amplify the difference between the two inputs, and M3 turns their two outputs into one.

R1, R2 and R3 set the gain of the first pair, Av1 = 1 + 2R/R1, which the analysis sets to 201. M3, with R4 = R5 = R6 = R7, subtracts Vo1 from Vo2, so the output is Vo = (1 + 2R/R1)(VC − VB).

FIG. 4 · Instrumentation amplifier · circuit

As designed

Instrumentation amplifierThree op-amp instrumentation amplifier: M1 and M2 with R1, R2 and R3 give 1 + 2R/R1 = 201, then M3 with R4 = R5 = R6 = R7.+−S2.M1OPA2141 or OPA4141+−S2.M2OPA2141 or OPA4141ADBCS2.R1100 ΩS2.R210 kΩS2.R310 kΩV_o1 − V_o2V_o1V_o2+−S2.M3OPA2141 or OPA4141S2.R4R4 = R5 = R6 = R7S2.R5R4 = R5 = R6 = R7S2.R7R4 = R5 = R6 = R7S2.R6R4 = R5 = R6 = R7V_oStage 2: instrumentation amplifier, V_o = A_v1 (V_C − V_B) (analysis p.3, p.4)
Instrumentation amplifier (analysis p.3).Instrumentation amplifier with the difference amplifier M3M_3 (analysis p.4).Drawing: hardware/svg/ina.svg.

Design targets

Av1 = 1 + 2R/R1
201 V/V p.3

Components

Instrumentation amplifier: component values from hardware/values.json, with the page of the analysis each comes from
ComponentValueRole in the circuitPage
S2.R1R1100 ΩGain resistor between nodes B and Cp.3
S2.R2R210 kΩFeedback resistor, node B to Vo1 (R = R2 = R3)p.3
S2.R3R310 kΩFeedback resistor, node C to Vo2 (R = R2 = R3)p.3
S2.R4R4R4 = R5 = R6 = R7Vo1 to the inverting input of M3p.4
S2.R5R5R4 = R5 = R6 = R7Vo2 to the non-inverting input of M3p.4
S2.R6R6R4 = R5 = R6 = R7Feedback resistor of M3, output to the inverting inputp.4
S2.R7R7R4 = R5 = R6 = R7Non-inverting input of M3 to groundp.4

Parts

S2.M1In-amp input op-amp, + input at node A (labelled M1 on p.4)
OPA2141 or OPA4141 p.9
S2.M2In-amp input op-amp, + input at node D (labelled M2 on p.4)
OPA2141 or OPA4141 p.9
S2.M3In-amp difference amplifier (labelled M3 on p.4)
OPA2141 or OPA4141 p.9

Derivation

On a narrow screen, scroll an equation sideways to see all of it.

∗  Av1=1+2RR1=201201−1=2RR1200 R1=2R100 R1=R\begin{align*}\ast\; A_{v_1} &= 1 + \frac{2R}{R_1} = 201 \\ 201 - 1 &= \frac{2R}{R_1} \\ 200\, R_1 &= 2R \\ 100\, R_1 &= R\end{align*}

Let R1=100 ΩR_1 = 100\,\Omega and R=10 kΩR = 10\,\mathrm{k}\Omega.    R2=R3≫R1R_2 = R_3 \gg R_1.

VA=VB=RinRin+RL+1sCL VMNCVB−VCR1=IR1VD=VC=RinRin+RL+1sCL VMHVo1−VBR2=VB−VCR1VC−Vo2R3=VB−VCR1Vo1=VB+R2R1 (VB−VC)\begin{align*}V_A = V_B &= \frac{R_{in}}{R_{in} + R_L + \frac{1}{sC_L}}\, V_{M_{NC}} & \frac{V_B - V_C}{R_1} &= I_{R_1} \\[4pt] V_D = V_C &= \frac{R_{in}}{R_{in} + R_L + \frac{1}{sC_L}}\, V_{M_H} & \frac{V_{o_1} - V_B}{R_2} &= \frac{V_B - V_C}{R_1} \\[4pt] \frac{V_C - V_{o_2}}{R_3} &= \frac{V_B - V_C}{R_1} & V_{o_1} &= V_B + \frac{R_2}{R_1}\,(V_B - V_C)\end{align*}
−Vo2=R3R1 (VB−VC)−VCVo2=VC−R3R1 (VB−VC)Vo1−Vo2=VB−VC+R3R1 (VB−VC)+R2R1 (VB−VC)=(VB−VC)(1+R3+R2R1)Vo1−Vo2VB−VC=1+2RR1=Av1∗\begin{align*}-V_{o_2} &= \frac{R_3}{R_1}\,(V_B - V_C) - V_C \\ V_{o_2} &= V_C - \frac{R_3}{R_1}\,(V_B - V_C) \\ V_{o_1} - V_{o_2} &= V_B - V_C + \frac{R_3}{R_1}\,(V_B - V_C) + \frac{R_2}{R_1}\,(V_B - V_C) \\ &= (V_B - V_C)\left(1 + \frac{R_3 + R_2}{R_1}\right) \\ \frac{V_{o_1} - V_{o_2}}{V_B - V_C} &= 1 + \frac{2R}{R_1} = A_{v_1} \quad \ast\end{align*}

For M3M_3

R1=1 kΩR2=R3=9.5 kΩR2=R3≫R1\begin{align*}R_1 &= 1\,\mathrm{k}\Omega \\ R_2 = R_3 &= 9.5\,\mathrm{k}\Omega \\ R_2 = R_3 &\gg R_1\end{align*}

If R4=R5=R6=R7R_4 = R_5 = R_6 = R_7:

V+=V−=R7R5+R7 Vo2=Vo22Vo1−V−R4+Vo−V−R6=0Vo1−V−+Vo−V−=0Vo1−Vo22+Vo−Vo22=0Vo=Vo2−Vo1\begin{align*}V^+ = V^- &= \frac{R_7}{R_5 + R_7}\, V_{o_2} = \frac{V_{o_2}}{2} \\[4pt] \frac{V_{o_1} - V^-}{R_4} + \frac{V_o - V^-}{R_6} &= 0 \\[4pt] V_{o_1} - V^- + V_o - V^- &= 0 \\ V_{o_1} - \frac{V_{o_2}}{2} + V_o - \frac{V_{o_2}}{2} &= 0 \\ V_o &= V_{o_2} - V_{o_1}\end{align*}
∵  Vo1−Vo2=(1+2RR1)(VB−VC)∵  Vo=Vo2−Vo1∴  Vo=(1+2RR1)(VC−VB)\begin{align*}\because\; V_{o_1} - V_{o_2} &= \left(1 + \frac{2R}{R_1}\right)(V_B - V_C) \\ \because\; V_o &= V_{o_2} - V_{o_1} \\ \therefore\; V_o &= \left(1 + \frac{2R}{R_1}\right)(V_C - V_B)\end{align*}

FIG. 5 · instrumentation amplifier · gain against frequency

1–2000 Hz

404244464850521101001000Frequency (Hz, log scale)Gain (dB)

Point at the chart, or focus it and use the arrow keys, to read the gain at one frequency.

Gain of the instrumentation amplifier in dB on a log frequency axis, computed from the design (hardware/response.json, ideal op-amps). It is a calculation, not a measurement. The curve is flat at 46.1 dB across the whole range.

Stage 3a · High-pass filter

Sallen-Key high-pass

A second-order Sallen-Key high-pass filter with a Butterworth response.

The analysis sets the corner f0 to 20 Hz and Q to 0.707, takes C1 = C2 = 1 µF, and solves for R1 and R2.

FIG. 6 · High-pass filter · circuit

As designed

High-pass filterSallen-Key high-pass with C1 = C2 = 1 uF, R1 = 5.628 kohm feedback and R2 = 11.252 kohm to ground.S3a.C11 µFS3a.C21 µFAB+−S3a.U1OPA4141 or OPA4197S3a.R211.252 kΩS3a.R15.628 kΩV_iV_oStage 3a: Sallen-Key Butterworth high-pass, f0 = 20 Hz, Q = 0.707 (analysis p.5)
High-pass Sallen-Key Butterworth filter (analysis p.5).Drawing: hardware/svg/hpf.svg.

Design targets

High-pass f0
20 Hz p.5
High-pass Q (Butterworth)
0.707 p.5

Components

High-pass filter: component values from hardware/values.json, with the page of the analysis each comes from
ComponentValueRole in the circuitPage
S3a.C1C11 µFInput capacitor, Vi to node Ap.5
S3a.C2C21 µFCapacitor from node A to node Bp.5
S3a.R1R15.628 kΩFeedback resistor, node A to Vop.5
S3a.R2R211.252 kΩResistor from node B to groundp.5

Parts

S3a.U1High-pass Sallen-Key op-amp
OPA4141 or OPA4197 p.9

Derivation

On a narrow screen, scroll an equation sideways to see all of it.

VB=VoV_B = V_o      IC2=IR2I_{C_2} = I_{R_2}

sC2(VA−Vo)=VoR2  →  VA−Vo=VosC2R2VA=Vo(1+1sC2R2)sC1(VA−Vi)+sC2(VA−Vo)+VA−VoR1=0sC1(VA−Vi)+VoR2+VosC2R1R2=0sC1(Vo(1+1sC2R2)−Vi)+VoR2+VosC2R1R2=0sC1Vo+C1C2R2 Vo−sC1Vi+VoR2+VosC2R1R2=0sC1Vi=Vo(sC1+C1C2R2+1R2+1sC2R1R2)∗ sC2R1R2s2C1C2R1R2 Vi=Vo(s2C1C2R1R2+sC1R1+sC2R1+1)VoVi=s2C1C2R1R2s2C1C2R1R2+sR1(C1+C2)+1=H(s)\begin{align*}sC_2 (V_A - V_o) &= \frac{V_o}{R_2} \;\to\; V_A - V_o = \frac{V_o}{sC_2R_2} \\ V_A &= V_o\left(1 + \frac{1}{sC_2R_2}\right) \\[4pt] sC_1 (V_A - V_i) + sC_2 (V_A - V_o) + \frac{V_A - V_o}{R_1} &= 0 \\ sC_1 (V_A - V_i) + \frac{V_o}{R_2} + \frac{V_o}{sC_2R_1R_2} &= 0 \\ sC_1\left(V_o\left(1 + \frac{1}{sC_2R_2}\right) - V_i\right) + \frac{V_o}{R_2} + \frac{V_o}{sC_2R_1R_2} &= 0 \\ sC_1V_o + \frac{C_1}{C_2R_2}\, V_o - sC_1V_i + \frac{V_o}{R_2} + \frac{V_o}{sC_2R_1R_2} &= 0 \\ sC_1V_i &= V_o\left(sC_1 + \frac{C_1}{C_2R_2} + \frac{1}{R_2} + \frac{1}{sC_2R_1R_2}\right) \qquad \ast\, sC_2R_1R_2 \\ s^2C_1C_2R_1R_2\, V_i &= V_o\left(s^2C_1C_2R_1R_2 + sC_1R_1 + sC_2R_1 + 1\right) \\ \frac{V_o}{V_i} &= \frac{s^2C_1C_2R_1R_2}{s^2C_1C_2R_1R_2 + sR_1(C_1 + C_2) + 1} = H(s)\end{align*}

Let A=C1C2R1R2A = C_1C_2R_1R_2   &   B=R1(C1+C2)B = R_1(C_1 + C_2)

∴  H(s)=As2As2+Bs+1dividing numerator & denominator by A=s2s2+BA s+1A  ⇒  standard 2nd order transfer fn  ⇒  H(s)=s2s2+ω0Q s+ω02∴  ω02=1A=1C1C2R1R2  →  ω0=1C1C2R1R2  →  f0=12πA∴  BA=ω0Q  →  Q=ω0AB=1A⋅A⋅1B=ABQ=C1C2R1R2R1(C1+C2)\begin{align*}\therefore\; H(s) &= \frac{As^2}{As^2 + Bs + 1} \qquad \text{dividing numerator \& denominator by } A \\ &= \frac{s^2}{s^2 + \frac{B}{A}\, s + \frac{1}{A}} \;\Rightarrow\; \text{standard 2}^{\text{nd}}\text{ order transfer f}^{\text{n}} \;\Rightarrow\; H(s) = \frac{s^2}{s^2 + \frac{\omega_0}{Q}\, s + \omega_0^2} \\[4pt] \therefore\; \omega_0^2 = \frac{1}{A} = \frac{1}{C_1C_2R_1R_2} &\;\to\; \omega_0 = \frac{1}{\sqrt{C_1C_2R_1R_2}} \;\to\; f_0 = \frac{1}{2\pi\sqrt{A}} \\[4pt] \therefore\; \frac{B}{A} = \frac{\omega_0}{Q} &\;\to\; Q = \frac{\omega_0 A}{B} = \frac{1}{\sqrt{A}} \cdot A \cdot \frac{1}{B} = \frac{\sqrt{A}}{B} \\ Q &= \frac{\sqrt{C_1C_2R_1R_2}}{R_1(C_1 + C_2)}\end{align*}
A=12πf0A=14π2f02A∣f0=20=14π2 202=63.326×10−6Q=AB  →  B=AQ  ⇒  B∣Q=0.707=63.33×10−60.707=11.256×10−3\begin{align*}\sqrt{A} &= \frac{1}{2\pi f_0} \qquad A = \frac{1}{4\pi^2 f_0^2} \\[4pt] A\big|_{f_0 = 20} &= \frac{1}{4\pi^2\, 20^2} = 63.326\times10^{-6} \\[4pt] Q = \frac{\sqrt{A}}{B} \;\to\; B = \frac{\sqrt{A}}{Q} \;\Rightarrow\; B\big|_{Q = 0.707} &= \frac{\sqrt{63.33\times10^{-6}}}{0.707} = 11.256\times10^{-3}\end{align*}

Assume: C1=C2=C=1 μFC_1 = C_2 = C = 1\,\mu\mathrm{F}

∴  A=C2R1R2=63.326×10−6∴  B=R1 (2C)=11.256×10−3∴  R1=5.628 kΩR2=11.252 kΩ\begin{align*}\therefore\; A &= C^2 R_1 R_2 = 63.326\times10^{-6} \\ \therefore\; B &= R_1\,(2C) = 11.256\times10^{-3} \\ \therefore\; R_1 &= 5.628\,\mathrm{k}\Omega \\ R_2 &= 11.252\,\mathrm{k}\Omega\end{align*}

FIG. 7 · high-pass filter · gain against frequency

1–2000 Hz

-60-50-40-30-20-100101101001000Frequency (Hz, log scale)Gain (dB)

Point at the chart, or focus it and use the arrow keys, to read the gain at one frequency.

Gain of the high-pass filter in dB on a log frequency axis, computed from the design (hardware/response.json, ideal op-amps). It is a calculation, not a measurement.

Stage 3b · Low-pass filter

Sallen-Key low-pass

A second-order Sallen-Key low-pass filter, also with Q equal to 1 over the square root of 2.

A low-pass filter passes frequencies below its corner and weakens those above it. With R1 = R2 and C1 = C2/2, the analysis sets f0 to 500 Hz and solves for R.

FIG. 8 · Low-pass filter · circuit

As designed

Low-pass filterSallen-Key low-pass with R1 = R2 = 22.508 kohm, C1 = 10 nF to ground and C2 = 20 nF feedback.S3b.R122.508 kΩS3b.R222.508 kΩAB+−S3b.U1OPA4141 or OPA4197S3b.C110 nFS3b.C220 nFV_iV_oStage 3b: Sallen-Key low-pass, f0 = 500 Hz, Q = 1/sqrt(2) (analysis p.6)
Low-pass Sallen-Key filter (analysis p.6).Drawing: hardware/svg/lpf.svg.

Design targets

Low-pass f0
500 Hz p.6
Low-pass Q = 1/sqrt(2)
0.7071 p.6

Components

Low-pass filter: component values from hardware/values.json, with the page of the analysis each comes from
ComponentValueRole in the circuitPage
S3b.R1R122.508 kΩSeries resistor, Vi to node A (R1 = R2)p.6
S3b.R2R222.508 kΩSeries resistor, node A to node B (R1 = R2)p.6
S3b.C1C110 nFCapacitor from node B to groundp.6
S3b.C2C220 nFFeedback capacitor, node A to Vop.6

Parts

S3b.U1Low-pass Sallen-Key op-amp
OPA4141 or OPA4197 p.9

Derivation

On a narrow screen, scroll an equation sideways to see all of it.

f0=500 Hzf_0 = 500\,\mathrm{Hz}

H(s)=1s2R1R2C1C2+sC1(R1+R2)+1  ⇒  H(s)=11+sQω0+s2ω02\begin{align*}H(s) &= \frac{1}{s^2R_1R_2C_1C_2 + sC_1(R_1 + R_2) + 1} \;\Rightarrow\; H(s) = \frac{1}{1 + \frac{s}{Q\omega_0} + \frac{s^2}{\omega_0^2}}\end{align*}

Let A=R1R2C1C2A = R_1R_2C_1C_2   &   B=C1(R1+R2)B = C_1(R_1 + R_2)

∴  H(s)=1As2+Bs+1As2=s2ω02  →  ω02=1A  →  ω0=1Aω0=1R1R2C1C2Bs=sQω0  →  Q=1Bω0=AB=R1R2C1C2C1(R1+R2)\begin{align*}\therefore\; H(s) &= \frac{1}{As^2 + Bs + 1} \\[4pt] A\cancel{s^2} = \frac{\cancel{s^2}}{\omega_0^2} &\;\to\; \omega_0^2 = \frac{1}{A} \;\to\; \omega_0 = \frac{1}{\sqrt{A}} \\ \omega_0 &= \frac{1}{\sqrt{R_1R_2C_1C_2}} \\[4pt] B\cancel{s} = \frac{\cancel{s}}{Q\omega_0} &\;\to\; Q = \frac{1}{B\omega_0} = \frac{\sqrt{A}}{B} = \frac{\sqrt{R_1R_2C_1C_2}}{C_1(R_1 + R_2)}\end{align*}

Assuming R1=R2R_1 = R_2

f0=12πRC1C2  →  R∣f0=500=11000πC1C2Q=RC1C2C1(2R)=C1C22C1=12C2C1Q=12=12C2C1  →  12=14⋅C2C1C1=12 C2using C1=10 nF,  C2=20 nF∴  R∣f=500=11000πC1C2=22507.9079 Ω≃22.508 kΩ\begin{align*}f_0 &= \frac{1}{2\pi R\sqrt{C_1C_2}} \;\to\; R\big|_{f_0 = 500} = \frac{1}{1000\pi\sqrt{C_1C_2}} \\[4pt] Q &= \frac{R\sqrt{C_1C_2}}{C_1(2R)} = \frac{\sqrt{C_1C_2}}{2C_1} = \frac{1}{2}\sqrt{\frac{C_2}{C_1}} \\[4pt] Q = \frac{1}{\sqrt{2}} = \frac{1}{2}\sqrt{\frac{C_2}{C_1}} &\;\to\; \frac{1}{2} = \frac{1}{4}\cdot\frac{C_2}{C_1} \\[4pt] C_1 &= \frac{1}{2}\, C_2 \qquad \text{using } C_1 = 10\,\mathrm{n}\mathrm{F}, \; C_2 = 20\,\mathrm{n}\mathrm{F} \\[4pt] \therefore\; R\big|_{f = 500} &= \frac{1}{1000\pi\sqrt{C_1C_2}} = 22507.9079\,\Omega \simeq 22.508\,\mathrm{k}\Omega\end{align*}

FIG. 9 · low-pass filter · gain against frequency

1–2000 Hz

-30-25-20-15-10-5051101001000Frequency (Hz, log scale)Gain (dB)

Point at the chart, or focus it and use the arrow keys, to read the gain at one frequency.

Gain of the low-pass filter in dB on a log frequency axis, computed from the design (hardware/response.json, ideal op-amps). It is a calculation, not a measurement.

Stage 4 · Notch filter

Notch filter

A notch filter built from two op-amps, centred on 60 Hz.

A notch filter weakens a narrow range of frequencies around its centre and passes the rest. The analysis gives its resistor and capacitor values, with f = 60 Hz, Q = 1 and a gain of 1.

FIG. 10 · Notch filter · circuit

As designed

Notch filterNotch filter with R1 = R2 = 12.1 kohm, R4 = 24.3 kohm, R3 = R5 = R6 = 10 kohm and C1 = C2 = 0.22 uF.S4.R310 kΩS4.R510 kΩS4.R112.1 kΩS4.R212.1 kΩS4.C10.22 µFS4.C20.22 µFS4.R424.3 kΩ+−S4.U1OPA4141 or OPA4197S4.R610 kΩ+−S4.U2OPA4141 or OPA4197V_inV_outStage 4: notch filter, f = 60 Hz, Q = 1, gain = 1 (analysis p.7)
Notch filter (analysis p.7).Drawing: hardware/svg/notch.svg.

Design targets

Notch frequency f
60 Hz p.7
Notch Q
1 p.7
Notch gain
1 V/V p.7

Components

Notch filter: component values from hardware/values.json, with the page of the analysis each comes from
ComponentValueRole in the circuitPage
S4.R1R112.1 kΩInput node to the R1/R2 junctionp.7
S4.R2R212.1 kΩR1/R2 junction to groundp.7
S4.R3R310 kΩInput node to the inverting input of the second op-ampp.7
S4.R4R424.3 kΩAcross the first op-amp, inverting input to outputp.7
S4.R5R510 kΩFeedback resistor of the second op-ampp.7
S4.R6R610 kΩFirst op-amp output to the inverting input of the second op-ampp.7
S4.C1C10.22 µFC1/C2 junction to the inverting input of the first op-ampp.7
S4.C2C20.22 µFC1/C2 junction to the output of the first op-ampp.7

Parts

S4.U1Notch, first op-amp
OPA4141 or OPA4197 p.9
S4.U2Notch, second op-amp
OPA4141 or OPA4197 p.9

Derivation

On a narrow screen, scroll an equation sideways to see all of it.

R1=R2=12.1 kΩR3=R5=R6=10 kΩR4=24.3 kΩC1=C2=0.22 μF\begin{align*}R_1 = R_2 &= 12.1\,\mathrm{k}\Omega & R_3 = R_5 = R_6 &= 10\,\mathrm{k}\Omega \\ R_4 &= 24.3\,\mathrm{k}\Omega & C_1 = C_2 &= 0.22\,\mu\mathrm{F}\end{align*}
f=60 HzQ=1Gain=1f = 60\,\mathrm{Hz} \qquad Q = 1 \qquad \text{Gain} = 1

FIG. 11 · notch filter · gain against frequency

1–2000 Hz

-40-30-20-100101101001000Frequency (Hz, log scale)Gain (dB)

Point at the chart, or focus it and use the arrow keys, to read the gain at one frequency.

Gain of the notch filter in dB on a log frequency axis, computed from the design (hardware/response.json, ideal op-amps). It is a calculation, not a measurement.

Stage 5 · Variable gain and ADC

Variable gain and the ADC input

A non-inverting amplifier whose gain is set by a potentiometer, then a coupling capacitor into the PCM1808 analog input.

With Rin = 1 kΩ and the potentiometer Rf between 0 and 100 kΩ, the gain Av = 1 + Rf/Rin runs from 1 to 101. CADC couples the output to the PCM1808 analog input, and RBias ties that input to the PCM1808's Vref.

The four settings of the variable gain stage in hardware/response.json
RfAv (V/V)Gain of this stage (dB)
0 Ω10.0
10 kΩ1120.8
50 kΩ5134.2
100 kΩ10140.1

FIG. 12 · Variable gain and ADC · circuit

As designed

Variable gain and ADC interfaceVariable gain stage with Rin = 1 kohm and a 0 to 100 kohm feedback potentiometer, then C_ADC and R_Bias into the PCM1808 analog input.+−S5.U1OPA2141 or OPA4141S5.Rin1 kΩAS5.Rf0 to 100 kΩV_iADC.C_ADC1 µFADC.R_Bias100 kΩV_ref (PCM1808)ADC.PCM1808PCM1808analog inputStage 5 and ADC: variable gain, C_ADC and R_Bias into the PCM1808 (analysis p.8, p.9)
Variable gain stage with CADCC_{ADC} and RBiasR_{Bias} (analysis p.8).ADC coupling (analysis p.9).Drawing: hardware/svg/gain_adc.svg.

Design targets

Av = 1 + Rf/Rin
1 to 101 V/V p.8
Rf
0 to 100 kΩ p.8

Components

Variable gain and ADC: component values from hardware/values.json, with the page of the analysis each comes from
ComponentValueRole in the circuitPage
S5.RinRin1 kΩNode A (inverting input) to groundp.8
S5.RfRf0 to 100 kΩFeedback potentiometer, output to node A; Rf = [0, 100k]p.8
ADC.C_ADCCADC1 µFCoupling capacitor from the variable gain output to the PCM1808 analog inputp.8, p.9
ADC.R_BiasRBias100 kΩResistor from the PCM1808 analog input to the PCM1808 Vrefp.8, p.9

Parts

S5.U1Variable gain op-amp
OPA2141 or OPA4141 p.9
ADC.PCM1808ADC; analog input pin and Vref
PCM1808 p.8, p.9

Derivation

On a narrow screen, scroll an equation sideways to see all of it.

VA=Vi  →  ViRin+Vi−VoRf=0Vi (Rf+Rin)RfRin=VoRfVoVi=Rf+RinRin=1+RfRin=Av\begin{align*}V_A = V_i \;\to\; \frac{V_i}{R_{in}} + \frac{V_i - V_o}{R_f} &= 0 \\[4pt] \frac{V_i\,(R_f + R_{in})}{R_f R_{in}} &= \frac{V_o}{R_f} \\[4pt] \frac{V_o}{V_i} = \frac{R_f + R_{in}}{R_{in}} = 1 + \frac{R_f}{R_{in}} &= A_v\end{align*}

Let Rin=1 kΩ  →  Rf=[0,100 kΩ]R_{in} = 1\,\mathrm{k}\Omega \;\to\; R_f = [0, 100\,\mathrm{k}\Omega]

∴  Av=[1,101]\therefore\; A_v = [1, 101]

ADC

PCM1808.

CADC=1 μFRBias=100 kΩ\begin{align*}C_{ADC} &= 1\,\mu\mathrm{F} \\ R_{Bias} &= 100\,\mathrm{k}\Omega\end{align*}

FIG. 13 · ADC coupling · gain against frequency

1–2000 Hz

-10-8-6-4-20241101001000Frequency (Hz, log scale)Gain (dB)

Point at the chart, or focus it and use the arrow keys, to read the gain at one frequency.

Gain of the ADC coupling in dB on a log frequency axis, computed from the design (hardware/response.json, ideal op-amps). It is a calculation, not a measurement. It is the response of the coupling capacitor and the bias resistor into the PCM1808 analog input. The variable-gain stage itself is flat, so its settings, listed above, do not change the shape of this curve.

Whole chain · Response

The gain of the whole chain.

The gain from the voltage of microphone MH, with MNC at zero, through every stage to the PCM1808 analog input, for each setting of the variable gain.

FIG. 14 · Whole chain · gain against frequency

1–2000 Hz

Variable gain setting
-40-200204060801001101001000Av = 1Av = 11Av = 51Av = 101Frequency (Hz, log scale)Gain (dB)

Point at the chart, or focus it and use the arrow keys, to read the gain at one frequency.

Gain in dB of the whole front end on a log frequency axis, computed from the design (hardware/response.json, ideal op-amps). It is a calculation, not a measurement.The variable-gain stage is flat, so each setting moves the whole curve up or down.
Show the numbers as a table
Gain in dB of each stage and of the whole chain at selected frequencies, computed from the design
FrequencyInput couplingInstrumentation amplifierHigh-passLow-passNotchADC couplingWhole chain, Av = 1Whole chain, Av = 11Whole chain, Av = 51Whole chain, Av = 101
1 Hz-20.646.1-52.00.00.0-5.5-32.1-11.22.18.0
5 Hz-7.646.1-24.10.00.0-0.414.034.848.154.0
10 Hz-3.646.1-12.30.0-0.1-0.129.950.864.170.0
20 Hz-1.546.1-3.00.0-0.60.040.961.775.181.0
60 Hz-0.746.1-0.10.0-33.40.011.932.746.052.0
100 Hz-0.646.10.00.0-2.70.042.863.676.982.8
500 Hz-0.646.10.0-3.0-0.10.042.463.376.682.5
600 Hz-0.646.10.0-4.90.00.040.661.474.780.7
1000 Hz-0.646.10.0-12.30.00.033.254.067.373.3
2000 Hz-0.646.10.0-24.10.00.021.442.355.661.5

Parts · Components and power

Components and power.

The op-amps and converter named for each stage, the inverted supply rail, and every component value in one place.

Parts by stage (analysis p.9):

Parts of each stage, from the analysis
StagePartFunction
Stage 2OPA2141 or OPA4141→\toIn Amp
Stage 3OPA4141 or OPA4197→\toBP Filter
Stage 4Same as Stage 3→\toT-Notch Filter
Stage 5Same as Stage 2→\toVariable Gain

ADC: PCM1808.

To produce the inverted rail add low noise charge pump inverter: TC7660H or LM27762.

Component values as given in the analysis:

Every component value of the front end, grouped by stage, from hardware/values.json
ComponentValuePage
Stage 1 · Input stage
S1.RL_NCRL (MNC)1 kΩp.1
S1.RL_HRL (MH)1 kΩp.1
S1.CL_NCCL (MNC)1 µFp.1
S1.CL_HCL (MH)1 µFp.1
S1.Rin_NCRin (MNC)14915.49 Ω (about 15 kΩ)p.2
S1.Rin_HRin (MH)14915.49 Ω (about 15 kΩ)p.2
Stage 2 · Instrumentation amplifier
S2.R1R1100 Ωp.3
S2.R2R210 kΩp.3
S2.R3R310 kΩp.3
S2.R4R4R4 = R5 = R6 = R7p.4
S2.R5R5R4 = R5 = R6 = R7p.4
S2.R6R6R4 = R5 = R6 = R7p.4
S2.R7R7R4 = R5 = R6 = R7p.4
Stage 3 · Band-pass filter (high-pass and low-pass Sallen-Key)
S3a.C1C11 µFp.5
S3a.C2C21 µFp.5
S3a.R1R15.628 kΩp.5
S3a.R2R211.252 kΩp.5
S3b.R1R122.508 kΩp.6
S3b.R2R222.508 kΩp.6
S3b.C1C110 nFp.6
S3b.C2C220 nFp.6
Stage 4 · Notch filter
S4.R1R112.1 kΩp.7
S4.R2R212.1 kΩp.7
S4.R3R310 kΩp.7
S4.R4R424.3 kΩp.7
S4.R5R510 kΩp.7
S4.R6R610 kΩp.7
S4.C1C10.22 µFp.7
S4.C2C20.22 µFp.7
Stage 5 · Variable gain stage
S5.RinRin1 kΩp.8
S5.RfRf0 to 100 kΩp.8
Stage ADC · ADC interface
ADC.C_ADCCADC1 µFp.8, p.9
ADC.R_BiasRBias100 kΩp.8, p.9

01 · The software at a glance

From samples to a decision.

The software is one chain of small steps. Each has one job and hands its result to the next. The answer is binary: murmur present or murmur absent, with a confidence.

Software design and implementation by Luca Mazzo.

FIG. 1 · The software, step by step

Runs on the Pi

  1. 01Recordinga file now, the microphone later
  2. 025 s windowsseveral heartbeats each
  3. 03Keep 20–500 Hzthe heart-sound band
  4. 04MFCC featuresa summary of the spectrum
  5. 05Classifiera random forest (scikit-learn)
  6. 06Present or absentwith a confidence
The six steps from a recording to an answer. The sections below take them one at a time.
Answer
murmur present or absent
Segmentation
implicit: 5 s windows, no S1/S2 finder
Features
MFCC, mean and standard deviation per window
Model
random forest, scikit-learn
Runs on
the Pi's CPU, no cloud, no network calls

02 · Acquisition

Samples in: a file or the ADC.

Everything starts as a stream of samples. In review mode the software reads a recording from a .wav file (WavFileSource). In live mode it reads blocks of samples from aBlockSource. On the Pi, AlsaCaptureSource (pcg/capture.py) reads the PCM1808 through the Pi's I2S input with arecord at 48 kHz and decimates it to 4 kHz. FileReplaySource replays .wav files in real time, so the live display can also run with no hardware attached.

The recordings are from the CirCor DigiScope dataset, stored as .wav files at 4 kHz. The capture source and the file replay implement the same BlockSource interface, so nothing above it changes. If the ADC is missing or delivers no signal, the display says so and nothing is classified.

File replay · runs today

Capture from the ADC · software written and tested, not yet run against the wired ADC

03 · Windows, band-limit, normalise

Five-second windows, one band, one loudness.

The samples are cut into 5 s windows, a new window every 2.5 s: long enough to hold several heartbeats. There is no S1/S2 finder. The model sees the repeating pattern of beats inside the window, so nobody has to find the heart sounds for it first.

Each window is then band-limited to 20–500 Hz and divided by its own Root mean square: the average loudness of the window, so a quiet and a loud recording look alike to the model. level. The order matters: the filter comes first, so the loudness is measured on the band the model actually uses. The same code does this for the offline baseline and for the live path, so the classifier always receives the same kind of window.

FIG. 2 · 9979_TV.wav · tricuspid · one 5 s window

Point at the plot, or focus it and use the arrow keys (Shift for 100 ms steps).

Murmur, holosystolic, grade III/VI (dataset label). Drawn by plot.js: it draws the axes and the trace, and the S1/S2 ticks and hatched murmur bands are laid over the layout it returns. Time in seconds from the start of the file; amplitude in file units (full scale ±1). Test split, held out. CirCor DigiScope, PhysioNet 2022, ODC-By 1.0.

04 · MFCC features

A window becomes a short list of numbers.

From each window the software computes Mel-frequency cepstral coefficients: a short list of numbers that describe the shape of a sound's spectrum., a compact description of how the window's energy is spread across frequency over time. The settings are chosen, not the library defaults: the mel bands cover only 20–500 Hz instead of 0 Hz up to the Nyquist frequency. The mel scale is almost a straight line below 1 kHz, so MFCCs are used here because they compress and decorrelate the spectrum, not for the mel warping.

A window becomes 26 numbers: for each of the 13 coefficients, its mean and its standard deviation over the window. The frames are 32 ms long, 16 ms apart. One piece of code, pcg/features.py, makes these numbers for training, for the offline baseline and for the live view.

05 · The classifier

Numbers in, a vote share out.

A random forest (scikit-learn) takes each window's 26 numbers and decides. Every tree in the forest votes "murmur" or "no murmur", and the share of trees voting murmur is the window's score; the confidence shown is the share that agrees with the chosen label. A recording's decision is the mean of its windows' values compared with one threshold, 0.32, fixed from the training data and never tuned for the live result.

It was chosen by cross-validation grouped by child, so a child never appears on both sides of a split. A random forest runs cheaply on the Pi and is easy to explain: the trees vote and the votes are counted. How it was trained and how well it works are on the Data & AI page.

06 · The HMI layers

Small layers, fixed interfaces.

The code is split into layers that talk through small interfaces. That is what lets the data source change from a file to live hardware without touching the rest.

FIG. 3 · The software layers

Data flows downward

  1. Sources

    pcg/sources.py, pcg/stream.py, pcg/capture.py

    Where samples come from: a .wav file, a file replay, or the PCM1808 ADC through AlsaCaptureSource, all behind the same BlockSource interface.

  2. Features

    pcg/features.py

    The only feature path: windows, band-limit to 20–500 Hz, divide by loudness, MFCCs, then the mean and standard deviation of each per window.

  3. Model

    pcg/model.py, pcg/classify.py

    A trained random forest, whose share of trees voting murmur is the window's score (confidence is the share agreeing with the chosen label), and the rule that turns window results into one decision per recording.

  4. JSON API

    hmi/app.py

    A small Flask server on the Pi. It calls the layers above and sends the results as JSON; it does no signal maths of its own.

  5. Controller and renderer

    hmi/static/hmi.js, hmi/static/plot.js

    The browser side: the controller fetches and keeps the page state, the renderer only draws the waveform on a canvas.

Solid left rule: the layer exists today.

On the Raspberry Pi

The instrument's own display. The Flask server also serves the monitor page, so it works with no internet connection. In the browser a controller (hmi.js) fetches a window of samples and fills in the readouts, and the renderer (plot.js) draws the waveform on a canvas. plot.js has not changed since the midterm.

This public site

A static site built from the same exported data, drawing its traces with the same unchanged plot.js. Its Live monitor link opens the Pi's own display at live.eecsyorku.app; when the Pi is off or cannot be reached, a page at /pi-offline says so plainly.

A swappable source

Review mode reads a file. Live mode reads blocks of samples from a BlockSource. AlsaCaptureSource reads the PCM1808 on the Pi, and FileReplaySource replays .wav files in real time for demos. Both implement the same interface, so nothing above them changes.

One feature path

The same feature code serves training, the offline baseline and the live view. That keeps the comparison fair: the only thing that differs is where the audio comes from.

07 · The experiment

Same files, same model, same threshold: live against offline.

The bench set is one recording from each of 160 held-out children, 80 with a murmur and 80 without. Each file is played through the hardware and classified live, and the result is compared with the model's offline score on the same files. The decision threshold is 0.32, fixed from the training data and never tuned for the live result.

Offline baseline · software, from training

The reference number

The model's score on the held-out files, worked out in software during training. It is a number, not something the sound passes through, so it shows what the model can do on these files before any hardware is involved. Any drop in the live result comes from what the sound passes through on the way.

Through the hardware · live

The headline result

Each held-out file is played, one at a time, through a loudspeaker in a 3D-printed coupler and a cast silicone layer, picked up by the microphone, passed through the analog front end and digitised (the circuit is on the Hardware tab), then read by the Raspberry Pi and classified live. The result is compared with the offline baseline on the same files, to show how much accuracy survives the real chain. It needs the hardware, so it is not measured yet.

Simulated bandpass

A software model

A software model of a 20–500 Hz bandpass filter applied to the same files. It shows how much of any loss a filter's nominal response alone could explain. It is a model, not a measurement, and never a result through the hardware.

What is measured

Accuracy
The share of recordings the classifier got right.
Sensitivity
Of the recordings with a murmur, the share it flagged as murmur present.
Specificity
Of the recordings without a murmur, the share it cleared as absent.
ROC AUC
How well the model's score ranks murmur recordings above normal ones, whatever threshold is used. 1 is perfect and 0.5 is chance.

To tell whether a change between two results on the same files is real and not luck, the files are paired and each class is tested separately with an exact Compares two results on the same files by looking only at the files whose decision changed, and asking whether the changes lean one way more than chance would., which looks only at the files where the two results disagree. The two p-values are adjusted with the Holm method.

Offline baseline · software, from training

The model's score on the held-out files.

ROC AUC1 is perfect · 0.5 is chance
0.724160 recordings
SensitivityMurmurs flagged
0.7195% CI 0.61–0.80 · 57 of 80
SpecificityNo-murmur recordings cleared
0.6895% CI 0.57–0.77 · 54 of 80
AccuracyShare of recordings classified right
0.6995% CI 0.62–0.76 · 111 of 160
Confusion matrixTrue class against the model's answer
Confusion matrix, offline baseline, bench set
Predicted murmurPredicted absent
Murmur, 8057found23missed
Absent, 8026false alarm54cleared

Through the hardware · live

The same files, played and classified live.

Hardware pending

Not measured

Needs the speaker, coupler, silicone, microphone, front end and ADC.

Source · results/injected__bench.jsonBench set, n = 160, one recording per held-out childWilson 95% intervalsThreshold 0.32, fixed from training, never tuned for the live result

A third run, simulated bandpass, applies a software filter to the files. It is not the hardware, so it is always labelled simulated and never merged into this comparison. Its rows are on the Data & AI page.

08 · Where to look in the code

Where to look in the code.

pcg/sources.py, pcg/stream.py
Where samples come from: WavFileSource, the BlockSource interface, FileReplaySource and the LiveMonitor.
pcg/capture.py
AlsaCaptureSource: reads the PCM1808 through the Pi's I2S input with arecord and decimates it to the model's 4 kHz.
pcg/features.py
The one feature path: windows, band-limit, normalise, MFCCs and their mean and standard deviation per window.
pcg/model.py, pcg/classify.py, pcg/train.py
The classifier, what its answer looks like, and how it is trained.
pcg/evaluate.py
Scores the model on the bench set, offline and through the hardware, and compares the two.
pcg/simulate_chain.py
The simulated bandpass: a software model of the filter.
hmi/app.py
The Flask server on the Pi and its JSON routes.
hmi/static/plot.js
The renderer: draws one window of samples. Unchanged since the midterm.
hmi/export_web.py
Writes the data files this site is built from.

09 · What the colours mean

Every colour means one thing, everywhere.

The same six marks are used on every page, so you only have to learn them once.
  • Teal trace

    The file's own signal, and the offline baseline: the model's score in software, from training.

  • Slate trace

    Not heard yet: the part of a recording that playback has not reached.

  • Murmur absent

    An outlined teal circle, always with the words "Murmur absent".

  • Murmur present

    A coral triangle with the words "Murmur present". A 45 degree hatch marks the murmur bands the dataset labels in time.

  • Violet, dashed

    Not measured, planned, awaiting parts or an example: never a number.

  • Amber

    Through the hardware, live: always with the words "Through the hardware" or a hardware name.