19 May '13 - 09:15 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: BASS_ChannelSlideAttribute fade not encoded  (Read 2048 times)
toob
Posts: 112


« on: 30 Aug '10 - 12:51 »
Reply with quoteQuote

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?


'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
           
Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #1 on: 30 Aug '10 - 14:24 »
Reply with quoteQuote

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...

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
Logged
toob
Posts: 112


« Reply #2 on: 30 Aug '10 - 15:15 »
Reply with quoteQuote

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..
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...

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 » Logged
fmcoder
Posts: 386


« Reply #3 on: 30 Aug '10 - 16:41 »
Reply with quoteQuote

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.
Logged
Ian @ un4seen
Administrator
Posts: 15244


« Reply #4 on: 30 Aug '10 - 16:44 »
Reply with quoteQuote

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

This is what I've got..
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?
Logged
toob
Posts: 112


« Reply #5 on: 30 Aug '10 - 16:56 »
Reply with quoteQuote

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..
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 » Logged
radio42
Posts: 4012


« Reply #6 on: 31 Aug '10 - 11:05 »
Reply with quoteQuote

Have you loaded BASS_FX prior to your call?
E.g. calling "BassFx.GetVersion()" would load the bass_fx assembly automatically.
Logged
toob
Posts: 112


« Reply #7 on: 31 Aug '10 - 11:17 »
Reply with quoteQuote

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 » Logged
toob
Posts: 112


« Reply #8 on: 31 Aug '10 - 12:16 »
Reply with quoteQuote

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
               
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines