BASS.NET API for the Un4seen BASS Audio Library

DSP_PeakLevelMeter Class

BASS.NET API for the Un4seen BASS Audio Library
Peak Level Meter DSP.
Inheritance Hierarchy

SystemObject
  Un4seen.Bass.MiscBaseDSP
    Un4seen.Bass.MiscDSP_PeakLevelMeter

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

public sealed class DSP_PeakLevelMeter : BaseDSP

The DSP_PeakLevelMeter type exposes the following members.

Constructors

  NameDescription
Public methodDSP_PeakLevelMeter
Creates a new instance of the PeakMeterLevel DSP, not assigning the DSP yet.
Public methodDSP_PeakLevelMeter(Int32, Int32)
Creates a new instance of the PeakMeterLevel DSP, which already assigns the DSP (Start will be called automatically).
Top
Properties

  NameDescription
Public propertyAVG
Returns the current AVG value (average, in linear voltage steps, between 0...32768...N) of the signal.
Public propertyAVG_dBV
Returns the current AVG value (average, in dBV) of the signal.
Public propertyCalcRMS
Gets or Sets if the AVG and RMS values should be calculated.
Public propertyChannelBitwidth
This property returns the actual bitwidth of the sample data of the channel (e.g. 8, 16, 32).
(Inherited from BaseDSP.)
Public propertyChannelHandle
Gets or Sets the channel that the DSP is being applied to.
(Inherited from BaseDSP.)
Public propertyChannelInfo
Gets the BASS_CHANNELINFO of the assigned ChannelHandle.
(Inherited from BaseDSP.)
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.).
(Inherited from BaseDSP.)
Public propertyChannelSampleRate
This property returns the actual sample rate in Hz of the sample data BASS is using with the channel (e.g. 44100).
(Inherited from BaseDSP.)
Public propertyDSPHandle
Returns the actual DSP handle (or 0, if the DSP has not been assigned to the channel).
(Inherited from BaseDSP.)
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.
(Inherited from BaseDSP.)
Public propertyDSPProc
Returns the actual DSPPROC (callback delegate) which is used by the DSP.
(Inherited from BaseDSP.)
Public propertyIsAssigned
Is the DSP assigned to an active channel? (=assigned, =not assigned).
(Inherited from BaseDSP.)
Public propertyIsBypassed
Returns if the DSP is currently bypassed (=bypass).
(Inherited from BaseDSP.)
Public propertyLevelL
Returns the current level signal (in linear voltage steps) of the left-channel as an integer value (between 0 and 32768, or above, if a floating-point channel was selected).
Public propertyLevelL_dBV
Returns the current level signal of the left-channel as a dBV value (between -Infinity and 0.0 - or above, if a floating-point channel was selected).
Public propertyLevelR
Returns the current level signal (in linear voltage steps) of the right-channel as an integer value (between 0 and 32768, or above, if a floating-point channel was selected).
Public propertyLevelR_dBV
Returns the current level signal of the right-channel as a dBV value (between -Infinity and 0.0 - or above, if a floating-point channel was selected).
Public propertyPeakHoldLevelL
Returns the peak level signal (in linear voltage steps) of the left-channel since the last channel change or ResetPeakHold.
Public propertyPeakHoldLevelL_dBV
Returns the peak level signal of the left-channel as a dBV value (between -Infinity and 0.0 - or above, if a floating-point channel was selected) since the last channel change or ResetPeakHold.
Public propertyPeakHoldLevelR
Returns the peak level signal (in linear voltage steps) of the right-channel since the last channel change or ResetPeakHold.
Public propertyPeakHoldLevelR_dBV
Returns the peak level signal of the right-channel as a dBV value (between -Infinity and 0.0 - or above, if a floating-point channel was selected) since the last channel change or ResetPeakHold.
Public propertyRMS
Returns the current RMS value (root mean square, in voltage steps, between 0...32768...N) of the signal.
Public propertyRMS_dBV
Returns the current RMS value (root mean square, in dBV) of the signal.
Public propertyUpdateTime
Gets or Sets the update time in seconds (default is 0.1 = 100ms, max. is 60 seconds) which is the timespan being used to measure RMS and PeakLevels and is also used for Notification trigges.
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)).
(Inherited from BaseDSP.)
Top
Methods

  NameDescription
Public methodDispose
Implement IDisposable.
(Inherited from BaseDSP.)
Public methodDSPCallback
User defined DSP callback function which does the peak level calculation. Not for direct use in your application!
(Overrides BaseDSPDSPCallback(Int32, Int32, IntPtr, Int32, IntPtr).)
Protected methodFinalize
Finalization code.
(Inherited from BaseDSP.)
Public methodOnBypassChanged
This method will be called every time the SetBypass(Boolean) method had been called.
(Inherited from BaseDSP.)
Public methodOnChannelChanged
Resets the PeakHoldLevelL and PeakHoldLevelR values when a channel change occurred.
(Overrides BaseDSPOnChannelChanged.)
Public methodOnStarted
This method will be called every time the Start method had been called.
(Inherited from BaseDSP.)
Public methodOnStopped
This method will be called every time the Stop method had been called.
(Inherited from BaseDSP.)
Public methodRaiseNotification
Fires the Notification event.
(Inherited from BaseDSP.)
Public methodResetPeakHold
Resets the PeakHoldLevelL and PeakHoldLevelR values when a channel change occurred.
Public methodSetBypass
Sets the Bypass mode.
(Inherited from BaseDSP.)
Public methodStart
Assigns the DSP to the channel (actually starts using the DSP).
(Inherited from BaseDSP.)
Public methodStop
Stops (removes) the DSP from the channel.
(Inherited from BaseDSP.)
Public methodToString
Returns the name of the DSP.
(Overrides BaseDSPToString.)
Top
Events

  NameDescription
Public eventNotification
Event handler used to notify that the DSP has processed some data.
(Inherited from BaseDSP.)
Top
Remarks

Calculates the volume (amplitude) of the channel signal in volts or dB.

The DSP automatically converts 8-, 16- or 32-bit sample data accordingly.

Use Start to assign the DSP to the channel. Use Stop to remove the DSP (you can (re)assign the DSP at any time again by calling Start). Changing the DSPPriority when the DSP is already assigned will automatically reassign the DSP.

Use the ChannelHandle property to change the channel assignment at any time. If the DSP has already been assigned, the DSP will immediately be reassigned to the new channel.

The peak levels (Left channel=LevelL and Right channel=LevelR) are integer values between 0 (-inf.dB) and 32768 (0dB) - or higher, if the channel is floating-point. Use the LevelL_dBV and LevelR_dBV properties, if you want these integer peak values already converted into dBV values (to a reference voltage of 1.0).

Examples

Set up a PeakLevelMeter DSP on a recording channel:
C#
private DSP_PeakLevelMeter _plm;
public delegate void UpdatePeakMeterCallback();
...
Bass.BASS_RecordInit(-1);
_recHandle = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_DEFAULT, _recProc, 0);
...
// set up a ready-made DSP (here the PeakLevelMeter)
_plm = new DSP_PeakLevelMeter(_recHandle, 1);
_plm.CalcRMS = true;
_plm.Notification += new EventHandler(UpdatePeakMeterDisplay);
...
private void UpdatePeakMeterDisplay(object sender, EventArgs e)
{
    this.progressBarRecL.Value = _plm.LevelL;
    this.progressBarRecR.Value = _plm.LevelR;
    this.labelRMS.Text = String.Format( "RMS: {0:#00.0} dB - AVG: {1:#00.0} dB - Peak: {2:#00.0} dB", 
                _plm.RMS_dBV, 
                _plm.AVG_dBV, 
                Math.Max(_plm.PeakHoldLevelL_dBV, _plm.PeakHoldLevelR_dBV) );
}
See Also

Reference