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

725{
726 return std::make_unique<SpectrogramBounds>(*this);
727}

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

718{
719 return Get(const_cast<WaveChannel&>(channel));
720}
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 706 of file SpectrogramSettings.cpp.

708{
709 return Get(const_cast<WaveTrack&>(track));
710}
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 712 of file SpectrogramSettings.cpp.

713{
714 return Get(channel.GetTrack());
715}
WaveTrack & GetTrack()
Definition: WaveTrack.h:840

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

702{
703 return track.Attachments::Get<SpectrogramBounds>(key2);
704}
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 729 of file SpectrogramSettings.cpp.

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

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: