Class BassFx
BassFx is a BASS addon providing several DSP functions, including tempo and pitch control.
Namespace: System.Dynamic.ExpandoObject
Assembly: ManagedBass.Fx.dll
Syntax
public static class BassFx : object
Properties
Version
Gets the Version of BassFx that is loaded.
Declaration
public static Version Version { get; }
Property Value
Version
|
Methods
BPMBeatCallbackReset(Int32)
Reset the BPM buffers.
Declaration
public static bool BPMBeatCallbackReset(int Handle)
Parameters
Int32
Handle
Stream/music/wma/cd/any other supported add-on format. |
Returns
Boolean
If successful, true is returned, else false is returned. Use LastError to get the error code. |
Remarks
This function flushes the internal buffers of the BPM callback. The BPM callback is automatically reset by ChannelSetPosition(Int32, Int64, PositionFlags), except when called from a Mixtime SyncProcedure.
BPMBeatCallbackSet(Int32, BPMBeatProcedure, IntPtr)
Enable getting Beat position in seconds in real-time.
Declaration
public static bool BPMBeatCallbackSet(int Handle, BPMBeatProcedure Procedure, IntPtr User = null)
Parameters
Int32
Handle
Stream/music/wma/cd/any other supported add-on format. |
BPMBeatProcedure
Procedure
User defined function to receive the beat position values. |
IntPtr
User
User instance data to pass to the callback function. |
Returns
Boolean
If successful, true is returned, else false is returned. Use LastError to get the error code. |
Remarks
This method works on real-time (buffered) as well as on decoding channels and might also be used together with Tempo channels.
BPMBeatFree(Int32) must be called at the end to free the real-time beat position callback and resources.
Note: You should call BPMBeatCallbackReset(Int32) after you have changed the position of the stream when called from a Mixtime SyncProcedure.
BPMBeatDecodeGet(Int32, Double, Double, BassFlags, BPMBeatProcedure, IntPtr)
Enable getting Beat position in seconds of the decoded channel using a callback function.
Declaration
public static bool BPMBeatDecodeGet(int Channel, double StartSec, double EndSec, BassFlags Flags, BPMBeatProcedure Procedure, IntPtr User = null)
Parameters
Int32
Channel
Stream/music/wma/cd/any other supported add-on format using a decoding channel. |
Double
StartSec
Start detecting position in seconds. |
Double
EndSec
End detecting position in seconds (greater than 0). |
BassFlags
Flags
Use one of FxBpmBackground and FxFreeSource. |
BPMBeatProcedure
Procedure
User defined function to receive the beat position values. |
IntPtr
User
User instance data to pass to the callback function. |
Returns
Boolean
If successful, true is returned, else false is returned. Use LastError to get the error code. |
Remarks
This method works pretty much as a mix of BPMBeatCallbackSet(Int32, BPMBeatProcedure, IntPtr) and BPMDecodeGet(Int32, Double, Double, Int32, BassFlags, BPMProgressProcedure, IntPtr).
BPMBeatFree(Int32)
Free all resources used by a given handle (decode or callback beat).
Declaration
public static bool BPMBeatFree(int Handle)
Parameters
Int32
Handle
Stream/music/wma/cd/any other supported add-on format. |
Returns
Boolean
If successful, true is returned, else false is returned. Use LastError to get the error code. |
Remarks
Used together with BPMBeatDecodeGet(Int32, Double, Double, BassFlags, BPMBeatProcedure, IntPtr) or BPMBeatCallbackSet(Int32, BPMBeatProcedure, IntPtr).
Note: If the FxFreeSource flag is used, this will free the source decoding channel as well.
You can't set/get this flag with ChannelFlags(Int32, BassFlags, BassFlags) and
BPMBeatGetParameters(Int32, out Single, out Single, out Single)
Gets the current beat detection parameter values.
Declaration
public static bool BPMBeatGetParameters(int Handle, out float Bandwidth, out float CenterFreq, out float Beat_rTime)
Parameters
Int32
Handle
Stream/music/wma/cd/any other supported add-on format. |
Single
Bandwidth
Current bandwidth in Hz. |
Single
CenterFreq
Current center-frequency in Hz of the band pass filter. |
Single
Beat_rTime
Current beat release time in ms. |
Returns
Boolean
If successful, true is returned, else false is returned. Use LastError to get the error code. |
Remarks
Beat detection is using a Band Pass Filter.
A band-pass filter is a device that passes frequencies within a certain range and rejects (attenuates) frequencies outside that range.
So the Bandwidth
parameter defines the range around a center-frequency to include in the beat detection algo.
The CenterFreq
parameter actually defines the center-frequency of the band pass filter.
Once a beat is detected, the Beat_rTime
parameter defines the time in ms. in which no other beat will be detected after that just detected beat.
The background is, that often you have kind-of 'double beats' in a drum set.
So the Beat_rTime
should avoid, that a second (quickly repeated beat) beat is detected.
BPMBeatSetParameters(Int32, Single, Single, Single)
Set new values for beat detection parameters.
Declaration
public static bool BPMBeatSetParameters(int Handle, float Bandwidth, float CenterFreq, float Beat_rTime)
Parameters
Int32
Handle
Stream/music/wma/cd/any other supported add-on format. |
Single
Bandwidth
Bandwidth in Hz between 0 and samplerate/2 (-1.0f = leave current, default is 10Hz). |
Single
CenterFreq
The center-frequency in Hz of the band pass filter between 0 and samplerate/2 (-1.0f = leave current, default is 90Hz). |
Single
Beat_rTime
Beat release time in ms. (-1.0f = leave current, default is 20ms). |
Returns
Boolean
If successful, true is returned, else false is returned. Use LastError to get the error code. |
Remarks
Beat detection is using a Band Pass Filter.
A band-pass filter is a device that passes frequencies within a certain range and rejects (attenuates) frequencies outside that range.
So the Bandwidth
parameter defines the range around a center-frequency to include in the beat detection algo.
The CenterFreq
parameter actually defines the center-frequency of the band pass filter.
Once a beat is detected, the Beat_rTime
parameter defines the time in ms. in which no other beat will be detected after that just detected beat.
The background is, that often you have kind-of 'double beats' in a drum set.
So the Beat_rTime
should avoid, that a second (quickly repeated beat) beat is detected.
BPMCallbackReset(Int32)
Reset the BPM buffers.
Declaration
public static bool BPMCallbackReset(int Handle)
Parameters
Int32
Handle
Stream/music/wma/cd/any other supported add-on format. |
Returns
Boolean
If successful, true is returned, else false is returned. Use LastError to get the error code. |
Remarks
This function flushes the internal buffers of the BPM callback. The BPM callback is automatically reset by ChannelSetPosition(Int32, Int64, PositionFlags), except when called from a Mixtime SyncProcedure.
BPMCallbackSet(Int32, BPMProcedure, Double, Int32, BassFlags, IntPtr)
Enable getting BPM value by period of time in seconds.
Declaration
public static bool BPMCallbackSet(int Handle, BPMProcedure Procedure, double Period, int MinMaxBPM, BassFlags Flags, IntPtr User = null)
Parameters
Int32
Handle
Stream/music/wma/cd/any other supported add-on format. |
BPMProcedure
Procedure
User defined function to receive the bpm value. |
Double
Period
Detection period in seconds. |
Int32
MinMaxBPM
Set min and max bpm, LowWord=Min, HighWord=Max. 0 = defaults to 45/230. |
BassFlags
Flags
Use FXBpmMult2 or Default. |
IntPtr
User
User instance data to pass to the callback function. |
Returns
Boolean
If successful, true is returned, else false is returned. Use LastError to get the error code. |
Remarks
Un4seen.Bass.BASSError | Description |
---|---|
BASS_ERROR_HANDLE | |
BASS_ERROR_ILLPARAM | |
BASS_ERROR_ALREADY |
BPMDecodeGet(Int32, Double, Double, Int32, BassFlags, BPMProgressProcedure, IntPtr)
Get the original BPM of a decoding channel.
Declaration
public static float BPMDecodeGet(int Channel, double StartSec, double EndSec, int MinMaxBPM, BassFlags Flags, BPMProgressProcedure Procedure, IntPtr User = null)
Parameters
Int32
Channel
Stream/music/wma/cd/any other supported add-on format using a decoding channel. |
Double
StartSec
Start detecting position in seconds (if less than 0 it uses the current position). |
Double
EndSec
End detecting position in seconds (greater than 0). |
Int32
MinMaxBPM
Set min and max bpm, LowWord=Min, HighWord=Max. 0 = defaults to 45/230. |
BassFlags
Flags
One of FxBpmBackground, FXBpmMult2 and FxFreeSource. |
BPMProgressProcedure
Procedure
User defined function to receive the process in percents, use null if not in use. |
IntPtr
User
User instance data to pass to the callback function. |
Returns
Single
If successful, the original BPM value is returned, else -1 is returned. Use LastError to get the error code. |
Remarks
The BPM detection algorithm works by detecting repeating low-frequency (less than 250Hz) sound patterns and thus works mostly with most rock/pop music with bass or drum beat. The BPM detection doesn't work on pieces such as classical music without distinct, repeating bass frequency patterns. Also pieces with varying tempo, varying bass patterns or very complex bass patterns (jazz, hiphop) may produce odd BPM readings.
In cases when the bass pattern drifts a bit around a nominal beat rate (e.g. drummer is again drunken ;-), the BPM algorithm may report incorrect harmonic one-halft to one-thirdth of the correct BPM value. In such case the system could for example report BPM value of 50 or 100 instead of correct BPM value of 150.
BPMFree(Int32)
Frees all resources used by a given handle.
Declaration
public static bool BPMFree(int Handle)
Parameters
Int32
Handle
Stream/music/wma/cd/any other supported add-on format. |
Returns
Boolean
If successful, true is returned, else false is returned. Use LastError to get the error code. |
Remarks
Used together with BPMDecodeGet(Int32, Double, Double, Int32, BassFlags, BPMProgressProcedure, IntPtr) or BPMCallbackSet(Int32, BPMProcedure, Double, Int32, BassFlags, IntPtr).
If FxFreeSource was used, this will also free the underlying decoding channel as well.
You can't set/get this flag with ChannelFlags(Int32, BassFlags, BassFlags)/
ReverseCreate(Int32, Single, BassFlags)
Creates a reversed stream from a decoding channel.
Example Create a Reverse stream.
// create decoded stream
var chan = Bass.CreateStream(FileName, Flags: BassFlags.Decode);
// create reverse stream, 2 secs decoding block
if (chan != 0)
chan = BassFx.TempoCreate(chan, 2, BassFlags.FxFreeSource);
Declaration
public static int ReverseCreate(int Channel, float DecodingBlockLength, BassFlags Flags)
Parameters
Int32
Channel
Stream/music/wma/cd/any other supported add-on format using a decoding channel. |
||||||||||||||||||
Single
DecodingBlockLength
Length of decoding blocks in seconds. Larger blocks means less seeking overhead but larger spikes. |
||||||||||||||||||
BassFlags
Flags
A combination of these flags:
|
Returns
Int32
If successful, the handle of the reversed stream is returned, else 0 is returned. Use LastError to get the error code. |
Remarks
MODs are supported, if Prescan flag was applied to a source handle.
For better MP3/2/1 reverse playback create the source stream using the Prescan flag.
Thes ReverseDirection attribute can either be applied to the reverse channel or the underlying decoding source channel. Note, that when playing the channel reverse, the end of a reverse stream is reached at the logial beginning of the stream (this also applies to End). By default stream's position will start from the end.
ReverseGetSource(Int32)
Get the source channel handle of the reversed stream.
Declaration
public static int ReverseGetSource(int Channel)
Parameters
Int32
Channel
The handle of the reversed stream. |
Returns
Int32
If successful, the handle of the source of the reversed stream is returned, else 0 is returned. Use LastError to get the error code. |
TempoCreate(Int32, BassFlags)
Creates a resampling stream from a decoding channel.
Example Create a Tempo stream.
// create decoded stream
var chan = Bass.CreateStream(FileName, Flags: BassFlags.Decode);
// create a tempo stream
if (chan != 0)
chan = BassFx.TempoCreate(chan, BassFlags.FxFreeSource);
Declaration
public static int TempoCreate(int Channel, BassFlags Flags)
Parameters
Int32
Channel
Stream/music/wma/cd/any other supported add-on format using a decoding channel (use Decode when creating the channel). |
||||||||||||||||||
BassFlags
Flags
A combination of these flags:
|
Returns
Int32
If successful, the tempo stream handle is returned, else 0 is returned. Use LastError to get the error code. |
Remarks
Multi-channels are supported.
TempoGetRateRatio(Int32)
Get the ratio of the resulting rate and source rate (the resampling ratio).
Declaration
public static float TempoGetRateRatio(int Channel)
Parameters
Int32
Channel
Tempo stream (or source channel) handle. |
Returns
Single
If successful, the resampling ratio is returned, else 0 is returned. Use LastError to get the error code. |
TempoGetSource(Int32)
Get the source channel handle of the reversed stream.
Declaration
public static int TempoGetSource(int Channel)
Parameters
Int32
Channel
The handle of the reversed stream. |
Returns
Int32
If successful, the handle of the source of the reversed stream is returned, else 0 is returned. Use LastError to get the error code. |