Author Topic: BASS_ChannelSlideAttribute fade not encoded  (Read 8246 times)

toob

  • Posts: 133
A simple question I hope...

When I apply the BASS_ChannelSlideAttribute fade-in code below I can hear the current playing stream fade from 0 to full over a period of time denoted by my trackbar2 control as expected.
However I was expecting that fade effect to also be encoded/recorded as it's using the same channel yet the volume in the resulting file is constant.

Any idea why the fade is not encoded and what I can do to fix it?

Code: [Select]

'play mp3
Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero)
Stream = Bass.BASS_StreamCreateFile(filepath, 0L, 0L, BASSFlag.BASS_STREAM_DECODE)
Stream = BassFx.BASS_FX_TempoCreate(Stream, BASSFlag.BASS_FX_FREESOURCE)
Bass.BASS_ChannelPlay(Stream, True)

set volume fadein
Bass.BASS_ChannelSetAttribute(Stream, BASSAttribute.BASS_ATTRIB_VOL, 0.0F)
Bass.BASS_ChannelSlideAttribute(Stream, BASSAttribute.BASS_ATTRIB_VOL, 1, Me.TrackBar2.Value * 1000)

'encode
BassEnc.BASS_Encode_Start(Stream, Command_Line, BASSEncode.BASS_ENCODE_DEFAULT, Nothing, IntPtr.Zero)
...
'stop encoding
BassEnc.BASS_Encode_Stop(Stream)

thanks
Mark
           

Ian @ un4seen

  • Administrator
  • Posts: 20426
Re: BASS_ChannelSlideAttribute fade not encoded
« Reply #1 on: 30 Aug '10 - 14:24 »
Yes, the BASS_ATTRIB_VOL/FREQ/PAN attributes only affect playback; they don't change the source sample data, which is what the encoder will receive. To have a fade-in that is present in the sample data, it needs to be implemented in a DSP function, eg. using BASS_ChannelSetDSP/FX. You could use BASS_FX's BASS_FX_BFX_VOLUME_ENV effect for that, something like this...

Code: [Select]
BASS_BFX_ENV_NODE nodes[2]={ // 2 nodes for a fade-in
{0, 0}, // start at vol=0
{secs, 1} // end at vol=1 after "secs" seconds
};
BASS_BFX_VOLUME_ENV param={-1, 2, nodes, 0}; // volume envelope FX parameters
HFX fx=BASS_ChannelSetFX(stream, BASS_FX_BFX_VOLUME_ENV, 0); // add the FX
BASS_FXSetParameters(fx, param); // set the parameters

toob

  • Posts: 133
Re: BASS_ChannelSlideAttribute fade not encoded
« Reply #2 on: 30 Aug '10 - 15:15 »
Ian, thanks for the quick response..

I think I have converted your example to VB with help from the bass.net API help.

This is what I've got..
Code: [Select]
Dim fx As Integer = Bass.BASS_ChannelSetFX(Stream, BASSFXType.BASS_FX_BFX_VOLUME_ENV, 0)
Dim ve As New BASS_BFX_VOLUME_ENV(New BASS_BFX_ENV_NODE(0.0, 0.0F), New BASS_BFX_ENV_NODE(3.0, 1.0F))
Bass.BASS_FXSetParameters(fx, ve)

Could you confirm this is correct as at present it has no effect on the output and I get  error 5 invalid handle after Bass.BASS_FXSetParameters(fx, ve)

M

Yes, the BASS_ATTRIB_VOL/FREQ/PAN attributes only affect playback; they don't change the source sample data, which is what the encoder will receive. To have a fade-in that is present in the sample data, it needs to be implemented in a DSP function, eg. using BASS_ChannelSetDSP/FX. You could use BASS_FX's BASS_FX_BFX_VOLUME_ENV effect for that, something like this...

Code: [Select]
BASS_BFX_ENV_NODE nodes[2]={ // 2 nodes for a fade-in
{0, 0}, // start at vol=0
{secs, 1} // end at vol=1 after "secs" seconds
};
BASS_BFX_VOLUME_ENV param={-1, 2, nodes, 0}; // volume envelope FX parameters
HFX fx=BASS_ChannelSetFX(stream, BASS_FX_BFX_VOLUME_ENV, 0); // add the FX
BASS_FXSetParameters(fx, param); // set the parameters
« Last Edit: 30 Aug '10 - 15:52 by toob »

fmcoder

  • Posts: 436
Re: BASS_ChannelSlideAttribute fade not encoded
« Reply #3 on: 30 Aug '10 - 16:41 »
It's much simpler to create a mixer channel and put your stream there. Then use this mixer channel in the call to BASS_Encode_Start. It'll take BASS_ChannelSlideAttribute into account, so you'll hear the volume change in the encoded stream.

Ian @ un4seen

  • Administrator
  • Posts: 20426
Re: BASS_ChannelSlideAttribute fade not encoded
« Reply #4 on: 30 Aug '10 - 16:44 »
I think I have converted your example to VB with help from the bass.net API help.

This is what I've got..
Code: [Select]
Dim fx As Integer = Bass.BASS_ChannelSetFX(Stream, BASSFXType.BASS_FX_BFX_VOLUME_ENV, 0)
Dim ve As New BASS_BFX_VOLUME_ENV(New BASS_BFX_ENV_NODE(0.0, 0.0F), New BASS_BFX_ENV_NODE(3.0, 1.0F))
Bass.BASS_FXSetParameters(fx, ve)

Could you confirm this is correct as at present it has no effect on the output and I get  error 5 invalid handle after Bass.BASS_FXSetParameters(fx, ve)

Error code 5 (BASS_ERROR_HANDLE) suggests that the BASS_ChannelSetFX call may have failed, eg. fx=0. If that is so, what is the error code from that call?

toob

  • Posts: 133
Re: BASS_ChannelSlideAttribute fade not encoded
« Reply #5 on: 30 Aug '10 - 16:56 »
Ian, yes you're right, I missed the error on:

Dim fx As Integer = Bass.BASS_ChannelSetFX(Stream, BASSFXType.BASS_FX_BFX_VOLUME_ENV, 0)

BASS_ERROR_ILLTYPE = 19   'an illegal type was specified

I'm using version 2.4.5.0 of bass_fx (I've also now tried it with the latest version, same error code)

Don't understand how BASSFXType.BASS_FX_BFX_VOLUME_ENV can be an illegal type?

I think I have converted your example to VB with help from the bass.net API help.

This is what I've got..
Code: [Select]
Dim fx As Integer = Bass.BASS_ChannelSetFX(Stream, BASSFXType.BASS_FX_BFX_VOLUME_ENV, 0)
Dim ve As New BASS_BFX_VOLUME_ENV(New BASS_BFX_ENV_NODE(0.0, 0.0F), New BASS_BFX_ENV_NODE(3.0, 1.0F))
Bass.BASS_FXSetParameters(fx, ve)

Could you confirm this is correct as at present it has no effect on the output and I get  error 5 invalid handle after Bass.BASS_FXSetParameters(fx, ve)

Error code 5 (BASS_ERROR_HANDLE) suggests that the BASS_ChannelSetFX call may have failed, eg. fx=0. If that is so, what is the error code from that call?
« Last Edit: 31 Aug '10 - 10:16 by toob »

radio42

  • Posts: 4576
Re: BASS_ChannelSlideAttribute fade not encoded
« Reply #6 on: 31 Aug '10 - 11:05 »
Have you loaded BASS_FX prior to your call?
E.g. calling "BassFx.GetVersion()" would load the bass_fx assembly automatically.

toob

  • Posts: 133
Re: BASS_ChannelSlideAttribute fade not encoded
« Reply #7 on: 31 Aug '10 - 11:17 »
Have you loaded BASS_FX prior to your call?
E.g. calling "BassFx.GetVersion()" would load the bass_fx assembly automatically.

Hi,

Thanks for replying... and still stuck!

BassFx.BASS_FX_GetVersion() returns "33818112" but I still get error 19

bass_fx is loaded in the main playing stream for tempocreate see
Stream = BassFx.BASS_FX_TempoCreate(Stream, BASSFlag.BASS_FX_FREESOURCE)
in first post.

I can change the tempo fine so I don't think it's the dll

Any other thoughts?

thanks
Mark
« Last Edit: 31 Aug '10 - 11:38 by toob »

toob

  • Posts: 133
Re: BASS_ChannelSlideAttribute fade not encoded
« Reply #8 on: 31 Aug '10 - 12:16 »
Yes I'm skipping round the room...

I changed this

Dim fx As Integer = Bass.BASS_ChannelSetFX(Stream, BASSFXType.BASS_FX_BFX_VOLUME_ENV, 0)

to

Dim fx As Integer = Bass.BASS_ChannelSetFX(Stream, Un4seen.Bass.BASSFXType.BASS_FX_BFX_VOLUME_ENV, 0)

And hey presto, it works, not sure why.

Thanks to everyone who helped on this
Mark