DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
MidSide.h File Reference

Mid/Side stereo encoding and decoding for real-time audio. More...

#include "../Core/AudioBuffer.h"
#include <cassert>
Include dependency graph for MidSide.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  dspark::MidSide< T >
 Static utility for Mid/Side stereo encoding and decoding. More...
 

Namespaces

namespace  dspark
 Main namespace for the DSPark framework.
 

Detailed Description

Mid/Side stereo encoding and decoding for real-time audio.

Provides conversion between Left/Right and Mid/Side representations. Useful for stereo processing where independent control over the centre image (mid) and stereo width (side) is needed.

Convention: M = (L + R) / 2, S = (L - R) / 2 on encode; L = M + S, R = M - S on decode. The 0.5 lives on the encode side so a full-scale correlated (mono) signal cannot clip the mid channel; decode() is the exact algebraic inverse of encode(). The round trip is mathematically lossless; in floating point it is exact to within one rounding of the inner sums (bit-exact whenever l+r and l-r round exactly, e.g. silence or equal channels).

Threading: stateless and re-entrant; safe to call from any thread on disjoint buffers.

Dependencies: AudioBuffer.h only.

Definition in file MidSide.h.