Author Topic: How to set FadeIn/Out a mp3 file?(encode not playback)  (Read 2186 times)

zz

  • Guest
Thanks.

Ian @ un4seen

  • Administrator
  • Posts: 20389
You could use the BASS_FX add-on's BASS_FX_BFX_VOLUME_ENV effect to do that, ie. set a volume envelope that fades-in at the start and fades-out at the end.

zz

  • Guest
I set the function, but it's no work. No fade-in on playback.
It's my code:

    PlayStream = BASS_StreamCreateFile(False, "1.mp3", 0, 0, 0);//Load file

    BASS_BFX_ENV_NODE nodes[2]={ // 2 nodes for a fade-in
            {0, 0}, // start at vol=0
            {4, 1} // end at vol=1 after "secs" seconds
    };

    BASS_BFX_VOLUME_ENV param={BASS_BFX_CHANALL, 2, nodes, true}; // volume envelope FX parameters
    HFX fx=BASS_ChannelSetFX(PlayStream, BASS_FX_BFX_VOLUME_ENV, 0); // add the FX
    BASS_FXSetParameters(fx, &param);

    BASS_ChannelPlay(PlayStream, False);// play

Ian @ un4seen

  • Administrator
  • Posts: 20389
Please check the function return values to confirm whether they are successful. If the BASS_ChannelSetFX call is failing, and the error code (see BASS_ErrorGetCode) is BASS_ERROR_ILLTYPE, it means that BASS_FX.DLL is not loaded. You can force it to be loaded by adding a BASS_FX function call (eg. BASS_FX_GetVersion) somewhere in your app.

zz

  • Guest
yes, I got error.
bass.dll is 2.4.7.1 version
bass_fx.dll is 2.4.6 version
How to get the bass 2.4.6 ?


zz

  • Guest
The BASS_ChannelSetFX call is true, but I still not hear the fade-in/out effect.

My code:
    PlayStream = BASS_StreamCreateFile(False, "1.mp3", 0, 0, 0);

BASS_BFX_ENV_NODE nodes[4]={
            {0, 0},
            {2, 1}, //0~2 sec fade-in
            {7, 1},
            {9, 0} //7~9 sec fade-out
};
    BASS_BFX_VOLUME_ENV param={BASS_BFX_CHANALL, 4, nodes, 1}; // volume envelope FX parameters
    HFX fx=BASS_ChannelSetFX(PlayStream, BASS_FX_BFX_VOLUME_ENV, 0); // add the FX
    BASS_FXSetParameters(fx, &param);//return 1

    BASS_ChannelPlay(PlayStream, False);

devid1988

  • Posts: 47
The BASS_ChannelSetFX call is true, but I still not hear the fade-in/out effect.

My code:
    PlayStream = BASS_StreamCreateFile(False, "1.mp3", 0, 0, 0);

BASS_BFX_ENV_NODE nodes[4]={
            {0, 0},
            {2, 1}, //0~2 sec fade-in
            {7, 1},
            {9, 0} //7~9 sec fade-out
};
    BASS_BFX_VOLUME_ENV param={BASS_BFX_CHANALL, 4, nodes, 1}; // volume envelope FX parameters
    HFX fx=BASS_ChannelSetFX(PlayStream, BASS_FX_BFX_VOLUME_ENV, 0); // add the FX
    BASS_FXSetParameters(fx, &param);//return 1

    BASS_ChannelPlay(PlayStream, False);



How that can be used in Delphi 7 or Delphi EX2  :)