Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
SpectrogramBounds Class Reference

#include <SpectrogramSettings.h>

Inheritance diagram for SpectrogramBounds:
[legend]
Collaboration diagram for SpectrogramBounds:
[legend]

Public Member Functions

 ~SpectrogramBounds () override
 
PointerType Clone () const override
 
void GetBounds (const WaveTrack &wt, float &min, float &max) const
 
void SetBounds (float min, float max)
 
- Public Member Functions inherited from ClientData::Cloneable< Covariant, Owner >
 Cloneable ()=default
 
 Cloneable (const Cloneable &)=default
 
Cloneableoperator= (const Cloneable &)=default
 
virtual ~Cloneable ()=default
 
virtual PointerType Clone () const =0
 

Static Public Member Functions

static SpectrogramBoundsGet (WaveTrack &track)
 Get either the global default settings, or the track's own if previously created. More...
 
static const SpectrogramBoundsGet (const WaveTrack &track)
 Get either the global default settings, or the track's own if previously created. More...
 

Private Attributes

float mSpectrumMin = -1
 
float mSpectrumMax = -1
 

Additional Inherited Members

- Public Types inherited from ClientData::Cloneable< Covariant, Owner >
using Base = std::conditional_t< std::is_void_v< Covariant >, Cloneable, Covariant >
 
using PointerType = Owner< Base >
 

Detailed Description

Definition at line 203 of file SpectrogramSettings.h.

Constructor & Destructor Documentation

◆ ~SpectrogramBounds()

SpectrogramBounds::~SpectrogramBounds ( )
overridedefault

Member Function Documentation

◆ Clone()

auto SpectrogramBounds::Clone ( ) const
overridevirtual

Implements ClientData::Cloneable< Covariant, Owner >.

Definition at line 713 of file SpectrogramSettings.cpp.

714{
715 return std::make_unique<SpectrogramBounds>(*this);
716}

◆ Get() [1/2]

const SpectrogramBounds & SpectrogramBounds::Get ( const WaveTrack track)
static

Get either the global default settings, or the track's own if previously created.

Definition at line 705 of file SpectrogramSettings.cpp.

707{
708 return Get(const_cast<WaveTrack&>(track));
709}
static SpectrogramBounds & Get(WaveTrack &track)
Get either the global default settings, or the track's own if previously created.
A Track that contains audio waveform data.
Definition: WaveTrack.h:227

References SpectrogramSettings::Get().

Here is the call graph for this function:

◆ Get() [2/2]

SpectrogramBounds & SpectrogramBounds::Get ( WaveTrack track)
static

Get either the global default settings, or the track's own if previously created.

Definition at line 699 of file SpectrogramSettings.cpp.

700{
701 return track.GetGroupData().Attachments
702 ::Get<SpectrogramBounds>(key2);
703}
static const ChannelGroup::Attachments::RegisteredFactory key2
ChannelGroupData & GetGroupData()
Definition: Track.cpp:159

References Track::GetGroupData(), and key2.

Referenced by SpectrumVRulerControls::DoHandleWheelRotation(), SpectrumView::DoSetMinimized(), SpectrumVRulerControls::DoUpdateVRuler(), SpectrumVZoomHandle::DoZoom(), anonymous_namespace{SpectrumView.cpp}::DrawClipSpectrum(), anonymous_namespace{BrushHandle.cpp}::FrequencyToPosition(), anonymous_namespace{SelectHandle.cpp}::FrequencyToPosition(), anonymous_namespace{BrushHandle.cpp}::PositionToFrequency(), anonymous_namespace{SelectHandle.cpp}::PositionToFrequency(), SpectrumPrefs::Preview(), SpectrumPrefs::Rollback(), and SpectrumPrefs::SpectrumPrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetBounds()

void SpectrogramBounds::GetBounds ( const WaveTrack wt,
float &  min,
float &  max 
) const

Definition at line 718 of file SpectrogramSettings.cpp.

720{
721 const double rate = wt.GetRate();
722
723 const auto &settings = SpectrogramSettings::Get(wt);
724 const auto type = settings.scaleType;
725
726 const float top = (rate / 2.);
727
728 float bottom;
730 bottom = 0.0f;
731 else if (type == SpectrogramSettings::stPeriod) {
732 // special case
733 const auto half = settings.GetFFTLength() / 2;
734 // EAC returns no data for below this frequency:
735 const float bin2 = rate / half;
736 bottom = bin2;
737 }
738 else
739 // logarithmic, etc.
740 bottom = 1.0f;
741
742 {
743 float spectrumMax = mSpectrumMax;
744 if (spectrumMax < 0)
745 spectrumMax = settings.maxFreq;
746 if (spectrumMax < 0)
747 max = top;
748 else
749 max = std::clamp(spectrumMax, bottom, top);
750 }
751
752 {
753 float spectrumMin = mSpectrumMin;
754 if (spectrumMin < 0)
755 spectrumMin = settings.minFreq;
756 if (spectrumMin < 0)
757 min = std::max(bottom, top / 1000.0f);
758 else
759 min = std::clamp(spectrumMin, bottom, top);
760 }
761}
int min(int a, int b)
static Settings & settings()
Definition: TrackInfo.cpp:69
static SpectrogramSettings & Get(const WaveTrack &track)
Mutative access to attachment even if the track argument is const.
double GetRate() const override
Definition: WaveTrack.cpp:1141

References SpectrogramSettings::Get(), WaveTrack::GetRate(), min(), settings(), SpectrogramSettings::stLinear, and SpectrogramSettings::stPeriod.

Referenced by SpectrumVRulerControls::DoHandleWheelRotation(), SpectrumVRulerControls::DoUpdateVRuler(), SpectrumVZoomHandle::DoZoom(), anonymous_namespace{SpectrumView.cpp}::DrawClipSpectrum(), anonymous_namespace{BrushHandle.cpp}::FrequencyToPosition(), anonymous_namespace{SelectHandle.cpp}::FrequencyToPosition(), anonymous_namespace{SelectHandle.cpp}::PositionToFrequency(), and SpectrumPrefs::SpectrumPrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetBounds()

void SpectrogramBounds::SetBounds ( float  min,
float  max 
)
inline

Definition at line 219 of file SpectrogramSettings.h.

220 { mSpectrumMin = min, mSpectrumMax = max; }

References min().

Referenced by SpectrumVRulerControls::DoHandleWheelRotation(), SpectrumView::DoSetMinimized(), SpectrumVZoomHandle::DoZoom(), SpectrumPrefs::Preview(), and SpectrumPrefs::Rollback().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mSpectrumMax

float SpectrogramBounds::mSpectrumMax = -1
private

Definition at line 223 of file SpectrogramSettings.h.

◆ mSpectrumMin

float SpectrogramBounds::mSpectrumMin = -1
private

Definition at line 223 of file SpectrogramSettings.h.


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