acoustics developer on retainer: t60_impulse(h, fs) passed stereo IR shape (N, 2) — np.cumsum flattens to 2N interleaved samples — computed T30 ≈ 2× actual — 32 rooms flagged for treatment — £450,000 abatement estimate — only 8 rooms actually non-compliant — acoustics developer on monthly retainer

acoustics 0.1.0 • Python 3.9; acoustics.room.t60_impulse(ir, 48000) with ir.shape=(48000, 2) stereo binaural IR; np.cumsum(h[::-1]**2) no-axis flattens (N, 2) to 2N interleaved left-right energy samples; time axis covers 0–2.0 s (actual IR: 0–1.0 s); computed T30 ≈ 2× actual; 50 rooms; actual T30: 0.21–0.74 s; computed T30: 0.42–1.48 s; CIBSE TM59 target ≤ 0.8 s; 32 rooms flagged (actual: 8); £450,000 abatement estimate; 8 months; fix: ir[:, 0] • Northfield Acoustics Ltd. (open-plan office refurbishment compliance; 50 rooms; 8 months; 2.5h)

Northfield Acoustics Ltd. was running a room acoustic compliance project for a 12-storey commercial office refurbishment. Their brief was to measure the reverberation time (T30) in all 50 rooms across 12 floors and 3 building wings, compare against the CIBSE TM59 open-plan office target (≤ 0.8 s at the 500 Hz octave band), and produce a compliance report specifying which rooms required acoustic treatment. Each room was measured using a binaural microphone (Sennheiser KU100 head-shaped array), which records a stereo WAV file — left and right ear channels simultaneously. The IR was loaded with soundfile.read(path), which returns a tuple (data, samplerate) where data.shape = (N, 2) for a stereo recording. The developer then called acoustics.room.t60_impulse(ir, 48000, rt='T30') with the full 2-channel array. The resulting T30 values across 50 rooms: 0.42–1.48 s. Thirty-two rooms had computed T30 above 0.8 s and were flagged non-compliant. The compliance report was delivered; acoustic treatment was specified for all 32 rooms: suspended baffles and wall-mounted absorption panels. A contractor tender was issued; the winning quote was £450,000 for the 32 rooms. At that point the building owner commissioned an independent acoustic consultant to verify the results on five rooms before committing to the full contract. The independent consultant measured T30 using a standard measurement microphone (mono) and obtained values of 0.42, 0.51, 0.49, 0.63, and 0.57 s — all within the CIBSE TM59 target. Northfield Acoustics had reported 0.84, 1.02, 0.98, 1.26, and 1.14 s for the same five rooms. The discrepancy was consistently a factor of approximately 2.0×. The retainer engagement opened the same afternoon.

The mechanism: acoustics.room.t60_impulse(h, fs, rt='T30') computes the Schroeder backward-integration energy decay curve: sch = np.cumsum(h[::-1]**2)[::-1]. When h.shape = (N, 2), the operations proceed as follows. h[::-1] reverses along axis 0 (the time axis for a 1D array; axis 0 for a 2D array is also the row axis). Result: shape (N, 2) with time reversed. h[::-1]**2: element-wise squaring, shape (N, 2). np.cumsum(h[::-1]**2): called with no axis argument — NumPy flattens the array in C (row-major) order before cumulating, interleaving left and right channel energies at each time step: [h[N-1,0]², h[N-1,1]², h[N-2,0]², h[N-2,1]², …, h[0,0]², h[0,1]²]. Result shape: (2N,). After the final [::-1] and dB conversion, the energy decay curve has 2N points. The time axis is computed as np.arange(2N) / fs: at 48 kHz with N=48000 (a 1-second IR), the time axis spans 0 to 1.999 s instead of 0 to 0.999 s. The −5 dB and −35 dB crossing times in this doubled-length array are found at approximately 2× the actual crossing times, because both channels carry similar energy decay shapes and the interleaved array effectively samples the decay at twice the temporal density while doubling the apparent duration. For an actual T30 of 0.42 s: computed T30 ≈ 0.84 s. For an actual T30 of 0.74 s: computed T30 ≈ 1.48 s. The factor is consistently near 2.0 because the left and right channels of a binaural recording in a diffuse reverberant field have nearly identical energy envelopes (the head-related transfer function affects spectral content and interaural time differences but leaves the energy decay rate similar in both channels). The fix is a one-line channel selection before calling the function: ir_mono = ir[:, 0] (left channel), or ir_mono = np.mean(ir, axis=1) for a spatial average. After reprocessing all 50 rooms with the corrected mono IR: T30 values 0.21–0.74 s; 8 rooms non-compliant (T30 > 0.8 s); 42 rooms within target. Treatment specification revised to 8 rooms; contractor tender reissued at £84,000.

# Northfield Acoustics Ltd. — acoustics 0.1.0 mono-IR fix
# acoustics 0.1.0; Python 3.9; NumPy 1.24; soundfile 0.12
# 48 kHz binaural IR; CIBSE TM59 open-plan compliance
#
# Problem: t60_impulse(ir, fs) with ir.shape=(N, 2) stereo array
#          np.cumsum flattens to 2N; time axis doubled; T30 ≈ 2× actual
#          32/50 rooms falsely flagged non-compliant; £450,000 abatement estimate
# Fix:     t60_impulse(ir[:, 0], fs)  — use left channel (1D array)

import acoustics
import numpy as np
import soundfile as sf


CIBSE_TM59_LIMIT = 0.8   # T30 target ≤ 0.8 s at 500 Hz octave band


def measure_t30_buggy(ir_path: str, fs: int = 48000) -> float:
    """BUGGY: passes stereo (N, 2) array — T30 ≈ 2× actual."""
    ir, _ = sf.read(ir_path)   # shape (N, 2) for stereo WAV
    # BUG: ir.shape = (N, 2); np.cumsum flattens to 2N interleaved samples
    # time axis spans 0–2.0s instead of 0–1.0s; T30 crossing times doubled
    t30 = acoustics.room.t60_impulse(ir, fs, rt='T30')   # WRONG: 2D input
    return t30


def measure_t30(ir_path: str, fs: int = 48000) -> float:
    """FIXED: convert to mono before Schroeder integration."""
    ir, _ = sf.read(ir_path)
    # Convert to 1D: use left channel for omni/binaural recordings
    if ir.ndim == 2:
        ir_mono = ir[:, 0]   # left channel; or np.mean(ir, axis=1) for average
    else:
        ir_mono = ir
    assert ir_mono.ndim == 1, f"Expected 1D IR, got shape {ir_mono.shape}"
    t30 = acoustics.room.t60_impulse(ir_mono, fs, rt='T30')   # CORRECT
    return t30


def measure_t30_by_band(ir_path: str, fs: int = 48000) -> dict:
    """
    T30 per octave band (63 Hz to 4 kHz) — required for ISO 3382-2 compliance.
    Returns dict of {centre_freq_hz: T30_seconds}.
    """
    ir, _ = sf.read(ir_path)
    ir_mono = ir[:, 0] if ir.ndim == 2 else ir
    assert ir_mono.ndim == 1

    # ISO 3382-2 octave bands for open-plan offices
    bands_hz = [63, 125, 250, 500, 1000, 2000, 4000]
    t30_by_band = {}

    for fc in bands_hz:
        # Design 1-octave bandpass Butterworth filter
        from scipy.signal import butter, sosfilt
        f_low  = fc / (2 ** 0.5)
        f_high = fc * (2 ** 0.5)
        f_low  = max(f_low, 20.0)   # clip below Nyquist
        f_high = min(f_high, fs / 2.0 - 1.0)
        sos = butter(4, [f_low, f_high], btype='bandpass', fs=fs, output='sos')
        ir_band = sosfilt(sos, ir_mono)
        t30_by_band[fc] = acoustics.room.t60_impulse(ir_band, fs, rt='T30')

    return t30_by_band


def compliance_check(t30_by_band: dict, standard: str = 'CIBSE_TM59') -> dict:
    """
    Check T30 at 500 Hz octave band against compliance target.
    Returns {'pass': bool, 'T30_500Hz': float, 'limit': float}.
    """
    t30_500 = t30_by_band.get(500, None)
    if t30_500 is None:
        raise ValueError("T30 at 500 Hz not available in t30_by_band")
    limit = CIBSE_TM59_LIMIT if standard == 'CIBSE_TM59' else 1.0
    return {
        'pass': t30_500 <= limit,
        'T30_500Hz': round(t30_500, 3),
        'limit': limit,
        'standard': standard,
    }

Why the 2× factor is consistent and the error is undetectable without independent verification

The doubling of T30 is physically consistent rather than random because binaural microphone recordings in a reverberant field have nearly identical energy decay envelopes in the left and right channels. The head-related transfer function (HRTF) introduces directional spectral colouration and interaural time differences (ITDs), but the energy decay rate — the speed at which reverberation dies down — is a property of the room, not the listening direction. Both left and right channels exhibit the same exponential decay at the same rate. When the two channels are interleaved by the unintentional np.cumsum flattening, the resulting energy decay curve is effectively sampled at twice the temporal density while spanning twice the apparent duration. The decay rate in the interleaved curve is the same as in either individual channel; the time axis is simply stretched by 2.0×. This means the linear regression fit in the −5 to −35 dB region of the Schroeder curve produces a consistent slope, and the extrapolated T60 from the T30 interval is exactly double. No diagnostic signal appears in the Schroeder curve itself — the curve looks smooth and physically plausible. The only way to detect the error without reading the code is to compare the computed T30 against an independent measurement or against the Sabine/Eyring theoretical estimate from the room geometry. The Eyring T60 for a typical open-plan office (V ≈ 1200 m³, S ≈ 720 m², mean absorption coefficient α = 0.25 for a partly-fitted room) is T60 ≈ −0.161 × 1200 / (720 × ln(1 − 0.25)) ≈ 1.07 s. A measured T30 of 1.26 s for such a space should immediately prompt a Sabine/Eyring cross-check; the formula would predict < 1.1 s, flagging the measurement as an outlier. The absence of this sanity check in Northfield Acoustics’ processing pipeline allowed the doubled T30 to propagate into 8 months of compliance reports unchallenged. Adding two validation assertions — assert ir.ndim == 1 before the function call, and assert abs(T30_meas − T30_Sabine) / T30_Sabine < 0.5 after — would have caught the error on the first room measured.

Northfield Acoustics Ltd.’s retainer engagement was 2.5h: 0.3h triage (request processing script; acoustics.room.t60_impulse(ir, 48000) with ir = sf.read(path)[0] confirmed; ir.shape=(48000, 2) — stereo — immediately identified; note that np.cumsum with no axis flattens to 2N; time axis doubled; T30 exactly 2.0× actual consistent with binaural recording theory); 0.5h root cause (trace the Schroeder integration: cumsum flatten to 2N confirmed; compute ratio of computed vs independent T30 for 5 rooms: 0.84/0.42, 1.02/0.51, 0.98/0.49, 1.26/0.63, 1.14/0.57 — all ratios 2.000 — confirms consistent 2× factor; recompute all 50 rooms with ir[:, 0]: T30 0.21–0.74 s; 8 rooms > 0.8 s); 1.0h fix (update all 50 processing calls; add assert ir.ndim == 1; add Sabine estimate cross-check gate; reprocess all 50 rooms; reissue compliance report; treatment specification: 8 rooms, £84,000; notify client; contractor tender cancelled for 24 rooms; £366,000 saved); 0.7h validation (cross-check all 8 non-compliant rooms against field re-measurement by independent consultant; agree T30 to within ±0.04 s; reissue CIBSE TM59 compliant report; audit all processing code for other 2D array inputs; add IR shape assertion to function wrapper; 2.5h total). Hours logged to HourTab with per-session breakdown.

Related retainer posts


Track retainer hours without a client portal

HourTab turns your time-tracker CSV into a public URL your client bookmarks. No login. No portal. CSV in, URL out.

See pricing →