mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-10 08:33:36 +02:00
Bug 2418 - Time toolbar displays incorrect time if project rate isn't 44100
This commit is contained in:
@@ -163,6 +163,20 @@ const NumericFormatSymbol & ProjectSettings::GetAudioTimeFormat() const
|
||||
return mAudioTimeFormat;
|
||||
}
|
||||
|
||||
double ProjectSettings::GetRate() const
|
||||
{
|
||||
return mRate;
|
||||
}
|
||||
|
||||
void ProjectSettings::SetRate(double rate)
|
||||
{
|
||||
auto &project = mProject;
|
||||
if (rate != mRate) {
|
||||
mRate = rate;
|
||||
Notify( project, ChangedProjectRate );
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectSettings::SetSnapTo(int snap)
|
||||
{
|
||||
mSnapTo = snap;
|
||||
|
@@ -58,14 +58,13 @@ public:
|
||||
// Values retrievable from GetInt() of the event for settings change
|
||||
enum EventCode : int {
|
||||
ChangedSyncLock,
|
||||
ChangedProjectRate
|
||||
};
|
||||
|
||||
explicit ProjectSettings( AudacityProject &project );
|
||||
ProjectSettings( const ProjectSettings & ) PROHIBITED;
|
||||
ProjectSettings &operator=( const ProjectSettings & ) PROHIBITED;
|
||||
|
||||
double GetRate() const { return mRate; }
|
||||
void SetRate( double value ) { mRate = value; }
|
||||
|
||||
bool GetTracksFitVerticallyZoomed() const { return mTracksFitVerticallyZoomed; } //lda
|
||||
void SetTracksFitVerticallyZoomed(bool flag) { mTracksFitVerticallyZoomed = flag; } //lda
|
||||
@@ -76,6 +75,11 @@ public:
|
||||
bool IsSyncLocked() const;
|
||||
void SetSyncLock(bool flag);
|
||||
|
||||
// Rate
|
||||
|
||||
void SetRate(double rate);
|
||||
double GetRate() const;
|
||||
|
||||
// Snap To
|
||||
|
||||
void SetSnapTo(int snap);
|
||||
|
@@ -23,12 +23,13 @@
|
||||
#include <wx/sizer.h>
|
||||
#endif
|
||||
|
||||
#include "SelectionBarListener.h"
|
||||
#include "TimeToolBar.h"
|
||||
#include "ToolManager.h"
|
||||
#include "SelectionBarListener.h"
|
||||
|
||||
#include "../AudioIO.h"
|
||||
#include "../ProjectAudioIO.h"
|
||||
#include "../ProjectSettings.h"
|
||||
#include "../ViewInfo.h"
|
||||
|
||||
IMPLEMENT_CLASS(TimeToolBar, ToolBar);
|
||||
@@ -51,6 +52,7 @@ TimeToolBar::TimeToolBar(AudacityProject &project)
|
||||
mListener(NULL),
|
||||
mAudioTime(NULL)
|
||||
{
|
||||
project.Bind(EVT_PROJECT_SETTINGS_CHANGE, &TimeToolBar::OnSettingsChanged, this);
|
||||
}
|
||||
|
||||
TimeToolBar::~TimeToolBar()
|
||||
@@ -70,16 +72,13 @@ const TimeToolBar &TimeToolBar::Get(const AudacityProject &project)
|
||||
|
||||
void TimeToolBar::Populate()
|
||||
{
|
||||
const auto &settings = ProjectSettings::Get(mProject);
|
||||
|
||||
// Get the default sample rate
|
||||
auto rate = gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"),
|
||||
AudioIO::GetOptimalSupportedSampleRate());
|
||||
auto rate = settings.GetRate();
|
||||
|
||||
// Get the default time format
|
||||
auto format = NumericConverter::HoursMinsSecondsFormat();
|
||||
if (mListener)
|
||||
{
|
||||
format = mListener->TT_GetAudioTimeFormat();
|
||||
}
|
||||
auto format = settings.GetAudioTimeFormat();
|
||||
|
||||
// Create the read-only time control
|
||||
mAudioTime = safenew NumericTextCtrl(this, AudioPositionID, NumericConverter::TIME, format, 0.0, rate);
|
||||
@@ -261,6 +260,18 @@ void TimeToolBar::SetResizingLimits()
|
||||
SetMaxSize(maxSize);
|
||||
}
|
||||
|
||||
// Called when the project settings change
|
||||
void TimeToolBar::OnSettingsChanged(wxCommandEvent &evt)
|
||||
{
|
||||
evt.Skip(false);
|
||||
|
||||
if (evt.GetInt() == ProjectSettings::ChangedProjectRate && mAudioTime)
|
||||
{
|
||||
const auto &settings = ProjectSettings::Get(mProject);
|
||||
mAudioTime->SetSampleRate(settings.GetRate());
|
||||
}
|
||||
}
|
||||
|
||||
// Called when the format drop downs is changed.
|
||||
// This causes recreation of the toolbar contents.
|
||||
void TimeToolBar::OnUpdate(wxCommandEvent &evt)
|
||||
|
@@ -46,6 +46,7 @@ private:
|
||||
void SetResizingLimits();
|
||||
wxSize ComputeSizing(int digitH);
|
||||
|
||||
void OnSettingsChanged(wxCommandEvent &evt);
|
||||
void OnUpdate(wxCommandEvent &evt);
|
||||
void OnSize(wxSizeEvent &evt);
|
||||
void OnIdle(wxIdleEvent &evt);
|
||||
|
Reference in New Issue
Block a user