Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linear dB Ruler Midterm-ready Changes #2

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/AdornedRulerPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
#include "widgets/AButton.h"
#include "widgets/AudacityMessageBox.h"
#include "widgets/Grabber.h"
#include "widgets/LinearUpdater.h"
#include "widgets/LogarithmicUpdater.h"
#include "widgets/wxWidgetsWindowPlacement.h"

#include <wx/dcclient.h>
Expand Down Expand Up @@ -1280,9 +1282,9 @@ AdornedRulerPanel::AdornedRulerPanel(AudacityProject* project,

mOuter = GetClientRect();

mRuler.SetUseZoomInfo(mLeftOffset, mViewInfo);
mRuler.SetUpdater( std::make_unique<LinearUpdater>( mViewInfo ), mLeftOffset );
mRuler.SetLabelEdges( false );
mRuler.SetFormat( Ruler::TimeFormat );
mRuler.SetFormat( TimeFormat );

mTracks = &TrackList::Get( *project );

Expand Down Expand Up @@ -2577,7 +2579,7 @@ int AdornedRulerPanel::GetRulerHeight(bool showScrubBar)
void AdornedRulerPanel::SetLeftOffset(int offset)
{
mLeftOffset = offset;
mRuler.SetUseZoomInfo(offset, mViewInfo);
mRuler.SetUpdater( std::make_unique<LinearUpdater>( mViewInfo ), offset );
}

// Draws the scrubbing/seeking indicator.
Expand Down
1 change: 0 additions & 1 deletion src/AudacityHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
#include "UndoManager.h"
#include "WaveTrack.h"
#include "widgets/ASlider.h"
#include "widgets/Ruler.h"

// PRL: These lines allow you to remove Project.h above.
// They must be included before the definition of macro NEW below.
Expand Down
14 changes: 14 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,12 @@ list( APPEND SOURCES
widgets/BackedPanel.h
widgets/BasicMenu.cpp
widgets/BasicMenu.h
widgets/CustomUpdater.cpp
widgets/CustomUpdater.h
widgets/CustomUpdaterPosition.cpp
widgets/CustomUpdaterPosition.h
widgets/CustomUpdaterValue.cpp
widgets/CustomUpdaterValue.h
widgets/ErrorDialog.cpp
widgets/ErrorDialog.h
widgets/ExpandingToolBar.cpp
Expand Down Expand Up @@ -1045,6 +1051,10 @@ list( APPEND SOURCES
widgets/ImageRoll.h
widgets/KeyView.cpp
widgets/KeyView.h
widgets/LinearUpdater.cpp
widgets/LinearUpdater.h
widgets/LogarithmicUpdater.cpp
widgets/LogarithmicUpdater.h
widgets/MeterPanel.cpp
widgets/MeterPanel.h
widgets/MeterPanelBase.cpp
Expand All @@ -1064,12 +1074,16 @@ list( APPEND SOURCES
widgets/ReadOnlyText.h
widgets/Ruler.cpp
widgets/Ruler.h
widgets/RulerPanel.cpp
widgets/RulerPanel.h
$<$<BOOL:${${_OPT}has_sentry_reporting}>:
widgets/ErrorReportDialog.cpp
widgets/ErrorReportDialog.h
>
widgets/UnwritableLocationErrorDialog.cpp
widgets/UnwritableLocationErrorDialog.h
widgets/Updater.cpp
widgets/Updater.h
widgets/VetoDialogHook.h
widgets/Warning.cpp
widgets/Warning.h
Expand Down
22 changes: 12 additions & 10 deletions src/FreqWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ the mouse around.

#include "./widgets/HelpSystem.h"
#include "widgets/AudacityMessageBox.h"
#include "widgets/Ruler.h"
#include "widgets/RulerPanel.h"
#include "widgets/LinearUpdater.h"
#include "widgets/LogarithmicUpdater.h"
#include "widgets/VetoDialogHook.h"

#if wxUSE_ACCESSIBILITY
Expand Down Expand Up @@ -293,7 +295,7 @@ void FrequencyPlotDialog::Populate()
S.GetParent(), wxID_ANY, wxVERTICAL,
wxSize{ 100, 100 }, // Ruler can't handle small sizes
RulerPanel::Range{ 0.0, -dBRange },
Ruler::LinearDBFormat,
LinearDBFormat,
XO("dB"),
RulerPanel::Options{}
.LabelEdges(true)
Expand Down Expand Up @@ -376,7 +378,7 @@ void FrequencyPlotDialog::Populate()
S.GetParent(), wxID_ANY, wxHORIZONTAL,
wxSize{ 100, 100 }, // Ruler can't handle small sizes
RulerPanel::Range{ 10, 20000 },
Ruler::RealFormat,
RealFormat,
XO("Hz"),
RulerPanel::Options{}
.Log(true)
Expand Down Expand Up @@ -674,10 +676,10 @@ void FrequencyPlotDialog::DrawPlot()
if (!mData || mDataLen < mWindowSize || mAnalyst->GetProcessedSize() == 0) {
wxMemoryDC memDC;

vRuler->ruler.SetLog(false);
vRuler->ruler.SetUpdater(std::make_unique<LinearUpdater>());
vRuler->ruler.SetRange(0.0, -dBRange);

hRuler->ruler.SetLog(false);
hRuler->ruler.SetUpdater(std::make_unique<LinearUpdater>());
hRuler->ruler.SetRange(0, 1);

DrawBackground(memDC);
Expand Down Expand Up @@ -714,10 +716,10 @@ void FrequencyPlotDialog::DrawPlot()

if (mAlg == SpectrumAnalyst::Spectrum) {
vRuler->ruler.SetUnits(XO("dB"));
vRuler->ruler.SetFormat(Ruler::LinearDBFormat);
vRuler->ruler.SetFormat(LinearDBFormat);
} else {
vRuler->ruler.SetUnits({});
vRuler->ruler.SetFormat(Ruler::RealFormat);
vRuler->ruler.SetFormat(RealFormat);
}
int w1, w2, h;
vRuler->ruler.GetMaxSize(&w1, &h);
Expand Down Expand Up @@ -752,19 +754,19 @@ void FrequencyPlotDialog::DrawPlot()
if (mLogAxis)
{
xStep = pow(2.0f, (log(xRatio) / log(2.0f)) / width);
hRuler->ruler.SetLog(true);
hRuler->ruler.SetUpdater(std::make_unique<LogarithmicUpdater>());
}
else
{
xStep = (xMax - xMin) / width;
hRuler->ruler.SetLog(false);
hRuler->ruler.SetUpdater(std::make_unique<LinearUpdater>());
}
hRuler->ruler.SetUnits(XO("Hz"));
} else {
xMin = 0;
xMax = mAnalyst->GetProcessedSize() / mRate;
xStep = (xMax - xMin) / width;
hRuler->ruler.SetLog(false);
hRuler->ruler.SetUpdater(std::make_unique<LinearUpdater>());
/* i18n-hint: short form of 'seconds'.*/
hRuler->ruler.SetUnits(XO("s"));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Printing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bool AudacityPrintout::OnPrintPage(int WXUNUSED(page))
ruler.SetBounds(0, 0, width, rulerPageHeight);
ruler.SetOrientation(wxHORIZONTAL);
ruler.SetRange(0.0, mTracks->GetEndTime());
ruler.SetFormat(Ruler::TimeFormat);
ruler.SetFormat(TimeFormat);
ruler.SetLabelEdges(true);
ruler.Draw(*dc);

Expand Down
9 changes: 5 additions & 4 deletions src/TimeTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <wx/dc.h>
#include <wx/intl.h>
#include "widgets/Ruler.h"
#include "widgets/LinearUpdater.h"
#include "Envelope.h"
#include "Mix.h"
#include "Project.h"
Expand Down Expand Up @@ -74,9 +75,9 @@ void TimeTrack::CleanState()
SetName(GetDefaultName());

mRuler = std::make_unique<Ruler>();
mRuler->SetUseZoomInfo(0, mZoomInfo);
mRuler->SetUpdater(std::make_unique<LinearUpdater>( mZoomInfo ), 0);
mRuler->SetLabelEdges(false);
mRuler->SetFormat(Ruler::TimeFormat);
mRuler->SetFormat(TimeFormat);
}

TimeTrack::TimeTrack(const TimeTrack &orig, ProtectedCreationArg &&a,
Expand All @@ -102,9 +103,9 @@ TimeTrack::TimeTrack(const TimeTrack &orig, ProtectedCreationArg &&a,

///@TODO: Give Ruler:: a copy-constructor instead of this?
mRuler = std::make_unique<Ruler>();
mRuler->SetUseZoomInfo(0, mZoomInfo);
mRuler->SetUpdater(std::make_unique<LinearUpdater>( mZoomInfo ), 0);
mRuler->SetLabelEdges(false);
mRuler->SetFormat(Ruler::TimeFormat);
mRuler->SetFormat(TimeFormat);
}

// Copy the track metadata but not the contents.
Expand Down
26 changes: 16 additions & 10 deletions src/commands/SetTrackInfoCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,17 +286,20 @@ static const EnumValueSymbol kColourStrings[nColours] =

enum kScaleTypes
{
kLinear,
kDb,
kLinearAmp,
kLogarithmicDb,
kLinearDb,
nScaleTypes
};

static const EnumValueSymbol kScaleTypeStrings[nScaleTypes] =
{
// These are acceptable dual purpose internal/visible names
{ XO("Linear") },
{ XO("Linear (amp)") },
/* i18n-hint: abbreviates decibels */
{ XO("dB") },
{ XO("Logarithmic (dB)") },
/* i18n-hint: abbreviates decibels */
{ XO("Linear (dB)")}
};

enum kZoomTypes
Expand Down Expand Up @@ -333,7 +336,7 @@ bool SetTrackVisualsCommand::VisitSettings( SettingsVisitorBase<Const> & S ){
S.OptionalN( bHasDisplayType ).DefineEnum( mDisplayType, wxT("Display"), 0, symbols.data(), symbols.size() );
}

S.OptionalN( bHasScaleType ).DefineEnum( mScaleType, wxT("Scale"), kLinear, kScaleTypeStrings, nScaleTypes );
S.OptionalN( bHasScaleType ).DefineEnum( mScaleType, wxT("Scale"), kLinearAmp, kScaleTypeStrings, nScaleTypes );
S.OptionalN( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, kColourStrings, nColours );
S.OptionalN( bHasVZoom ).DefineEnum( mVZoom, wxT("VZoom"), kReset, kZoomTypeStrings, nZoomTypes );
S.OptionalN( bHasVZoomTop ).Define( mVZoomTop, wxT("VZoomHigh"), 1.0, -2.0, 2.0 );
Expand Down Expand Up @@ -422,11 +425,14 @@ bool SetTrackVisualsCommand::ApplyInner(const CommandContext & context, Track *
view.SetDisplay( WaveTrackSubViewType::Default(), false );
}
}
if( wt && bHasScaleType )
wt->GetWaveformSettings().scaleType =
(mScaleType==kLinear) ?
WaveformSettings::stLinear
: WaveformSettings::stLogarithmic;
if (wt && bHasScaleType) {
switch (mScaleType) {
default:
case kLinearAmp: wt->GetWaveformSettings().scaleType = WaveformSettings::stLinearAmp;
case kLogarithmicDb: wt->GetWaveformSettings().scaleType = WaveformSettings::stLogarithmicDb;
case kLinearDb: wt->GetWaveformSettings().scaleType = WaveformSettings::stLinearDb;
}
}

if( wt && bHasVZoom ){
switch( mVZoom ){
Expand Down
4 changes: 2 additions & 2 deletions src/effects/Compressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,15 +649,15 @@ void EffectCompressorPanel::OnPaint(wxPaintEvent & WXUNUSED(evt))
vRuler.SetBounds(0, 0, width, height);
vRuler.SetOrientation(wxVERTICAL);
vRuler.SetRange(0, -rangeDB);
vRuler.SetFormat(Ruler::LinearDBFormat);
vRuler.SetFormat(LinearDBFormat);
vRuler.SetUnits(XO("dB"));
vRuler.GetMaxSize(&w, NULL);

Ruler hRuler;
hRuler.SetBounds(0, 0, width, height);
hRuler.SetOrientation(wxHORIZONTAL);
hRuler.SetRange(-rangeDB, 0);
hRuler.SetFormat(Ruler::LinearDBFormat);
hRuler.SetFormat(LinearDBFormat);
hRuler.SetUnits(XO("dB"));
hRuler.SetFlip(true);
hRuler.GetMaxSize(NULL, &h);
Expand Down
16 changes: 9 additions & 7 deletions src/effects/Equalization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@
#include "../WaveClip.h"
#include "ViewInfo.h"
#include "../WaveTrack.h"
#include "../widgets/Ruler.h"
#include "../widgets/LinearUpdater.h"
#include "../widgets/LogarithmicUpdater.h"
#include "../widgets/RulerPanel.h"
#include "../widgets/AudacityTextEntryDialog.h"
#include "XMLFileReader.h"
#include "AllThemeResources.h"
Expand Down Expand Up @@ -722,7 +724,7 @@ std::unique_ptr<EffectUIValidator> EffectEqualization::PopulateOrExchange(
S.GetParent(), wxID_ANY, wxVERTICAL,
wxSize{ 100, 100 }, // Ruler can't handle small sizes
RulerPanel::Range{ 60.0, -120.0 },
Ruler::LinearDBFormat,
LinearDBFormat,
XO("dB"),
RulerPanel::Options{}
.LabelEdges(true)
Expand Down Expand Up @@ -779,7 +781,7 @@ std::unique_ptr<EffectUIValidator> EffectEqualization::PopulateOrExchange(
S.GetParent(), wxID_ANY, wxHORIZONTAL,
wxSize{ 100, 100 }, // Ruler can't handle small sizes
RulerPanel::Range{ mLoFreq, mHiFreq },
Ruler::IntFormat,
IntFormat,
XO("Hz"),
RulerPanel::Options{}
.Log(true)
Expand Down Expand Up @@ -2288,7 +2290,7 @@ void EffectEqualization::UpdateDraw()
{
EnvLogToLin();
mEnvelope = mLinEnvelope.get();
mFreqRuler->ruler.SetLog(false);
mFreqRuler->ruler.SetUpdater(std::make_unique<LinearUpdater>());
mFreqRuler->ruler.SetRange(0, mHiFreq);
}

Expand Down Expand Up @@ -2320,7 +2322,7 @@ void EffectEqualization::UpdateGraphic()

EnvLinToLog();
mEnvelope = mLogEnvelope.get();
mFreqRuler->ruler.SetLog(true);
mFreqRuler->ruler.SetUpdater(std::make_unique<LogarithmicUpdater>());
mFreqRuler->ruler.SetRange(mLoFreq, mHiFreq);
}

Expand Down Expand Up @@ -2909,15 +2911,15 @@ void EffectEqualization::OnLinFreq(wxCommandEvent & WXUNUSED(event))
mLin = mLinFreq->IsChecked();
if(IsLinear()) //going from log to lin freq scale
{
mFreqRuler->ruler.SetLog(false);
mFreqRuler->ruler.SetUpdater(std::make_unique<LinearUpdater>());
mFreqRuler->ruler.SetRange(0, mHiFreq);
EnvLogToLin();
mEnvelope = mLinEnvelope.get();
mLin = true;
}
else //going from lin to log freq scale
{
mFreqRuler->ruler.SetLog(true);
mFreqRuler->ruler.SetUpdater(std::make_unique<LogarithmicUpdater>());
mFreqRuler->ruler.SetRange(mLoFreq, mHiFreq);
EnvLinToLog();
mEnvelope = mLogEnvelope.get();
Expand Down
6 changes: 3 additions & 3 deletions src/effects/ScienFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ a graph for EffectScienFilter.
#include "../WaveTrack.h"
#include "../widgets/valnum.h"
#include "../widgets/AudacityMessageBox.h"
#include "../widgets/Ruler.h"
#include "../widgets/RulerPanel.h"
#include "../widgets/WindowAccessible.h"

#if !defined(M_PI)
Expand Down Expand Up @@ -278,7 +278,7 @@ std::unique_ptr<EffectUIValidator> EffectScienFilter::PopulateOrExchange(
S.GetParent(), wxID_ANY, wxVERTICAL,
wxSize{ 100, 100 }, // Ruler can't handle small sizes
RulerPanel::Range{ 30.0, -120.0 },
Ruler::LinearDBFormat,
LinearDBFormat,
XO("dB"),
RulerPanel::Options{}
.LabelEdges(true)
Expand Down Expand Up @@ -336,7 +336,7 @@ std::unique_ptr<EffectUIValidator> EffectScienFilter::PopulateOrExchange(
S.GetParent(), wxID_ANY, wxHORIZONTAL,
wxSize{ 100, 100 }, // Ruler can't handle small sizes
RulerPanel::Range{ mLoFreq, mNyquist },
Ruler::IntFormat,
IntFormat,
{},
RulerPanel::Options{}
.Log(true)
Expand Down
Loading