BASS.NET API for the Un4seen BASS Audio LibraryBaseDSP ClassBASS.NET API for the Un4seen BASS Audio Library
Base class for all user defined DSP classes (e.g. DSP_PeakLevelMeter, DSP_Gain or your own DSP implementations).
Inheritance Hierarchy


Namespace: Un4seen.Bass.Misc
Assembly: Bass.Net (in Bass.Net.dll) Version:

public abstract class BaseDSP

The BaseDSP type exposes the following members.


Public methodBaseDSP
Default constructor. Not assigning a DSP yet.
Public methodBaseDSP(Int32, Int32, IntPtr)
Default constructor, which already evaluates the channel handle and assigns the DSP (Start will be called automatically).

Public propertyChannelBitwidth
This property returns the actual bitwidth of the sample data of the channel (e.g. 8, 16, 32).
Public propertyChannelHandle
Gets or Sets the channel that the DSP is being applied to.
Public propertyChannelInfo
Gets the BASS_CHANNELINFO of the assigned ChannelHandle.
Public propertyChannelNumChans
This property returns the actual number of channles of the sample data BASS is using with the channel (e.g. 1=mono, 2=stereo, etc.).
Public propertyChannelSampleRate
This property returns the actual sample rate in Hz of the sample data BASS is using with the channel (e.g. 44100).
Public propertyDSPHandle
Returns the actual DSP handle (or 0, if the DSP has not been assigned to the channel).
Public propertyDSPPriority
Sets or reassigns the priority of the DSP, which determines it's position in the DSP chain - DSPs with higher priority are called before those with lower.
Public propertyDSPProc
Returns the actual DSPPROC (callback delegate) which is used by the DSP.
Public propertyIsAssigned
Is the DSP assigned to an active channel? (=assigned, =not assigned).
Public propertyIsBypassed
Returns if the DSP is currently bypassed (=bypass).
Public propertyUser
Gets or Sets the value of the user instance data to pass to the callback function (see DSPCallback(Int32, Int32, IntPtr, Int32, IntPtr)).

Public methodDispose
Implement IDisposable.
Public methodDSPCallback
User defined DSP callback function which needs to be implemented in the derived class.
Protected methodFinalize
Finalization code.
(Overrides ObjectFinalize.)
Public methodOnBypassChanged
This method will be called every time the SetBypass(Boolean) method had been called.
Public methodOnChannelChanged
This method will be called every time the ChannelHandle changed.
Public methodOnStarted
This method will be called every time the Start method had been called.
Public methodOnStopped
This method will be called every time the Stop method had been called.
Public methodRaiseNotification
Fires the Notification event.
Public methodSetBypass
Sets the Bypass mode.
Public methodStart
Assigns the DSP to the channel (actually starts using the DSP).
Public methodStop
Stops (removes) the DSP from the channel.
Public methodToString
Returns the name of the DSP implementation.
(Overrides ObjectToString.)

Public eventNotification
Event handler used to notify that the DSP has processed some data.

This base class is not intended for direct use, but defines all abstract properties and methods which needs to be implemented by an actual DSP class. A derived class must implement: DSPCallback(Int32, Int32, IntPtr, Int32, IntPtr).

The properties ChannelHandle, ChannelBitwidth, ChannelSampleRate, ChannelNumChans, DSPPriority, DSPHandle, DSPProc, User, IsBypassed and IsAssigned as well as the methods Start, Stop and SetBypass(Boolean) have been already implemented.

You might use this base class to derive your own DSP implementations. In this case a derived class must implement the DSPCallback(Int32, Int32, IntPtr, Int32, IntPtr) method and might override the OnChannelChanged method (e.g. in order to reset an internal buffer etc.).

The whole DSP framework is based on the standard BASS DSP functionality. So as with all DSP's - the DSP is automatically freed whenever the source stream is freed, e.g. when calling BASS_StreamFree(Int32) or when using the BASS_STREAM_AUTOFREE flag.


This example shows a basic implementation of an own DSP class:
public class DSP_MyDsp : BaseDSP
    // First Constructor overload
    public DSP_MyDsp() : base()
    // Second Constructor overload
    public DSP_MyDsp(int channel, int priority) : base(channel, priority, 0)

    // example implementation of the DSPCallback method
    unsafe public override void DSPCallback(int handle, int channel, IntPtr buffer, int length, IntPtr user)
        if (IsBypassed)

        if (ChannelBitwidth == 16)
            // process the data
            short *data = (short*)buffer;
            for (int a = 0; a < length/2; a++)
                // your work goes here (16-bit sample data)
        else if (ChannelBitwidth == 32)
            // process the data
            float *data = (float*)buffer;
            for (int a = 0; a < length/4; a++)
                // your work goes here (32-bit sample data)
            // process the data
            byte *data = (byte*)buffer;
            for (int a = 0; a < length; a++)
                // your work goes here (8-bit sample data)
        // if you have calculated UI relevant data you might raise the event
        // else comment out the following line

    public override void OnChannelChanged()
        // override this method if you need to react on channel changes
        // e.g. usefull, if an internal buffer needs to be reset etc.

    public override string ToString()
        return "My DSP";
See Also


Inheritance Hierarchy