Author Topic: BASS/nBASS as SHOUTcast Source IS Not Possible  (Read 3080 times)

Dredd

  • Posts: 3
Well..for all of you wondering....

I could be wrong about this..I've only been playhing with BASS for a few days..but here it is...

It looks like you can't use BASS as an easy way to send data to SHOUTcast. Whenever you get data from a BASS stream, it always decodes it. You aren't getting the compressed mp3,ogg or whatever data, its decoded by the time you get the data.

I was hoping to leverage BASS's built built in timing features..so you don't stream music too fast or slow. Below is a VB.NET code snippet that I got off this forum, and modified it to write to a network socket. Look for my  '## RIGHT HERE comment :

   Public Sub streamSong()
       Dim BA As New nBASS.BASS(-2, 44100, nBASS.DeviceSetupFlags.LeaveVolume, Me.Handle)
       Dim sLen As Integer = CType(FileLen(Me.FileToStream), Integer)
       Dim strm As nBASS.Stream = BA.LoadStream(False, Me.FileToStream, 0, 0, nBASS.StreamFlags.DecodeOnly)
       ' Other Misc. Declarations
       Dim RawPad As Integer = 1000
       Dim RetVal As Integer
       Dim T(RawPad) As Byte
       Dim sPos As Integer
       Dim a As Integer
       Dim iRetVal As Integer

       Try
           Do While strm.ActivityState = nBASS.State.Playing

               '## RIGHT HERE
               '## The chunk of data that gets put into T
               '## is not MP3 dta off the disk, its already
               '## decoded here
               RetVal = strm.GetData(T, RawPad)
               
               If RetVal = RawPad Then
                   'Write the progress percentage to the label control
                   sPos = strm.GetFilePosition(nBASS.Stream.Mode.Decoding)
                   RaiseEvent msgBytesSent(Percentage(sPos, sLen).ToString + "%")

                   networkStream.Write(T, 0, T.Length)
                   Thread.Sleep(strm.Bytes2Seconds(1000) * 1000)
                   Application.DoEvents()
                   ' Don't hog the CPU
               End If
           Loop
           iRetVal = 1
       Catch eAbort As ThreadAbortException
           iRetVal = 2
           iBytesTransferred = 0
           StartDate = Date.Now
           EventLog.WriteEntry("Rip Radio Stream Error", eAbort.Message & vbCrLf & eAbort.StackTrace)
       Catch eAny As Exception
           iBytesTransferred = 0
           StartDate = Date.Now
           EventLog.WriteEntry("Rip Radio Stream Error", eAny.Message & vbCrLf & eAny.StackTrace)
           iRetVal = 3
       Finally
           BA.Dispose()
           cbSongEndedMethod(iRetVal)
       End Try



   End Sub