BigJoe714
BigJoe714

Reputation: 6902

How can I save a byte array of audio data using NAudio?

I have a byte array of audio data that is supposedly in 8-bit uLaw format. However, when I try and save it to a wav file, the file is just static. Below is how I am trying to save the byte array. What am I doing wrong?

        var ulawFormat = WaveFormat.CreateMuLawFormat(8000, 1);
        using (WaveFileWriter w=new WaveFileWriter(AssemblyDirectory + @"\..\..\..\TestAudio\output.wav", ulawFormat))
        {
            foreach(var kwa in knownWorkingAudio)
            {
                byte[] data = kwa.Value;
                w.Write(data, 0, data.Length);
            }
            w.Flush();
        }

Upvotes: 1

Views: 782

Answers (1)

Mark Heath
Mark Heath

Reputation: 49482

The code sample looks correct. I suspect the audio is not in the format you think its in.

Upvotes: 1

Related Questions