mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
Waveform dB is not a track type. Logarithmic is a Wavetrack scale type...
... Also removed one line from the track control drop-down, and changed accelerators to more mnemonic choices. Also the open page of View Settings... determines track view type after OK
This commit is contained in:
parent
5b72b1f23b
commit
5abbd463b2
@ -94,6 +94,7 @@ It handles initialization and termination by subclassing wxApp.
|
||||
#include "widgets/ErrorDialog.h"
|
||||
#include "prefs/DirectoriesPrefs.h"
|
||||
#include "prefs/SpectrogramSettings.h"
|
||||
#include "prefs/WaveformSettings.h"
|
||||
|
||||
//temporarilly commented out till it is added to all projects
|
||||
//#include "Profiler.h"
|
||||
@ -1017,6 +1018,7 @@ void AudacityApp::InitLang( const wxString & lang )
|
||||
|
||||
// Some static arrays unconnected with any project want to be informed of language changes.
|
||||
SpectrogramSettings::InvalidateNames();
|
||||
WaveformSettings::InvalidateNames();
|
||||
}
|
||||
|
||||
void AudacityApp::OnFatalException()
|
||||
|
@ -175,6 +175,7 @@ audio tracks.
|
||||
#include "TimeTrack.h"
|
||||
#include "Prefs.h"
|
||||
#include "prefs/SpectrogramSettings.h"
|
||||
#include "prefs/WaveformSettings.h"
|
||||
#include "Sequence.h"
|
||||
#include "Spectrum.h"
|
||||
#include "ViewInfo.h"
|
||||
@ -457,13 +458,9 @@ void TrackArtist::DrawTrack(const Track * t,
|
||||
bool muted = (hasSolo || t->GetMute()) && !t->GetSolo();
|
||||
|
||||
switch (wt->GetDisplay()) {
|
||||
case WaveTrack::WaveformDisplay:
|
||||
case WaveTrack::Waveform:
|
||||
DrawWaveform(wt, dc, rect, selectedRegion, zoomInfo,
|
||||
drawEnvelope, bigPoints, drawSliders, false, muted);
|
||||
break;
|
||||
case WaveTrack::WaveformDBDisplay:
|
||||
DrawWaveform(wt, dc, rect, selectedRegion, zoomInfo,
|
||||
drawEnvelope, bigPoints, drawSliders, true, muted);
|
||||
drawEnvelope, bigPoints, drawSliders, muted);
|
||||
break;
|
||||
case WaveTrack::Spectrum:
|
||||
DrawSpectrum(wt, dc, rect, selectedRegion, zoomInfo);
|
||||
@ -685,107 +682,115 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & rect)
|
||||
// The ruler needs a bevelled surround.
|
||||
if (t->GetKind() == Track::Wave) {
|
||||
WaveTrack *wt = static_cast<WaveTrack*>(t);
|
||||
int display = wt->GetDisplay();
|
||||
|
||||
if (display == WaveTrack::WaveformDisplay) {
|
||||
// Waveform
|
||||
const int display = wt->GetDisplay();
|
||||
|
||||
float min, max;
|
||||
wt->GetDisplayBounds(&min, &max);
|
||||
if(wt->GetLastDisplay()==WaveTrack::WaveformDBDisplay)
|
||||
{
|
||||
// do a translation into the WaveTrack::WaveformDisplay space
|
||||
wt->SetDisplay(WaveTrack::WaveformDisplay); // this makes the last display not WaveformDBDisplay
|
||||
float sign = (min >= 0 ? 1 : -1);
|
||||
if (min != 0.) {
|
||||
min = DB_TO_LINEAR(fabs(min)*mdBrange - mdBrange);
|
||||
if (min < 0.0)
|
||||
min = 0.0;
|
||||
min *= sign;
|
||||
}
|
||||
sign = (max >= 0 ? 1 : -1);
|
||||
if (display == WaveTrack::Waveform) {
|
||||
WaveformSettings::ScaleType scaleType =
|
||||
wt->GetWaveformSettings().scaleType;
|
||||
|
||||
if (max != 0.) {
|
||||
max = DB_TO_LINEAR(fabs(max)*mdBrange - mdBrange);
|
||||
if (max < 0.0)
|
||||
max = 0.0;
|
||||
max *= sign;
|
||||
}
|
||||
wt->SetDisplayBounds(min, max);
|
||||
}
|
||||
if (scaleType == WaveformSettings::stLinear) {
|
||||
// Waveform
|
||||
|
||||
vruler->SetBounds(rect.x, rect.y+1, rect.x + rect.width, rect.y + rect.height-1);
|
||||
vruler->SetOrientation(wxVERTICAL);
|
||||
vruler->SetRange(max, min);
|
||||
vruler->SetFormat(Ruler::RealFormat);
|
||||
vruler->SetUnits(wxT(""));
|
||||
vruler->SetLabelEdges(false);
|
||||
vruler->SetLog(false);
|
||||
}
|
||||
else if (display == WaveTrack::WaveformDBDisplay) {
|
||||
// Waveform (db)
|
||||
float min, max;
|
||||
wt->GetDisplayBounds(&min, &max);
|
||||
if (wt->GetLastScaleType() != scaleType)
|
||||
{
|
||||
// do a translation into the linear space
|
||||
wt->SetLastScaleType(scaleType);
|
||||
float sign = (min >= 0 ? 1 : -1);
|
||||
if (min != 0.) {
|
||||
min = DB_TO_LINEAR(fabs(min)*mdBrange - mdBrange);
|
||||
if (min < 0.0)
|
||||
min = 0.0;
|
||||
min *= sign;
|
||||
}
|
||||
sign = (max >= 0 ? 1 : -1);
|
||||
|
||||
vruler->SetUnits(wxT(""));
|
||||
|
||||
float min, max;
|
||||
wt->GetDisplayBounds(&min, &max);
|
||||
|
||||
if(wt->GetLastDisplay()==WaveTrack::WaveformDisplay)
|
||||
{
|
||||
// do a translation into the WaveTrack::WaveformDBDisplay space
|
||||
wt->SetDisplay(WaveTrack::WaveformDBDisplay); // this makes the last display not WaveformDisplay
|
||||
float sign = (min >= 0 ? 1 : -1);
|
||||
if (min != 0.) {
|
||||
min = (LINEAR_TO_DB(fabs(min)) + mdBrange) / mdBrange;
|
||||
if (min < 0.0)
|
||||
min = 0.0;
|
||||
min *= sign;
|
||||
}
|
||||
sign = (max >= 0 ? 1 : -1);
|
||||
|
||||
if (max != 0.) {
|
||||
max = (LINEAR_TO_DB(fabs(max)) + mdBrange) / mdBrange;
|
||||
if (max < 0.0)
|
||||
max = 0.0;
|
||||
max *= sign;
|
||||
}
|
||||
wt->SetDisplayBounds(min, max);
|
||||
}
|
||||
|
||||
if (max > 0) {
|
||||
int top = 0;
|
||||
float topval = 0;
|
||||
int bot = rect.height;
|
||||
float botval = -mdBrange;
|
||||
|
||||
if (min < 0) {
|
||||
bot = top + (int)((max / (max-min))*(bot-top));
|
||||
min = 0;
|
||||
if (max != 0.) {
|
||||
max = DB_TO_LINEAR(fabs(max)*mdBrange - mdBrange);
|
||||
if (max < 0.0)
|
||||
max = 0.0;
|
||||
max *= sign;
|
||||
}
|
||||
wt->SetDisplayBounds(min, max);
|
||||
}
|
||||
|
||||
if (max > 1) {
|
||||
top += (int)((max-1)/(max-min) * (bot-top));
|
||||
max = 1;
|
||||
}
|
||||
|
||||
if (max < 1 && max > 0)
|
||||
topval = -((1-max)*mdBrange);
|
||||
|
||||
if (min > 0) {
|
||||
botval = -((1-min)*mdBrange);
|
||||
}
|
||||
|
||||
vruler->SetBounds(rect.x, rect.y+top+1, rect.x + rect.width, rect.y + bot-1);
|
||||
vruler->SetBounds(rect.x, rect.y + 1, rect.x + rect.width, rect.y + rect.height - 1);
|
||||
vruler->SetOrientation(wxVERTICAL);
|
||||
vruler->SetRange(topval, botval);
|
||||
}
|
||||
else
|
||||
vruler->SetBounds(0.0, 0.0, 0.0, 0.0); // A.C.H I couldn't find a way to just disable it?
|
||||
vruler->SetFormat(Ruler::RealLogFormat);
|
||||
vruler->SetLabelEdges(true);
|
||||
vruler->SetLog(false);
|
||||
vruler->SetRange(max, min);
|
||||
vruler->SetFormat(Ruler::RealFormat);
|
||||
vruler->SetUnits(wxT(""));
|
||||
vruler->SetLabelEdges(false);
|
||||
vruler->SetLog(false);
|
||||
}
|
||||
else {
|
||||
wxASSERT(scaleType == WaveformSettings::stLogarithmic);
|
||||
scaleType = WaveformSettings::stLogarithmic;
|
||||
|
||||
vruler->SetUnits(wxT(""));
|
||||
|
||||
float min, max;
|
||||
wt->GetDisplayBounds(&min, &max);
|
||||
|
||||
if (wt->GetLastScaleType() != scaleType)
|
||||
{
|
||||
// do a translation into the dB space
|
||||
wt->SetLastScaleType(scaleType);
|
||||
float sign = (min >= 0 ? 1 : -1);
|
||||
if (min != 0.) {
|
||||
min = (LINEAR_TO_DB(fabs(min)) + mdBrange) / mdBrange;
|
||||
if (min < 0.0)
|
||||
min = 0.0;
|
||||
min *= sign;
|
||||
}
|
||||
sign = (max >= 0 ? 1 : -1);
|
||||
|
||||
if (max != 0.) {
|
||||
max = (LINEAR_TO_DB(fabs(max)) + mdBrange) / mdBrange;
|
||||
if (max < 0.0)
|
||||
max = 0.0;
|
||||
max *= sign;
|
||||
}
|
||||
wt->SetDisplayBounds(min, max);
|
||||
}
|
||||
|
||||
if (max > 0) {
|
||||
int top = 0;
|
||||
float topval = 0;
|
||||
int bot = rect.height;
|
||||
float botval = -mdBrange;
|
||||
|
||||
if (min < 0) {
|
||||
bot = top + (int)((max / (max - min))*(bot - top));
|
||||
min = 0;
|
||||
}
|
||||
|
||||
if (max > 1) {
|
||||
top += (int)((max - 1) / (max - min) * (bot - top));
|
||||
max = 1;
|
||||
}
|
||||
|
||||
if (max < 1 && max > 0)
|
||||
topval = -((1 - max)*mdBrange);
|
||||
|
||||
if (min > 0) {
|
||||
botval = -((1 - min)*mdBrange);
|
||||
}
|
||||
|
||||
vruler->SetBounds(rect.x, rect.y + top + 1, rect.x + rect.width, rect.y + bot - 1);
|
||||
vruler->SetOrientation(wxVERTICAL);
|
||||
vruler->SetRange(topval, botval);
|
||||
}
|
||||
else
|
||||
vruler->SetBounds(0.0, 0.0, 0.0, 0.0); // A.C.H I couldn't find a way to just disable it?
|
||||
vruler->SetFormat(Ruler::RealLogFormat);
|
||||
vruler->SetLabelEdges(true);
|
||||
vruler->SetLog(false);
|
||||
}
|
||||
}
|
||||
else if (display == WaveTrack::Spectrum) {
|
||||
else {
|
||||
wxASSERT(display == WaveTrack::Spectrum);
|
||||
switch (wt->GetSpectrogramSettings().scaleType) {
|
||||
default:
|
||||
wxASSERT(false);
|
||||
@ -1416,9 +1421,10 @@ void TrackArtist::DrawWaveform(WaveTrack *track,
|
||||
bool drawEnvelope,
|
||||
bool bigPoints,
|
||||
bool drawSliders,
|
||||
bool dB,
|
||||
bool muted)
|
||||
{
|
||||
const bool dB = !track->GetWaveformSettings().isLinear();
|
||||
|
||||
DrawBackgroundWithSelection(&dc, rect, track, blankSelectedBrush, blankBrush,
|
||||
selectedRegion, zoomInfo);
|
||||
|
||||
|
@ -97,7 +97,7 @@ class AUDACITY_DLL_API TrackArtist {
|
||||
wxDC & dc, const wxRect & rect,
|
||||
const SelectedRegion &selectedRegion, const ZoomInfo &zoomInfo,
|
||||
bool drawEnvelope, bool bigPoints, bool drawSliders,
|
||||
bool dB, bool muted);
|
||||
bool muted);
|
||||
|
||||
void DrawSpectrum(WaveTrack *track,
|
||||
wxDC & dc, const wxRect & rect,
|
||||
|
@ -327,7 +327,6 @@ enum {
|
||||
OnFloatID, // <---
|
||||
|
||||
OnWaveformID,
|
||||
OnWaveformDBID,
|
||||
OnSpectrumID,
|
||||
OnViewSettingsID,
|
||||
|
||||
@ -723,10 +722,9 @@ void TrackPanel::BuildMenus(void)
|
||||
/* build the pop-down menu used on wave (sampled audio) tracks */
|
||||
mWaveTrackMenu = new wxMenu();
|
||||
BuildCommonDropMenuItems(mWaveTrackMenu); // does name, up/down etc
|
||||
mWaveTrackMenu->Append(OnWaveformID, _("Wa&veform"));
|
||||
mWaveTrackMenu->Append(OnWaveformDBID, _("&Waveform (dB)"));
|
||||
mWaveTrackMenu->Append(OnWaveformID, _("&Waveform"));
|
||||
mWaveTrackMenu->Append(OnSpectrumID, _("&Spectrum"));
|
||||
mWaveTrackMenu->Append(OnViewSettingsID, _("View& Settings...")); // PRL: all the other letters already taken for accelerators!
|
||||
mWaveTrackMenu->Append(OnViewSettingsID, _("&View Settings..."));
|
||||
mWaveTrackMenu->AppendSeparator();
|
||||
|
||||
mWaveTrackMenu->AppendRadioItem(OnChannelMonoID, _("&Mono"));
|
||||
@ -3776,10 +3774,8 @@ void TrackPanel::ForwardEventToWaveTrackEnvelope(wxMouseEvent & event)
|
||||
// This asks which one is in use. (ie, Wave, Spectrum, etc)
|
||||
int display = pwavetrack->GetDisplay();
|
||||
|
||||
// AS: If we're using the right type of display for envelope operations
|
||||
// ie one of the Wave displays
|
||||
const bool dB = (display == WaveTrack::WaveformDBDisplay);
|
||||
if (dB || (display == WaveTrack::WaveformDisplay)) {
|
||||
if (display == WaveTrack::Waveform) {
|
||||
const bool dB = !pwavetrack->GetWaveformSettings().isLinear();
|
||||
bool needUpdate;
|
||||
|
||||
// AS: Then forward our mouse event to the envelope.
|
||||
@ -4850,20 +4846,12 @@ bool TrackPanel::IsSampleEditingPossible( wxMouseEvent &event, Track * t )
|
||||
//If we aren't displaying the waveform, Display a message dialog
|
||||
WaveTrack *const wt = static_cast<WaveTrack*>(t);
|
||||
const int display = wt->GetDisplay();
|
||||
#if 1
|
||||
if (!(WaveTrack::WaveformDisplay == display ||
|
||||
WaveTrack::WaveformDBDisplay == display))
|
||||
{
|
||||
wxMessageBox(_("To use Draw, choose 'Waveform' or 'Waveform dB' in the Track Drop-down Menu."), wxT("Draw Tool"));
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
if(WaveTrack::WaveformDisplay != display)
|
||||
|
||||
if (WaveTrack::Waveform != display)
|
||||
{
|
||||
wxMessageBox(_("To use Draw, choose 'Waveform' in the Track Drop-down Menu."), wxT("Draw Tool"));
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool showPoints;
|
||||
{
|
||||
@ -4901,7 +4889,7 @@ float TrackPanel::FindSampleEditingLevel(wxMouseEvent &event, double t0)
|
||||
|
||||
const int y = event.m_y - mDrawingTrackTop;
|
||||
const int height = mDrawingTrack->GetHeight();
|
||||
const bool dB = (WaveTrack::WaveformDBDisplay == mDrawingTrack->GetDisplay());
|
||||
const bool dB = !mDrawingTrack->GetWaveformSettings().isLinear();
|
||||
float newLevel = ::ValueOfPixel(y, height, false, dB, mdBr, zoomMin, zoomMax);
|
||||
|
||||
//Take the envelope into account
|
||||
@ -6909,16 +6897,14 @@ bool TrackPanel::HitTestEnvelope(Track *track, wxRect &r, wxMouseEvent & event)
|
||||
if (!envelope)
|
||||
return false;
|
||||
|
||||
int displayType = wavetrack->GetDisplay();
|
||||
const int displayType = wavetrack->GetDisplay();
|
||||
// Not an envelope hit, unless we're using a type of wavetrack display
|
||||
// suitable for envelopes operations, ie one of the Wave displays.
|
||||
const bool dB = (displayType == WaveTrack::WaveformDBDisplay);
|
||||
if (!
|
||||
(dB || (displayType == WaveTrack::WaveformDisplay))
|
||||
)
|
||||
if ( displayType != WaveTrack::Waveform)
|
||||
return false; // No envelope, not a hit, so return.
|
||||
|
||||
// Get envelope point, range 0.0 to 1.0
|
||||
const bool dB = !wavetrack->GetWaveformSettings().isLinear();
|
||||
// Convert x to time.
|
||||
const double envValue = envelope->GetValue(mViewInfo->PositionToTime(event.m_x, r.x));
|
||||
|
||||
@ -6976,10 +6962,10 @@ bool TrackPanel::HitTestSamples(Track *track, wxRect &r, wxMouseEvent & event)
|
||||
//Get rate in order to calculate the critical zoom threshold
|
||||
double rate = wavetrack->GetRate();
|
||||
|
||||
int displayType = wavetrack->GetDisplay();
|
||||
bool dB = (WaveTrack::WaveformDBDisplay == displayType);
|
||||
if (!(WaveTrack::WaveformDisplay == displayType || dB))
|
||||
const int displayType = wavetrack->GetDisplay();
|
||||
if (WaveTrack::Waveform != displayType)
|
||||
return false; // Not a wave, so return.
|
||||
const bool dB = !wavetrack->GetWaveformSettings().isLinear();
|
||||
|
||||
const double tt = mViewInfo->PositionToTime(event.m_x, r.x);
|
||||
if (!SampleResolutionTest(*mViewInfo, wavetrack, tt, rate))
|
||||
@ -8449,11 +8435,9 @@ void TrackPanel::OnTrackMenu(Track *t)
|
||||
theMenu->Enable(OnChannelLeftID, !t->GetLinked());
|
||||
theMenu->Enable(OnChannelRightID, !t->GetLinked());
|
||||
|
||||
int display = ((WaveTrack *) t)->GetDisplay();
|
||||
const int display = static_cast<WaveTrack *>(t)->GetDisplay();
|
||||
|
||||
theMenu->Enable(OnWaveformID, display != WaveTrack::WaveformDisplay);
|
||||
theMenu->Enable(OnWaveformDBID,
|
||||
display != WaveTrack::WaveformDBDisplay);
|
||||
theMenu->Enable(OnWaveformID, display != WaveTrack::Waveform);
|
||||
theMenu->Enable(OnSpectrumID, display != WaveTrack::Spectrum);
|
||||
theMenu->Enable(OnViewSettingsID, true);
|
||||
|
||||
@ -8977,9 +8961,7 @@ void TrackPanel::OnSetDisplay(wxCommandEvent & event)
|
||||
switch (idInt) {
|
||||
default:
|
||||
case OnWaveformID:
|
||||
id = WaveTrack::WaveformDisplay; break;
|
||||
case OnWaveformDBID:
|
||||
id = WaveTrack::WaveformDBDisplay; break;
|
||||
id = WaveTrack::Waveform; break;
|
||||
case OnSpectrumID:
|
||||
id = WaveTrack::Spectrum; break;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ WaveTrack *TrackFactory::NewWaveTrack(sampleFormat format, double rate)
|
||||
return new WaveTrack(mDirManager, format, rate);
|
||||
}
|
||||
|
||||
WaveTrack::WaveTrack(DirManager *projDirManager, sampleFormat format, double rate):
|
||||
WaveTrack::WaveTrack(DirManager *projDirManager, sampleFormat format, double rate) :
|
||||
Track(projDirManager)
|
||||
, mpSpectrumSettings(0)
|
||||
, mpWaveformSettings(0)
|
||||
@ -103,7 +103,7 @@ WaveTrack::WaveTrack(DirManager *projDirManager, sampleFormat format, double rat
|
||||
mDisplayNumLocations = 0;
|
||||
mDisplayLocations = NULL;
|
||||
mDisplayNumLocationsAllocated = 0;
|
||||
mLastDisplay = -1;
|
||||
mLastScaleType = -1;
|
||||
mAutoSaveIdent = 0;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ WaveTrack::WaveTrack(WaveTrack &orig):
|
||||
? new WaveformSettings(*orig.mpWaveformSettings) : 0)
|
||||
{
|
||||
mDisplay = FindDefaultViewMode();
|
||||
mLastDisplay = -1;
|
||||
mLastScaleType = -1;
|
||||
|
||||
mLegacyProjectFileOffset = 0;
|
||||
|
||||
@ -211,7 +211,7 @@ WaveTrack::WaveTrackDisplay WaveTrack::FindDefaultViewMode()
|
||||
if (viewMode < 0) {
|
||||
int oldMode;
|
||||
gPrefs->Read(wxT("/GUI/DefaultViewMode"), &oldMode,
|
||||
int(WaveTrack::WaveformDisplay));
|
||||
int(WaveTrack::Waveform));
|
||||
viewMode = WaveTrack::ConvertLegacyDisplayValue(oldMode);
|
||||
}
|
||||
|
||||
@ -238,9 +238,12 @@ WaveTrack::ConvertLegacyDisplayValue(int oldValue)
|
||||
switch (oldValue) {
|
||||
default:
|
||||
case Waveform:
|
||||
newValue = WaveTrack::WaveformDisplay; break;
|
||||
case WaveformDB:
|
||||
newValue = WaveTrack::Waveform; break;
|
||||
/*
|
||||
case WaveformDB:
|
||||
newValue = WaveTrack::WaveformDBDisplay; break;
|
||||
*/
|
||||
case Spectrogram:
|
||||
case SpectrogramLogF:
|
||||
case Pitch:
|
||||
@ -261,8 +264,7 @@ WaveTrack::ValidateWaveTrackDisplay(WaveTrackDisplay display)
|
||||
{
|
||||
switch (display) {
|
||||
// non-obsolete codes
|
||||
case WaveformDisplay:
|
||||
case WaveformDBDisplay:
|
||||
case Waveform:
|
||||
case Spectrum:
|
||||
return display;
|
||||
|
||||
@ -273,6 +275,9 @@ WaveTrack::ValidateWaveTrackDisplay(WaveTrackDisplay display)
|
||||
case obsolete4: // was PitchDisplay
|
||||
return Spectrum;
|
||||
|
||||
case obsolete5: // was WaveformDBDisplay
|
||||
return Waveform;
|
||||
|
||||
// codes out of bounds (from future prefs files?)
|
||||
default:
|
||||
return MinDisplay;
|
||||
|
@ -420,10 +420,11 @@ class AUDACITY_DLL_API WaveTrack: public Track {
|
||||
|
||||
// DO NOT REORDER OLD VALUES! Replace obsoletes with placeholders.
|
||||
|
||||
WaveformDisplay = 0,
|
||||
MinDisplay = WaveformDisplay,
|
||||
Waveform = 0,
|
||||
MinDisplay = Waveform,
|
||||
|
||||
obsolete5, // was WaveformDBDisplay
|
||||
|
||||
WaveformDBDisplay,
|
||||
Spectrum,
|
||||
|
||||
obsolete1, // was SpectrumLogDisplay
|
||||
@ -447,14 +448,15 @@ class AUDACITY_DLL_API WaveTrack: public Track {
|
||||
// Handle restriction of range of values of the enum from future versions
|
||||
static WaveTrackDisplay ValidateWaveTrackDisplay(WaveTrackDisplay display);
|
||||
|
||||
void SetDisplay(WaveTrackDisplay display) {
|
||||
if (mDisplay < Spectrum)
|
||||
// remember last display mode for wave and wavedb so they can remap the vertical ruler
|
||||
mLastDisplay = mDisplay;
|
||||
mDisplay = display;
|
||||
int GetLastScaleType() { return mLastScaleType; }
|
||||
void SetLastScaleType(int scaleType)
|
||||
{
|
||||
// remember last display mode for wave and wavedb so vertical ruler can remap
|
||||
mLastScaleType = scaleType;
|
||||
}
|
||||
|
||||
WaveTrackDisplay GetDisplay() const { return mDisplay; }
|
||||
int GetLastDisplay() {return mLastDisplay;}
|
||||
void SetDisplay(WaveTrackDisplay display) { mDisplay = display; }
|
||||
|
||||
void GetDisplayBounds(float *min, float *max);
|
||||
void SetDisplayBounds(float min, float max);
|
||||
@ -480,7 +482,7 @@ class AUDACITY_DLL_API WaveTrack: public Track {
|
||||
float mDisplayMin;
|
||||
float mDisplayMax;
|
||||
WaveTrackDisplay mDisplay;
|
||||
int mLastDisplay; // last display mode
|
||||
int mLastScaleType; // last scale type choice
|
||||
int mDisplayNumLocations;
|
||||
int mDisplayNumLocationsAllocated;
|
||||
Location* mDisplayLocations;
|
||||
|
@ -789,8 +789,7 @@ bool NyquistEffect::ProcessOne()
|
||||
type = wxT("wave");
|
||||
switch (((WaveTrack *) mCurTrack[0])->GetDisplay())
|
||||
{
|
||||
case WaveTrack::WaveformDisplay: view = wxT("\"Waveform\""); break;
|
||||
case WaveTrack::WaveformDBDisplay: view = wxT("\"Waveform (dB)\""); break;
|
||||
case WaveTrack::Waveform: view = wxT("\"Waveform\""); break;
|
||||
case WaveTrack::Spectrum: view = wxT("\"Spectrum\""); break;
|
||||
default: view = wxT("NIL"); break;
|
||||
}
|
||||
|
@ -60,10 +60,7 @@ void TracksPrefs::Populate()
|
||||
// we don't display them by increasing integer values.
|
||||
|
||||
mViewChoices.Add(_("Waveform"));
|
||||
mViewCodes.Add(int(WaveTrack::WaveformDisplay));
|
||||
|
||||
mViewChoices.Add(_("Waveform (dB)"));
|
||||
mViewCodes.Add(int(WaveTrack::WaveformDBDisplay));
|
||||
mViewCodes.Add(int(WaveTrack::Waveform));
|
||||
|
||||
mViewChoices.Add(_("Spectrum"));
|
||||
mViewCodes.Add(WaveTrack::Spectrum);
|
||||
|
@ -47,11 +47,13 @@ WaveformPrefs::~WaveformPrefs()
|
||||
enum {
|
||||
ID_DEFAULTS = 10001,
|
||||
ID_APPLY,
|
||||
|
||||
ID_SCALE,
|
||||
};
|
||||
|
||||
void WaveformPrefs::Populate()
|
||||
{
|
||||
// Create control objects
|
||||
mScaleChoices = WaveformSettings::GetScaleNames();
|
||||
|
||||
//------------------------- Main section --------------------
|
||||
// Now construct the GUI itself.
|
||||
@ -77,6 +79,9 @@ void WaveformPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
{
|
||||
S.StartTwoColumn();
|
||||
{
|
||||
S.Id(ID_SCALE).TieChoice(_("S&cale") + wxString(wxT(":")),
|
||||
*(int*)&mTempSettings.scaleType,
|
||||
&mScaleChoices);
|
||||
}
|
||||
S.EndTwoColumn();
|
||||
}
|
||||
@ -151,12 +156,9 @@ bool WaveformPrefs::Apply()
|
||||
}
|
||||
|
||||
if (mWt && isOpenPage) {
|
||||
// Future: open page will determine view type
|
||||
/*
|
||||
mWt->SetDisplay(WaveTrack::Waveform);
|
||||
if (partner)
|
||||
partner->SetDisplay(WaveTrack::Waveform);
|
||||
*/
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -194,6 +196,9 @@ void WaveformPrefs::OnApply(wxCommandEvent &)
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(WaveformPrefs, PrefsPanel)
|
||||
|
||||
EVT_CHOICE(ID_SCALE, WaveformPrefs::OnControl)
|
||||
|
||||
EVT_CHECKBOX(ID_DEFAULTS, WaveformPrefs::OnDefaults)
|
||||
EVT_BUTTON(ID_APPLY, WaveformPrefs::OnApply)
|
||||
END_EVENT_TABLE()
|
||||
|
@ -41,6 +41,8 @@ private:
|
||||
|
||||
wxCheckBox *mDefaultsCheckbox;
|
||||
|
||||
wxArrayString mScaleChoices;
|
||||
|
||||
WaveformSettings mTempSettings;
|
||||
|
||||
bool mPopulating;
|
||||
|
@ -16,6 +16,11 @@ Paul Licameli
|
||||
#include "../Audacity.h"
|
||||
#include "WaveformSettings.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <wx/intl.h>
|
||||
|
||||
#include "../Prefs.h"
|
||||
|
||||
WaveformSettings::Globals::Globals()
|
||||
{
|
||||
LoadPrefs();
|
||||
@ -42,12 +47,14 @@ WaveformSettings::WaveformSettings()
|
||||
}
|
||||
|
||||
WaveformSettings::WaveformSettings(const WaveformSettings &other)
|
||||
: scaleType(other.scaleType)
|
||||
{
|
||||
}
|
||||
|
||||
WaveformSettings &WaveformSettings::operator= (const WaveformSettings &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
scaleType = other.scaleType;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@ -62,11 +69,17 @@ bool WaveformSettings::Validate(bool quiet)
|
||||
{
|
||||
quiet;
|
||||
|
||||
scaleType = ScaleType(
|
||||
std::max(0, std::min(int(stNumScaleTypes) - 1, int(scaleType)))
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void WaveformSettings::LoadPrefs()
|
||||
{
|
||||
scaleType = ScaleType(gPrefs->Read(wxT("/Waveform/ScaleType"), 0L));
|
||||
|
||||
// Enforce legal values
|
||||
Validate(true);
|
||||
|
||||
@ -75,12 +88,42 @@ void WaveformSettings::LoadPrefs()
|
||||
|
||||
void WaveformSettings::SavePrefs()
|
||||
{
|
||||
gPrefs->Write(wxT("/Waveform/ScaleType"), long(scaleType));
|
||||
}
|
||||
|
||||
void WaveformSettings::Update()
|
||||
{
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
wxArrayString &scaleNamesArray()
|
||||
{
|
||||
static wxArrayString theArray;
|
||||
return theArray;
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
void WaveformSettings::InvalidateNames()
|
||||
{
|
||||
scaleNamesArray().Clear();
|
||||
}
|
||||
|
||||
//static
|
||||
const wxArrayString &WaveformSettings::GetScaleNames()
|
||||
{
|
||||
wxArrayString &theArray = scaleNamesArray();
|
||||
|
||||
if (theArray.IsEmpty()) {
|
||||
// Keep in correspondence with enum WaveTrack::WaveTrackDisplay:
|
||||
theArray.Add(_("Linear"));
|
||||
theArray.Add(_("Logarithmic"));
|
||||
}
|
||||
|
||||
return theArray;
|
||||
}
|
||||
|
||||
WaveformSettings::~WaveformSettings()
|
||||
{
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ Paul Licameli
|
||||
#ifndef __AUDACITY_WAVEFORM_SETTINGS__
|
||||
#define __AUDACITY_WAVEFORM_SETTINGS__
|
||||
|
||||
class wxArrayString;
|
||||
|
||||
class WaveformSettings
|
||||
{
|
||||
public:
|
||||
@ -42,5 +44,20 @@ public:
|
||||
void LoadPrefs();
|
||||
void SavePrefs();
|
||||
void Update();
|
||||
|
||||
enum ScaleType {
|
||||
stLinear,
|
||||
stLogarithmic,
|
||||
|
||||
stNumScaleTypes,
|
||||
};
|
||||
|
||||
static void InvalidateNames(); // in case of language change
|
||||
static const wxArrayString &GetScaleNames();
|
||||
|
||||
ScaleType scaleType;
|
||||
|
||||
// Convenience
|
||||
bool isLinear() const { return stLinear == scaleType; }
|
||||
};
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user