Wave Conversion

Jul 17, 2014 at 11:24 AM
Is the functionality there to Convert between types of wave formats from a Network Stream.

I tried something like this but this don't work
        var wvreader = new WaveFileReader(networkStream);          
        var bytes = new byte[wvreader.Length];
        wvreader.Read(bytes, 0, bytes.Length);
        var memorystream = new MemoryStream();
        var format = new WaveFormat(wvreader.WaveFormat.SampleRate, wvreader.WaveFormat.BitsPerSample, wvreader.WaveFormat.Channels, AudioEncoding.Pcm);
        var writer = new WaveWriter(memorystream, format);
        writer.Write(bytes, 0, bytes.Length);
The network stream recieves bytes from a different wave format, but I want to convert these bytes to PCM and then play it on the computer
Coordinator
Jul 17, 2014 at 1:07 PM
The WaveWriter class is just an encoder for Wave-Files and won't convert the encoded data. The main part of the WaveWriter class is to keep track of the amount of written data and the creation of the Wave-Header and its chunks.
If you want to just play the network stream, the following would be useful to know:
  • The WaveFormat of the networkStream.
  • The type of the "networkStream" variable.
  • The operating system you are using.
Jul 17, 2014 at 2:08 PM
The wave formats I am receiving currently are just the following
The WaveFormat of the networkStream.
  • PCM
  • G792
The type of the "networkStream" variable.
the type of networkstream, for testing I created to Socket Applications the one that reads a basic PCM file and then sends the bytes to the other application to play.
I am using the NetworkStream(*socket) class

The operating system you are using.
I am developing on a windows 8.1 environment and also windows 7 environment.

I noticed that I cannot play G792 wave files, but I can play PCM wave files on my computer, thus I want to convert G792 to PCM
Coordinator
Jul 19, 2014 at 8:13 AM
Sorry for the late reply. So you want to decode G.792. CSCore does not have a built in G.792 decoder. You could try out the MediafoundationDecoder class. If there is any G.792 decoder, the MediafoundationDecoder class will use it.