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

New Post: Recording audio and save as Raw data (A-Law)

$
0
0

Thanks Mark, I went with the ALawEncoder class and it works like a charm.

I had a look here

 http://bit.ly/wp45x5 

and reused like this

        byte[] GetALawBytes(ref MemoryStream ms)
        {
            byte[] data = ms.ToArray();
            int length = ms.ToArray().Length;
            byte[] encoded = new byte[length/ 2];
            int outIndex = 0;
            
            for (int n = 0; n < length; n += 2)
            {
                encoded[outIndex++] = NAudio.Codecs.ALawEncoder.LinearToALawSample(BitConverter.ToInt16(data, n));
            }

            return encoded;
        }

To keep it simple, I saved the byte array to the disk and played the file with audacity. It works as intended!

Thanks!


Viewing all articles
Browse latest Browse all 5831

Trending Articles



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