Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length



Pages: [1] 2  All
  Print  
Author Topic: Shoutcast/Mp3 Radio Client  (Read 4656 times)
elzekool
Jr. Member
**
Posts: 76


View Profile WWW
« on: September 08, 2008, 01:29:51 PM »

A little while ago someone proposed making a streaming mp3 client with a GHI EmbeddedMaster and a VS1002 MP3 decoder,

I thought this was a great idea, so i started with my project. A simple shoutcast client.

It has the following functions:
- Selection of radio station
- MP3 header decoding for displaying bitrate, samplerate, mono/stereo
- Simple FIFO

I think it's a usable project. It can be a help using the dispatcher for WPF and it can be a start for making threaded applications.

It's not finished but what software is  Wink

Kown issues:
- When the garbage collector kicks in a blib can be heard sometimes
- The controls aren't very sophisticated, e.g. volume/bass control doesn't realy work yet.

I hope someone likes it,

Your free to use the source code, as long as you keep sharing it to the world..

I always like to recieve some feedback when you use it ofcourse Wink


Aloha,

E. Kool

I forgot to upload the source.. whoops.. it's okay now Tongue
« Last Edit: September 08, 2008, 01:41:15 PM by elzekool » Logged

Visit my blog about the .NET Micro Framework at
http://www.microframework.nl
Or look at the .NET Micro Framework Wiki at:
http://wiki.microframework.nl/
elzekool
Jr. Member
**
Posts: 76


View Profile WWW
« Reply #1 on: September 08, 2008, 02:50:40 PM »

Yet again a update. A little description how to find and add radio stations to the RadioStation list as the stations currenty in the list are dutch.

First we have to find a radio station, let's go to shoutcast.com..
Select the radio station you want (Make sure it's MP3 and not AAC!) and choose Tune In!
Don't open but save the file.

Open the file (with .pls) extention with a text editor, the contents of the file should look like this:

[playlist]
numberofentries=1
File1=http://scfire-chi-aa02.stream.aol.com:80/stream/1074
Title1=(#1 - 480/900) .977 The Hitz Channel
Length1=-1


We take the File1 property of the file and use this for our list.. For the station above the new radio station looks like this

new RadioStation(".977 The Hitz Channel","scfire-chi-aa02.stream.aol.com", 80, "/stream/1074"),

When there is no path given use "/".

Good luck!

Logged

Visit my blog about the .NET Micro Framework at
http://www.microframework.nl
Or look at the .NET Micro Framework Wiki at:
http://wiki.microframework.nl/
SupportAdmin
Administrator
Hero Member
*****
Posts: 5516



View Profile WWW
« Reply #2 on: September 08, 2008, 04:32:40 PM »

Can you please add this project to our projects page? Or we can add it for you but if you add it then you can modify it in future
http://www.ghielectronics.com/projects.php

Note that we are still working on the projects page so layout can change slightly tonight but you shouldn't lose your project if you upload it
Logged
elzekool
Jr. Member
**
Posts: 76


View Profile WWW
« Reply #3 on: September 08, 2008, 04:36:31 PM »

Very cool you realy added the project page i suggested.. I'll upload my projects right away! Smiley Smiley
Logged

Visit my blog about the .NET Micro Framework at
http://www.microframework.nl
Or look at the .NET Micro Framework Wiki at:
http://wiki.microframework.nl/
SupportAdmin
Administrator
Hero Member
*****
Posts: 5516



View Profile WWW
« Reply #4 on: September 08, 2008, 05:40:24 PM »

We listen to our customers Smiley

Thanks for suggesting it and thanks for uploading your projects. We have approved them so you can view them and modify them if you like

Thanks again and keep up these fun projects
Logged
snupi
Full Member
***
Posts: 198


View Profile
« Reply #5 on: September 09, 2008, 01:27:11 AM »

hi nice project

i also working on my internet radio project - but i am pinched for time

its a console program for mf .net using also threads (WebClient/AudioClient) and a Circular byte buffer
reading of the song title is also implemented (IcyMetaData)
in the audio section bass/volume is possible (commands from vs10xx spec)

there a some peanuts to fix in the program (add state machine) - if they are finished, i will post the project too
Logged
elzekool
Jr. Member
**
Posts: 76


View Profile WWW
« Reply #6 on: September 09, 2008, 02:35:54 AM »

Thnx!,

I also implemented the bass/volume functions into the VS1002 class. When you set the volume at 20 or higher the bass should  be quite noticable. I also tryed implementing the Icy Metadata but at this time the application uses to much cpu power for this. I think this becouse I used the WPF classes, there great but consume some cpu cycles.

When you're making a console app maybe it could work, I look out for your project, and many people with me i think!
Logged

Visit my blog about the .NET Micro Framework at
http://www.microframework.nl
Or look at the .NET Micro Framework Wiki at:
http://wiki.microframework.nl/
snupi
Full Member
***
Posts: 198


View Profile
« Reply #7 on: September 09, 2008, 03:22:24 AM »

hi

i think it should be possible with wpf too :

the http response header contains the tag IcyMetaInt - the value is the number of bytes of mp3 data that will be sent between each chunk of metadata
 -> so you have to count the bytes received

i read from socket in chunks with size 1024 - at IcyMetaInt i parse the metadata

the webclient (socket thread) has its own thread: there should be enough performance to parse the songs metadata for the wpf version too
Logged
elzekool
Jr. Member
**
Posts: 76


View Profile WWW
« Reply #8 on: September 09, 2008, 03:33:31 AM »

High,

Maybe after some optimizing.. In my attempt I got a buffer underrun after some time

I use this document about Icy metadata:
http://www.smackfu.com/stuff/programming/shoutcast.html
Logged

Visit my blog about the .NET Micro Framework at
http://www.microframework.nl
Or look at the .NET Micro Framework Wiki at:
http://wiki.microframework.nl/
snupi
Full Member
***
Posts: 198


View Profile
« Reply #9 on: September 09, 2008, 03:43:46 AM »

yes i used the same document  Wink

i also played a while with different buffer sizes - but it seems, that the socket.receive function sometimes doesnt get enough bytes to read (sometimes i get only a bytesRead < 10 !), so a buffer underun is preprogrammed (i solved this issue for me with stop playing and buffering again low/high watermark in the circular buffer)
Logged
elzekool
Jr. Member
**
Posts: 76


View Profile WWW
« Reply #10 on: September 09, 2008, 04:10:39 AM »

Yeah,

I know this issue,

A don't use a very sophisticated FIFO, just an arraylist where it puts the bytes that are read. The thread that outputs to the VS1002 just reads from index 0 and deletes that index.

This is also the part where i can get some performance increase.. becouse the bytes read keep changing i create a byte array each time. This had to be cleaned by the garbage collector ofcourse.. taking precious time..

Quote
yes i used the same document   Wink
It's a small world..  Cheesy
Logged

Visit my blog about the .NET Micro Framework at
http://www.microframework.nl
Or look at the .NET Micro Framework Wiki at:
http://wiki.microframework.nl/
snupi
Full Member
***
Posts: 198


View Profile
« Reply #11 on: September 11, 2008, 07:09:52 AM »

i tried also the MP3HeaderReader class -

i get some troubles with the vs1001 (i use the old one Wink) when reading the header register while playing : incorrect speed of playback (or a threading issue, but without reading the mp3header from chip no problems while playing) ... i get the same issue also using your code with the vs1001 device

i will change to vs1002 ...  Grin
« Last Edit: September 11, 2008, 08:27:32 AM by snupi » Logged
elzekool
Jr. Member
**
Posts: 76


View Profile WWW
« Reply #12 on: September 11, 2008, 12:19:52 PM »

Maybe it's an issue with the calculation of the crystal speed..

Do you know how many hertz the crystal is that you attached to the VS1001?
Maybe you should alter the Xtal var..?

I played with the crystal speed settings.. you can do some cool effects with it.. ever heard madonna as a 60 year old man that drank to much beer?Tongue

Good luck!
Logged

Visit my blog about the .NET Micro Framework at
http://www.microframework.nl
Or look at the .NET Micro Framework Wiki at:
http://wiki.microframework.nl/
snupi
Full Member
***
Posts: 198


View Profile
« Reply #13 on: September 11, 2008, 12:43:51 PM »

yes the crystal is also my assumption since i use the internal clock doubler ... but apart from that i cant control the vs1001 according spec sinc i shoul set false/true the cs pin for every byte, but i think here mf is to slow .

where did you get the vs1002 (direct from olimex or sparkfun) ?
« Last Edit: September 11, 2008, 12:47:15 PM by snupi » Logged
elzekool
Jr. Member
**
Posts: 76


View Profile WWW
« Reply #14 on: September 11, 2008, 02:54:20 PM »

I got mine from SparkFun,

You have to solder your own Ext connector but it's a lot smaller.. and cheaper.. It doesn't have an amplifier, i'm not shure it the olimex part has one..

But strange that it doesn't work.. The sparkfun module uses a 12.xxxx crystal so that uses the clock doubler also... It's initialized in the Reset() function..

Logged

Visit my blog about the .NET Micro Framework at
http://www.microframework.nl
Or look at the .NET Micro Framework Wiki at:
http://wiki.microframework.nl/
snupi
Full Member
***
Posts: 198


View Profile
« Reply #15 on: September 11, 2008, 03:30:07 PM »

yes but the vs1002 can use bulk byte transfer - the vs1001 should use only byte transfer (foreach byte set false/true the cs pin)
Logged
elzekool
Jr. Member
**
Posts: 76


View Profile WWW
« Reply #16 on: September 11, 2008, 04:08:28 PM »

Ow,

I didn't know that.. ouch that's a real performance drawback.. Maybe you can use a simple logical counter that asserts/deasserts the CS pin when 8 bits are clocked out?

Logged

Visit my blog about the .NET Micro Framework at
http://www.microframework.nl
Or look at the .NET Micro Framework Wiki at:
http://wiki.microframework.nl/
elzekool
Jr. Member
**
Posts: 76


View Profile WWW
« Reply #17 on: September 14, 2008, 10:03:00 AM »

Hi,

I started reading the meta information from the stream but i have troubles with the buffer.. It doesn't allow you to skip bytes
very easy.. Also it gives troubles when the complete meta information isn't in the last read block..

So I want to implement another qeue class..

I think I gona use this one.. Or someone has a better class I can use?
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3158761&SiteID=1


Logged

Visit my blog about the .NET Micro Framework at
http://www.microframework.nl
Or look at the .NET Micro Framework Wiki at:
http://wiki.microframework.nl/
elzekool
Jr. Member
**
Posts: 76


View Profile WWW
« Reply #18 on: September 15, 2008, 01:36:05 PM »

Hi,

For reading the icy metadata I needed another method for buffering. I used a simple ArrayList method.
I implemented a circular buffer into the project. This not only keeps the garbage collector happier but it also allows you to read a certain amount of bytes wich is needed to read the meta data.

For designing the circular buffer I used the following page which explains the basic principals of a circular buffer
http://elonen.iki.fi/code/misc-notes/ringbuffer/

I uploaded the new project files.
Logged

Visit my blog about the .NET Micro Framework at
http://www.microframework.nl
Or look at the .NET Micro Framework Wiki at:
http://wiki.microframework.nl/
elzekool
Jr. Member
**
Posts: 76


View Profile WWW
« Reply #19 on: September 16, 2008, 02:37:51 PM »

Hi,

Another update:
- Reading the Icy Metadata (o.a. Shoutcast StreamTitle) is added.
- Buffer sizes are a optimized. This was needed becouse some radiostreams fluctuate more then I ever imagened the would do. 32Kb (about 2 sec for 128kbps) is buffered and the circular buffer is 512Kb.
- VS1002 class is updated to use a little less memory (= as happier Garbage Collector)

Next to do is updating the GUI and controls.

You can download the new source from the projects page!
(http://www.ghielectronics.com/projects.php)
« Last Edit: September 16, 2008, 02:41:04 PM by elzekool » Logged

Visit my blog about the .NET Micro Framework at
http://www.microframework.nl
Or look at the .NET Micro Framework Wiki at:
http://wiki.microframework.nl/
snupi
Full Member
***
Posts: 198


View Profile
« Reply #20 on: October 03, 2008, 01:08:17 PM »

yes, cicular buffer with locking for threadsafety (+ events) is also the technology chosen for my streaming client - so i had no problems to read the streaming title from icy meta data Wink
Logged
elzekool
Jr. Member
**
Posts: 76


View Profile WWW
« Reply #21 on: October 04, 2008, 04:14:12 AM »

Yeah,

It's the only correct way of implementing a buffer for streaming data.. Now i'm busy working on a web interface only i have some memory issues.. So i'm busy getting the memory usage as low as posible.. But that's a little low priority project right now.. I'm now working on a application that works with RFID tags.. Maybe you've seen the thread..

Logged

Visit my blog about the .NET Micro Framework at
http://www.microframework.nl
Or look at the .NET Micro Framework Wiki at:
http://wiki.microframework.nl/
snupi
Full Member
***
Posts: 198


View Profile
« Reply #22 on: October 04, 2008, 06:47:11 AM »

yes i am also busy with other things ... for my free time i ordered a serial bluetooth device to playing with the embedded master system Wink
Logged
snupi
Full Member
***
Posts: 198


View Profile
« Reply #23 on: October 07, 2008, 06:07:14 AM »

i have seen, vs1002/vs1011 have a streaming support for MP3 and WAV - activated through SM_STREAM

i will order a vs1011 from sparkfun (since vs1002 is not recommended for new projects; vs1011 has a vs1002 mode) and play around with the stream mode
Logged
SupportAdmin
Administrator
Hero Member
*****
Posts: 5516



View Profile WWW
« Reply #24 on: October 07, 2008, 08:26:58 AM »

Stream mode slows down the playing speed when the buffers are low trying to eliminate data underflow (breaking the sound) but the audio with feature didn't work so well when we tried it.
Logged
Pages: [1] 2  All
  Print  
 
Jump to: