Alvas.Audio Class Library

AudioCompressionManager.Convert Method (IntPtr, IntPtr, Byte[], Boolean)

Converts the audio data from the specified old format to the new format.

[Visual Basic]
Overloads Public Shared Function Convert( _
   ByVal oldFormat As IntPtr, _
   ByVal newFormat As IntPtr, _
   ByVal data As Byte(), _
   ByVal fastConversion As Boolean _
) As Byte()
[C#]
public static byte[] Convert(
   IntPtr oldFormat,
   IntPtr newFormat,
   Byte[] data,
   Boolean fastConversion
);

Parameters

oldFormat
Old audio format.
newFormat
New audio format. Use ChooseCompatibleFormat or GetCompatibleFormatList or GetCompatibleFormat for search compatible format
data
The audio data.
fastConversion
true if the conversion is fast; otherwise, the conversion is high-quality.

Return Value

Returns the audio data in the new format.

Example

This example shows simple using of Convert method.

Mp3Reader mr = new Mp3Reader(File.OpenRead("in.mp3"));
IntPtr formatMp3 = mr.ReadFormat();
byte[] dataMp3 = mr.ReadData();
mr.Close();
IntPtr formatPcm = AudioCompressionManager.GetCompatibleFormat(formatMp3,
    AudioCompressionManager.PcmFormatTag);
byte[] dataPcm = AudioCompressionManager.Convert(formatMp3, formatPcm, dataMp3, false);
WaveWriter ww = new WaveWriter(File.Create("out.wav"),
    AudioCompressionManager.FormatBytes(formatPcm));
ww.WriteData(dataPcm);
ww.Close();
 

See Also

AudioCompressionManager Class | Alvas.Audio Namespace | AudioCompressionManager.Convert Overload List