Skip to main content

ALAW/G.711 encoder

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 directionMedia typePins count
InputPCM1
Outputaudio/x-alaw1

The sample pipeline

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.