How to read radio stream info?

BlitzMax Forums/BlitzMax Programming/How to read radio stream info?

Hello again!

I'm planing on an writing a simple internet radio player.
My problem is: How do I read the meta data that is included in the mp3-stream, such as "Station Name" and "Current Title"?

Example from Winamp:


Can I do this with MAXmod or FMOD?

Grisu

I've got shoutcast working nicely with my BASS module, although I haven't tried retrieving the metadata from it as yet. I guess it's on there somewhere.

Oooh... seems it does work :
DebugLog:ICY 200 OK
DebugLog:icy-notice1:<BR>This stream requires <a href="http://www.winamp.com/">Winamp</a><BR>
DebugLog:icy-notice2:SHOUTcast Distributed Network Audio Server/Linux v1.9.8<BR>
DebugLog:icy-name:S K Y . F M - Simply Soundtracks - a wide variety of Soundtracks from Movies, show themes, & more!
DebugLog:icy-genre:Film Classical Soundtracks
DebugLog:icy-url:http://www.sky.fm/soundtracks/
DebugLog:icy-pub:1
DebugLog:icy-metaint:8192
DebugLog:icy-br:96

:-)

FYI, this is what the code looks like :
Local tags:String[] = channel.getTags(BASS_TAG_ICY)


Haven't even thought of the bass module. Thanks for the hint.
It's just that I don't want to reinvent the wheel here...

Just saw, you were faster... Looking great.

Is there a complete bass interface / module to download somewhere?
Haven't wörked with it yet at all. :/

Are there any license limitations?

There are around here somewhere.

Mine is still available only via SVN (until it's finished), from http://code.google.com/p/maxmods/
So, if you aren't up on SVN, you may wish to look elsewhere for now.

Example 6 would be of interest here, since it shows shoutcast usage.

Thanks a lot Brucey!

Could you point me to the svn subdir as I'm using a plain batch file for checking?

http://blitzbasic.com:81/svn/blitzmax/dev/?

I think it's something like :

http://maxmods.googlecode.com/svn/trunk/bass.mod

Cheers!

Edit:

1. Still getting some heavy crackeling background sounds out of nowhere.
On some channels they are very seldom on others like the example one there are insane.

2. Meta data "BASS_TAG_ICY"
Does it also give some like the current title. Couldn't find a name tag for this?

' Play a shoutcast stream...
'
SuperStrict

Framework BaH.Bass
Import BRL.GLMax2D
Import BRL.StandardIO

If Not TBass.Init(-1,48000,0,Null,Null) Then
	DebugLog "Can't initialize device : " + TBass.ErrorGetCode()
	End
End If

BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST,0) ' enable playlist processing
BASS_SetConfig(BASS_CONFIG_NET_PREBUF,0) ' minimize automatic pre-buffering, so we can do it (And display it) instead

Local isMod:Int = False

' rocking!
Global url:String = "http://194.158.114.68:5000"
'Global url:String = "http://scfire-nyk-aa02.stream.aol.com:80/stream/1074"
Global channel:TBassChannel = New TBassStream.StreamCreateURL(url, 0, BASS_SAMPLE_FLOAT|BASS_STREAM_STATUS|BASS_STREAM_AUTOFREE, Null, Null)

If channel Then
	Local length:Long = channel.GetLength(BASS_POS_BYTE)

	If Not channel.Play(False) Then
		DebugLog "can't play... : "  + TBass.ErrorGetCode()
		'Exit 
      End If 

	Graphics 640, 480, 0

	Local active:Int = channel.IsActive()
	
	While active And Not KeyDown(key_escape)
	
		Cls
		
		' display some stuff And wait a bit
		Local _left:Int, _right:Int

		channel.GetLevel(_left, _right)

		Local pos:Long = channel.GetPosition(BASS_POS_BYTE)
		Local time:Double = channel.Bytes2Seconds(pos)

		DrawText "position - " + pos, 20, 50
		DrawText "elapsed  - " + Int(time/60) + ":" + Int(time Mod 60), 20, 65

		If isMod Then
			Local low:Int, high:Int
			pos = channel.GetPositionLowHigh(BASS_POS_MUSIC_ORDER, low, high)
			DrawText "         - " + low + ":" + high, 50, 80
		End If
		
		If active = BASS_ACTIVE_STALLED And TBassStream(channel) Then  ' playback has stalled

			DrawText "-- Buffering : " + TBassStream(channel).GetFilePosition(BASS_FILEPOS_BUFFER) + " --", 20, 90

		Else
			Local lwidth:Int = _left / 410.0
			DrawRect 100 - lwidth, 100, lwidth, 20
			DrawRect 110, 100, _right / 410.0, 20
		End If

		DrawText "CPU - " + TBass.GetCPU(), 240, 50

		Get_StreamTagIDs()
		Delay 100

		Flip 1

		active = channel.IsActive()

	Wend

	'End If
'Else
'	DebugLog "didn't load : " + TBass.ErrorGetCode()
End If

TBass.Free()

End

Function Get_StreamTagIDs()
' output some stream information
If channel.Play(False) Then
	Local tags:String[] = channel.getTags(BASS_TAG_ICY)
      Local ypos:Int=150
	For Local s:String = EachIn tags
           If s <> Null Then 
                 DrawText s, 20, ypos                   
                 'DebugLog s
                 ypos=ypos+15
           EndIf 
               
     Next 
EndIf 
End Function


Still experimenting around....

Seems like there's an extension for the bass.dll in order to display all sorts of fancy tags.

"Tags
An extension producing formatted text from the ID3v1/v2, OGG/FLAC, WMA, or APEv2 tags of a BASS stream. C/C++, Delphi, and Visual Basic APIs are included." - http://www.un4seen.com/

Though this stuff is far too high for me... :(

Could someone please test my example to verify the sound issues?