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 WaveChannel &wc, 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...
 
static SpectrogramBoundsGet (WaveChannel &channel)
 Get either the global default settings, or the track's own if previously created. More...
 
static const SpectrogramBoundsGet (const WaveChannel &channel)
 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 209 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 722 of file SpectrogramSettings.cpp.

723{
724 return std::make_unique<SpectrogramBounds>(*this);
725}

◆ Get() [1/4]

const SpectrogramBounds & SpectrogramBounds::Get ( const WaveChannel channel)
static

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

Definition at line 715 of file SpectrogramSettings.cpp.

716{
717 return Get(const_cast<WaveChannel&>(channel));
718}
static SpectrogramBounds & Get(WaveTrack &track)
Get either the global default settings, or the track's own if previously created.

References SpectrogramSettings::Get().

Here is the call graph for this function:

◆ Get() [2/4]

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 704 of file SpectrogramSettings.cpp.

706{
707 return Get(const_cast<WaveTrack&>(track));
708}
A Track that contains audio waveform data.
Definition: WaveTrack.h:203

References SpectrogramSettings::Get().

Here is the call graph for this function:

◆ Get() [3/4]

SpectrogramBounds & SpectrogramBounds::Get ( WaveChannel channel)
static

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

Definition at line 710 of file SpectrogramSettings.cpp.

711{
712 return Get(channel.GetTrack());
713}
WaveTrack & GetTrack()
Definition: WaveTrack.h:841

References SpectrogramSettings::Get(), and WaveChannel::GetTrack().

Here is the call graph for this function:

◆ Get() [4/4]

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.Attachments::Get<SpectrogramBounds>(key2);
702}
static const ChannelGroup::Attachments::RegisteredFactory key2

References 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 caller graph for this function:

◆ GetBounds()

void SpectrogramBounds::GetBounds ( const WaveChannel wc,
float &  min,
float &  max 
) const

Definition at line 727 of file SpectrogramSettings.cpp.

729{
730 auto &wt = wc.GetTrack();
731 const double rate = wt.GetRate();
732
733 const auto &settings = SpectrogramSettings::Get(wt);
734 const auto type = settings.scaleType;
735
736 const float top = (rate / 2.);
737
738 float bottom;
740 bottom = 0.0f;
741 else if (type == SpectrogramSettings::stPeriod) {
742 // special case
743 const auto half = settings.GetFFTLength() / 2;
744 // EAC returns no data for below this frequency:
745 const float bin2 = rate / half;
746 bottom = bin2;
747 }
748 else
749 // logarithmic, etc.
750 bottom = 1.0f;
751
752 {
753 float spectrumMax = mSpectrumMax;
754 if (spectrumMax < 0)
755 spectrumMax = settings.maxFreq;
756 if (spectrumMax < 0)
757 max = top;
758 else
759 max = std::clamp(spectrumMax, bottom, top);
760 }
761
762 {
763 float spectrumMin = mSpectrumMin;
764 if (spectrumMin < 0)
765 spectrumMin = settings.minFreq;
766 if (spectrumMin < 0)
767 min = std::max(bottom, top / 1000.0f);
768 else
769 min = std::clamp(spectrumMin, bottom, top);
770 }
771}
int min(int a, int b)
static Settings & settings()
Definition: TrackInfo.cpp:51
static SpectrogramSettings & Get(const WaveTrack &track)
double GetRate() const override
Definition: WaveTrack.cpp:821

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

Referenced by SpectrumVRulerControls::DoHandleWheelRotation(), SpectrumVRulerControls::DoUpdateVRuler(), 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 231 of file SpectrogramSettings.h.

232 { mSpectrumMin = min, mSpectrumMax = max; }

References min().

Referenced by SpectrumVRulerControls::DoHandleWheelRotation(), SpectrumView::DoSetMinimized(), 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 235 of file SpectrogramSettings.h.

◆ mSpectrumMin

float SpectrogramBounds::mSpectrumMin = -1
private

Definition at line 235 of file SpectrogramSettings.h.


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