Author Topic: Shoutcast MixStream by WASAPI InputChannel and PlayerDecode  (Read 155 times)

cool_Jack

  • Posts: 45
Hello everyone,
I have tried all day to find a solution for my problem.
In one scenario there should be the possibility to send a shoutcast stream fed from a player and from an input of the soundcard via WASAPI. Specified individually in the encoder, both work. Together over a Bass_Mixer Channel not. How can I help there?

My Code Snippets:

Code: [Select]
  MixerHandle = BassMix.BASS_Mixer_StreamCreate(SampleRate, 2, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_SAMPLE_FLOAT Or BASSFlag.BASS_DEFAULT Or BASSFlag.BASS_MIXER_NONSTOP)

Add Player:

Code: [Select]
PlayerHandle = Bass.BASS_StreamCreateFile(PATH, 0, 0,
                                  BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_SAMPLE_FLOAT)

BassMix.BASS_Mixer_StreamAddChannel(MixerHandle, PlayerHandle, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_SAMPLE_FLOAT)

Decode Stream by Timer and Threading

Code: [Select]
                                              Dim need As Integer = Bass.BASS_ChannelSeconds2Bytes(MixerHandle, 0.2)
                                              Dim buffer(need) As Byte
                                              Bass.BASS_ChannelGetData(MixerHandle, buffer, need) ' // decode the data
                                              buffer = Nothing

Send Shoutcast

Code: [Select]
        Dim encoder As IBaseEncoder = Nothing
        Dim server As IStreamingServer = Nothing

        Dim lame As EncoderLAME

        lame = New EncoderLAME(MixerHandle)
        lame.EncoderDirectory = Application.StartupPath & "\Plugins"
        lame.LAME_Bitrate = _Stream.kbps
        lame.LAME_Mode = EncoderLAME.LAMEMode.Default
        lame.LAME_TargetSampleRate = _Stream.SampleRate
        lame.LAME_Quality = EncoderLAME.LAMEQuality.Q5
           
        encoder = lame
        Dim shoutcast As New SHOUTcast(encoder, True)
        ......

It Works perfect. I can hear the songs from player. Now I want to add a Input signal from soundcard via wasapi to the existing mixer.

Code: [Select]
BassMix.BASS_Mixer_StreamAddChannel(MixerHandle, WasAPIHandler.InputChannel, BASSFlag.BASS_DEFAULT)

But nothing happens. If I use "WasAPIHandler.InputChannel" instead  "lame = New EncoderLAME(MixerHandle)", I can hear the signal in stream, but logically without the player :(.

Is there a way to implement my project? I am at a loss and hope for help. Many thanks
« Last Edit: 30 Nov '20 - 13:57 by cool_Jack »

cool_Jack

  • Posts: 45
I have found a solution.:

Code: [Select]
WasAPIHandler.UseInput = True
WasAPIHandler.SetFullDuplex(0, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_SAMPLE_FLOAT, False)
BassMix.BASS_Mixer_StreamAddChannel(MixerHandle, WasAPIHandler.OutputChannel, BASSFlag.BASS_STREAM_DECODE)

>> SetFullDuplex(0,....
>> WasAPIHandler.OutputChannel


I hope that maybe it can help others.