-2

How to play wav file format (A-Law, 8000 Hz, 64 Kbps, mono ) in c# asp.net web forms.

c# asp.net supports only to play wav PCM format

Jegadeesh
  • 335
  • 2
  • 16
  • Take a look at this post, you will need to do some encoding / converting of the file format type http://stackoverflow.com/questions/4070294/playback-audio-file-from-byte-code-audio-file-format-is-ccitt-a-law – MethodMan Apr 15 '14 at 15:55

2 Answers2

1

Use HTML5 to achieve this. It supports WAV files :)

Take a look at this: http://www.w3schools.com/html/html5_audio.asp

NOTE: Be aware that not all browsers support WAV files. You'll find more details on that page!

Kennyomar
  • 107
  • 1
  • 7
0

It is extremely difficult to create your own a-law player, this will require deep understanding of the algorithm . fortunately there are tools out there such as SoX to help you convert that file to the desired .wav format.

Here 's a function I wrote to convert files u-law files to wav format so I could read it

    /// <summary>
    /// Generates the sound file using SoX.exe.
    /// </summary>
    /// <param name="fromFile">From file in uLaw encoding.</param>
    /// <param name="toFile">To wav file.</param>
    public bool GenerateSoundFile(string fromFile, string toFile)
    {
        string log = string.Format("fromFile={0},toFile={1}", fromFile, toFile);
        //EventLogger.Log(log);
        string arguments;

        //check the extension
        string ext = Path.GetExtension(fromFile);
        if (ext == ".ulaw")
        {
            arguments = string.Format("-t ul {0} -c 1 -r 8000 {1}", fromFile, toFile);
        }
        else
        {
            arguments = string.Format(" {0} -c 1 -r 8000 {1}", fromFile, toFile);
        }
        //EventLogger.Log(arguments);
        string command = System.Environment.CurrentDirectory + "\\sox.exe";
        try
        {   
            Process p = new Process();
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.FileName = command;
            p.StartInfo.Arguments = arguments;
            p.StartInfo.LoadUserProfile = true;

            p.Start();
            string output = p.StandardOutput.ReadToEnd();
            p.WaitForExit();
        }
        catch (Exception e)
        {
            EventLogger.Error("GenerateSoundFile", e);
        }

        //check output file exists           
        if (!File.Exists(toFile))
        {
            //EventLogger.Error("No output sound file generated");

            return false;
        }
        else
        {
            return true;

        }

    }
meda
  • 45,103
  • 14
  • 92
  • 122