Author Topic: Clone "mixed" stream to another output device ?  (Read 5097 times)

Couin

  • Posts: 124
Hi Ian, hi friends,

I'm about testing for a new feature.

I would set a second device for ouput.

Actually, from an example project, I load an audio file on a first stream.
When I click on "Play", it clones on a second stream for the second device, and it plays both.
When I stop, the second stream is freed.
In this way, it clones streams only if I play, not directly on loading. Why ? Because I would the user can change the second device even if audio file is already loaded.
Note that in the joined project, I directly set "2" for first device ID, and "3" for the second device. They match with my soundcard ID and a VirtualCable. It's just for testing.

The final goal is to have 2 dropdown lists to choose between available device or "None", for both.

Is there a way to do easier ? 
I mean, just clone what the first device receive (even if device is "None") to send to the second ? Like if I would clone the "mixed stream" to send it to second device. (See small joined draw ahah).

It would makes easier coding for me, to change code to clone 1 time instead of changeing code on several places of the VB project.

In the final project, there are several streams that can plays at the same time. There are FX streams in the final projectbut I thing it won't make big difference in coding.

Thanks for ideas :D
Couin

Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Clone "mixed" stream to another output device ?
« Reply #1 on: 7 May '24 - 16:42 »
From the diagram, it looks like the BASSmix add-on is what you need. With it you could create a mixer (BASS_Mixer_StreamCreate) for combining the audio streams, and splitters (BASS_Split_StreamCreate) for the multiple outputs part. That could look something like this:

Code: [Select]
mixer = BASS_Mixer_StreamCreate(freq, chans, BASS_SAMPLE_FLOAT | BASS_STREAM_DECODE); // create a mixer
// add the audio streams to the mixer here via BASS_Mixer_StreamAddChannel

for (int n = 0; n < numoutputs; n++) {
BASS_SetDevice(device[n]); // set device for n'th output
output[n] = BASS_Split_StreamCreate(mixer, 0, 0); // create a splitter from the mixer
if (n) BASS_ChannelSetLink(output[0], output[n]); // link all outputs to the 1st output
}
BASS_ChannelStart(output[0]); // start the outputs

Please see the documentation for details on the mentioned functions. Note that the audio streams must be "decoding channels", ie. created with the BASS_STREAM_DECODE flag.

Couin

  • Posts: 124
Re: Clone "mixed" stream to another output device ?
« Reply #2 on: 12 May '24 - 04:28 »
Hi Ian,

Thanks for the way to explore, I will test that :)

Couin

  • Posts: 124
Re: Clone "mixed" stream to another output device ?
« Reply #3 on: 12 May '24 - 06:20 »
Hi again,

I'm trying to create a simple test code from your guide, but I get no sound.
I found BASS_Mixer_StreamAddChannel in the "Speakers" example of BassMix.
The example looks different that what I would (I play/stop/loop/fx channels/streams independantly), I tried just with adding a button to BASS_ChannelStop(Source) , it stop but with a latency (stop 0.5 sec after click on button).
I noticed the same latency with checking/unchecking Speaker 1 .

Is it normal ?


Edit :

I get some first results (I have sound AHAH !) with this code:
Code: [Select]
    ' Let the user choose the output devices
    With frmDevice
        .SelectDevice 1
        .Show vbModal, Me
        device(0) = .device
        .SelectDevice 2
        .Show vbModal, Me
        device(1) = .device
    End With

    ' setup output devices
    If (BASS_Init(device(0), 44100, 0, Me.hWnd, 0) = 0) Then
        Call Error_("Can't initialize device 1")
        Unload Me
    End If
   
    If (BASS_Init(device(1), 44100, 0, Me.hWnd, 0) = 0) Then
        Call Error_("Can't initialize device 2")
        Unload Me
    End If

    Dim i As BASS_DEVICEINFO
   
    Call BASS_GetDeviceInfo(device(0), i)
    DeviceName(0).Caption = "Device 0 " & VBStrFromAnsiPtr(i.Name) & " "

    Call BASS_GetDeviceInfo(device(1), i)
    DeviceName(1).Caption = "Device 1 " & VBStrFromAnsiPtr(i.Name) & " "
   
    Call BASS_SetDevice(device(0))
    mixer = BASS_Mixer_StreamCreate(44100, 2, BASS_SAMPLE_FLOAT Or BASS_STREAM_DECODE) 'create a mixer
   
    chan(0) = BASS_StreamCreateFile(BASSFALSE, StrPtr("1.mp3"), 0, 0, BASS_UNICODE)
    chan(1) = BASS_StreamCreateFile(BASSFALSE, StrPtr("2.mp3"), 0, 0, BASS_UNICODE)
    Call BASS_Mixer_StreamAddChannel(mixer, chan(0), 0)
    Call BASS_Mixer_StreamAddChannel(mixer, chan(1), 0)

I get sound when I BASS_ChannelPlay chan(0) or chan(1), on the first device (so device(0) ) I selected.

But even with adding:
Code: [Select]
    Dim ndev As Byte
    For ndev = 0 To 1
        Call BASS_SetDevice(device(ndev)) 'set device for n'th output
        output(ndev) = BASS_Split_StreamCreate(mixer, 0, 0)
        If ndev <> 0 Then Call BASS_ChannelSetLink(output(0), output(ndev)) 'link all outputs to the 1st output
    Next ndev
    Call BASS_ChannelStart(device(0)) 'start the outputs
I get no sound on device(1) .

I know you are not a VB6 user but I don't think it's a syntax problem: I have no error in IDE or at runtime.

BASS_ErrorGetCode on BASS_Split_StreamCreate(mixer, 0, 0) returns error 20, so output(ndev) is false (0), that probably explain that SetLik does not work.

« Last Edit: 13 May '24 - 05:03 by Couin »

Chris

  • Posts: 2217
Re: Clone "mixed" stream to another output device ?
« Reply #4 on: 13 May '24 - 08:52 »
Code: [Select]
chan(0) = BASS_StreamCreateFile(BASSFALSE, StrPtr("1.mp3"), 0, 0, BASS_UNICODE)
chan(1) = BASS_StreamCreateFile(BASSFALSE, StrPtr("2.mp3"), 0, 0, BASS_UNICODE)

you must add BASS_STREAM_DECODE Flag

chan(0) = BASS_StreamCreateFile(BASSFALSE, StrPtr("1.mp3"), 0, 0, BASS_STREAM_DECODE or BASS_UNICODE)
chan(1) = BASS_StreamCreateFile(BASSFALSE, StrPtr("2.mp3"), 0, 0, BASS_STREAM_DECODE or BASS_UNICODE)

Couin

  • Posts: 124
Re: Clone "mixed" stream to another output device ?
« Reply #5 on: 13 May '24 - 12:54 »
Hi Chris,

Thanks for anwser, but with BASS_STREAM_DECODE flag, I have no sound at all and still get the error 20 (in the "For" loop)   :'(

Code: [Select]
No sound at all with:
    chan(0) = BASS_StreamCreateFile(BASSFALSE, StrPtr("1.mp3"), 0, 0, BASS_STREAM_DECODE Or BASS_UNICODE)
    chan(1) = BASS_StreamCreateFile(BASSFALSE, StrPtr("2.mp3"), 0, 0, BASS_STREAM_DECODE Or BASS_UNICODE)
   
Sound on first device only, with:
    chan(0) = BASS_StreamCreateFile(BASSFALSE, StrPtr("1.mp3"), 0, 0, BASS_UNICODE)
    chan(1) = BASS_StreamCreateFile(BASSFALSE, StrPtr("2.mp3"), 0, 0, BASS_UNICODE)
   
Or:
    chan(0) = BASS_StreamCreateFile(BASSFALSE, StrPtr("1.mp3"), 0, 0, 0)
    chan(1) = BASS_StreamCreateFile(BASSFALSE, StrPtr("2.mp3"), 0, 0, 0)

Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Clone "mixed" stream to another output device ?
« Reply #6 on: 13 May '24 - 17:28 »
The example looks different that what I would (I play/stop/loop/fx channels/streams independantly), I tried just with adding a button to BASS_ChannelStop(Source) , it stop but with a latency (stop 0.5 sec after click on button).
I noticed the same latency with checking/unchecking Speaker 1 .

Is it normal ?

Yes, that latency is caused by the mixer's playback buffer, ie. the mixer output already in that buffer will be heard before the changes are. You can avoid that latency by setting BASS_ATTRIB_BUFFER to 0 on the mixer, to disable playback buffering:

Code: [Select]
BASS_ChannelSetAttribute(mixer, BASS_ATTRIB_BUFFER, 0)

Code: [Select]
    Dim ndev As Byte
    For ndev = 0 To 1
        Call BASS_SetDevice(device(ndev)) 'set device for n'th output
        output(ndev) = BASS_Split_StreamCreate(mixer, 0, 0)
        If ndev <> 0 Then Call BASS_ChannelSetLink(output(0), output(ndev)) 'link all outputs to the 1st output
    Next ndev
    Call BASS_ChannelStart(device(0)) 'start the outputs
I get no sound on device(1) .

It looks like that should be "output(0)" rather than "device(0)" in the BASS_ChannelStart call, ie. the stream handle returned by BASS_Split_StreamCreate.

As Chris already mentioned, you should also add the BASS_STREAM_DECODE flag to the BASS_StreamCreateFile calls, otherwise the BASS_Mixer_StreamAddChannel calls will fail.

Couin

  • Posts: 124
Re: Clone "mixed" stream to another output device ?
« Reply #7 on: 13 May '24 - 18:11 »
Hi Ian,

Thanks for answer :)

You are right, about BASS_ChannelStart, it was a wrong copy/paste from my hand.

Code: [Select]
' Let the user choose the output devices
With frmDevice
.SelectDevice 1
.Show vbModal, Me
device(0) = .device
.SelectDevice 2
.Show vbModal, Me
device(1) = .device
End With

' setup output devices
If (BASS_Init(device(0), 44100, 0, Me.hWnd, 0) = 0) Then
Call Error_("Can't initialize device 1")
Unload Me
End If

If (BASS_Init(device(1), 44100, 0, Me.hWnd, 0) = 0) Then
Call Error_("Can't initialize device 2")
Unload Me
End If

Dim i As BASS_DEVICEINFO

Call BASS_GetDeviceInfo(device(0), i)
DeviceName(0).Caption = "Device 0 " & VBStrFromAnsiPtr(i.Name) & " "

Call BASS_GetDeviceInfo(device(1), i)
DeviceName(1).Caption = "Device 1 " & VBStrFromAnsiPtr(i.Name) & " "

Call BASS_SetDevice(device(0))

mixer = BASS_Mixer_StreamCreate(44100, 2, BASS_SAMPLE_FLOAT Or BASS_STREAM_DECODE) 'create a mixer

chan(0) = BASS_StreamCreateFile(BASSFALSE, StrPtr("1.mp3"), 0, 0, BASS_STREAM_DECODE)
chan(1) = BASS_StreamCreateFile(BASSFALSE, StrPtr("2.mp3"), 0, 0, BASS_STREAM_DECODE)

Call BASS_Mixer_StreamAddChannel(mixer, chan(0), 0)
Debug.Print BASS_ErrorGetCode() ' >>> Returns 0 so "BASS_OK"
Call BASS_Mixer_StreamAddChannel(mixer, chan(1), 0)
Debug.Print BASS_ErrorGetCode() ' >>> Retunrs 0 too

Dim ndev As Byte
For ndev = 0 To 1
Call BASS_SetDevice(device(ndev)) 'set device for ndev'th output
output(ndev) = BASS_Split_StreamCreate(mixer, 0, 0)
Debug.Print ndev & " " & output(ndev) & " " & BASS_ErrorGetCode() ' >>> Returns "0 (or 1 if ndev is 1) 0 20" so BASS_Split_StreamCreate(mixer, 0, 0) gives me 0, and it's error code is 20 (so "An illegal parameter was specified", but I don't know which it is)
If ndev <> 0 Then
Call BASS_ChannelSetLink(output(0), output(ndev)) 'link all outputs to the 1st output
Debug.Print BASS_ErrorGetCode() ' >>> Returns 5 (Invalid handle)
End If
Next ndev
Call BASS_ChannelStart(output(0)) 'start the outputs
Debug.Print BASS_ErrorGetCode() ' >>> Returns 5 (Invalid handle)
And I have no sound on any both devices.
I'm pretty sure I make a small mistake but I can't find it :(



Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Clone "mixed" stream to another output device ?
« Reply #8 on: 14 May '24 - 16:09 »
BASS_ERROR_ILLPARAM (error code 20) indicates that the BASS_Split_StreamCreate "chanmap" parameter is invalid. As you're using VB6, please try adding "ByVal" like this:

Code: [Select]
output(ndev) = BASS_Split_StreamCreate(mixer, 0, ByVal 0)

Couin

  • Posts: 124
Re: Clone "mixed" stream to another output device ?
« Reply #9 on: 14 May '24 - 16:27 »
Hi Ian,

Thanks, I get sound now, on both devices.

But both tracks (1.mp3 and 2.mp3) plays automatically at startup :(

Also, even wit BASS_ChannelSetAttribute(mixer, BASS_ATTRIB_BUFFER, 0), I get 0,5 second of latency for example to stop playback.

Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Clone "mixed" stream to another output device ?
« Reply #10 on: 14 May '24 - 17:08 »
But both tracks (1.mp3 and 2.mp3) plays automatically at startup :(

You can delay playback by not calling BASS_Mixer_StreamAddChannel until you want them to play. Another option is to use the BASS_MIXER_CHAN_PAUSE flag.

Also, even wit BASS_ChannelSetAttribute(mixer, BASS_ATTRIB_BUFFER, 0), I get 0,5 second of latency for example to stop playback.

In this case, it's the splitters that have a playback buffer (the mixer has BASS_STREAM_DECODE set which means no playback and no playback buffer), so you need to set BASS_ATTRIB_BUFFER to 0 on them instead.

Couin

  • Posts: 124
Re: Clone "mixed" stream to another output device ?
« Reply #11 on: 14 May '24 - 18:36 »
Thanks, tricks did the job :)
So now, I have the sound on demand, on both devices, without latency.

Before continuing tests (insert FX, set volume per device), I would compare with "Multi" example of bass24.zip, in vb subdirectory.

I adapted the clone channel as a function so after BASS_StreamCreateFile (and BASS_FX_TempoCreate) I Call CloneStrm(0, 1) (where 0 if the chan(0) of chan array, 1 is device #1).

Code: [Select]
' clone stream
Private Sub CloneStrm(ChanIDsrc As Integer, TargetDev As Integer)

    Dim i As BASS_CHANNELINFO
    If (BASS_ChannelGetInfo(chan(ChanIDsrc), i) = 0) Then
        Call Error_("Nothing to clone")
        Exit Sub
    End If

    Call BASS_StreamFree(chanclone(ChanIDsrc)) ' free old stream
    Call BASS_SetDevice(outdev(TargetDev)) ' set the device to create stream on

    chanclone(ChanIDsrc) = BASS_StreamCreate(i.freq, i.chans, i.Flags, STREAMPROC_PUSH, 0)

    If (chanclone(ChanIDsrc) = 0) Then  ' create a "push" stream
        'cmdOpen(1).Caption = "click here to open a file..."
        Call Error_("Can't create clone")
        Exit Sub
    End If

    Call BASS_ChannelLock(chan(ChanIDsrc), BASSTRUE) ' lock source stream to synchonise buffer contents
    Call BASS_ChannelSetDSP(chan(ChanIDsrc), AddressOf CloneDSP, chanclone(ChanIDsrc), 0) ' set DSP to feed data to clone
    ' copy buffered data to clone
    Dim c As Long
    c = BASS_ChannelGetData(chan(ChanIDsrc), ByVal 0, BASS_DATA_AVAILABLE)
    Dim buf() As Long
    ReDim buf(c) As Long
    c = BASS_ChannelGetData(chan(ChanIDsrc), buf(0), c)
    Call BASS_StreamPutData(chanclone(ChanIDsrc), buf(0), c)
    Erase buf

    Call BASS_ChannelLock(chan(ChanIDsrc), BASSFALSE) ' unlock source stream
End Sub

I think it does something like that I drawn as attachment.

I get the same result (a very small delay between both device, but I think that is because there are not the same, one is the audio chip of PC , the other is an USB stick, the delay uis always in the same direction, regardless with device is the first selected).

The "clone" way looks easier for me (just have to add CloneStrm calls), do you think one way is better than the other ?

Thanks :)


Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Clone "mixed" stream to another output device ?
« Reply #12 on: 15 May '24 - 14:43 »
One advantage of using a mixer is that it gives you easy access to the mix (eg. if you want to write/cast it all), but if you don't need that and you find the clones simpler then you may as well stick with the latter.

For completeness, there's also a third option: using splitters for the cloning. The mixer is removed and the BASS_Split_StreamCreate calls are on the file streams instead. The BASSmix version of the MULTI.C example does this.

Couin

  • Posts: 124
Re: Clone "mixed" stream to another output device ?
« Reply #13 on: 15 May '24 - 15:03 »
Hi Ian,

Thanks for answer :)

I will try to do otherwise than clone, because I tried it in the final project, and I encounter problems ( 1) sound is played twice on the same device instead of one time on each device, I did not found why for the moment, even with changing the target device in the CloneStream sub , 2) I use BASS_POS_BYTE/BASS_POS_LOOP/BASS_POS_END and it makes some strange things).

About BASS_Split_StreamCreate, will it acts correctly with BASS_POS_BYTE/BASS_POS_LOOP/BASS_POS_END ?  I mean these parameters are applied before splitting (so the sound should be the same on each outputs) ?

The goal for the moment is to send to another device, live a Virtual Cable, and from this virtual cable, pass through a sound processor (like Breakaway or which user want, if want a processing) and an encoder (like BUTT for example) to broadcast/record.
Perhaps in the future, broadcast/record directly from the app, but as well as some other apps can already do it, it's not a priority.
« Last Edit: 15 May '24 - 17:44 by Couin »

Couin

  • Posts: 124
Re: Clone "mixed" stream to another output device ?
« Reply #14 on: 16 May '24 - 03:48 »
Hi again :)

I'm near to obtain good results with mixer and split.

Previously (when using one device only, without mixer), I was getting the level of each streams, to been displayed on VU-meters (the louder stream defines the level, at the measure moment), with a Timer.

Since I changed for mixer and split, the audio plays crappy faster (but at the same height, with missing parts of audio). I join the normal and wrong playbacks as zip file.

I use BASS_ChannelGetLevel(chan(x)), I tried (outsite from the For x = 0 to nTracks loop)  BASS_ChannelGetLevel(mixer), same result.
Also with BASS_ChannelGetLevelEx, I get the same result (on individual track like with mixer).

Is there a way to get the level without this problem ? Per streams and/or per device (preventing to having to make a For loop to measure each streams) ?

Thanks :)

(PS : A friend comes this afternoon until sunday , so I could probably not test until he's gone)

Chris

  • Posts: 2217
Re: Clone "mixed" stream to another output device ?
« Reply #15 on: 16 May '24 - 11:12 »
Hi,
in the BASS_Mixer_StreamAddChannel Call you must add the Flag
BASS_MIXER_CHAN_BUFFER

Couin

  • Posts: 124
Re: Clone "mixed" stream to another output device ?
« Reply #16 on: 16 May '24 - 12:37 »
Hi Chris,

Thanks for the tip :)

My friend is near to arrive but I had time to test.

I was not getting good result but after some search I had to change BASS_ChannelGetLevel for BASS_Mixer_ChannelGetLevel in the Timer

So I used:
Code: [Select]
Call BASS_Mixer_StreamAddChannel(mixer, chan(x), BASS_MIXER_CHAN_BUFFER)
and in the Timer:
Code: [Select]
ChanLev = BASS_Mixer_ChannelGetLevel(chan(x))
'and extract values with LoWord and HiWord...

Is it OK ? It looks giving good result for me :)

Chris

  • Posts: 2217
Re: Clone "mixed" stream to another output device ?
« Reply #17 on: 16 May '24 - 12:53 »
yes that will looks fine.

Couin

  • Posts: 124
Re: Clone "mixed" stream to another output device ?
« Reply #18 on: 16 May '24 - 13:35 »
Thanks again both Ian and Chris  :-*

Couin

  • Posts: 124
Re: Clone "mixed" stream to another output device ?
« Reply #19 on: 22 May '24 - 06:22 »
Hi friends :D

I'm near from obtaining very good results but I encounter 2 problems with mixer and splits.

The first: I set the volume for each device with
Code: [Select]
BASS_SetDevice (OutDev(nDev))
BASS_SetVolume (vol(nDev) / 100)
Where nDev is 0 or 1 (for 2 output devices), vol(nDev) is an array where are stored volume values from 0 to 100. The problem is that it change the volume of device for all other  application that using it. I mean, if I listen something with Winamp, and with my app, if I turn down the volume in my app, I can not ear what Winamp plays.

The second: If a device is a Virtual Audio Cable (for example https://vac.muzychenko.net/en/ ), BASS_SetVolume does nothing for sound and is to much loud (clipping and saturated). But BASS_ChannelGetAttribute and BASS_Mixer_ChannelGetLevel reflects volume changes.

Is there a way to set the volume of splits (I mean, between mixer and devices) ? So it would not affect other apps and would really change the volume before to send to Virtual Cable.

Thanks :D

Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Clone "mixed" stream to another output device ?
« Reply #20 on: 22 May '24 - 13:42 »
BASS_SetVolume sets the device's master volume, which indeed affects all users of the device. You can instead use each splitter's BASS_ATTRIB_VOL setting (via BASS_ChannelSetAttribute) to control their volume levels without affecting anything else.

Couin

  • Posts: 124
Re: Clone "mixed" stream to another output device ?
« Reply #21 on: 22 May '24 - 17:22 »
Hi Ian,

Thanks, I didn't think it was possible with split channels, but it's good.
Plus, I also used BASS_ChannelGetLevel on splitted channels to display volume on VU-Meter, it's much simpler than looping over each channel going to the mixer to measure their level.

About loud and clipping with Virtual Cable, I uninstalled and reinstalled it and the problem seems gone...

:)

Couin

  • Posts: 124
Re: Clone "mixed" stream to another output device ?
« Reply #22 on: 23 May '24 - 17:31 »
Hi Ian ,

I would add a microphone input on my app, but with possibility to choose on which of two devices to send it. So I can not use the mixer.
In a first time, I tried to split the recordstart handle, and setdevice, StreamCreateFile, and channelplay, but without success, it even crashes the VB6 IDE.
So I created a second mixed, and I manage splitted outputs level to choose if the mic plays on a device or the other or both or none.

I runs* but perhaps a way to do nicer?

*I notice a latency (measured 123 ms) when I listen the mic input, is there a way to reduce this ? Having this delay in headphones when we speak is just very disturbing  :o ).

Thanks :)

Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Clone "mixed" stream to another output device ?
« Reply #23 on: 24 May '24 - 13:44 »
It doesn't seem like you really need a second mixer for that, as you aren't mixing anything with the recording? You could instead create splitter(s) directly from the recording, ie. use the recording channel handle in the BASS_Split_StreamCreate call(s). You can minimize latency by setting the splitter's BASS_ATTRIB_BUFFER to 0 like before. Note the splitter(s) should be started before or straight after the recording to avoid a build-up of data in the recording buffer (which will increase latency). If needed, you can also use BASS_ChannelGetData to remove data from the recording buffer.

Couin

  • Posts: 124
Re: Clone "mixed" stream to another output device ?
« Reply #24 on: 24 May '24 - 16:30 »
Hi Ian,

To clarify my needing, I made a schematic of what I want to do :)

I removed the second mixer, and splitted directly the Mic stream, still running (I won 3 ms latency, now I'm at 118 ms).

About latency, BASS_ATTRIB_BUFFER  should be placed before "Split" ? Before RecordStart ?

Here is my actual code:
Code: [Select]
Call BASS_RecordFree
Call BASS_RecordInit(-1)
Call BASS_RecordSetInput(-1, BASS_INPUT_ON, -1)
MicInput = BASS_RecordStart(44100, 2, 0, 0, 0)
Call BASS_ChannelSetAttribute(MicInput, BASS_ATTRIB_BUFFER, 0)

For nDev = 0 To 1
Call BASS_SetDevice(OutDev(nDev))
SplitInput(nDev) = BASS_Split_StreamCreate(MicInput, 0, ByVal 0)
Call BASS_ChannelSetAttribute(SplitInput(nDev), BASS_ATTRIB_BUFFER, 0)
If nDev <> 0 Then
Call BASS_ChannelSetLink(SplitInput(0), SplitInput(nDev))
End If
Call BASS_ChannelSetAttribute(SplitInput(nDev), BASS_ATTRIB_VOL, 0)
Next nDev
Call BASS_ChannelStart(SplitInput(0))

'For testing, set volume for each splitted mic channel
Call BASS_ChannelSetAttribute(SplitInput(0), BASS_ATTRIB_VOL, 1)
Call BASS_ChannelSetAttribute(SplitInput(1), BASS_ATTRIB_VOL, 0)

About BASS_ChannelGetData, I checked the documentation but I don't understand what to do with it.
I tried to place it ( Call BASS_ChannelGetData(MicInput, ByVal 0, BASS_DATA_FFT256) )  after MicInput = BASS_RecordStart(44100, 2, 0, 0, 0) but it does not change slighly.

I join a zip file including a mp3 of what gives the latency between mic and headphones/speakers: I took my phone to record when I hit the microphone (first "poc") and when the sound is played by speaker (the second "poc").

If you have an idea to reduce it slighly, because in radio shows for example, we listen our voice, but with this latency, it's hard to not stutt lol

Thanks :)