Audacity  2.2.2
Public Member Functions | Private Attributes | List of all members
ExportMP3Options Class Referencefinal
Inheritance diagram for ExportMP3Options:
wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Public Member Functions

 ExportMP3Options (wxWindow *parent, int format)
 
virtual ~ExportMP3Options ()
 
void PopulateOrExchange (ShuttleGui &S)
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
void OnSET (wxCommandEvent &evt)
 
void OnVBR (wxCommandEvent &evt)
 
void OnABR (wxCommandEvent &evt)
 
void OnCBR (wxCommandEvent &evt)
 
void OnQuality (wxCommandEvent &evt)
 
void OnMono (wxCommandEvent &evt)
 
void LoadNames (CHOICES *choices, int count)
 
wxArrayString GetNames (CHOICES *choices, int count)
 
std::vector< int > GetLabels (CHOICES *choices, int count)
 
int FindIndex (CHOICES *choices, int cnt, int needle, int def)
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 

Private Attributes

wxRadioButton * mStereo
 
wxRadioButton * mJoint
 
wxCheckBox * mMono
 
wxRadioButton * mSET
 
wxRadioButton * mVBR
 
wxRadioButton * mABR
 
wxRadioButton * mCBR
 
wxChoice * mRate
 
wxChoice * mMode
 
long mSetRate
 
long mVbrRate
 
long mAbrRate
 
long mCbrRate
 

Detailed Description

Definition at line 266 of file ExportMP3.cpp.

Constructor & Destructor Documentation

ExportMP3Options::ExportMP3Options ( wxWindow *  parent,
int  format 
)

Definition at line 320 of file ExportMP3.cpp.

References eIsCreatingFromPrefs, gPrefs, InitMP3_Statics(), PRESET_STANDARD, and QUALITY_2.

321 : wxPanelWrapper(parent, wxID_ANY)
322 {
323  InitMP3_Statics();
324 
325  mSetRate = gPrefs->Read(wxT("/FileFormats/MP3SetRate"), PRESET_STANDARD);
326  mVbrRate = gPrefs->Read(wxT("/FileFormats/MP3VbrRate"), QUALITY_2);
327  mAbrRate = gPrefs->Read(wxT("/FileFormats/MP3AbrRate"), 192);
328  mCbrRate = gPrefs->Read(wxT("/FileFormats/MP3CbrRate"), 192);
329 
332 
334 }
#define QUALITY_2
Definition: ExportMP3.cpp:119
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:366
static void InitMP3_Statics()
Definition: ExportMP3.cpp:219
#define PRESET_STANDARD
Definition: ExportMP3.cpp:133
wxFileConfig * gPrefs
Definition: Prefs.cpp:72
void PopulateOrExchange(ShuttleGui &S)
Definition: ExportMP3.cpp:343
bool TransferDataToWindow() override
Definition: ExportMP3.cpp:442
ExportMP3Options::~ExportMP3Options ( )
virtual

Definition at line 336 of file ExportMP3.cpp.

References TransferDataFromWindow().

337 {
339 }
bool TransferDataFromWindow() override
Definition: ExportMP3.cpp:447

Member Function Documentation

int ExportMP3Options::FindIndex ( CHOICES choices,
int  cnt,
int  needle,
int  def 
)

Definition at line 566 of file ExportMP3.cpp.

References label.

Referenced by OnABR(), OnCBR(), OnSET(), and OnVBR().

567 {
568  for (int i = 0; i < cnt; i++) {
569  if (choices[i].label == needle) {
570  return i;
571  }
572  }
573 
574  return def;
575 }
wxString label
Definition: Tags.cpp:727
std::vector< int > ExportMP3Options::GetLabels ( CHOICES choices,
int  count 
)

Definition at line 555 of file ExportMP3.cpp.

References label.

Referenced by PopulateOrExchange().

556 {
557  std::vector<int> labels;
558 
559  for (int i = 0; i < count; i++) {
560  labels.push_back(choices[i].label);
561  }
562 
563  return labels;
564 }
wxString label
Definition: Tags.cpp:727
wxArrayString ExportMP3Options::GetNames ( CHOICES choices,
int  count 
)

Definition at line 544 of file ExportMP3.cpp.

References name, and names().

Referenced by PopulateOrExchange().

545 {
546  wxArrayString names;
547 
548  for (int i = 0; i < count; i++) {
549  names.Add(choices[i].name);
550  }
551 
552  return names;
553 }
static wxArrayString names()
Definition: Tags.cpp:697
const wxChar * name
Definition: Distortion.cpp:94
void ExportMP3Options::LoadNames ( CHOICES choices,
int  count 
)

Definition at line 534 of file ExportMP3.cpp.

References mRate, and name.

Referenced by OnABR(), OnCBR(), OnSET(), and OnVBR().

535 {
536  mRate->Clear();
537 
538  for (int i = 0; i < count; i++)
539  {
540  mRate->Append(choices[i].name);
541  }
542 }
wxChoice * mRate
Definition: ExportMP3.cpp:298
const wxChar * name
Definition: Distortion.cpp:94
void ExportMP3Options::OnABR ( wxCommandEvent &  evt)

Definition at line 485 of file ExportMP3.cpp.

References FindIndex(), LoadNames(), mAbrRate, mMode, and mRate.

486 {
487  LoadNames(fixRates, WXSIZEOF(fixRates));
488 
489  mRate->SetSelection(FindIndex(fixRates, WXSIZEOF(fixRates), mAbrRate, 10));
490  mRate->Refresh();
491  mMode->Enable(false);
492 }
void LoadNames(CHOICES *choices, int count)
Definition: ExportMP3.cpp:534
int FindIndex(CHOICES *choices, int cnt, int needle, int def)
Definition: ExportMP3.cpp:566
wxChoice * mRate
Definition: ExportMP3.cpp:298
static CHOICES fixRates[]
Definition: ExportMP3.cpp:148
wxChoice * mMode
Definition: ExportMP3.cpp:299
void ExportMP3Options::OnCBR ( wxCommandEvent &  evt)

Definition at line 496 of file ExportMP3.cpp.

References FindIndex(), LoadNames(), mCbrRate, mMode, and mRate.

497 {
498  LoadNames(fixRates, WXSIZEOF(fixRates));
499 
500  mRate->SetSelection(FindIndex(fixRates, WXSIZEOF(fixRates), mCbrRate, 10));
501  mRate->Refresh();
502  mMode->Enable(false);
503 }
void LoadNames(CHOICES *choices, int count)
Definition: ExportMP3.cpp:534
int FindIndex(CHOICES *choices, int cnt, int needle, int def)
Definition: ExportMP3.cpp:566
wxChoice * mRate
Definition: ExportMP3.cpp:298
static CHOICES fixRates[]
Definition: ExportMP3.cpp:148
wxChoice * mMode
Definition: ExportMP3.cpp:299
void ExportMP3Options::OnMono ( wxCommandEvent &  evt)

Definition at line 523 of file ExportMP3.cpp.

References gPrefs, mJoint, mMono, and mStereo.

524 {
525  bool mono = false;
526  mono = mMono->GetValue();
527  mJoint->Enable(!mono);
528  mStereo->Enable(!mono);
529 
530  gPrefs->Write(wxT("/FileFormats/MP3ForceMono"), mono);
531  gPrefs->Flush();
532 }
wxRadioButton * mStereo
Definition: ExportMP3.cpp:291
wxFileConfig * gPrefs
Definition: Prefs.cpp:72
wxCheckBox * mMono
Definition: ExportMP3.cpp:293
wxRadioButton * mJoint
Definition: ExportMP3.cpp:292
void ExportMP3Options::OnQuality ( wxCommandEvent &  evt)

Definition at line 505 of file ExportMP3.cpp.

References CHOICES::label, mABR, mAbrRate, mCbrRate, mRate, mSET, mSetRate, mVBR, and mVbrRate.

506 {
507  int sel = mRate->GetSelection();
508 
509  if (mSET->GetValue()) {
510  mSetRate = setRates[sel].label;
511  }
512  else if (mVBR->GetValue()) {
513  mVbrRate = varRates[sel].label;
514  }
515  else if (mABR->GetValue()) {
516  mAbrRate = fixRates[sel].label;
517  }
518  else {
519  mCbrRate = fixRates[sel].label;
520  }
521 }
wxRadioButton * mVBR
Definition: ExportMP3.cpp:295
static CHOICES varRates[]
Definition: ExportMP3.cpp:171
wxChoice * mRate
Definition: ExportMP3.cpp:298
static CHOICES setRates[]
Definition: ExportMP3.cpp:191
static CHOICES fixRates[]
Definition: ExportMP3.cpp:148
wxRadioButton * mSET
Definition: ExportMP3.cpp:294
wxRadioButton * mABR
Definition: ExportMP3.cpp:296
int label
Definition: ExportMP3.cpp:145
void ExportMP3Options::OnSET ( wxCommandEvent &  evt)

Definition at line 463 of file ExportMP3.cpp.

References FindIndex(), LoadNames(), mMode, mRate, and mSetRate.

464 {
465  LoadNames(setRates, WXSIZEOF(setRates));
466 
467  mRate->SetSelection(FindIndex(setRates, WXSIZEOF(setRates), mSetRate, 2));
468  mRate->Refresh();
469  mMode->Enable(true);
470 }
void LoadNames(CHOICES *choices, int count)
Definition: ExportMP3.cpp:534
int FindIndex(CHOICES *choices, int cnt, int needle, int def)
Definition: ExportMP3.cpp:566
wxChoice * mRate
Definition: ExportMP3.cpp:298
static CHOICES setRates[]
Definition: ExportMP3.cpp:191
wxChoice * mMode
Definition: ExportMP3.cpp:299
void ExportMP3Options::OnVBR ( wxCommandEvent &  evt)

Definition at line 474 of file ExportMP3.cpp.

References FindIndex(), LoadNames(), mMode, mRate, and mVbrRate.

475 {
476  LoadNames(varRates, WXSIZEOF(varRates));
477 
478  mRate->SetSelection(FindIndex(varRates, WXSIZEOF(varRates), mVbrRate, 2));
479  mRate->Refresh();
480  mMode->Enable(true);
481 }
void LoadNames(CHOICES *choices, int count)
Definition: ExportMP3.cpp:534
static CHOICES varRates[]
Definition: ExportMP3.cpp:171
int FindIndex(CHOICES *choices, int cnt, int needle, int def)
Definition: ExportMP3.cpp:566
wxChoice * mRate
Definition: ExportMP3.cpp:298
wxChoice * mMode
Definition: ExportMP3.cpp:299
void ExportMP3Options::PopulateOrExchange ( ShuttleGui S)

Definition at line 343 of file ExportMP3.cpp.

References _(), ShuttleGuiBase::AddCheckBox(), ShuttleGuiBase::AddPrompt(), CHANNEL_JOINT, CHANNEL_STEREO, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndRadioButtonGroup(), ShuttleGuiBase::EndTwoColumn(), ShuttleGuiBase::EndVerticalLay(), fixRates, GetLabels(), GetNames(), gPrefs, ShuttleGui::Id(), ID_ABR, ID_CBR, ID_MONO, ID_QUALITY, ID_SET, ID_VBR, mABR, mAbrRate, mCBR, mCbrRate, mJoint, mMode, mMono, MODE_ABR, MODE_CBR, MODE_SET, MODE_VBR, mRate, mSET, mSetRate, mStereo, mVBR, mVbrRate, ROUTINE_FAST, setRates, ShuttleGuiBase::SetStretchyCol(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartRadioButtonGroup(), ShuttleGuiBase::StartTwoColumn(), ShuttleGuiBase::StartVerticalLay(), ShuttleGuiBase::TieChoice(), ShuttleGuiBase::TieRadioButton(), and varRates.

Referenced by TransferDataFromWindow().

344 {
345  S.StartVerticalLay();
346  {
347  S.StartHorizontalLay(wxCENTER);
348  {
349  S.StartMultiColumn(2, wxCENTER);
350  {
351  S.SetStretchyCol(1);
352  S.StartTwoColumn();
353  {
354  S.AddPrompt(_("Bit Rate Mode:"));
355  S.StartHorizontalLay();
356  {
357  S.StartRadioButtonGroup(wxT("/FileFormats/MP3RateMode"), MODE_SET);
358  {
359  mSET = S.Id(ID_SET).TieRadioButton(_("Preset"), MODE_SET);
360  mVBR = S.Id(ID_VBR).TieRadioButton(_("Variable"), MODE_VBR);
361  mABR = S.Id(ID_ABR).TieRadioButton(_("Average"), MODE_ABR);
362  mCBR = S.Id(ID_CBR).TieRadioButton(_("Constant"), MODE_CBR);
363  }
365  }
366  S.EndHorizontalLay();
367 
368  CHOICES *choices;
369  int cnt;
370  bool enable;
371  int defrate;
372 
373  if (mSET->GetValue()) {
374  choices = setRates;
375  cnt = WXSIZEOF(setRates);
376  enable = true;
377  defrate = mSetRate;
378  }
379  else if (mVBR->GetValue()) {
380  choices = varRates;
381  cnt = WXSIZEOF(varRates);
382  enable = true;
383  defrate = mVbrRate;
384  }
385  else if (mABR->GetValue()) {
386  choices = fixRates;
387  cnt = WXSIZEOF(fixRates);
388  enable = false;
389  defrate = mAbrRate;
390  }
391  else {
392  mCBR->SetValue(true);
393  choices = fixRates;
394  cnt = WXSIZEOF(fixRates);
395  enable = false;
396  defrate = mCbrRate;
397  }
398 
399  mRate = S.Id(ID_QUALITY).TieChoice(_("Quality"),
400  wxT("/FileFormats/MP3Bitrate"),
401  defrate,
402  GetNames(choices, cnt),
403  GetLabels(choices, cnt));
404 
405  mMode = S.TieChoice(_("Variable Speed:"),
406  wxT("/FileFormats/MP3VarMode"),
407  ROUTINE_FAST,
408  GetNames(varModes, WXSIZEOF(varModes)),
409  GetLabels(varModes, WXSIZEOF(varModes)));
410  mMode->Enable(enable);
411 
412  S.AddPrompt(_("Channel Mode:"));
413  S.StartMultiColumn(3, wxEXPAND);
414  {
415  bool mono = false;
416  gPrefs->Read(wxT("/FileFormats/MP3ForceMono"), &mono, 0);
417 
418  S.StartRadioButtonGroup(wxT("/FileFormats/MP3ChannelMode"), CHANNEL_JOINT);
419  {
420  mJoint = S.TieRadioButton(_("Joint Stereo"), CHANNEL_JOINT);
421  mStereo = S.TieRadioButton(_("Stereo"), CHANNEL_STEREO);
422  mJoint->Enable(!mono);
423  mStereo->Enable(!mono);
424  }
426 
427  mMono = S.Id(ID_MONO).AddCheckBox(_("Force export to mono"), mono? wxT("true") : wxT("false"));
428  }
429  S.EndTwoColumn();
430  }
431  S.EndTwoColumn();
432  }
433  S.EndMultiColumn();
434  }
435  S.EndHorizontalLay();
436  }
437  S.EndVerticalLay();
438 }
wxChoice * TieChoice(const wxString &Prompt, WrappedType &WrappedRef, const wxArrayString *pChoices)
wxRadioButton * mStereo
Definition: ExportMP3.cpp:291
void EndRadioButtonGroup()
#define ID_SET
Definition: ExportMP3.cpp:212
wxRadioButton * mVBR
Definition: ExportMP3.cpp:295
#define CHANNEL_JOINT
Definition: ExportMP3.cpp:113
void EndMultiColumn()
#define MODE_VBR
Definition: ExportMP3.cpp:109
static CHOICES varRates[]
Definition: ExportMP3.cpp:171
void EndHorizontalLay()
Definition: ShuttleGui.cpp:975
void AddPrompt(const wxString &Prompt)
Right aligned text string.
Definition: ShuttleGui.cpp:215
void EndVerticalLay()
Definition: ShuttleGui.cpp:991
wxFileConfig * gPrefs
Definition: Prefs.cpp:72
wxCheckBox * AddCheckBox(const wxString &Prompt, const wxString &Selected)
Definition: ShuttleGui.cpp:267
wxRadioButton * mCBR
Definition: ExportMP3.cpp:297
wxCheckBox * mMono
Definition: ExportMP3.cpp:293
void StartTwoColumn()
Definition: ShuttleGui.h:125
std::vector< int > GetLabels(CHOICES *choices, int count)
Definition: ExportMP3.cpp:555
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:966
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:998
ShuttleGui & Id(int id)
static CHOICES varModes[]
Definition: ExportMP3.cpp:185
#define ID_VBR
Definition: ExportMP3.cpp:213
#define MODE_ABR
Definition: ExportMP3.cpp:110
wxChoice * mRate
Definition: ExportMP3.cpp:298
wxRadioButton * TieRadioButton(const wxString &Prompt, WrappedType &WrappedRef)
#define ID_ABR
Definition: ExportMP3.cpp:214
#define ROUTINE_FAST
Definition: ExportMP3.cpp:128
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
#define MODE_SET
Definition: ExportMP3.cpp:108
#define CHANNEL_STEREO
Definition: ExportMP3.cpp:114
#define ID_CBR
Definition: ExportMP3.cpp:215
#define MODE_CBR
Definition: ExportMP3.cpp:111
wxArrayString GetNames(CHOICES *choices, int count)
Definition: ExportMP3.cpp:544
static CHOICES setRates[]
Definition: ExportMP3.cpp:191
#define ID_QUALITY
Definition: ExportMP3.cpp:216
static CHOICES fixRates[]
Definition: ExportMP3.cpp:148
wxRadioButton * mJoint
Definition: ExportMP3.cpp:292
#define ID_MONO
Definition: ExportMP3.cpp:217
wxRadioButton * mSET
Definition: ExportMP3.cpp:294
wxRadioButton * mABR
Definition: ExportMP3.cpp:296
void EndTwoColumn()
Definition: ShuttleGui.h:126
void StartRadioButtonGroup(const wxString &SettingName)
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:192
wxChoice * mMode
Definition: ExportMP3.cpp:299
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:982
bool ExportMP3Options::TransferDataFromWindow ( )
override

Definition at line 447 of file ExportMP3.cpp.

References eIsSavingToPrefs, gPrefs, mAbrRate, mCbrRate, mSetRate, mVbrRate, and PopulateOrExchange().

Referenced by ~ExportMP3Options().

448 {
449  ShuttleGui S(this, eIsSavingToPrefs);
451 
452  gPrefs->Write(wxT("/FileFormats/MP3SetRate"), mSetRate);
453  gPrefs->Write(wxT("/FileFormats/MP3VbrRate"), mVbrRate);
454  gPrefs->Write(wxT("/FileFormats/MP3AbrRate"), mAbrRate);
455  gPrefs->Write(wxT("/FileFormats/MP3CbrRate"), mCbrRate);
456  gPrefs->Flush();
457 
458  return true;
459 }
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:366
wxFileConfig * gPrefs
Definition: Prefs.cpp:72
void PopulateOrExchange(ShuttleGui &S)
Definition: ExportMP3.cpp:343
bool ExportMP3Options::TransferDataToWindow ( )
override

Definition at line 442 of file ExportMP3.cpp.

443 {
444  return true;
445 }

Member Data Documentation

wxRadioButton* ExportMP3Options::mABR
private

Definition at line 296 of file ExportMP3.cpp.

Referenced by OnQuality(), and PopulateOrExchange().

long ExportMP3Options::mAbrRate
private

Definition at line 303 of file ExportMP3.cpp.

Referenced by OnABR(), OnQuality(), PopulateOrExchange(), and TransferDataFromWindow().

wxRadioButton* ExportMP3Options::mCBR
private

Definition at line 297 of file ExportMP3.cpp.

Referenced by PopulateOrExchange().

long ExportMP3Options::mCbrRate
private

Definition at line 304 of file ExportMP3.cpp.

Referenced by OnCBR(), OnQuality(), PopulateOrExchange(), and TransferDataFromWindow().

wxRadioButton* ExportMP3Options::mJoint
private

Definition at line 292 of file ExportMP3.cpp.

Referenced by OnMono(), and PopulateOrExchange().

wxChoice* ExportMP3Options::mMode
private

Definition at line 299 of file ExportMP3.cpp.

Referenced by OnABR(), OnCBR(), OnSET(), OnVBR(), and PopulateOrExchange().

wxCheckBox* ExportMP3Options::mMono
private

Definition at line 293 of file ExportMP3.cpp.

Referenced by OnMono(), and PopulateOrExchange().

wxChoice* ExportMP3Options::mRate
private

Definition at line 298 of file ExportMP3.cpp.

Referenced by LoadNames(), OnABR(), OnCBR(), OnQuality(), OnSET(), OnVBR(), and PopulateOrExchange().

wxRadioButton* ExportMP3Options::mSET
private

Definition at line 294 of file ExportMP3.cpp.

Referenced by OnQuality(), and PopulateOrExchange().

long ExportMP3Options::mSetRate
private

Definition at line 301 of file ExportMP3.cpp.

Referenced by OnQuality(), OnSET(), PopulateOrExchange(), and TransferDataFromWindow().

wxRadioButton* ExportMP3Options::mStereo
private

Definition at line 291 of file ExportMP3.cpp.

Referenced by OnMono(), and PopulateOrExchange().

wxRadioButton* ExportMP3Options::mVBR
private

Definition at line 295 of file ExportMP3.cpp.

Referenced by OnQuality(), and PopulateOrExchange().

long ExportMP3Options::mVbrRate
private

Definition at line 302 of file ExportMP3.cpp.

Referenced by OnQuality(), OnVBR(), PopulateOrExchange(), and TransferDataFromWindow().


The documentation for this class was generated from the following file: