Author Topic: BASS_ASIO_Monitor  (Read 582 times)

SotirisPapad

  • Posts: 15
BASS_ASIO_Monitor
« on: 15 Apr '17 - 07:36 »
I am try this function to hear mic sound without latency in my headphones.
Is it possimple ?
I can't understud the gain and pan parameter. 


Ian @ un4seen

  • Administrator
  • Posts: 20152
Re: BASS_ASIO_Monitor
« Reply #1 on: 17 Apr '17 - 16:25 »
Assuming you want the sound to be centred at 0 dB (normal level), then "gain" should be set to 0x20000000 and "pan" set to 0x40000000, like this:

Code: [Select]
result = BASS_ASIO_Monitor(input, output, 0x20000000, 1, 0x40000000);

Note that BASS_ASIO_Monitor isn't supported by all devices, and the output/gain/pan settings may also be ignored by some. In that case, you could use BASS_ASIO_ChannelEnableMirror instead:

Code: [Select]
result = BASS_ASIO_ChannelEnableMirror(output, true, input);

SotirisPapad

  • Posts: 15
Re: BASS_ASIO_Monitor
« Reply #2 on: 18 Apr '17 - 00:49 »
I tried but it's hard for me.
If you have some code for Delphi would be very useful for me

3delite

  • Posts: 888
Re: BASS_ASIO_Monitor
« Reply #3 on: 18 Apr '17 - 10:45 »
This seems working here:

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
begin
    // not playing anything via BASS, so don't need an update thread
    BASS_SetConfig(BASS_CONFIG_UPDATEPERIOD,0);
    // init BASS (for the FX)
    BASS_Init(0,44100,0,0,nil);

    // init ASIO - first device
    if not (BASS_ASIO_Init(0,0)) then begin
        BASS_Free();
        ShowMessage('Can''t initialize ASIO');
    end;

    if NOT BASS_ASIO_ChannelEnableMirror(0, true, 0) then begin
        Showmessage('Error: BASS_ASIO_Monitor ' + IntToStr(BASS_ASIO_ErrorGetCode));
    end;

    if NOT BASS_ASIO_ChannelEnableMirror(1, true, 1) then begin
        Showmessage('Error: BASS_ASIO_Monitor ' + IntToStr(BASS_ASIO_ErrorGetCode));
    end;

    BASS_ASIO_Start(0,1);

end;

SotirisPapad

  • Posts: 15
Re: BASS_ASIO_Monitor
« Reply #4 on: 24 Apr '17 - 09:37 »
BASS_ASIO_ChannelEnableMirror  and Asioproc ????? 
Asio drivers and BASS_ChannelSlideAttribute(Stream,BASS_ATTRIB_VOL,0,2000);
is working with asio drivers ?
« Last Edit: 24 Apr '17 - 09:42 by SotirisPapad »

Ian @ un4seen

  • Administrator
  • Posts: 20152
Re: BASS_ASIO_Monitor
« Reply #5 on: 24 Apr '17 - 17:26 »
You don't need an ASIOPROC callback function when using BASS_ASIO_ChannelEnableMirror. If you want to implement an ASIOPROC function, then you should use BASS_ASIO_ChannelEnable instead of BASS_ASIO_ChannelEnableMirror.

BASS_ChannelSlideAttribute won't have any direct effect on ASIO output; you can use BASS_ASIO_ChannelSetVolume instead to adjust the level. If you happen to be feeding a mixer to an ASIO output, then BASS_ChannelSlideAttribute would have effect on the mixer's sources.

SotirisPapad

  • Posts: 15
Re: BASS_ASIO_Monitor
« Reply #6 on: 28 Apr '17 - 12:58 »
How can i record from my asio card ?
I want record microphone and music.

Ian @ un4seen

  • Administrator
  • Posts: 20152
Re: BASS_ASIO_Monitor
« Reply #7 on: 28 Apr '17 - 17:04 »
It depends on what input channels your ASIO device/driver has. You can use the pre-compiled LIST.EXE example included in the BASSASIO package (C\BIN folder) to quickly check that.

SotirisPapad

  • Posts: 15
Re: BASS_ASIO_Monitor
« Reply #8 on: 28 Apr '17 - 18:56 »
List.exe is runing but after is closing and i can't see
I have tascam 4x4
4 inpouts and 4 outputs

Ian @ un4seen

  • Administrator
  • Posts: 20152
Re: BASS_ASIO_Monitor
« Reply #9 on: 2 May '17 - 13:02 »
The pre-compiled LIST.EXE example should be run in a Command Prompt window. You can then copy'n'paste the text from there.

Dev01

  • Posts: 16
Re: BASS_ASIO_Monitor
« Reply #10 on: 26 Jun '17 - 16:17 »
I'm also stuck here.

If I use BASS_ASIO_ChannelEnableMirror() following the other cases in the forum
lRet = BASS_ASIO_ChannelEnableMirror(2, True, 2) 
I can hear the input but:
1) I cannot play anymore
2) I cannot stop the monitor
    I've tried some combinations of
    lRet = BASS_ASIO_ChannelReset(False, 2, BASS_ASIO_RESET_ENABLE)
    lRet = BASS_ASIO_ChannelReset(True, 2, BASS_ASIO_RESET_ENABLE)
    lRet = BASS_ASIO_ChannelReset(False, -1, BASS_ASIO_RESET_ENABLE Or BASS_ASIO_RESET_JOIN)
    but they don't work.


If I use BASS_ASIO_Monitor() following the doc in http://www.bass.radio42.com/help/html/9f3864e7-8753-6beb-e793-7d8ff207d1a5.htm
(because it's undocumented in   http://www.un4seen.com/doc/#bassasio/)
lRet = BASS_ASIO_Monitor(2, 2, &H20000000, 1, &H40000000)
or
lRet = BASS_ASIO_Monitor(2, 2, &H20000000, 3, &H40000000)
the play still works, but I cannot hear incoming audio.
No error, just silence.

Please, help.

NOTE: this case is similar to  Topic: Input to output "loop through" via ASIO https://www.un4seen.com/forum/?topic=7140.msg48526
« Last Edit: 26 Jun '17 - 16:34 by Dev01 »

Ian @ un4seen

  • Administrator
  • Posts: 20152
Re: BASS_ASIO_Monitor
« Reply #11 on: 26 Jun '17 - 17:17 »
If I use BASS_ASIO_ChannelEnableMirror() following the other cases in the forum
lRet = BASS_ASIO_ChannelEnableMirror(2, True, 2) 
I can hear the input but:
1) I cannot play anymore

Do you want to monitor an input channel and play other sounds at the same time on the same output channel? If so, you would need to use a mixer instead of the mirroring option. The input channel would be plugged into the mixer (via a "push" stream) along with the other sounds that you want to play, and the output's ASIOPROC would get its data from the mixer. It could look something like this:

Code: [Select]
BASS_ASIO_ChannelEnable(FALSE, 0, OutputAsioProc, 0); // enable the ASIO output channel
BASS_ASIO_ChannelSetFormat(FALSE, 0, BASS_ASIO_FORMAT_FLOAT); // set it to floating-point
BASS_ASIO_ChannelEnable(TRUE, 0, InputAsioProc, 0); // enable the ASIO input channel
BASS_ASIO_ChannelSetFormat(TRUE, 0, BASS_ASIO_FORMAT_FLOAT); // set it to floating-point
mixer = BASS_Mixer_StreamCreate(BASS_ASIO_GetRate(), 1, BASS_SAMPLE_FLOAT|BASS_STREAM_DECODE); // create a mixer for the output channel
instream = BASS_StreamCreate(BASS_ASIO_GetRate(), 1, BASS_SAMPLE_FLOAT|BASS_STREAM_DECODE, STREAMPROC_PUSH, 0); // create a push stream for the input channel
BASS_Mixer_StreamAddChannel(mixer, instream, 0); // plug it into the mixer
// plug other sounds into the mixer here
BASS_ASIO_Start(0, 0); // start it

...

DWORD CALLBACK InputAsioProc(BOOL input, DWORD channel, void *buffer, DWORD length, void *user)
{
BASS_StreamPutData(instream, buffer, length); // pass the input's data to the push stream
return 0;
}

DWORD CALLBACK OutputAsioProc(BOOL input, DWORD channel, void *buffer, DWORD length, void *user)
{
int r = BASS_ChannelGetData(mixer, buffer, length); // get data from the mixer
if (r == -1) return 0;
return r;
}

That is assuming that the input and output are both mono. Adjust the "chans" parameter in the BASS_Mixer_StreamCreate and/or BASS_StreamCreate calls if not.

If I use BASS_ASIO_Monitor() following the doc in http://www.bass.radio42.com/help/html/9f3864e7-8753-6beb-e793-7d8ff207d1a5.htm
(because it's undocumented in   http://www.un4seen.com/doc/#bassasio/)
lRet = BASS_ASIO_Monitor(2, 2, &H20000000, 1, &H40000000)
or
lRet = BASS_ASIO_Monitor(2, 2, &H20000000, 3, &H40000000)
the play still works, but I cannot hear incoming audio.
No error, just silence.

The ASIO monitoring feature isn't supported by all devices/drivers, so that may be why nothing seems to be happening in your case. For comparison, are you able to get it working in any other ASIO software?

Dev01

  • Posts: 16
Re: BASS_ASIO_Monitor
« Reply #12 on: 27 Jun '17 - 10:18 »
Do you want to monitor an input channel and play other sounds at the same time on the same output channel?
    >>>Yes

If so, you would need to use a mixer instead of the mirroring option.
   >>>I cannot make this works.
          I've followed your snipped as far I can (thanks about it), seems to work but no sound.
          I've tried different combination of the functions, flags, order of call, but no luck.

 For comparison, are you able to get it working in any other ASIO software?
   >>>No, at the moment.



The only things that seems to work for me is BASS_ASIO_ChannelEnableMirror() but I cannot undertand how to detach.
In fact, when I try to play, I always hear the incoming audio in.
I've tried:
BASS_ASIO_Stop()
BASS_ChannelStop()
BASS_ASIO_ChannelEnableMirror(-1, True, 2)
BASS_ASIO_ChannelReset()
and other BASS_function_combination but no luck, again.

Please, help.

Ian @ un4seen

  • Administrator
  • Posts: 20152
Re: BASS_ASIO_Monitor
« Reply #13 on: 27 Jun '17 - 14:09 »
Do you want to monitor an input channel and play other sounds at the same time on the same output channel?
    >>>Yes

If so, you would need to use a mixer instead of the mirroring option.
   >>>I cannot make this works.
          I've followed your snipped as far I can (thanks about it), seems to work but no sound.
          I've tried different combination of the functions, flags, order of call, but no luck.

Are all of the BASSASIO function calls reporting success in their return values? Also, are your ASIOPROC functions getting called after you call BASS_ASIO_Start?

The only things that seems to work for me is BASS_ASIO_ChannelEnableMirror() but I cannot undertand how to detach.
In fact, when I try to play, I always hear the incoming audio in.
I've tried:
BASS_ASIO_Stop()
BASS_ChannelStop()
BASS_ASIO_ChannelEnableMirror(-1, True, 2)
BASS_ASIO_ChannelReset()
and other BASS_function_combination but no luck, again.

What is the return value of the BASS_ASIO_ChannelReset call? If it's FALSE (0), also check the error code with BASS_ASIO_ErrorGetCode.

Dev01

  • Posts: 16
Re: BASS_ASIO_Monitor
« Reply #14 on: 27 Jun '17 - 15:14 »
Are all of the BASSASIO function calls reporting success in their return values?
       >>>All functions return 1
Also, are your ASIOPROC functions getting called after you call BASS_ASIO_Start?
       >>>It's very difficult for me to answer to this question.
              Since I'm using VB6 and BASS+callback is not compatible with VB6 (it always crashes)
              I'm not sure of nothing, because I cannot debug with VB6 IDE.
              I've to use MsgBox and log file to try to understand something. 
 
What is the return value of the BASS_ASIO_ChannelReset call? If it's FALSE (0), also check the error code with BASS_ASIO_ErrorGetCode.
        >>>I've found a combination that works
               lRet = BASS_ASIO_Stop()
               lRet = BASS_ASIO_ChannelReset(False, 2, BASS_ASIO_RESET_ENABLE)
               lRet = BASS_ASIO_ChannelReset(False, 2 + 1, BASS_ASIO_RESET_ENABLE)
               but only in some circumstance, in others it doesn't work.
               Thus, sometimes I've to close/oper the monitorIN twice to get things working.

Ian @ un4seen

  • Administrator
  • Posts: 20152
Re: BASS_ASIO_Monitor
« Reply #15 on: 27 Jun '17 - 17:35 »
Also, are your ASIOPROC functions getting called after you call BASS_ASIO_Start?
       >>>It's very difficult for me to answer to this question.
              Since I'm using VB6 and BASS+callback is not compatible with VB6 (it always crashes)
              I'm not sure of nothing, because I cannot debug with VB6 IDE.
              I've to use MsgBox and log file to try to understand something. 

What about if you check the levels of the input and output channels with BASS_ASIO_ChannelGetLevel? Do the calls succeed and are the levels 0?
 
        >>>I've found a combination that works
               lRet = BASS_ASIO_Stop()
               lRet = BASS_ASIO_ChannelReset(False, 2, BASS_ASIO_RESET_ENABLE)
               lRet = BASS_ASIO_ChannelReset(False, 2 + 1, BASS_ASIO_RESET_ENABLE)
               but only in some circumstance, in others it doesn't work.
               Thus, sometimes I've to close/oper the monitorIN twice to get things working.

Are you mirroring 2 channels (2 & 3), ie. a stereo pair? If so, you would indeed need to reset both.