#
Audio processing and effect blocks
VisioForge Media Blocks SDK .Net includes a set of audio processing and effect blocks that allow you to create audio processing pipelines for your applications.
The blocks can be connected to each other to create a processing pipeline.
Most of the blocks are available for all platforms, including Windows, Linux, MacOS, Android, and iOS.
#
Processing blocks
#
Amplify
Block amplifies an audio stream by an amplification factor. Several clipping modes are available.
Use method and level values to configure.
#
Block info
Name: AmplifyBlock.
#
The sample pipeline
graph LR; UniversalSourceBlock-->AmplifyBlock; AmplifyBlock-->AudioRendererBlock;
#
Sample code
var pipeline = new MediaBlocksPipeline();
var filename = "test.mp3";
var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(new Uri(filename)));
var amplify = new AmplifyBlock(AmplifyClippingMethod.Normal, 2.0);
pipeline.Connect(fileSource.AudioOutput, amplify.Input);
var audioRenderer = new AudioRendererBlock();
pipeline.Connect(amplify.Output, audioRenderer.Input);
await pipeline.StartAsync();
#
Platforms
Windows, macOS, Linux, iOS, Android.
#
Audio mixer
The audio mixer block mixes multiple audio streams into one. Block mixes the streams regardless of their format, converting if necessary.
All input streams will be synchronized.
Use the AudioMixerSettings
class to set the custom output format.
#
Block info
Name: AudioMixerBlock.
#
The sample pipeline
graph LR; VirtualAudioSourceBlock#1-->AudioMixerBlock; VirtualAudioSourceBlock#2-->AudioMixerBlock; AudioMixerBlock-->VorbisEncoderBlock; VorbisEncoderBlock-->OGGSinkBlock;
#
Sample code
var pipeline = new MediaBlocksPipeline();
var audioSource1Block = new VirtualAudioSourceBlock(new VirtualAudioSourceSettings());
var audioSource2Block = new VirtualAudioSourceBlock(new VirtualAudioSourceSettings());
var audioMixerBlock = new AudioMixerBlock(new AudioMixerSettings());
pipeline.Connect(audioSource1Block.Output, audioMixerBlock.CreateNewInput());
pipeline.Connect(audioSource2Block.Output, audioMixerBlock.CreateNewInput());
var vorbisEncoderBlock = new VorbisEncoderBlock(new VorbisEncoderSettings());
pipeline.Connect(audioMixerBlock.Output, vorbisEncoderBlock.Input);
var oggSinkBlock = new OGGSinkBlock(new OGGSinkSettings(@"output.ogg"));
pipeline.Connect(vorbisEncoderBlock.Output, oggSinkBlock.CreateNewInput(MediaBlockPadMediaType.Audio));
await pipeline.StartAsync();
#
Platforms
Windows, macOS, Linux, iOS, Android.
#
Audio sample grabber
The audio sample grabber block allows you to access the raw audio samples from the audio stream.
#
Block info
Name: AudioSampleGrabberBlock.
#
The sample pipeline
graph LR; UniversalSourceBlock-->AudioSampleGrabberBlock; AudioSampleGrabberBlock-->AudioRendererBlock;
#
Sample code
var pipeline = new MediaBlocksPipeline();
var filename = "test.mp3";
var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(new Uri(filename)));
var audioSampleGrabber = new AudioSampleGrabberBlock();
audioSampleGrabber.SampleGrabbed += (sender, args) =>
{
// Process audio samples
// args.AudioData - audio samples
// args.AudioFormat - audio format
};
pipeline.Connect(fileSource.AudioOutput, audioSampleGrabber.Input);
var audioRenderer = new AudioRendererBlock();
pipeline.Connect(audioSampleGrabber.Output, audioRenderer.Input);
await pipeline.StartAsync();
#
Platforms
Windows, macOS, Linux, iOS, Android.
#
Balance
Block allows you to control the balance between left and right channels.
#
Block info
Name: AudioBalanceBlock.
#
The sample pipeline
graph LR; UniversalSourceBlock-->AudioBalanceBlock; AudioBalanceBlock-->AudioRendererBlock;
#
Sample code
var pipeline = new MediaBlocksPipeline();
var filename = "test.mp3";
var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(new Uri(filename)));
// Balance: -1.0 (full left) to 1.0 (full right), 0.0 - center
var balance = new AudioBalanceBlock(0.5);
pipeline.Connect(fileSource.AudioOutput, balance.Input);
var audioRenderer = new AudioRendererBlock();
pipeline.Connect(balance.Output, audioRenderer.Input);
await pipeline.StartAsync();
#
Platforms
Windows, macOS, Linux, iOS, Android.
#
Compressor/Expander
The compressor/expander block provides dynamic range compression or expansion.
#
Block info
Name: CompressorExpanderBlock.
#
The sample pipeline
graph LR; UniversalSourceBlock-->CompressorExpanderBlock; CompressorExpanderBlock-->AudioRendererBlock;
#
Sample code
var pipeline = new MediaBlocksPipeline();
var filename = "test.mp3";
var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(new Uri(filename)));
var compressor = new CompressorExpanderBlock(0.5, 0.9, 0.1, 0.5);
pipeline.Connect(fileSource.AudioOutput, compressor.Input);
var audioRenderer = new AudioRendererBlock();
pipeline.Connect(compressor.Output, audioRenderer.Input);
await pipeline.StartAsync();
#
Platforms
Windows, macOS, Linux, iOS, Android.
#
Echo
The echo block adds echo effect to the audio stream.
#
Block info
Name: EchoBlock.
#
The sample pipeline
graph LR; UniversalSourceBlock-->EchoBlock; EchoBlock-->AudioRendererBlock;
#
Sample code
var pipeline = new MediaBlocksPipeline();
var filename = "test.mp3";
var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(new Uri(filename)));
// Delay in ms, strength 0.0 - 1.0
var echo = new EchoBlock(500, 0.5);
pipeline.Connect(fileSource.AudioOutput, echo.Input);
var audioRenderer = new AudioRendererBlock();
pipeline.Connect(echo.Output, audioRenderer.Input);
await pipeline.StartAsync();
#
Platforms
Windows, macOS, Linux, iOS, Android.
#
Equalizer (10 bands)
The 10-band equalizer block provides a 10-band equalizer for audio processing.
#
Block info
Name: Equalizer10Block.
#
The sample pipeline
graph LR; UniversalSourceBlock-->Equalizer10Block; Equalizer10Block-->AudioRendererBlock;
#
Sample code
var pipeline = new MediaBlocksPipeline();
var filename = "test.mp3";
var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(new Uri(filename)));
// Create 10-band equalizer with all bands set to 0 dB
var equalizer = new Equalizer10Block(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
// Or set bands individually
equalizer.SetBand(0, 3); // Band 0 (31 Hz) to +3 dB
equalizer.SetBand(1, 2); // Band 1 (62 Hz) to +2 dB
equalizer.SetBand(9, -3); // Band 9 (16 kHz) to -3 dB
pipeline.Connect(fileSource.AudioOutput, equalizer.Input);
var audioRenderer = new AudioRendererBlock();
pipeline.Connect(equalizer.Output, audioRenderer.Input);
await pipeline.StartAsync();
#
Platforms
Windows, macOS, Linux, iOS, Android.
#
Equalizer (Parametric)
The parametric equalizer block provides a parametric equalizer for audio processing.
#
Block info
Name: EqualizerParametricBlock.
#
The sample pipeline
graph LR; UniversalSourceBlock-->EqualizerParametricBlock; EqualizerParametricBlock-->AudioRendererBlock;
#
Sample code
var pipeline = new MediaBlocksPipeline();
var filename = "test.mp3";
var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(new Uri(filename)));
// Create parametric equalizer
var equalizer = new EqualizerParametricBlock();
// Set up to 4 bands
equalizer.SetBand(0, 100, 1.0, 3); // Band 0: 100 Hz frequency, 1.0 Q, +3 dB gain
equalizer.SetBand(1, 1000, 1.5, -2); // Band 1: 1000 Hz frequency, 1.5 Q, -2 dB gain
pipeline.Connect(fileSource.AudioOutput, equalizer.Input);
var audioRenderer = new AudioRendererBlock();
pipeline.Connect(equalizer.Output, audioRenderer.Input);
await pipeline.StartAsync();
#
Platforms
Windows, macOS, Linux, iOS, Android.
#
Scale/Tempo
The scale/tempo block allows you to change the tempo and pitch of the audio stream.
#
Block info
Name: ScaleTempoBlock.
#
The sample pipeline
graph LR; UniversalSourceBlock-->ScaleTempoBlock; ScaleTempoBlock-->AudioRendererBlock;
#
Sample code
var pipeline = new MediaBlocksPipeline();
var filename = "test.mp3";
var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(new Uri(filename)));
// Scale tempo by factor (1.0 is normal, 0.5 is half-speed, 2.0 is double-speed)
var scaleTempo = new ScaleTempoBlock(1.5);
pipeline.Connect(fileSource.AudioOutput, scaleTempo.Input);
var audioRenderer = new AudioRendererBlock();
pipeline.Connect(scaleTempo.Output, audioRenderer.Input);
await pipeline.StartAsync();
#
Platforms
Windows, macOS, Linux, iOS, Android.
#
Volume
The volume block allows you to control the volume of the audio stream.
#
Block info
Name: VolumeBlock.
#
The sample pipeline
graph LR; UniversalSourceBlock-->VolumeBlock; VolumeBlock-->AudioRendererBlock;
#
Sample code
var pipeline = new MediaBlocksPipeline();
var filename = "test.mp3";
var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(new Uri(filename)));
// Volume: 0.0 (silence) to 1.0 (normal) or higher (amplification)
var volume = new VolumeBlock(0.8);
pipeline.Connect(fileSource.AudioOutput, volume.Input);
var audioRenderer = new AudioRendererBlock();
pipeline.Connect(volume.Output, audioRenderer.Input);
await pipeline.StartAsync();
#
Platforms
Windows, macOS, Linux, iOS, Android.
#
Volume meter and analyzing blocks
#
VU Meter
The VU meter block allows you to measure the volume level of the audio stream.
#
Block info
Name: VUMeterBlock.
#
The sample pipeline
graph LR; UniversalSourceBlock-->VUMeterBlock; VUMeterBlock-->AudioRendererBlock;
#
Sample code
var pipeline = new MediaBlocksPipeline();
var filename = "test.mp3";
var fileSource = new UniversalSourceBlock(await UniversalSourceSettings.CreateAsync(new Uri(filename)));
var vuMeter = new VUMeterBlock();
vuMeter.VolumeUpdated += (sender, args) =>
{
// Left channel volume in dB
var leftVolume = args.LeftVolume;
// Right channel volume in dB
var rightVolume = args.RightVolume;
Console.WriteLine($"Left: {leftVolume:F2} dB, Right: {rightVolume:F2} dB");
};
pipeline.Connect(fileSource.AudioOutput, vuMeter.Input);
var audioRenderer = new AudioRendererBlock();
pipeline.Connect(vuMeter.Output, audioRenderer.Input);
await pipeline.StartAsync();
#
Platforms
Windows, macOS, Linux, iOS, Android.