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

Ian @ un4seen

  • Administrator
  • Posts: 25884
Re: Clone "mixed" stream to another output device ?
« Reply #50 on: 13 Jun '24 - 17:08 »
I tried with both , no problem with measurement between MixerSources and MixerMain (excepted that with BASS_ChannelGetLevel the audio plays too fast).

Yes, you should only use BASS_Mixer_ChannelGetLevel on mixer sources, because the data taken by BASS_ChannelGetLevel wouldn't be seen by the mixer (causing skipping/speedy playback).

Measuring MixerMain output receving zeros but sound still ok (no dropouts).

Do you mean BASS_ChannelGetLevel on SplitOutDev? To perhaps narrow it down, does it still happen if you don't set BASS_ATTRIB_BUFFER to 0 on SplitOutDev?

Couin

  • Posts: 118
Re: Clone "mixed" stream to another output device ?
« Reply #51 on: 14 Jun '24 - 22:44 »
Hi Ian

Removing buffer attribute resolves the "missing measures" but makes getposition jerky (resulting to a remaining time slow refresh). Plus, it add delay bewteen hitting play and sound.

Couin

  • Posts: 118
Re: Clone "mixed" stream to another output device ?
« Reply #52 on: 25 Jun '24 - 01:34 »
Hi :)

I'm modifying ouput device selection method so now, changing device directly apply, without reloading audio files:
Call BASS_StreamFree(SplitOutDev(outp)) 'where outp is 0 or 1, related with Main or Aux outputs of the schematic here https://www.un4seen.com/forum/?topic=20403.msg143048#msg143048
Changing the device number et recreate the SplitOutDev (split) stream.

Works OK, but just a minor question (for a rare situation):
If Aux is firstly set on "None" device (so 0), if I played some jingle, when I change Aux for an output device, I get the end part of last playback.

I tried to add some BASS_Split_StreamReset calls , for SplitOutDev, MixerMain or MixerAux, but nothing change.
I added BASS_CONFIG_SPLIT_BUFFER, if I set to 0, I get no more part of last playback on device change, but playback is to fast and crappy. If I set to a value like 100, the playback speed is ok but I get a small part of previous playback.

Is there a way to clear buffer to prevent this ?

Thanks :D




Ian @ un4seen

  • Administrator
  • Posts: 25884
Re: Clone "mixed" stream to another output device ?
« Reply #53 on: 25 Jun '24 - 14:38 »
Removing buffer attribute resolves the "missing measures" but makes getposition jerky (resulting to a remaining time slow refresh). Plus, it add delay bewteen hitting play and sound.

OK. Here's a modified version of the CONTEST.C example for you to try for comparison, adding a BASS_ATTRIB_BUFFER=0 option and a BASS_DATA_AVAILABLE display:

   www.un4seen.com/stuff/contest-nobuf.exe

Please try that with and without the "-n" option (BASS_ATTRIB_BUFFER=0), and see whether the level display is working and what "data" values (BASS_DATA_AVAILABLE) are shown in each case. If it's working fine even with "-n" then you can also try monitoring the BASS_DATA_AVAILABLE values (with BASS_ChannelGetData) in your app to see if they're different.

I'm modifying ouput device selection method so now, changing device directly apply, without reloading audio files:
Call BASS_StreamFree(SplitOutDev(outp)) 'where outp is 0 or 1, related with Main or Aux outputs of the schematic here https://www.un4seen.com/forum/?topic=20403.msg143048#msg143048
Changing the device number et recreate the SplitOutDev (split) stream.

Works OK, but just a minor question (for a rare situation):
If Aux is firstly set on "None" device (so 0), if I played some jingle, when I change Aux for an output device, I get the end part of last playback.

A new splitter shouldn't play old data from its source, so it seems like the old sound may actually be in new data from the source. How much old sound are you getting? And is this happening on the same WinXP VM and/or on other systems? Does adding the BASS_MIXER_NONSTOP flag to MixerAux make any difference?

Couin

  • Posts: 118
Re: Clone "mixed" stream to another output device ?
« Reply #54 on: 26 Jun '24 - 00:05 »
Hi Ian :)

BASS_MIXER_NONSTOP flag seems resolve the problem :)
(It's not on the XP VM of the level measurement problem, the re-playing was on a non-VM W10, which I use for main developpment).

About contest exe, I will test this afternoon at work (where is the XP VM on which I get some missing level measures), it's my last day before summer hollydays.

Couin

  • Posts: 118
Re: Clone "mixed" stream to another output device ?
« Reply #55 on: 26 Jun '24 - 14:45 »
Hi Ian,

I tested the exe with and without -n flag, with a 10 seconds sine of 1 kHz @ max amplitude.

With -n , the VU-meters doesn't fall down. Data value runs around 20000, but sometimes with a near from 0 (too fast to read exactly), no sound problem.

Without -n , VU-meters still OK, Data around 160000 , and I did not saw 0 values.

Ian @ un4seen

  • Administrator
  • Posts: 25884
Re: Clone "mixed" stream to another output device ?
« Reply #56 on: 26 Jun '24 - 17:26 »
Is that on the same system that you're having the BASS_ChannelGetLevel=0 problem with your app? If so, strange that it isn't happening with the modified example. You could try monitoring the BASS_DATA_AVAILABLE value in your app for comparison.

Code: [Select]
avail = BASS_ChannelGetData(handle, 0, BASS_DATA_AVAILABLE)

Also, if you're changing any config settings via BASS_SetConfig, try removing that to use the defaults (which is what the example does).

Couin

  • Posts: 118
Re: Clone "mixed" stream to another output device ?
« Reply #57 on: 26 Jun '24 - 23:16 »
Yes, I tested your exe on the samed XP VM which makes some missing level measures.
But as I previoulsy wrote, I get missing messures on splitted output of second mixer (Main or Aux), but not if I measure between primary and secondary mixer ( so SplitSources ).

I took the pc where the VM is hosted, for hollydays :P
So I will be able to do tests on it (but not today and friday).

Couin

  • Posts: 118
Re: Clone "mixed" stream to another output device ?
« Reply #58 on: 16 Jul '24 - 03:26 »
Hi :)

Working on ASIO output with a soundcard that has ASIO driver (Rane SL3) so now I understand better, about channels (as well as this soundcard has 3 Stereo outputsso GetInfo returns me "6").

I can setup on which pair of channels to send the splitted stream ( SplitOutDev(0) ), but if I want to change of channel pair, I must BASS_ASIO_Free and BASS_ASIO_Init, BASS_Split_StreamCreate, BASS_ASIO_ChannelEnableBASS etc and it takes a delay to do all these steps.

It's not a big problem, but is there a best way to change channels where to send stream, without free and init the device ?

Thanks :)


Ian @ un4seen

  • Administrator
  • Posts: 25884
Re: Clone "mixed" stream to another output device ?
« Reply #59 on: 16 Jul '24 - 17:12 »
You don't actually need to call BASS_ASIO_Free and BASS_ASIO_Init to change the enabled ASIO channels. BASS_ASIO_Stop and BASS_ASIO_Start will suffice, like this:

Code: [Select]
BASS_ASIO_Stop(); // stop ASIO device
BASS_ASIO_ChannelEnable(false, oldoutput, 0, 0); // disable old channels
BASS_ASIO_ChannelEnableBASS(false, newoutput, handle, true); // enable new channels
BASS_ASIO_Start(0, 0); // resume ASIO device

If there are no other ASIO channels being used then you could use BASS_ASIO_ChannelReset instead of BASS_ASIO_ChannelEnable to disable the old channels, which has the advantage of not needing to know the "oldoutput" value.

Code: [Select]
BASS_ASIO_ChannelReset(false, -1, BASS_ASIO_RESET_ENABLE); // disable all output channels

Couin

  • Posts: 118
Re: Clone "mixed" stream to another output device ?
« Reply #60 on: 16 Jul '24 - 23:48 »
Hi Ian :)

I tried these solution, looks OK if changing channels while nothing is playing, but I get bad result is something is playing while I change channels: on the old channels I get stuttering last part of audio. If I come back on old channels, the stuttering diseappear and the sound plays fine.

I attach a zip file including a recording of channels 5+6 ("Right deck" output of Rane SL3).
@10 seconds, I change for channels "1+2" (AUX Output)
@16 seconds, I change back for channels 5+6 (Right Deck)

Of course "1+2" or "5+6" is to match with ASIO panel, but BASS ASIO channels are 0+1 , and 4+5.

The dropdown list (cmbASIOChanOut) allows to choose between these possibilities:
1+2
2+3
3+4
4+5
5+6

Here is the code:
Code: [Select]
Call BASS_ASIO_Stop
Call BASS_ASIO_ChannelEnable(BASSFALSE, ASIOChanOut, 0, 0) 'disable old channels
ASIOChanOut = cmbASIOChanOut.ListIndex
Call BASS_ASIO_ChannelEnableBASS(0, ASIOChanOut, SplitOutDev(0), BASSTRUE)
Call BASS_ASIO_Start(0, 0)

I tried to place BASS_ASIO_ChannelReset but change nothing.

If I remove BASS_ASIO_Stop call, it's ok, but I don't know if it's a clean procedure.



Ian @ un4seen

  • Administrator
  • Posts: 25884
Re: Clone "mixed" stream to another output device ?
« Reply #61 on: 17 Jul '24 - 13:53 »
That's strange. Sounds like the ASIO driver isn't clearing and/or ignoring the disabled channel buffers. Here's a BASSASIO update for you to try, which will clear the buffers in BASS_ASIO_Stop.

   www.un4seen.com/stuff/bassasio.zip

Let me know whether it helps.

Couin

  • Posts: 118
Re: Clone "mixed" stream to another output device ?
« Reply #62 on: 18 Jul '24 - 00:49 »
Hi Ian,

Thanks for the dll, but it did not changed the behavior.

Objectively, I think that not putting BASS_ASIO_Stop is a real problem, given that we don't change channels regularly but just at the hardware configuration.
Also, knowing that I want to use ASIO inputs, BASS_ASIO_Stop could stop the inputs (?)

But I noticed another problem (I did not saw it before, because I plugged only one stereo cable on 5+6):
If I change the channels, sound stops on old channel, but I get no sound on new selecte channels.

The only way to get sound back is re-selecting initial channels, or restart the software.
« Last Edit: 18 Jul '24 - 01:25 by Couin »

Couin

  • Posts: 118
Re: Clone "mixed" stream to another output device ?
« Reply #63 on: 19 Jul '24 - 01:21 »
Hi,

I read in the documentation that no more channel can be enabled if device has not been stopped before, that should explain why I get no sound on new selected channels.

So must use BASS_ASIO_Stop but I get stuttering , even if I stop all streams before.

Ian @ un4seen

  • Administrator
  • Posts: 25884
Re: Clone "mixed" stream to another output device ?
« Reply #64 on: 19 Jul '24 - 12:09 »
Yes, the ASIO device does need to be stopped before enabling new ASIO channels (output or input), and BASS_ASIO_ChannelEnable/etc will otherwise fail with BASS_ERROR_START. It is possible to disable and then re-enable the same channels (ie. not new ones) without stopping the device, so if even a slight pause to enable channels would be a problem then you could pre-enable all channels.

But first, I think it would be best to get to the bottom of the stuttering sound issue. To narrow it down, please try using a plain file stream (eg. from BASS_StreamCreateFile) instead of a splitter in the BASS_ASIO_ChannelEnableBASS calls and see if the problem is still present then.

Couin

  • Posts: 118
Re: Clone "mixed" stream to another output device ?
« Reply #65 on: 20 Jul '24 - 03:49 »
Hi Ian,

That what I was thinkng  (testing without split) -> Same result

Tested with a minimal project, without mixer -> Same result

Added a button that calls Bass_ASIo_Stop and I notice one repeat of last audio part (around few 200 ms I think).


The code of project (1 button "btStop", 1 button "btExit", 1 dropdown list (Combo) "cmbASIOChanOut", 1 label "lblfeedback"):

Code: [Select]
Option Explicit

Dim AudioStream As Long
Dim ASIODevOut As Integer
Dim ASIOChanOutCount As Integer
Dim ASIOChanOut As Integer

Private Sub btExit_Click()
Unload Me
End Sub

Private Sub btStop_Click()
    Call BASS_ASIO_Stop
End Sub

Public Sub cmbASIOChanOut_Click()
    Dim i As Integer

    Call BASS_ASIO_Stop   'stop ASIO processing
    Call BASS_ASIO_ChannelEnable(0, ASIOChanOut, 0, 0) 'disable old inputs
    ASIOChanOut = cmbASIOChanOut.ListIndex
    Debug.Print ASIOChanOut
    Call BASS_ASIO_ChannelEnableBASS(0, ASIOChanOut, AudioStream, BASSTRUE) 'enable new inputs
    Call BASS_ASIO_Start(0, 0) 'resume ASIO processing
   
End Sub

Private Sub Form_Load()
    ' change and set the current path, to prevent from VB not finding BASS.DLL
    ChDrive App.Path
    ChDir App.Path
   
    Call BASS_Init(0, 44100, 0, 0, 0)
   
    ASIODevOut = 2
    ASIOChanOut = 4
    Call BASS_ASIO_Init(ASIODevOut, 0)
    ListChanOutASIO
   
    AudioStream = BASS_StreamCreateFile(BASSFALSE, StrPtr("track.mp3"), 0, 0, BASS_STREAM_DECODE)
    lblfeedback.Caption = AudioStream
   
    Dim i As BASS_CHANNELINFO
   
    Call BASS_ASIO_ChannelEnableBASS(0, ASIOChanOut, AudioStream, BASSTRUE)
    Call BASS_ASIO_SetRate(i.freq) 'try to set the device rate to avoid resampling

    'start it using default buffer size
    If (BASS_ASIO_Start(0, 0) = 0) Then
        Call BASS_ASIO_Free
        Call BASS_Free
        MsgBox "Can't initialize device " & ASIODevOut
    End If
   
End Sub

Public Sub ListChanOutASIO()

    Dim info As BASS_ASIO_INFO
    Call BASS_ASIO_GetInfo(info)
    ASIOChanOutCount = info.outputs
 
    Dim o As Integer
    cmbASIOChanOut.Clear
    For o = 1 To ASIOChanOutCount - 1
        cmbASIOChanOut.AddItem o & "+" & o + 1
    Next o
    cmbASIOChanOut.ListIndex = ASIOChanOut
   
End Sub

Private Sub Form_Unload(Cancel As Integer)
        Call BASS_ASIO_Free
        Call BASS_Free
End Sub

Ian @ un4seen

  • Administrator
  • Posts: 25884
Re: Clone "mixed" stream to another output device ?
« Reply #66 on: 22 Jul '24 - 18:04 »
The problem doesn't seem to be happening here (not using your VB code above but something very similar in C), so I suspect it may be driver-specific. To confirm that, does it happen for you when using a different ASIO device/driver? If you don't currently have another one to try, you could try ASIO4ALL.

Couin

  • Posts: 118
Re: Clone "mixed" stream to another output device ?
« Reply #67 on: 23 Jul '24 - 13:51 »
Hi,

With ASIO4ALL, I can't reproduce, but perhaps because not a real ASIO device (?).
I have no other ASIO device (hardware) ellse to test for the moment, Rane SL 1 ASIO drivers seems not Win10 compatible :(

Ian @ un4seen

  • Administrator
  • Posts: 25884
Re: Clone "mixed" stream to another output device ?
« Reply #68 on: 24 Jul '24 - 13:03 »
OK. Just to be sure VB6 isn't interfering somehow, here's a modified version of BASSASIO's CONTEST.C example for you to try. When you press the spacebar, it'll switch to the next stereo output pair. Do you hear the problem when doing that?