XNA Creators Club Online
Page 1 of 1 (6 items)
Sort Posts: Previous Next

Wav Packet Compression Decompression

Last post 04-03-2008 12:29 PM by The ZMan. 5 replies.
  • 04-03-2008 11:12 AM

    Wav Packet Compression Decompression

    Hi,

    I have a c# program that records WAV and gives me WAV packets which I transfer over the wire and play. The bandwidth used is very high. To reduce the bandwidth I want to compress to an intermediate format packet (any format is fine) and decompress it to wav on the client and play it.

    I cannot change the source and destination formats which have to be wav. I have tried file compression algorithms but they don't reduce bandwidth by more than 5-10%.

    Can you please consider suggesting how I could do this? Any sample code would be appreciated.


  • 04-03-2008 11:16 AM In reply to

    Re: Wav Packet Compression Decompression

    YOur WAV file is probably already compressed using PCM compression which would explain the small amount that you get from file compression.

    The only way to go beyond that would be to use some lossy formats such as .mp3 or .ogg. They usually have a sliding scale of compression ratio compared to quality so you can find a sweet spot.


    The ZBuffer News and information for XNA
    Please read the forum FAQs - Bug reporting
  • 04-03-2008 11:27 AM In reply to

    Re: Wav Packet Compression Decompression

    Thanks for the reply.

    Since WMA is the microsoft format. I was hoping to compress the WAV PACKETS to WMA but I'm unable to figure out how to encode/decode ONE PACKET at a time. Would you consider helping me out with that if you can?


  • 04-03-2008 11:34 AM In reply to

    Re: Wav Packet Compression Decompression

    The only way I know how to encode to WMA is using the media encoder command line/UI tools https://www.microsoft.com/windows/windowsmedia/forpros/encoder/default.mspx

    To do it in code means stepping into the world of DirectShow and its filters codec etc. There's few people in these forums who know how to do that.

    Thats why I recommended Ogg - there's lots of source code out there - even managed wrappers.


    The ZBuffer News and information for XNA
    Please read the forum FAQs - Bug reporting
  • 04-03-2008 12:17 PM In reply to

    Re: Wav Packet Compression Decompression

    YOur WAV file is probably already compressed using PCM compression which would explain the small amount that you get from file compression.


    PCM is not a compression format, it is raw, uncompressed sample data (one value per sample). However, it likely won't compress very well, just like "zip" on a short wav file won't give you a whole lot.

    There are two APIs that are part of Windows you can use to compress sound data. One is the acm functions (Audio Compression Manager, part of the old-school mmio interface); the other is DirectShow. There are samples in the Windows SDK for how to compress a stream of data using DirectShow. Even though you have packets, that's not too hard to re-buffer into the stream needed by DirectShow, then you send that data, and re-buffer the output of decompression on the other end.

    The Audio Compression Manager is documented on MSDN. Again, because some compression codecs require specific buffer sizes, you may need to re-buffer between your wave input and the compressor.

    Finally, if it's voice, you probably want to use a format like 16 kHz, 16 bits, mono as the baseline to save on bandwidth (if you're using 48 kHz, 16 bits, stereo right now, that's a savings of 6:1 without compression!)


    Jon Watte, Direct3D MVP kW X-port 3ds Max .X exporter kW Animation source code
  • 04-03-2008 12:29 PM In reply to

    Re: Wav Packet Compression Decompression

    jwatte:
    YOur WAV file is probably already compressed using PCM compression which would explain the small amount that you get from file compression.


    PCM is not a compression format, it is raw, uncompressed sample data (one value per sample). However, it likely won't compress very well, just like "zip" on a short wav file won't give you a whole lot.

    John is quite right.. I meant ADPCM but had a slip of the brain....


    The ZBuffer News and information for XNA
    Please read the forum FAQs - Bug reporting
Page 1 of 1 (6 items) Previous Next