Urgent.News

What's breaking now, across thousands of outlets.

Tech

Detecting fake hi-res audio in the browser: a peak-hold FFT with the Web Audio API

The file header says 24-bit/96 kHz, but that only describes the container. If you want to know what is actually in the file, you have to look at the spectrum. I built a browser tool that does this for The Audio Stuff, the FLAC & Hi-Res Audio Checker . Here is how to build the core of one with the Web Audio API and a plain JavaScript FFT, with no server and no libraries. 1. Don't let…

Detecting fake high-resolution audio in a web browser requires understanding that the file header does not always accurately describe the contents. To analyze a file's true properties, it is necessary to examine its spectrum. The Audio Stuff has created a browser tool to perform this analysis called The FLAC & Hi-Res Audio Checker. This tool utilizes the Web Audio API and a plain JavaScript Fast Fourier Transform (FFT) without relying on any additional libraries or servers.

One common mistake is allowing the decodeAudioData() function to resample the audio file. This function defaults to sampling the decoded audio at the context's sample rate, which is typically 44.1 or 48 kHz. Consequently, a genuine 96 kHz file would be sampled at 48 kHz, losing all data above 24 kHz before analysis can begin. To prevent this, the sample rate must be read from the file header first, then decoded using an OfflineAudioContext at the correct rate.

To read the sample rate, a function called readSampleRate() is provided. This function takes the bytes of the file as input and checks for different file types such as FLAC and WAV, extracting the sample rate from the appropriate byte positions. If the file type is not recognized or the rate is unsupported, a default sample rate of 48000 Hz is used.

Once the correct sample rate is determined, the decodeNative() function can be used to decode the audio file. This function first converts the file bytes into an ArrayBuffer, then attempts to create an OfflineAudioContext with the determined sample rate. If this fails, it falls back to using a default OfflineAudioContext with a 48000 Hz sample rate. The decoded audio is then returned, allowing for further analysis.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

TIL: How to Read GBase Database Package Names Before Installation

A package filename can tell you more than the database version. When deploying GBase Database(GBase 8a), it can also indicate the target CPU architecture, operating system family, and Python runtime.

  • Package filename reveals CPU architecture, OS family, Python runtime
  • Extract CPU architecture from filename segment (e.g., aarch64)
  • Verify OS identity and kernel using uname -m and uname -r commands

Shared household expenses without merging anyone's bank login

Roommates, couples, and small teams hit the same awkward wall: everyone needs a shared picture of “what we spent,” but nobody wants to hand a budgeting app their bank password — or merge three…

  • Money Tracker app helps roommates track expenses separately
  • Users create distinct ledgers for different purposes
  • App operates without linking bank accounts or sharing passwords

More from Monday 26 October →