Click or drag to resize
VoxRaw2Vox Method
Encode raw PCM-data to Dialogic .vox (adpcm) format data

Namespace: Alvas.Audio
Assembly: Alvas.Audio (in Alvas.Audio.dll) Version: 2016.0.6173.41573
Syntax
public static void Raw2Vox(
	BinaryReader br,
	BinaryWriter bw,
	short bitsPerSample
)

Parameters

br
Type: System.IOBinaryReader

[Missing <param name="br"/> documentation for "M:Alvas.Audio.Vox.Raw2Vox(System.IO.BinaryReader,System.IO.BinaryWriter,System.Int16)"]

bw
Type: System.IOBinaryWriter

[Missing <param name="bw"/> documentation for "M:Alvas.Audio.Vox.Raw2Vox(System.IO.BinaryReader,System.IO.BinaryWriter,System.Int16)"]

bitsPerSample
Type: SystemInt16

[Missing <param name="bitsPerSample"/> documentation for "M:Alvas.Audio.Vox.Raw2Vox(System.IO.BinaryReader,System.IO.BinaryWriter,System.Int16)"]

Examples
This example shows simple using of Raw2Vox method.
private static void Decode2Pcm(ref IntPtr format, ref byte[] data, ref WaveFormat wf)
{
    IntPtr newFormat = AudioCompressionManager.GetCompatibleFormat(format, AudioCompressionManager.PcmFormatTag);
    byte[] buffer = AudioCompressionManager.Convert(format, newFormat, data, false);
    wf = AudioCompressionManager.GetWaveFormat(newFormat);
    format = newFormat;
    data = buffer;
}

public static void Raw2VoxTest()
{
    string inFile = "in.wav";
    string outFile = "out.vox";
    WaveReader wr = new WaveReader(File.OpenRead(inFile));
    IntPtr format = wr.ReadFormat();
    byte[] data = wr.ReadData();
    wr.Close();
    WaveFormat wf = AudioCompressionManager.GetWaveFormat(format);
    if (wf.wFormatTag != AudioCompressionManager.PcmFormatTag)//Decode if not PCM data 
    {
        Decode2Pcm(ref format, ref data, ref wf);
    }
    BinaryWriter bw = new BinaryWriter(File.OpenWrite(outFile));
    BinaryReader br = new BinaryReader(new MemoryStream(data));
    Vox.Raw2Vox(br, bw, wf.wBitsPerSample);
    br.Close();
    bw.Close();
}
See Also