# ALAW/G.711 encoder

Media Blocks SDK .Net

ALAW: A companding algorithm used primarily in voice communications, notably in telephone systems, that compresses audio data to reduce bandwidth usage while maintaining sound integrity.

ALAW/G.711 encoder is used to encode audio streams in ALAW format.

# Block info

Name: ALAWEncoderBlock.

Pin direction Media type Pins count
Input PCM 1
Output audio/x-alaw 1

# The sample pipeline

graph LR;
    UniversalSourceBlock-->ALAWEncoderBlock;
    ALAWEncoderBlock-->WAVSinkBlock;

# Sample code

var pipeline = new MediaBlocksPipeline();

var filename = "test.mp3";
var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(new Uri(filename)));

var alawEncoderBlock = new ALAWEncoderBlock();

pipeline.Connect(fileSource.AudioOutput, alawEncoderBlock.Input);

var wavSinkBlock = new WAVSinkBlock(@"output.wav");
pipeline.Connect(alawEncoderBlock.Output, wavSinkBlock.Input);

await pipeline.StartAsync();

# Platforms

Windows, macOS, Linux, iOS, Android.