Author Topic: radio shoutcast  (Read 2107 times)


  • Posts: 11
radio shoutcast
« on: 13 Dec '07 - 12:22 »
hi, I'm using modCast for conect to shoutcast server.
well, i modify this module for stream audio of file.

The connection ends at the end of the file, I need that connection remains active. I need to be able to play multiple files with the same connection.

How can I solve this problem?

This is part of the code:

Code: (vb) [Select]
Public Sub Start(Optional ByVal archivo As String)
    Dim com As String, server As String, pass As String, name As String, URL As String, genre As String, _
        desc As String, content As String
    Dim bitrate As Long, pub As Long
    'limpiamos el canal rchan (0)
    Call BASS_StreamFree(rchan)
    Call BASS_MusicFree(rchan)

    If archivo = "" Then
        archivo = "C:\x.wav" 'file "out of service" sound
    End If
    rchan = BASS_StreamCreateFile(BASSFALSE, archivo, 0, 0, BASS_MUSIC_AUTOFREE) 'BASS_SAMPLE_LOOP)

    If (rchan = 0) Then
        Call Error_("Couldn't start recording")
        Exit Sub
    End If
    With frmCast
        bitrate = bitrates(.cmbBitrate.ListIndex) ' get bitrate
        ' setup encoder command-line (raw PCM data to avoid length limit)
        If (.Options(0).value) Then  ' MP3
            com = "lame -r -x -s 44100 -b " & bitrate & " -"
            content = BASS_ENCODE_TYPE_MP3
        Else  ' OGG
            com = "oggenc -r -R 44100 -b " & bitrate & " -m 16 -"
            content = BASS_ENCODE_TYPE_OGG
        End If
        encoder = BASS_Encode_Start(rchan, com, BASS_ENCODE_NOHEAD Or BASS_ENCODE_AUTOFREE, 0, 0) ' start the encoder
        If (encoder = 0) Then
            Call Error_("Couldn't start encoding..." & vbCrLf & _
                "Make sure OGGENC.EXE (if encoding to OGG) is in the same" & vbCrLf & _
                "direcory as this RECTEST, or LAME.EXE (if encoding to MP3).")
            Call BASS_ChannelStop(rchan)
            rchan = 0
            Exit Sub
        End If
        ' setup cast
        server = .txtServer.Text
        pass = .txtPassword.Text
        name = .txtName.Text
        URL = .txtURL.Text
        genre = .txtGenre.Text
        desc = .txtDescription.Text
        pub = .chkPublic.value
        If (BASS_Encode_CastInit(encoder, server, pass, content, name, URL, genre, desc, vbNullString, bitrate, pub) = 0) Then
            Call Error_("Couldn't setup connection with server")
            Call BASS_ChannelStop(rchan)
            rchan = 0
            Exit Sub
        End If
        Call BASS_ChannelPlay(rchan, False) ' resume recording
        .btnStart.Caption = "Stop"
        Call EnableControl(.txtServer, False, True)
        Call EnableControl(.txtPassword, False, True)
        Call EnableControl(.chkPublic, False, False)
        Call EnableControl(.txtName, False, True)
        Call EnableControl(.txtURL, False, True)
        Call EnableControl(.txtGenre, False, True)
        Call EnableControl(.txtDescription, False, True)
        Call EnableControl(.Options(0), False, False)
        Call EnableControl(.Options(1), False, False)
        Call EnableControl(.cmbBitrate, False, True)
        Call EnableControl(.txtTrack, True, True)
        Call BASS_Encode_SetNotify(encoder, AddressOf EncoderNotify, 0) ' notify of dead encoder/connection
    End WithEnd Sub

NOTE: I am sorry if my English is bad. My friend Google Translator has helped me because they were not much of the language, I speak Spanish.
« Last Edit: 13 Dec '07 - 12:26 by SERBice »

Ian @ un4seen

  • Administrator
  • Posts: 21379
Re: radio shoutcast
« Reply #1 on: 13 Dec '07 - 17:57 »
You can use the BASS_Encode_SetChannel function to move the encoder to another channel. For example, you could set a BASS_SYNC_END sync on a stream (via BASS_ChannelSetSync), and then move the encoder onto the next stream in the SYNCPROC.


  • Posts: 11
Re: radio shoutcast
« Reply #2 on: 13 Dec '07 - 18:11 »
Do a lot of serious trouble if you ask me des an example code?.

Thanks Google Translator: P

Ian @ un4seen

  • Administrator
  • Posts: 21379
Re: radio shoutcast
« Reply #3 on: 14 Dec '07 - 16:30 »
It's not VB, but you could do something like this...

Code: [Select]
BASS_ChannelSetSync(channel, BASS_SYNC_END, 0, EndSync, 0); // set end sync


void CALLBACK EndSync(HSYNC handle, DWORD channel, DWORD data, DWORD user)
BASS_Encode_SetChannel(encoder, next_channel); // switch encoder to next file
BASS_ChannePlay(next_channel, FALSE); // start playing next file


  • Posts: 11
Re: radio shoutcast
« Reply #4 on: 15 Dec '07 - 04:16 »