Author Topic: BassVst - Change VST Volume input and output  (Read 208 times)

mferre

  • Posts: 4
Hi!

I'm using the BassVst class in VB to process an audio stream. This is the portion of code where I use it.

Code: [Select]
        recHandle = Bass.BASS_RecordStart(samplerate, 2, BASSFlag.BASS_RECORD_PAUSE, _myRecProc, IntPtr.Zero)
        vstHandle = BassVst.BASS_VST_ChannelSetDSP(recHandle, process, BASSVSTDsp.BASS_VST_DEFAULT, 1)
        Bass.BASS_ChannelPlay(recHandle, False)

I need to change the Volume in input to the vst. Now i'm using:
Code: [Select]
        Bass.BASS_ChannelSetAttribute(recHandle, BASSAttribute.BASS_ATTRIB_VOL, volume)
But, looking at the input meter of the vst nothing change and the volume still at 0dB.

How does the audio chain in Bass and BassVst works? How can i control the input and output level before and after the vst process in the proper way?

Thanks

Marco

Ian @ un4seen

  • Administrator
  • Posts: 22841
Re: BassVst - Change VST Volume input and output
« Reply #1 on: 5 Jun '20 - 14:04 »
The BASS_ATTRIB_VOL setting indeed won't affect the level of a recording (it only affects playback). You can instead use the BASS_FX_VOLUME effect via BASS_ChannelSetFX (and BASS_FXSetParamters) to adjust the level of the recording. That should be given a higher "priorirty" value than the VST, to have it applied before the VST. For example:

Code: [Select]
volfx = BASS_ChannelSetFX(recHandle, BASS_FX_VOLUME, 2);

...

BASS_FX_VOLUME_PARAM param;
param.fTarget = volume;
param.fTime = 0;
BASS_FXSetParamters(volfx, &param);

mferre

  • Posts: 4
Re: BassVst - Change VST Volume input and output
« Reply #2 on: 18 Jun '20 - 10:48 »
it works perfectly! Thanks

I've got another  issue: Now how can I get the level post Vst?

Ian @ un4seen

  • Administrator
  • Posts: 22841
Re: BassVst - Change VST Volume input and output
« Reply #3 on: 18 Jun '20 - 15:24 »
Are there any other DSP/FX applied after the VST? If not, you could use BASS_ChannelGetLevel(Ex) to get the level. Otherwise, you will need to set a DSP function on the stream (via BASS_ChannelSetDSP) with a lower "priority" value than the VST (eg. 1 lower), and measure the level of the data in there. In that case, it would probably be best to make the recording floating-point (via the BASS_SAMPLE_FLOAT flag) so that your DSP function only has to deal with floating-point data. VST processing is floating-point, so doing that will also avoid BASS_VST having to convert between formats internally.

mferre

  • Posts: 4
Re: BassVst - Change VST Volume input and output
« Reply #4 on: 23 Jun '20 - 09:44 »
This is my current chain:

Code: [Select]
recHandle = Bass.BASS_RecordStart(samplerate, 2, BASSFlag.BASS_RECORD_PAUSE, _myRecProc, IntPtr.Zero)
volfx = Bass.BASS_ChannelSetFX(recHandle, BASSFXType.BASS_FX_VOLUME, 2) 'set the volume at the input of the vst
vstHandle = BassVst.BASS_VST_ChannelSetDSP(recHandle, process, BASSVSTDsp.BASS_VST_DEFAULT, 1)

where i would like to get the level to update the meters is:


Code: [Select]
recHandle = Bass.BASS_RecordStart(samplerate, 2, BASSFlag.BASS_RECORD_PAUSE, _myRecProc, IntPtr.Zero)
'GET INPUT LEVEL BEFORE PROCESSING
volfx = Bass.BASS_ChannelSetFX(recHandle, BASSFXType.BASS_FX_VOLUME, 2) 'set the volume at the input of the vst
vstHandle = BassVst.BASS_VST_ChannelSetDSP(recHandle, process, BASSVSTDsp.BASS_VST_DEFAULT, 1)
'GET OUTPUT LEVEL AFTER PROCESSING


This is just a channel strip fashion idea of what i would like to do. Obviously is not mandatory to have functions that gets the level perfectly in that portion of code. There is no other vst in the chain.

How can I do that? Thanks :)
« Last Edit: 23 Jun '20 - 10:00 by mferre »

Ian @ un4seen

  • Administrator
  • Posts: 22841
Re: BassVst - Change VST Volume input and output
« Reply #5 on: 23 Jun '20 - 14:04 »
You can simply use BASS_ChannelGetLevel(Ex) to get the final "OUTPUT LEVEL AFTER PROCESSING" level, but you would need to use a DSP function to get the earlier "INPUT LEVEL BEFORE PROCESSING" level. If you're using BASS.Net (it looks like you are), it provides a DSP_PeakLevelMeter class that you could use for that. Please see its documentation for details.

mferre

  • Posts: 4
Re: BassVst - Change VST Volume input and output
« Reply #6 on: 23 Jun '20 - 15:20 »
works perfectly, thanks :)