Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Surround Sound Matrix Encoding and Decoding

This example shows how to generate a stereo signal from a multichannel audio signal using matrix encoding, and how to recover the original channels from the stereo mix using matrix decoding. This example has two flavors - one in Simulink and the other in MATLAB.

Introduction

Matrix decoding is an audio technique that decodes an audio signal with M channels into a audio signal with N channels (N > M) for play back on a system with N speakers. The original audio signal is usually generated using a matrix encoder, which transforms N-channel signals to M-channel signals.

Matrix encoding and decoding enables the same audio content to be played on different systems. For example, a surround sound multichannel signal may be encoded into a stereo signal. The stereo signal may be played back on a stereo system to accommodate settings where a surround sound receiver does not exist, or it may decoded and played as surround if surround equipment is present [1].

In this example, we showcase a matrix encoder used to encode a four-channel signal (left, right, center and surround) to a stereo signal. The four original signals are then regenerated using a matrix decoder. This example is a simplified version of the encoding and decoding scheme used in the Dolby Pro Logic system [2].

Simulink Version

The model audiomatrixdecoding implements the audio matrix encoding/decoding example.

The input to the matrix encoder consists of four separate audio channels (center, left, right and surround).

Double-click the Audio Channels subsystem to launch a tuning dialog. The dialog enables you to control the relative power between the right channel and left channel inputs, as well as the power level of the surround channel.

You can also toggle between listening to any of the original, encoded or decoded audio channels by double-clicking the Audio Player Selector subsystem and selecting the channel of your choice from the dialog drop down menu.

Matrix Encoder

The Matrix Encoder encodes the four input channels into a stereo signal.

Notice that since the input left and right channels only contribute to the output left and right channels, respectively, the output stereo signal conserves the balance between left and right channels.

The surround input channel is passed through a Hilbert transformer, thereby creating a 180 degree phase differential between the surround component feeding the left and right stereo outputs [2].

You may listen to the encoded left and right stereo signals by double-clicking the Audio Player Selector subsystem and selecting either the 'Encoded Total Left' or 'Encoded Total Right' channels.

Matrix Decoder

The Matrix Decoder extracts the four original channels from the encoded stereo signal.

The lowpass frequencies are first separated using a Linkwitz-Riley cross-over filter. For more information about the implementation of the Linkwitz-Riley filter, please refer to the Multiband Dynamic Range Compression example.

The left and right stereo channels are passed through to the left and right output channels, respectively. Therefore, there is no loss of separation between left and right channels in the output.

The center output channel is equal to the sum of the stereo input signals, thereby cancelling the phase-shifted surround left and right components.

The surround output channel is derived by first taking the difference of the stereo signals. Since the original input center signal contributes equally to both stereo channels, the center channel does not leak into the output surround signal. Moreover, note that the original left and right signals contribute to the output surround channel. The surround signal is delayed by 10 msec to achieve a precedence effect [3].

You may listen to the decoded surround signal by double-clicking the Audio Player Selector subsystem and selecting one of the decoded signals.

MATLAB Version

HelperAudioMatrixDecoderSim is the MATLAB function containing the audio matrix decoder example's implementation. It instantiates, initializes and steps through the objects forming the algorithm.

The function audioMatrixDecoderApp wraps around HelperAudioMatrixDecoderSim and iteratively calls it.

Execute audioMatrixDecoderApp to run the simulation. Note that the simulation runs for as long as the user does not explicitly stop it.

audioMatrixDecoderApp launches a UI designed to interact with the simulation. Similar to the Simulink version of the example, the UI allows you to tune the relative power between the right channel and left channel inputs, as well as the power level of the surround channel. You can also toggle between listening to any of the original, encoded or decoded audio channels by changing the value of the 'Audio Output' drop-down box in the UI.

There are also three buttons on the UI - the 'Reset' button will reset the simulation internal state to its initial condition and the 'Pause Simulation' button will hold the simulation until you press on it again. The simulation may be terminated by either closing the UI or by clicking on the 'Stop simulation' button.

MATLAB Coder can be used to generate C code for the function HelperAudioMatrixDecoderSim. In order to generate a MEX-file for your platform, execute the command HelperMatrixDecodingCodeGeneration from a folder with write permissions.

By calling the wrapper function audioMatrixDecoderApp with 'true' as an argument, the generated MEX-file can be used instead of HelperAudioMatrixDecoderSim for the simulation. In this scenario, the UI is still running inside the MATLAB environment, but the main processing algorithm is being performed by a MEX-file. Performance is improved in this mode without compromising the ability to tune parameters.

References

[1] http://en.wikipedia.org/wiki/Matrix_decoder

[2] Dolby Pro Logic Surround Decoder: Principles of Operation, Roger Dressler, Dolby Labs

[3] http://en.wikipedia.org/wiki/Precedence_effect

Was this topic helpful?