mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-04 22:29:27 +02:00
Remove uses of overload of TieRadioButton taking int values...
... and migrate old preferences with EnumSetting
This commit is contained in:
parent
0d910bbe02
commit
51115903d4
@ -576,12 +576,12 @@ bool MacroCommands::WriteMp3File( const wxString & Name, int bitrate )
|
||||
bool rc;
|
||||
long prevBitRate = gPrefs->Read(wxT("/FileFormats/MP3Bitrate"), 128);
|
||||
gPrefs->Write(wxT("/FileFormats/MP3Bitrate"), bitrate);
|
||||
int prevMode = gPrefs->Read(wxT("/FileFormats/MP3RateMode"), MODE_CBR);
|
||||
gPrefs->Write(wxT("/FileFormats/MP3RateMode"), MODE_CBR);
|
||||
auto prevMode = MP3RateModeSetting.ReadEnum();
|
||||
MP3RateModeSetting.WriteEnum(MODE_CBR);
|
||||
|
||||
auto cleanup = finally( [&] {
|
||||
gPrefs->Write(wxT("/FileFormats/MP3Bitrate"), prevBitRate);
|
||||
gPrefs->Write(wxT("/FileFormats/MP3RateMode"), prevMode);
|
||||
MP3RateModeSetting.WriteEnum(prevMode);
|
||||
gPrefs->Flush();
|
||||
} );
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "DirManager.h"
|
||||
#include "Prefs.h"
|
||||
#include "ProjectFileIORegistry.h"
|
||||
#include "prefs/ImportExportPrefs.h"
|
||||
|
||||
#include "InconsistencyException.h"
|
||||
|
||||
@ -847,8 +848,7 @@ bool NoteTrack::ExportMIDI(const wxString &f) const
|
||||
bool NoteTrack::ExportAllegro(const wxString &f) const
|
||||
{
|
||||
double offset = GetOffset();
|
||||
bool in_seconds;
|
||||
gPrefs->Read(wxT("/FileFormats/AllegroStyle"), &in_seconds, true);
|
||||
auto in_seconds = ImportExportPrefs::AllegroStyleSetting.ReadEnum();
|
||||
auto &seq = GetSeq();
|
||||
if (in_seconds) {
|
||||
seq.convert_to_seconds();
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include "../FileFormats.h"
|
||||
#include "../Mix.h"
|
||||
#include "../Prefs.h"
|
||||
#include "../prefs/ImportExportPrefs.h"
|
||||
#include "../Project.h"
|
||||
#include "../ProjectHistory.h"
|
||||
#include "../ProjectSettings.h"
|
||||
@ -847,7 +848,7 @@ bool Exporter::CheckMix()
|
||||
// Detemine if exported file will be stereo or mono or multichannel,
|
||||
// and if mixing will occur.
|
||||
|
||||
int downMix = gPrefs->Read(wxT("/FileFormats/ExportDownMix"), true);
|
||||
auto downMix = ImportExportPrefs::ExportDownMixSetting.ReadEnum();
|
||||
int exportedChannels = mPlugins[mFormat]->SetNumExportChannels();
|
||||
|
||||
if (downMix) {
|
||||
|
@ -332,6 +332,38 @@ ExportMP3Options::~ExportMP3Options()
|
||||
TransferDataFromWindow();
|
||||
}
|
||||
|
||||
EnumSetting< MP3RateMode > MP3RateModeSetting{
|
||||
wxT("/FileFormats/MP3RateModeChoice"),
|
||||
{
|
||||
{ wxT("SET"), XO("Preset") },
|
||||
{ wxT("VBR"), XO("Variable") },
|
||||
{ wxT("ABR"), XO("Average") },
|
||||
{ wxT("CBR"), XO("Constant") },
|
||||
},
|
||||
0, // MODE_SET
|
||||
|
||||
// for migrating old preferences:
|
||||
{
|
||||
MODE_SET, MODE_VBR, MODE_ABR, MODE_CBR
|
||||
},
|
||||
wxT("/FileFormats/MP3RateMode"),
|
||||
};
|
||||
|
||||
static EnumSetting< MP3ChannelMode > MP3ChannelModeSetting{
|
||||
wxT("/FileFormats/MP3ChannelModeChoice"),
|
||||
{
|
||||
EnumValueSymbol{ wxT("JOINT"), XO("Joint Stereo") },
|
||||
EnumValueSymbol{ wxT("STEREO"), XO("Stereo") },
|
||||
},
|
||||
0, // CHANNEL_JOINT
|
||||
|
||||
// for migrating old preferences:
|
||||
{
|
||||
CHANNEL_JOINT, CHANNEL_STEREO,
|
||||
},
|
||||
wxT("/FileFormats/MP3ChannelMode"),
|
||||
};
|
||||
|
||||
///
|
||||
///
|
||||
void ExportMP3Options::PopulateOrExchange(ShuttleGui & S)
|
||||
@ -348,12 +380,12 @@ void ExportMP3Options::PopulateOrExchange(ShuttleGui & S)
|
||||
S.AddPrompt(_("Bit Rate Mode:"));
|
||||
S.StartHorizontalLay();
|
||||
{
|
||||
S.StartRadioButtonGroup(wxT("/FileFormats/MP3RateMode"), MODE_SET);
|
||||
S.StartRadioButtonGroup(wxT("/FileFormats/MP3RateModeChoice"), wxT("SET"));
|
||||
{
|
||||
mSET = S.Id(ID_SET).TieRadioButton(_("Preset"), MODE_SET);
|
||||
mVBR = S.Id(ID_VBR).TieRadioButton(_("Variable"), MODE_VBR);
|
||||
mABR = S.Id(ID_ABR).TieRadioButton(_("Average"), MODE_ABR);
|
||||
mCBR = S.Id(ID_CBR).TieRadioButton(_("Constant"), MODE_CBR);
|
||||
mSET = S.Id(ID_SET).TieRadioButton(_("Preset"), wxT("SET"));
|
||||
mVBR = S.Id(ID_VBR).TieRadioButton(_("Variable"), wxT("VBR"));
|
||||
mABR = S.Id(ID_ABR).TieRadioButton(_("Average"), wxT("ABR"));
|
||||
mCBR = S.Id(ID_CBR).TieRadioButton(_("Constant"), wxT("CBR"));
|
||||
}
|
||||
S.EndRadioButtonGroup();
|
||||
}
|
||||
@ -409,10 +441,10 @@ void ExportMP3Options::PopulateOrExchange(ShuttleGui & S)
|
||||
bool mono = false;
|
||||
gPrefs->Read(wxT("/FileFormats/MP3ForceMono"), &mono, 0);
|
||||
|
||||
S.StartRadioButtonGroup(wxT("/FileFormats/MP3ChannelMode"), CHANNEL_JOINT);
|
||||
S.StartRadioButtonGroup(wxT("/FileFormats/MP3ChannelModeChoice"), wxT("JOINT"));
|
||||
{
|
||||
mJoint = S.TieRadioButton(_("Joint Stereo"), CHANNEL_JOINT);
|
||||
mStereo = S.TieRadioButton(_("Stereo"), CHANNEL_STEREO);
|
||||
mJoint = S.TieRadioButton(_("Joint Stereo"), wxT("JOINT"));
|
||||
mStereo = S.TieRadioButton(_("Stereo"), wxT("STEREO"));
|
||||
mJoint->Enable(!mono);
|
||||
mStereo->Enable(!mono);
|
||||
}
|
||||
@ -1797,15 +1829,13 @@ ProgressResult ExportMP3::Export(AudacityProject *project,
|
||||
int lowrate = 8000;
|
||||
int bitrate = 0;
|
||||
int brate;
|
||||
int rmode;
|
||||
int vmode;
|
||||
int cmode;
|
||||
bool forceMono;
|
||||
|
||||
gPrefs->Read(wxT("/FileFormats/MP3Bitrate"), &brate, 128);
|
||||
gPrefs->Read(wxT("/FileFormats/MP3RateMode"), &rmode, MODE_CBR);
|
||||
auto rmode = MP3RateModeSetting.ReadEnumWithDefault( MODE_CBR );
|
||||
gPrefs->Read(wxT("/FileFormats/MP3VarMode"), &vmode, ROUTINE_FAST);
|
||||
gPrefs->Read(wxT("/FileFormats/MP3ChannelMode"), &cmode, CHANNEL_STEREO);
|
||||
auto cmode = MP3ChannelModeSetting.ReadEnumWithDefault( CHANNEL_STEREO );
|
||||
gPrefs->Read(wxT("/FileFormats/MP3ForceMono"), &forceMono, 0);
|
||||
|
||||
// Set the bitrate/quality and mode
|
||||
|
@ -15,10 +15,15 @@
|
||||
|
||||
#include "../MemoryX.h"
|
||||
|
||||
#define MODE_SET 0
|
||||
#define MODE_VBR 1
|
||||
#define MODE_ABR 2
|
||||
#define MODE_CBR 3
|
||||
enum MP3RateMode : unsigned {
|
||||
MODE_SET = 0,
|
||||
MODE_VBR,
|
||||
MODE_ABR,
|
||||
MODE_CBR,
|
||||
};
|
||||
|
||||
template< typename Enum > class EnumSetting;
|
||||
extern EnumSetting< MP3RateMode > MP3RateModeSetting;
|
||||
|
||||
#if defined(__WXMSW__) || defined(__WXMAC__)
|
||||
#define MP3_EXPORT_BUILT_IN 1
|
||||
|
@ -60,6 +60,36 @@ void ImportExportPrefs::Populate()
|
||||
// ----------------------- End of main section --------------
|
||||
}
|
||||
|
||||
EnumSetting< bool > ImportExportPrefs::ExportDownMixSetting{
|
||||
wxT("/FileFormats/ExportDownMixChoice"),
|
||||
{
|
||||
EnumValueSymbol{ wxT("MixDown"), XO("&Mix down to Stereo or Mono") },
|
||||
EnumValueSymbol{ wxT("Custom"), XO("&Use Advanced Mixing Options") },
|
||||
},
|
||||
0, // true
|
||||
|
||||
// for migrating old preferences:
|
||||
{
|
||||
true, false,
|
||||
},
|
||||
wxT("/FileFormats/ExportDownMix"),
|
||||
};
|
||||
|
||||
EnumSetting< bool > ImportExportPrefs::AllegroStyleSetting{
|
||||
wxT("/FileFormats/AllegroStyleChoice"),
|
||||
{
|
||||
EnumValueSymbol{ wxT("Seconds"), XO("&Seconds") },
|
||||
EnumValueSymbol{ wxT("Beats"), XO("&Beats") },
|
||||
},
|
||||
0, // true
|
||||
|
||||
// for migrating old preferences:
|
||||
{
|
||||
true, false,
|
||||
},
|
||||
wxT("/FileFormats/AllegroStyle"),
|
||||
};
|
||||
|
||||
void ImportExportPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
{
|
||||
S.SetBorder(2);
|
||||
@ -81,12 +111,12 @@ void ImportExportPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
#endif
|
||||
S.StartStatic(_("When exporting tracks to an audio file"));
|
||||
{
|
||||
S.StartRadioButtonGroup(wxT("/FileFormats/ExportDownMix"), true);
|
||||
S.StartRadioButtonGroup(wxT("/FileFormats/ExportDownMixChoice"), wxT("MixDown"));
|
||||
{
|
||||
S.TieRadioButton(_("&Mix down to Stereo or Mono"),
|
||||
true);
|
||||
wxT("MixDown"));
|
||||
S.TieRadioButton(_("&Use Advanced Mixing Options"),
|
||||
false);
|
||||
wxT("Custom"));
|
||||
}
|
||||
S.EndRadioButtonGroup();
|
||||
|
||||
@ -102,12 +132,12 @@ void ImportExportPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
#ifdef USE_MIDI
|
||||
S.StartStatic(_("Exported Allegro (.gro) files save time as:"));
|
||||
{
|
||||
S.StartRadioButtonGroup(wxT("/FileFormats/AllegroStyle"), true);
|
||||
S.StartRadioButtonGroup(wxT("/FileFormats/AllegroStyleChoice"), wxT("Seconds"));
|
||||
{
|
||||
S.TieRadioButton(_("&Seconds"),
|
||||
true);
|
||||
wxT("Seconds"));
|
||||
S.TieRadioButton(_("&Beats"),
|
||||
false);
|
||||
wxT("Beats"));
|
||||
}
|
||||
S.EndRadioButtonGroup();
|
||||
}
|
||||
|
@ -21,9 +21,14 @@ class ShuttleGui;
|
||||
|
||||
#define IMPORT_EXPORT_PREFS_PLUGIN_SYMBOL ComponentInterfaceSymbol{ XO("IMPORT EXPORT") }
|
||||
|
||||
template< typename Enum > class EnumSetting;
|
||||
|
||||
class ImportExportPrefs final : public PrefsPanel
|
||||
{
|
||||
public:
|
||||
static EnumSetting< bool > ExportDownMixSetting;
|
||||
static EnumSetting< bool > AllegroStyleSetting;
|
||||
|
||||
ImportExportPrefs(wxWindow * parent, wxWindowID winid);
|
||||
~ImportExportPrefs();
|
||||
ComponentInterfaceSymbol GetSymbol() override;
|
||||
@ -39,4 +44,5 @@ class ImportExportPrefs final : public PrefsPanel
|
||||
|
||||
/// A PrefsPanel::Factory that creates one ImportExportPrefs panel.
|
||||
extern PrefsPanel::Factory ImportExportPrefsFactory;
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user