^ What's the point?
^ Functions
^ Events
^ Structures
^ BASS Fade Volume Shaped Library in shareware and commercial software?
^ Useful information

Download :: Topics on this subject on the Forum :: Top
BASS Fade Volume Shaped Library

BASS Fade Volume Shaped Library is a component (.dll) for use in Win32 (XP/Vista/7) and Win64 software.
It's purpose is to provide user configurable fade volume shapes for BASS channels.

  • Selectable shapes include: linear, exponential, smooth (sinus), arcus sinus, fast, aggressive (all combineable)
  • Window for setting the parameters
  • Presets system
  • Specify affected channels
  • Win64 version

  • BASS_SetFadeVolumeShaped = function (Channel: HStream; Parameters: TBASSFadeVolumeShapedParameters): Pointer;
    Set the fade volume shaped DSP on a BASS channel handle.
    • Channel: the BASS channel handle to which to apply the fade. The channel needs to be 32 bit float or BASS needs to be set to use 32 bit float DSP sample data, else the funciton will return 0.
    • Parameters: the effect and the shape parameters. You can manually set the parameters or you can use the BASS_FadeVolumeShapedEditor() to generate the parameters. The 'Parameters.Duration' needs to bet set (in seconds) and the 'Parameters.ChannelMapping' (0 means all channels).
    • Result: is the handle to the assigned effect. It is useable for BASS_RemoveFadeVolumeShaped() to remove the effect if needed. This object is automatically freed when the BASS channel handle is freed.
  • BASS_RemoveFadeVolumeShaped = function (ParametersObject: TBASSFadeVolumeShapedParametersObject): Bool;
    Remove the effect from the channel handle.
    • ParametersObject: the handle that was returned from BASS_SetFadeVolumeShaped().
  • BASS_FadeVolumeShapedEditor = function (Settings: TBASSFadeVolumeShapedEditorSettings): TBASSFadeVolumeShapedEditor;
    Show the shape editor window. The window is displayed in not modal mode. If you want to make it modal use the returned window handle ('WindowHandle') for WinAPI function SetParent() to integrate the window into your host window. The settings the user chooses will be returned in the specified callback 'Settings.ActionCallback'.
    • Settings.PresetsFolder: unicode string, specifies the folder where the presets will be saved including the last settings the user made.
    • Settings.Flags: one flag available 'BFVSL_EDITOR_NO_BORDER', usefull when integrating the editor inside a host window.
    • Settings.ActionCallback: the callback that will be called when the user closes the editor window. See below (events).
    • Settings.User: for storing data that will be given back in the ActionCallback. See below (events).
  • BASS_FadeVolumeShapedEditorGetParameters = function (BASSFadeVolumeShapedEditor: TBASSFadeVolumeShapedEditor; var Parameters: TBASSFadeVolumeShapedParameters): Bool;
    Get the current shape parameters from the specified window.
    • BASSFadeVolumeShapedEditor: the object that was returned from BASS_FadeVolumeShapedEditor().
    • Parameters: the structure where the current parameters will be returned.
  • BASS_FadeVolumeShapedGetValues = function (Buffer: PDouble; NoOfValues: Integer; Parameters: TBASSFadeVolumeShapedParameters): Bool;
    Get the shape values for the given parameters. Usefull if you need to draw the shape yourself.
    • Buffer: the array where the shape's values will be returned (Double values).
    • NoOfValues: the size of the 'Buffer' in Double values (the size of the buffer needs to be 'NoOfValues * 4' in bytes)
    • Parameters: the parameters for which the values are wanted.

  • t_BASSFadeVolumeShapedEditorActionCallback = procedure (Apply: Bool; Parameters: TBASSFadeVolumeShapedParameters; User: Pointer); stdcall;
    This event is called when the user closes the editor window.
    • Apply: True if user pressed 'Apply', false otherwise.
    • Parameters: The parameters structure containing the settings the user choose. You have to use this structure as a parameter for BASS_SetFadeVolumeShaped().
    • User: The user variable that was specified for BASS_FadeVolumeShapedEditor().
    Do not forget to specify the 'Parameters.Duration' variable (in seconds) before passing 'Parameters' to BASS_SetFadeVolumeShaped() and set the Parameters.ChannelMapping to 0 for all channels or use the function BASS_FVS_CHANNEL_N() (can be multiple OR'ed together) to specify the affected channels.

  • TBASSFadeVolumeShapedParameters
    The parameters to use for the effect.
    • DSPPriority: Integer: BASS DSP priority. Nothe that BASSEnc DSP is set to -1000 so set it to -999 if using BASSEnc with the channel!
    • Duration: Double: The fade's duration in seconds. Note that you have to specify this value always!
    • FadeIn: Bool: use 'fade in'. This value or 'FadeOut' must be set to True. But always only one of them to True!
    • FadeOut: Bool: use 'fade out'. This value or 'FadeIn' must be set to True.
    • StartFrom: Double: start the fade from this value (percents). 1 means 100%, so for example a value of 0.75 means start from 75% volume level.
    • EndTo: Double: end the fade at this value (percents). 1 means 100%, 0 means total silence.
    • Linear: Bool: use the 'linear' mode.
    • Exponential: Bool: use the 'exponential' mode. You need to set 'ExponentialPower' too.
    • ExponentialPower: Double: the power of the exponential effect (default is 2).
    • Smooth: Bool: use the 'smooth' mode.
    • SmoothScale: Double: the scale of the 'smooth' mode.
    • ArcusSinus: Bool: use the 'arcus sinus' mode.
    • Fast: Bool: use the 'fast' mode.
    • Aggressive: Bool: use the 'aggressive' mode.
    • ChannelMapping: DWord: the channels affected. Use 0 for all channels. Use the function BASS_FVS_CHANNEL_N() OR'ed together to specify a channel mapping for example: BASS_FVS_CHANNEL_N(0) OR BASS_FVS_CHANNEL_N(2) to set the fade effect on front left and center channel (for a 3 channel audio). See BASS's documentation about channel configurations.

How to integrate the shape editor window into a host window?
//* The class that will be passed as 'User' parameter. Usefull to keep a reference to some usefull data such as the host window.
    TActionCallbackData = class
        FormDialogFadeVolumeShapedHost: TFormDialogFadeVolumeShapedHost;
        Channel: HStream;

    PluginWindowHandle: HWND;

procedure TFormDialogFadeVolumeShapedHost.IntegratePluginWindow;
    WindowRect: TRect;
    LStyle: Cardinal;
    BASSFadeVolumeShapedEditorSettings: TBASSFadeVolumeShapedEditorSettings;
    ActionCallbackData: TActionCallbackData;
    ActionCallbackData := TActionCallbackData.Create;
    ActionCallbackData.FormDialogFadeVolumeShapedHost := Self;
    ActionCallbackData.Channel := Channel;

    BASSFadeVolumeShapedEditorSettings.PresetsFolder := PChar(IncludeTrailingPathDelimiter(ExtractFilePath(Application.ExeName) + 'BASS Fade Volume Shaped Presets'));
    BASSFadeVolumeShapedEditorSettings.Flags := BFVSL_EDITOR_NO_BORDER;
    BASSFadeVolumeShapedEditorSettings.ActionCallback := BASSFadeVolumeShapedEditorActionCallback;
    BASSFadeVolumeShapedEditorSettings.User := ActionCallbackData;

    Editor := BASS_FadeVolumeShapedEditor(BASSFadeVolumeShapedEditorSettings);

    PluginWindowHandle := Editor.WindowHandle;

    //* Integrate the shape editor window into our host window
    if PluginWindowHandle <> 0 then begin
        LStyle := GetWindowLong(PluginWindowHandle, GWL_STYLE);
        //* Make the plugin's window a child window
        LStyle := LStyle OR WS_CHILD;
        LStyle := LStyle XOR WS_POPUP;
        SetWindowLong(PluginWindowHandle, GWL_STYLE, LStyle);
        GetWindowRect(PluginWindowHandle, WindowRect);
        //* Adjust our host window's size to the shape editor's window size
        Self.ClientWidth := WindowRect.Width;
        Self.ClientHeight := WindowRect.Height;
        //* PanelParent is TPanel where the plugin window will appear
        Winapi.Windows.SetParent(PluginWindowHandle, PanelParent.Handle);
        SetWindowPos(PluginWindowHandle, 0, 0, 0, WindowRect.Width, WindowRect.Height, SWP_FRAMECHANGED {OR SWP_NOSIZE} OR SWP_SHOWWINDOW);

//* The action callback that we specified above
procedure BASSFadeVolumeShapedEditorActionCallback(Apply: Bool; Parameters: TBASSFadeVolumeShapedParameters; User: Pointer); stdcall;
    FadeTime: Double;
    //* This is how to get our host window object back and call it's Close methode
        if Apply then begin
            Parameters.DSPPriority := - 999;
            Parameters.Duration := FadeTime;
            Parameters.ChannelMapping := 0;
            BASS_SetFadeVolumeShaped(TActionCallbackData(User).Channel, Parameters);

Useful information and links