Quantcast
Channel: NAudio
Viewing all articles
Browse latest Browse all 5831

New Post: Problem Converting To GSM610

$
0
0

Here is the full source code for CreateWaveFile:

        public static void CreateWaveFile(string filename, IWaveProvider sourceProvider)
        {
            using (WaveFileWriter writer = new WaveFileWriter(filename, sourceProvider.WaveFormat))
            {
                byte[] buffer = new byte[sourceProvider.WaveFormat.AverageBytesPerSecond * 4];
                while (true)
                {
                    int bytesRead = sourceProvider.Read(buffer, 0, buffer.Length);
                    if (bytesRead == 0)
                        break;
                    writer.Write(buffer, 0, bytesRead);
                }
            }
        }

The problem is simply that the size of the buffer ought to be a multiple of 65. Make it 65000 or something. Then it should work.

As for how to insert silence, your way is fine. The only alternative is to create one 65 byte block of GSM silence (don't know what that looks like), and insert those blocks. However, even that may produce artefacts if the GSM codec stores state between consecutive blocks.


Viewing all articles
Browse latest Browse all 5831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>