Author Topic: Audio input straight to output device VB Cable using Streamproc  (Read 177 times)

tsl

  • Posts: 7
Even though I have looked at the documentation of STREAMPROC, I struggle a bit understanding how to set it up and specify it.
Converting a C# code to VB code from user namsource post on BASS forum https://www.un4seen.com/forum/?topic=18881.msg132067;topicseen#msg132067 gives me the following issues.
This line of C# code.
Code: [Select]
private static readonly STREAMPROC _dataRequestedProc = AudioBufferOut;In VB it converts to
Code: [Select]
Private Shared ReadOnly _dataRequestedProc As STREAMPROC = AudioBufferOut()I get an Argument not specified error for handle, buffer and length parameter. Reffering to the AudioBufferOut Function.
Code: [Select]
Private Shared Function AudioBufferOut(handle As Integer, buffer As IntPtr, length As Integer, user As IntPtr) As Integer
            Return Un4seen.Bass.Bass.BASS_ChannelGetData(rec_handle, buffer, length)
End Function
Any suggestion on how to proceed from here ?

Ian @ un4seen

  • Administrator
  • Posts: 24424
I'm not .Net user myself, but I believe you need to create a delegate for your STREAMPROC callback function, something like this:

Code: [Select]
__dataRequestedProc = New STREAMPROC(AddressOf AudioBufferOut)

There's some example code in BASS.Net's BASS_StreamCreate and STREAMPROC documentation, so please have a look at that. Also check the "Callbacks and Delegates" section of the "Interoperating with Unmanaged Code" page for more related info.

tsl

  • Posts: 7
Thanks Ian. :D
That solved the issues.
I'm now able to control live audio using Bass Equalizer. The audio received from networkcam RTSP stream is directed to VB-Cable and buffered trough Streamproc with acceptable low latency. :)

Now I try to set up a HighPass filter.
This link has some interesting work on the issue. https://www.un4seen.com/forum/?topic=12970.msg90367#msg90367. Posted by user wiseguybec.
Converted to VB:
Code: [Select]
rchan=BASS_RecordStart(44100, 1, 0, RecordingCallback, 0)

Dim fxBQF As HFX = BASS_ChannelSetFX(rchan, BASS_FX_BFX_BQF,0)

Dim hiPass As New BASS_BFX_BQF()
hiPass.lFilter = BASS_BFX_BQF_HIGHPASS
hiPass.fCenter=300.0f
hiPass.fGain=0
hiPass.fBandwidth=3.0f
hiPass.fQ=0.1f
hiPass.fS=0.0f
hiPass.lChannel = BASS_BFX_CHANALL

BASS_FXSetParameters(fxBQF, DirectCast(hiPass, Object))

I have 2 questions.

1.
In my code I successfully use
Code: [Select]
rchan =  Bass.BASS_RecordStart(44100, 2, 0, Nothing, IntPtr.Zero)
Do I need "RecordingCallback" to implement HighPass ?
In the post from wiseguybec,  we have:
Code: [Select]
rchan = BASS_RecordStart(44100, 1, 0, RecordingCallback, 0)

2.
In the second line of code, HFX seems like it is not transferable to VB, or perhaps changed in newer Bass versions? I 'm suggested by Visual Studio to change it to SFX or FX.
What should follow after Sfx. ?? , Fx. ??

e.g.
Code: [Select]
Dim fxBQF As Fx.???? = BASS_ChannelSetFX(rchan, BASS_FX_BFX_BQF,0)
Again, thank you so much for all the help.


Ian @ un4seen

  • Administrator
  • Posts: 24424
Good to hear that you've got things working well now. In answer to your new questions, you don't need to use a RECORDPROC to set effects on a recording, and you can replace "HFX" with "Integer".

tsl

  • Posts: 7
Thanks. Almost there I hope. :)
I made a simple test loading a mp3 file with the following code, implementing the changes you suggested. The file plays fine, and the EQ works fine also.
Just cant get the HiPass to work. No effect on the cutoff.
The fxBQF = 0, while chan is ok.

Code: [Select]
  'Open File Stream
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
         Console.WriteLine(Bass.BASS_GetVersion().ToString)
     
  'Set Output Device e.g. Speaker
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then

            If ComboBox1.Text = Nothing Then Return
            Select Case ComboBox1.Text
                Case "Default"
                    Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle.ToInt32)
                Case Else
                    Bass.BASS_Init(Convert.ToInt32(ComboBox1.SelectedIndex), 44100, BASSInit.BASS_DEVICE_DEFAULT, Me.Handle.ToInt32)
            End Select
           
            chan = Bass.BASS_StreamCreateFile(OpenFileDialog1.FileName, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT)
           
 '***  HiPass TEST
            Dim fxBQF As Integer
            fxBQF = BASS_ChannelSetFX(chan, BASSFXType.BASS_FX_BFX_BQF, 0)
            Dim hiPass As New BASS_BFX_BQF()
            hiPass.lFilter = BASSBFXBQF.BASS_BFX_BQF_HIGHPASS
            hiPass.fCenter = 300
            hiPass.fGain = 0
            hiPass.fBandwidth = 0
            hiPass.fQ = 0.7
            hiPass.fS = 0
            hiPass.lChannel = BASSFXChan.BASS_BFX_CHANALL
            BASS_FXSetParameters(fxBQF, hiPass)

 '******

            Timer1.Enabled = True
            Timer1.Start()
            My.Settings.EQsaved0 = True
            Bass.BASS_ChannelSetAttribute(chan, Un4seen.Bass.BASSAttribute.BASS_ATTRIB_VOL, CSng(tbVolume.Value) / 100.0F)
            BASS_ChannelSetFXEQ(chan, fxeq, peq, 28)
            TrackBar1_Scroll(sender, e)
            TrackBar2_Scroll(sender, e)
            TrackBar3_Scroll(sender, e)
            TrackBar4_Scroll(sender, e)
            TrackBar5_Scroll(sender, e)
            TrackBar6_Scroll(sender, e)
            TrackBar7_Scroll(sender, e)
            TrackBar8_Scroll(sender, e)
            TrackBar9_Scroll(sender, e)
            TrackBar10_Scroll(sender, e)
            TrackBar11_Scroll(sender, e)
            TrackBar12_Scroll(sender, e)
            TrackBar13_Scroll(sender, e)
            TrackBar14_Scroll(sender, e)
            TrackBar15_Scroll(sender, e)
            TrackBar16_Scroll(sender, e)
            TrackBar17_Scroll(sender, e)
            TrackBar18_Scroll(sender, e)
            TrackBar19_Scroll(sender, e)
            TrackBar20_Scroll(sender, e)
            TrackBar21_Scroll(sender, e)
            TrackBar22_Scroll(sender, e)
            TrackBar23_Scroll(sender, e)
            TrackBar24_Scroll(sender, e)
            TrackBar25_Scroll(sender, e)
            TrackBar26_Scroll(sender, e)
            TrackBar27_Scroll(sender, e)
            TrackBar28_Scroll(sender, e)
            TrackBar29_Scroll(sender, e)

            Bass.BASS_ChannelPlay(chan, False)

        End If

    End Sub

Ian @ un4seen

  • Administrator
  • Posts: 24424
It may be that the BASS_FX add-on (which provides the BASS_FX_BFX_BQF effect) isn't loaded. You can ensure that it is loaded by calling a function from it, eg. BASS_FX_GetVersion during initialization.

tsl

  • Posts: 7
I have Imports Un4Seen.Bass.Addon.Fx set on top of my code.
But cant see any BASS_FX_GetVersion available, only Bass_Getversion.