Audacity  2.2.0
Meter Class Referencefinal

VU Meter, for displaying recording/playback level. More...

#include <Meter.h>

Inheritance diagram for Meter:
wxTabTraversalWrapper< Base >

Classes

struct  Resetter
 
struct  State
 

Public Types

enum  Style {
  AutomaticStereo, HorizontalStereo, VerticalStereo, MixerTrackCluster,
  HorizontalStereoCompact, VerticalStereoCompact
}
 

Public Member Functions

 Meter (AudacityProject *, wxWindow *parent, wxWindowID id, bool isInput, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, Style style=HorizontalStereo, float fDecayRate=60.0f)
 
 ~Meter ()
 
bool AcceptsFocus () const override
 
bool AcceptsFocusFromKeyboard () const override
 
void SetFocusFromKbd () override
 
void UpdatePrefs ()
 
void Clear ()
 
Style GetStyle () const
 
Style GetDesiredStyle () const
 
void SetStyle (Style newStyle)
 
void Reset (double sampleRate, bool resetClipping)
 This method is thread-safe! Feel free to call from a different thread (like from an audio I/O callback). More...
 
void UpdateDisplay (unsigned numChannels, int numFrames, float *sampleData)
 Update the meters with a block of audio data. More...
 
bool IsMeterDisabled () const
 Find out if the level meter is disabled or not. More...
 
float GetMaxPeak () const
 
bool IsClipping () const
 
void StartMonitoring ()
 
void StopMonitoring ()
 
State SaveState ()
 
void RestoreState (const State &state)
 
- Public Member Functions inherited from wxTabTraversalWrapper< Base >
template<typename... Args>
 wxTabTraversalWrapper (Args &&...args)
 
 ~wxTabTraversalWrapper ()
 

Static Public Member Functions

static TempAllowFocus TemporarilyAllowFocus ()
 

Private Types

using TempAllowFocus = std::unique_ptr< bool, Resetter >
 

Private Member Functions

void OnErase (wxEraseEvent &evt)
 
void OnPaint (wxPaintEvent &evt)
 
void OnSize (wxSizeEvent &evt)
 
bool InIcon (wxMouseEvent *pEvent=nullptr) const
 
void OnMouse (wxMouseEvent &evt)
 
void OnKeyDown (wxKeyEvent &evt)
 
void OnKeyUp (wxKeyEvent &evt)
 
void OnContext (wxContextMenuEvent &evt)
 
void OnSetFocus (wxFocusEvent &evt)
 
void OnKillFocus (wxFocusEvent &evt)
 
void OnAudioIOStatus (wxCommandEvent &evt)
 
void OnMeterUpdate (wxTimerEvent &evt)
 
void HandleLayout (wxDC &dc)
 
void SetActiveStyle (Style style)
 
void SetBarAndClip (int iBar, bool vert)
 
void DrawMeterBar (wxDC &dc, MeterBar *meterBar)
 
void ResetBar (MeterBar *bar, bool resetClipping)
 
void RepaintBarsNow ()
 
wxFont GetFont () const
 
void ShowMenu (const wxPoint &pos)
 
void OnMonitor (wxCommandEvent &evt)
 
void OnPreferences (wxCommandEvent &evt)
 
void OnMeterPrefsUpdated (wxCommandEvent &evt)
 
wxString Key (const wxString &key) const
 

Private Attributes

AudacityProjectmProject
 
MeterUpdateQueue mQueue
 
wxTimer mTimer
 
int mWidth
 
int mHeight
 
int mRulerWidth
 
int mRulerHeight
 
bool mIsInput
 
Style mStyle
 
Style mDesiredStyle
 
bool mGradient
 
bool mDB
 
int mDBRange
 
bool mDecay
 
float mDecayRate
 
bool mClip
 
int mNumPeakSamplesToClip
 
double mPeakHoldDuration
 
double mT
 
double mRate
 
long mMeterRefreshRate
 
long mMeterDisabled
 
bool mMonitoring
 
bool mActive
 
unsigned mNumBars
 
MeterBar mBar [kMaxMeterBars]
 
bool mLayoutValid
 
std::unique_ptr< wxBitmap > mBitmap
 
wxRect mIconRect
 
wxPoint mLeftTextPos
 
wxPoint mRightTextPos
 
wxSize mLeftSize
 
wxSize mRightSize
 
std::unique_ptr< wxBitmap > mIcon
 
wxPen mPen
 
wxPen mDisabledPen
 
wxPen mPeakPeakPen
 
wxBrush mBrush
 
wxBrush mRMSBrush
 
wxBrush mClipBrush
 
wxBrush mBkgndBrush
 
wxBrush mDisabledBkgndBrush
 
Ruler mRuler
 
wxString mLeftText
 
wxString mRightText
 
bool mIsFocused
 
wxRect mFocusRect
 
bool mAccSilent
 
bool mHighlighted {}
 

Static Private Attributes

static bool s_AcceptsFocus { false }
 

Friends

class MeterAx
 

Detailed Description

VU Meter, for displaying recording/playback level.

This is a bunch of common code that can display many different forms of VU meters and other displays.

But note that a lot of later code here assumes these are MeterToolBar meters, e.g., Meter::StartMonitoring, so these are not as generic/common as originally intended.

Member Typedef Documentation

using Meter::TempAllowFocus = std::unique_ptr<bool, Resetter>
private

Member Enumeration Documentation

Enumerator
AutomaticStereo 
HorizontalStereo 
VerticalStereo 
MixerTrackCluster 
HorizontalStereoCompact 
VerticalStereoCompact 

Constructor & Destructor Documentation

Meter::Meter ( AudacityProject project,
wxWindow *  parent,
wxWindowID  id,
bool  isInput,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
Style  style = HorizontalStereo,
float  fDecayRate = 60.0f 
)

Member Function Documentation

bool Meter::AcceptsFocus ( ) const
inlineoverride

References s_AcceptsFocus.

bool Meter::AcceptsFocusFromKeyboard ( ) const
inlineoverride
void Meter::Clear ( )
Style Meter::GetDesiredStyle ( ) const
inline

References mDesiredStyle.

wxFont Meter::GetFont ( ) const
private

Referenced by HandleLayout(), and OnPaint().

float Meter::GetMaxPeak ( ) const

References mBar, and mNumBars.

Referenced by audacityAudioCallback().

Style Meter::GetStyle ( ) const
inline

References mStyle.

bool Meter::InIcon ( wxMouseEvent *  pEvent = nullptr) const
private

References mIconRect.

Referenced by OnMouse(), and OnPaint().

bool Meter::IsClipping ( ) const

References kMaxMeterBars, and mBar.

bool Meter::IsMeterDisabled ( ) const

Find out if the level meter is disabled or not.

This method is thread-safe! Feel free to call from a different thread (like from an audio I/O callback).

References mMeterDisabled.

Referenced by audacityAudioCallback().

wxString Meter::Key ( const wxString &  key) const
private

References mIsInput, and mStyle.

Referenced by OnPreferences(), and UpdatePrefs().

void Meter::OnAudioIOStatus ( wxCommandEvent &  evt)
private

References mActive, mMeterRefreshRate, mMonitoring, mProject, and mTimer.

Referenced by ~Meter().

void Meter::OnContext ( wxContextMenuEvent &  evt)
private

References mIconRect, mStyle, and ShowMenu().

void Meter::OnErase ( wxEraseEvent &  evt)
private
void Meter::OnKeyDown ( wxKeyEvent &  evt)
private
void Meter::OnKeyUp ( wxKeyEvent &  evt)
private

References mIconRect, mStyle, and ShowMenu().

void Meter::OnKillFocus ( wxFocusEvent &  evt)
private

References mIsFocused.

void Meter::OnMeterPrefsUpdated ( wxCommandEvent &  evt)
private

References UpdatePrefs().

Referenced by ~Meter().

void Meter::OnMonitor ( wxCommandEvent &  evt)
private

References StartMonitoring().

void Meter::OnSetFocus ( wxFocusEvent &  evt)
private

References mIsFocused.

void Meter::OnSize ( wxSizeEvent &  evt)
private

References mHeight, mLayoutValid, and mWidth.

void Meter::RepaintBarsNow ( )
private

References mLayoutValid, and mNumBars.

Referenced by OnMeterUpdate().

void Meter::Reset ( double  sampleRate,
bool  resetClipping 
)

This method is thread-safe! Feel free to call from a different thread (like from an audio I/O callback).

References MeterUpdateQueue::Clear(), kMaxMeterBars, mBar, mLayoutValid, mMeterRefreshRate, mQueue, mRate, mT, mTimer, and ResetBar().

Referenced by OnMouse(), MixerTrackCluster::ResetMeter(), AudioIO::SetCaptureMeter(), AudioIO::SetMeters(), AudioIO::SetPlaybackMeter(), AudioIO::StopStream(), and UpdatePrefs().

void Meter::ResetBar ( MeterBar bar,
bool  resetClipping 
)
private
auto Meter::SaveState ( )
void Meter::SetBarAndClip ( int  iBar,
bool  vert 
)
private
void Meter::SetFocusFromKbd ( )
override
void Meter::SetStyle ( Style  newStyle)
void Meter::ShowMenu ( const wxPoint &  pos)
private
void Meter::StopMonitoring ( )
auto Meter::TemporarilyAllowFocus ( )
static
void Meter::UpdateDisplay ( unsigned  numChannels,
int  numFrames,
float *  sampleData 
)

Update the meters with a block of audio data.

Process the supplied block of audio data, extracting the peak and RMS levels to send to the meter. Also record runs of clipped samples to detect clipping that lies on block boundaries. This method is thread-safe! Feel free to call from a different thread (like from an audio I/O callback).

First overload:

Parameters
numChannelsThe number of channels of audio being played back or recorded.
numFramesThe number of frames (samples) in this data block. It is assumed that there are the same number of frames in each channel.
sampleDataThe audio data itself, as interleaved samples. So indexing through the array we get the first sample of channel, first sample of channel 2 etc up to the first sample of channel (numChannels), then the second sample of channel 1, second sample of channel 2, and so to the second sample of channel (numChannels). The last sample in the array will be the (numFrames) sample for channel (numChannels).

The second overload is for ease of use in MixerBoard.

References MeterUpdateMsg::clipping, floatMax(), MeterUpdateMsg::headPeakCount, MAX_AUDIO, min(), mNumBars, mNumPeakSamplesToClip, mQueue, MeterUpdateMsg::numFrames, MeterUpdateMsg::peak, MeterUpdateQueue::Put(), MeterUpdateMsg::rms, and MeterUpdateMsg::tailPeakCount.

Referenced by audacityAudioCallback(), and MixerTrackCluster::UpdateMeter().

Friends And Related Function Documentation

friend class MeterAx
friend

Member Data Documentation

bool Meter::mAccSilent
private

Referenced by ShowMenu().

bool Meter::mActive
private
std::unique_ptr<wxBitmap> Meter::mBitmap
private

Referenced by DrawMeterBar(), and OnPaint().

wxBrush Meter::mBkgndBrush
private

Referenced by DrawMeterBar(), and OnPaint().

wxBrush Meter::mBrush
private
bool Meter::mClip
private
wxBrush Meter::mClipBrush
private
bool Meter::mDB
private
int Meter::mDBRange
private
bool Meter::mDecay
private

Referenced by OnMeterUpdate().

float Meter::mDecayRate
private

Referenced by OnMeterUpdate().

Style Meter::mDesiredStyle
private
wxBrush Meter::mDisabledBkgndBrush
private

Referenced by DrawMeterBar().

wxPen Meter::mDisabledPen
private
wxRect Meter::mFocusRect
private
bool Meter::mGradient
private
int Meter::mHeight
private

Referenced by HandleLayout(), OnPaint(), and OnSize().

bool Meter::mHighlighted {}
private

Referenced by OnMouse().

std::unique_ptr<wxBitmap> Meter::mIcon
private

Referenced by HandleLayout(), and OnPaint().

wxRect Meter::mIconRect
private
bool Meter::mIsFocused
private

Referenced by OnKillFocus(), OnPaint(), and OnSetFocus().

bool Meter::mIsInput
private
bool Meter::mLayoutValid
private
wxSize Meter::mLeftSize
private

Referenced by HandleLayout(), and UpdatePrefs().

wxString Meter::mLeftText
private

Referenced by HandleLayout(), and OnPaint().

wxPoint Meter::mLeftTextPos
private

Referenced by HandleLayout(), and OnPaint().

long Meter::mMeterDisabled
private
long Meter::mMeterRefreshRate
private
bool Meter::mMonitoring
private
unsigned Meter::mNumBars
private
int Meter::mNumPeakSamplesToClip
private

Referenced by OnMeterUpdate(), and UpdateDisplay().

double Meter::mPeakHoldDuration
private

Referenced by OnMeterUpdate().

wxPen Meter::mPeakPeakPen
private

Referenced by DrawMeterBar().

wxPen Meter::mPen
private

Referenced by DrawMeterBar().

AudacityProject* Meter::mProject
private

Referenced by OnAudioIOStatus().

MeterUpdateQueue Meter::mQueue
private
double Meter::mRate
private
wxSize Meter::mRightSize
private

Referenced by HandleLayout(), and UpdatePrefs().

wxString Meter::mRightText
private

Referenced by HandleLayout(), and OnPaint().

wxPoint Meter::mRightTextPos
private

Referenced by HandleLayout(), and OnPaint().

wxBrush Meter::mRMSBrush
private
Ruler Meter::mRuler
private
int Meter::mRulerHeight
private

Referenced by HandleLayout(), and SetActiveStyle().

int Meter::mRulerWidth
private

Referenced by HandleLayout(), and SetActiveStyle().

double Meter::mT
private

Referenced by OnMeterUpdate(), and Reset().

wxTimer Meter::mTimer
private
int Meter::mWidth
private

Referenced by HandleLayout(), OnPaint(), and OnSize().

bool Meter::s_AcceptsFocus { false }
staticprivate

Referenced by AcceptsFocus().


The documentation for this class was generated from the following files: