Author Topic: encoder and casting  (Read 81 times)


  • Posts: 20
encoder and casting
« on: 3 Apr '21 - 17:52 »
Hello Guys,
This is my first effort to stream to a shoutcastserver from a Bass-application and I ran into problems:
This is my goal:
I have a mixer with a splitstream, the sound in the splitstream goes to an encoder to produce an mp3-stream. That stream needs to be send to a shoutcast server.

Here is my code (in Visual Basic):

Code: [Select]
dim strCom as string =  "lame -r -s " + strStream1Samples + " -b " & strStream1Bitrate & " -"
intEncoder1 = BassEnc.BASS_Encode_Start(intSplit1, strCom, BASS_ENCODE_NOHEAD Or BASS_ENCODE_AUTOFREE, _MyEncProc1, 0)

' IntEncoder1 gives me an positive number

Code: [Select]
blsuccess = BassEnc.BASS_Encode_CastInit(intEncoder1, strStream1Ip + ":" + strStream1Port, strStream1Password, BASS_ENCODE_TYPE_MP3, strStream1Name, strStream1url, Nothing, Nothing, Nothing, Val(strStream1Bitrate), blStream1)
'this produces a true for blsuccess

'my shoutcast server then recognizes my stream, stationname, stationurl and password are accepted. But, I guess, no audiodata is available in the shoutcast server, for it ends the connection after 30 secs with a 'Data not Available Time Out" message.

'This is my callbackfunction, it just returns TRUE:
Code: [Select]
_MyEncProc1 = New Un4seen.Bass.AddOn.Enc.ENCODEPROC(AddressOf EncodingCallback1)
Public Function EncodingCallback1(encoder As Integer, chan As Integer, bytes As Long, byteslength As Long, user As Long) As Boolean
    EncodingCallback1 = True
End Function

I've just one simple question: What am I doing wrong???
Thanks in advance for your answers.


  • Posts: 1921
Re: encoder and casting
« Reply #1 on: 4 Apr '21 - 20:53 »
Code: [Select]
intEncoder1 = BassEnc.BASS_Encode_Start(intSplit1, strCom, BASS_ENCODE_NOHEAD Or BASS_ENCODE_AUTOFREE, _MyEncProc1, 0)
should be
Code: [Select]
intEncoder1 = BassEnc.BASS_Encode_Start(intSplit1, strCom, BASS_ENCODE_NOHEAD Or BASS_ENCODE_AUTOFREE, 0, 0)
because you do nothing in the encproc so then the encproc can you remove.
would be interesting to see the Mixer / Split Stuff Source to find  the error.


  • Posts: 20
Re: encoder and casting
« Reply #2 on: 5 Apr '21 - 13:52 »
Thanks for your reaction, Chris, here is my code for the mixer and the splitstream:

Code: [Select]
blSucces = Bass.BASS_SetDevice(0)
intMixer = BassMix.BASS_Mixer_StreamCreate(intSamplerate, 2, BASSFlag.BASS_MIXER_NONSTOP Or BASSFlag.BASS_STREAM_DECODE)
intVolfx = Bass.BASS_ChannelSetFX(intMixer, BASSFXType.BASS_FX_BFX_VOLUME, 1)
blSucces = Bass.BASS_ChannelPlay(intMixer, True)
intSplit1 = BassMix.BASS_Split_StreamCreate(intMixer, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_DEFAULT, Nothing)
fout = Bass.BASS_ErrorGetCode() 

All the blSucceses are returning TRUE and the FOUTs (errors) are 0 (OK).

I've used this code in a few other situations with success. I'm feeding this mixer with another splitstream.
In this situation I have another splitstream connected to this mixer (Spilt 2). That one is successfully producing audio into an audiodevice.
I hope you see the mistake(s), that I can correct.
Thanks again in advance.


  • Posts: 1921
Re: encoder and casting
« Reply #3 on: 5 Apr '21 - 14:25 »
I`m not a VB Coder BUT
FRom what I will see :
Code: [Select]
blSucces = Bass.BASS_ChannelPlay(intMixer, True)That can not work because your Mixer has the Flag Decoded and your splitstream have also the flag decoded.
(Of yource a Mixerstream must be have the Flag decoded if you are using Splitstreams)
So in your example there are still no SampleData .
there are 2 ways
you must Use BASS_ChannelGetData to retrieve the sample data or
you must remove in the Split Creation the Bass_Stream_Decode Flag.

Ian @ un4seen

  • Administrator
  • Posts: 23470
Re: encoder and casting
« Reply #4 on: 5 Apr '21 - 16:27 »
Yep, unless there's more unshown code for this, it looks like the issue there is that the splitter isn't being processed. Are you sure you actually need another splitter, eg. for DSP/FX? If there are no DSP/FX differences then you can probably just set the encoder on the playback splitter that you mention. You may also want to set the BASS_ENCODE_QUEUE flag on the encoder then (please see the BASS_Encode_Start documentation for details) to avoid delaying the playback processing.

If the separate splitter really is needed then you will need to process it by calling BASS_ChannelPlay (without BASS_STREAM_DECODE set), or repeatedly calling BASS_ChannelGetData in a worker thread or timer (with BASS_STREAM_DECODE set). If you don't want to hear it playing in the former case then you could create it on the "No Sound" (0) device (looks like you already are in the code above).

As Chris says, the BASS_ChannelPlay call on the mixer will also be failing (can't play a stream with BASS_STREAM_DECODE set), but that won't be causing the problem.


  • Posts: 20
Re: encoder and casting
« Reply #5 on: 6 Apr '21 - 15:54 »
Thanks Ian and Chris, you are great,

I just had to set the encoder on de mixer, that was feeding the splitstream, I mentioned in my first post.
 Now it works great. I didn't nee that splitstream at all.

Thanks once again for your help.