Alvas.Audio Class Library

Vox.Raw2Vox Method 

Encode raw PCM-data to Dialogic .vox (adpcm) format data

[Visual Basic]
Public Shared Sub Raw2Vox( _
   ByVal br As BinaryReader, _
   ByVal bw As BinaryWriter, _
   ByVal bitsPerSample As Short _
)
[C#]
public static void Raw2Vox(
   BinaryReader br,
   BinaryWriter bw,
   Int16 bitsPerSample
);

Parameters

br
bw
bitsPerSample

Example

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

Vox Class | Alvas.Audio Namespace