Alvas.Audio Class Library

AudioCompressionManager.ChangeVolume Method 

Changes the volume of audio data

[Visual Basic]
Public Shared Function ChangeVolume( _
   ByVal format As IntPtr, _
   ByVal data As Byte(), _
   ByVal persent As Integer _
) As Byte()
[C#]
public static byte[] ChangeVolume(
   IntPtr format,
   Byte[] data,
   Int32 persent
);

Parameters

format
audio format
data
audio data
persent
100 is normal volume, 50 is reduced by half, 200 is increased in 2 times

Return Value

Example

This example shows simple using of ChangeVolume method.

string inFile = @"in.mp3";
string outFile = @"out.mp3";
int persent = 50;
Mp3Reader mr = new Mp3Reader(File.OpenRead(inFile));
IntPtr format = mr.ReadFormat();
byte[] data = mr.ReadData();
mr.Close();
byte[] outData = AudioCompressionManager.ChangeVolume(format, data, persent);
Mp3Writer mw = new Mp3Writer(File.Create(outFile));
mw.WriteData(outData);
mw.Close();
 

See Also

AudioCompressionManager Class | Alvas.Audio Namespace