PHPackages                             pforret/leqm-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. pforret/leqm-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

pforret/leqm-php
================

PHP Package to do audio measurement/correction with leqm/goqm

0.2.3(6mo ago)06PHPPHP ^8.1

Since Nov 19Pushed 6mo agoCompare

[ Source](https://github.com/pforret/leqm-php)[ Packagist](https://packagist.org/packages/pforret/leqm-php)[ RSS](/packages/pforret-leqm-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (9)Used By (0)

[![Static Badge](https://camo.githubusercontent.com/b99c0182d028865642c135927e23c9cc0fc8dd2a369f82444366be73cf405544/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312d626c7565)](https://camo.githubusercontent.com/b99c0182d028865642c135927e23c9cc0fc8dd2a369f82444366be73cf405544/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312d626c7565)[![GitHub Tag](https://camo.githubusercontent.com/870d05de10c45cbc414a6ac6e26880ff3176de9e375663e94773319af91432a7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f70666f727265742f6c65716d2d706870)](https://camo.githubusercontent.com/870d05de10c45cbc414a6ac6e26880ff3176de9e375663e94773319af91432a7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f70666f727265742f6c65716d2d706870)

pforret/leqm-php
================

[](#pforretleqm-php)

PHP library for LEQ(m) audio loudness measurement using the goqm binary.

Requirements
------------

[](#requirements)

- PHP 8.1+
- One of the supported platforms: macOS (Intel/ARM), Linux, or Windows

Installation
------------

[](#installation)

```
composer require pforret/leqm-php
```

The goqm binaries for all platforms are included in the package.

Usage
-----

[](#usage)

### Basic Measurement

[](#basic-measurement)

```
use Pforret\LeqmPhp\LeqmPhp;

$leqm = new LeqmPhp();
$result = $leqm->measure('/path/to/audio.wav');

echo "Leq(M): " . $result->getLeqM() . " dB\n";
echo "Duration: " . $result->getDuration() . " seconds\n";
```

### Accessing Measurements

[](#accessing-measurements)

The result is returned as a DTO with public properties:

```
$result = $leqm->measure('/path/to/audio.wav');

// Direct property access (recommended)
$result->measurements->leqM;           // Leq(M) weighted loudness in dB
$result->measurements->leqNoWeight;    // Unweighted Leq in dB
$result->measurements->meanPower;      // Mean power
$result->measurements->meanPowerWeighted;

$result->metadata->file;               // File path
$result->metadata->durationSeconds;    // Duration in seconds
$result->metadata->effectiveSampleRate; // Sample rate in Hz
$result->metadata->channels;           // Number of channels
$result->metadata->frames;             // Total frames

$result->channelStats[0]->peakDb;      // Peak dB for channel 0
$result->channelStats[0]->averageDb;   // Average dB for channel 0

$result->execution->executionSeconds;  // Processing time
$result->execution->binaryVersion;     // goqm version
$result->execution->speedIndex;        // Processing speed index

// Convenience getter methods also available
$result->getLeqM();
$result->getDuration();
$result->getChannelPeakDb(0);

// Serialization
$result->toArray();              // Full result as array
$result->toJson();               // Full result as JSON string
```

### Custom Binary Path

[](#custom-binary-path)

```
$leqm = new LeqmPhp('/custom/path/to/goqm');
$result = $leqm->measure('/path/to/audio.wav');
```

### Error Handling

[](#error-handling)

```
use Pforret\LeqmPhp\LeqmPhp;
use Pforret\LeqmPhp\Exceptions\BinaryNotFoundException;
use Pforret\LeqmPhp\Exceptions\MeasurementException;

try {
    $leqm = new LeqmPhp();
    $result = $leqm->measure('/path/to/audio.wav');
} catch (BinaryNotFoundException $e) {
    // Binary not found or not executable
    echo "Binary error: " . $e->getMessage();
} catch (MeasurementException $e) {
    // File not found or measurement failed
    echo "Measurement error: " . $e->getMessage();
}
```

Supported Audio Formats
-----------------------

[](#supported-audio-formats)

The goqm binary supports WAV files with various configurations:

- Sample rates: 44.1kHz, 48kHz, 96kHz, etc.
- Bit depths: 16-bit, 24-bit, 32-bit
- Channel layouts: Mono, Stereo, 5.1, 7.1

API Reference
-------------

[](#api-reference)

### LeqmPhp

[](#leqmphp)

MethodDescription`__construct(?string $binaryPath = null)`Create instance with optional custom binary path`measure(string $audioFile): LeqmResult`Measure audio file and return results`getBinaryPath(): string`Get the path to the goqm binary### LeqmResult (DTO)

[](#leqmresult-dto)

LeqmResult is a DTO with the following public properties:

PropertyTypeDescription`metadata``Metadata`File metadata`measurements``Measurements`Loudness measurements`channelStats``array`Per-channel statistics`execution``Execution`Execution info`referenceOffsetDb``float`Reference offset in dB### DTO Classes

[](#dto-classes)

#### Metadata

[](#metadata)

PropertyTypeDescription`file``string`Audio file path`originalSampleRate``int`Original sample rate in Hz`effectiveSampleRate``int`Effective sample rate in Hz`channels``int`Number of channels`frames``int`Total frames`durationSeconds``float`Duration in seconds#### Measurements

[](#measurements)

PropertyTypeDescription`leqM``float`Leq(M) weighted loudness in dB`leqNoWeight``float`Unweighted Leq in dB`meanPower``float`Mean power`meanPowerWeighted``float`Weighted mean power#### ChannelStat

[](#channelstat)

PropertyTypeDescription`channel``int`Channel index`peakDb``float`Peak level in dB`averageDb``float`Average level in dB#### Execution

[](#execution)

PropertyTypeDescription`binaryPath``string`Path to binary`binaryVersion``string`Binary version`executionSeconds``float`Processing time`speedIndex``float`Speed index`mbps``float`Megabytes per second### Exceptions

[](#exceptions)

- `LeqmException` - Base exception class
- `BinaryNotFoundException` - Binary not found or not executable
- `MeasurementException` - File not found or measurement failed

Testing
-------

[](#testing)

```
composer test
```

Code Style
----------

[](#code-style)

```
composer lint
```

About LEQ(m)
------------

[](#about-leqm)

LEQ(m) (Equivalent Continuous Sound Level with M-weighting) is a loudness measurement standard used in cinema and broadcast. It provides a single number representing the average loudness of audio content, weighted to match human hearing perception.

The goqm binary is a Go implementation of the LEQ(m) algorithm, providing JSON output with detailed measurements and channel statistics.

License
-------

[](#license)

MIT

Credits
-------

[](#credits)

- goqm binary from [pforret/leqm-nrt](https://github.com/pforret/leqm-nrt)
- Original leqm-nrt C code by Luca Trisciani

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance69

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

8

Last Release

181d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/474312?v=4)[Peter Forret](/maintainers/pforret)[@pforret](https://github.com/pforret)

---

Top Contributors

[![pforret](https://avatars.githubusercontent.com/u/474312?v=4)](https://github.com/pforret "pforret (18 commits)")

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/pforret-leqm-php/health.svg)

```
[![Health](https://phpackages.com/badges/pforret-leqm-php/health.svg)](https://phpackages.com/packages/pforret-leqm-php)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
