Getting hiccup noise from Shoutcast

690 Views Asked by At

I'm trying to read Shoutcast stream and then play it using MediaStreamSource. Here is the excellent open source project that saved lot of my time. After little bit modification I'm able to hear perfect sound. But the problem is I'm getting a periodic blip/hiccup kind of noise.

Any idea how I can stop that noise. I thought its may be Shoutcast sends some metadata in interval but don't find out how to stop that. Tried with request.Headers["Icy-MetaData"] = "0"; But it doesn't fix my problem either. Any help will be greatly appreciated.

Edit1: I did some more investigation. I read my stream data for 2-3 mins and found that there are lot of 'zero' byte in that stream. Here is the list of index of '0' byte

92 247 359 1208 1904 2037 2227 2397 2536 2694 2740 2863 2952 3048 3110 3689 3994 4027 4098 4218 4730 4830 4943 5029 5115 5248 5315 5358 5666 6084 6375 6873 6920 7441 7660 7700 7756 8174 8254 8614 9010 9018 9025 9039 9541 9846.....

Is it because httpwebrequest slow download/failed to download or Shoutcast itself sending those zero bytes? Also does this '0' bytes causing that hiccup noise?

Edit2: Here is few line of code of how I'm getting response from shoutcast

        HttpWebRequest request = result.AsyncState as HttpWebRequest;
        HttpWebResponse response = request.EndGetResponse(result) as HttpWebResponse;     
        r = response.GetResponseStream();
        ShoutcastHeader(r);

And here is my ShoutcastHeader method definition:

        StreamReader headerReader = new StreamReader(r);
        bool headerIsDone = false;
        while (!headerIsDone)
        {
            string headerLine = headerReader.ReadLine();

            if (headerLine.StartsWith("icy-name:"))
            {
                StationName = headerLine.Substring(9);
            }
            else if (headerLine.StartsWith("icy-genre:"))
            {
                Genre = headerLine.Substring(10);
            }
            else if (headerLine.StartsWith("icy-br:"))
            {
                BitRate = short.Parse(headerLine.Substring(7));
            }
            else if (headerLine.StartsWith("icy-metaint:"))
            {
                MetaInt = int.Parse(headerLine.Substring(12)) * 1111084;
                MetadataAvailable = true;
            }
            else if (headerLine.Equals(""))
                headerIsDone = true;
        }

And here is the response in headerReader

ICY 200 OK icy-notice1:
This stream requires Winamp
icy-notice2:SHOUTcast Distributed Network Audio Server/Linux v1.9.93atdn
icy-name:Bollywood & Beyond - Radio NRI 24/7 icy-genre:Indian Hindi Tamil Telugu Malayalam Desi icy-url:http://www.radionri.com content-type:audio/mpeg icy-pub:1 icy-br:128

Also I have places the stream bytes in my skydrive share location.

1

There are 1 best solutions below

2
On BEST ANSWER

Based on this thread it looks like the hiccups are the header information being resent periodically. There is an issue on ShoutStreamSource project referencing this too:

"The current implementation does not discard the mp3headers after the first one has been parsed. This causes hicups in the sound coming from the stream, and will be fixed in the near future."

However at the time of this answer it looks like the project was put on hold. Hopefully you or someone else can add this functionality. At least knowing what the problem is should help with a solution.