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

Public Member Functions

 ExportPCMOptions (wxWindow *parent, int format)
 
virtual ~ExportPCMOptions ()
 
void PopulateOrExchange (ShuttleGui &S)
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
void OnHeaderChoice (wxCommandEvent &evt)
 
- 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 Member Functions

bool ValidatePair (int format)
 
int GetFormat ()
 

Private Attributes

wxArrayString mHeaderNames
 
wxArrayString mEncodingNames
 
wxChoice * mHeaderChoice
 
wxChoice * mEncodingChoice
 
int mHeaderFromChoice
 
int mEncodingFromChoice
 
std::vector< int > mEncodingFormats
 

Detailed Description

Definition at line 96 of file ExportPCM.cpp.

Constructor & Destructor Documentation

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

Definition at line 131 of file ExportPCM.cpp.

References eIsCreatingFromPrefs, format, kFormats, ReadExportFormatPref(), sf_encoding_index_name(), sf_encoding_index_to_subtype(), sf_header_index_name(), sf_header_index_to_type(), sf_num_encodings(), and sf_num_headers().

132 : wxPanelWrapper(parent, wxID_ANY)
133 {
134  int format;
135 
136  if (selformat < 0 || selformat >= WXSIZEOF(kFormats))
137  {
138  format = ReadExportFormatPref();
139  }
140  else
141  {
142  format = kFormats[selformat].format;
143  }
144 
145  mHeaderFromChoice = 0;
146  for (int i = 0, num = sf_num_headers(); i < num; i++) {
148  if ((format & SF_FORMAT_TYPEMASK) == (int)sf_header_index_to_type(i))
149  mHeaderFromChoice = i;
150  }
151 
153  for (int i = 0, sel = 0, num = sf_num_encodings(); i < num; i++) {
154  int enc = sf_encoding_index_to_subtype(i);
155  int fmt = (format & SF_FORMAT_TYPEMASK) | enc;
156  bool valid = ValidatePair(fmt);
157  if (valid)
158  {
160  mEncodingFormats.push_back(enc);
161  if ((format & SF_FORMAT_SUBMASK) == (int)sf_encoding_index_to_subtype(i))
162  mEncodingFromChoice = sel;
163  else
164  sel++;
165  }
166  }
167 
170 
173 }
wxString sf_encoding_index_name(int i)
Get the string name of the data encoding of the requested format.
Definition: FileFormats.cpp:84
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:366
wxString sf_header_index_name(int format)
Get the name of a container format from libsndfile.
Definition: FileFormats.cpp:47
wxArrayString mEncodingNames
Definition: ExportPCM.cpp:117
bool TransferDataFromWindow() override
Definition: ExportPCM.cpp:216
int format
Definition: ExportPCM.cpp:56
struct @37 kFormats[]
wxArrayString mHeaderNames
Definition: ExportPCM.cpp:116
int sf_num_encodings()
Get the number of data encodings libsndfile supports (in any container or none.
Definition: FileFormats.cpp:75
std::vector< int > mEncodingFormats
Definition: ExportPCM.cpp:122
void PopulateOrExchange(ShuttleGui &S)
Definition: ExportPCM.cpp:180
bool TransferDataToWindow() override
Definition: ExportPCM.cpp:209
unsigned int sf_encoding_index_to_subtype(int i)
Definition: FileFormats.cpp:95
bool ValidatePair(int format)
Definition: ExportPCM.cpp:294
static int ReadExportFormatPref()
Definition: ExportPCM.cpp:72
unsigned int sf_header_index_to_type(int i)
Definition: FileFormats.cpp:59
int sf_num_headers()
Get the number of container formats supported by libsndfile.
Definition: FileFormats.cpp:37
ExportPCMOptions::~ExportPCMOptions ( )
virtual

Definition at line 175 of file ExportPCM.cpp.

References TransferDataFromWindow().

176 {
178 }
bool TransferDataFromWindow() override
Definition: ExportPCM.cpp:216

Member Function Documentation

int ExportPCMOptions::GetFormat ( )
private

Definition at line 282 of file ExportPCM.cpp.

References mEncodingChoice, mEncodingFormats, mHeaderChoice, and sf_header_index_to_type().

Referenced by OnHeaderChoice(), and TransferDataFromWindow().

283 {
284  int hdr = sf_header_index_to_type(mHeaderChoice->GetSelection());
285  int sel = mEncodingChoice->GetSelection();
286  int enc = mEncodingFormats[sel];
287  return hdr | enc;
288 }
wxChoice * mEncodingChoice
Definition: ExportPCM.cpp:119
std::vector< int > mEncodingFormats
Definition: ExportPCM.cpp:122
wxChoice * mHeaderChoice
Definition: ExportPCM.cpp:118
unsigned int sf_header_index_to_type(int i)
Definition: FileFormats.cpp:59
void ExportPCMOptions::OnHeaderChoice ( wxCommandEvent &  evt)

Definition at line 228 of file ExportPCM.cpp.

References format, GetFormat(), mEncodingChoice, mEncodingFormats, mEncodingFromChoice, mEncodingNames, mHeaderChoice, name, sf_encoding_index_name(), sf_encoding_index_to_subtype(), sf_header_index_to_type(), sf_num_encodings(), sf_num_simple_formats(), sf_simple_format(), TransferDataFromWindow(), and ValidatePair().

229 {
230  int format = sf_header_index_to_type(mHeaderChoice->GetSelection());
231  // Fix for Bug 1218 - AIFF with no option should default to 16 bit.
232  if( format == SF_FORMAT_AIFF )
233  format = SF_FORMAT_AIFF | SF_FORMAT_PCM_16;
234 
235  mEncodingNames.Clear();
236  mEncodingChoice->Clear();
237  mEncodingFormats.clear();
238  int sel = wxNOT_FOUND;
239  int i,j;
240 
241  int sfnum = sf_num_simple_formats();
242  std::vector<int> sfs;
243 
244  for (i = 0; i < sfnum; i++)
245  {
246  SF_FORMAT_INFO *fi = sf_simple_format(i);
247  sfs.push_back(fi->format);
248  }
249 
250  int num = sf_num_encodings();
251  for (i = 0; i < num; i++)
252  {
253  int enc = sf_encoding_index_to_subtype(i);
254  int fmt = format | enc;
255  bool valid = ValidatePair(fmt);
256  if (valid)
257  {
258  const auto name = sf_encoding_index_name(i);
259  mEncodingNames.Add(name);
260  mEncodingChoice->Append(name);
261  mEncodingFormats.push_back(enc);
262  for (j = 0; j < sfnum; j++)
263  {
264  int enc = sfs[j];
265  if ((sel == wxNOT_FOUND) && (fmt == enc))
266  {
267  sel = mEncodingFormats.size() - 1;
268  break;
269  }
270  }
271  }
272  }
273 
274  if (sel == wxNOT_FOUND) sel = 0;
275  mEncodingFromChoice = sel;
276  mEncodingChoice->SetSelection(sel);
278 
280 }
wxString sf_encoding_index_name(int i)
Get the string name of the data encoding of the requested format.
Definition: FileFormats.cpp:84
wxChoice * mEncodingChoice
Definition: ExportPCM.cpp:119
wxArrayString mEncodingNames
Definition: ExportPCM.cpp:117
SF_FORMAT_INFO * sf_simple_format(int i)
bool TransferDataFromWindow() override
Definition: ExportPCM.cpp:216
int format
Definition: ExportPCM.cpp:56
int sf_num_encodings()
Get the number of data encodings libsndfile supports (in any container or none.
Definition: FileFormats.cpp:75
std::vector< int > mEncodingFormats
Definition: ExportPCM.cpp:122
unsigned int sf_encoding_index_to_subtype(int i)
Definition: FileFormats.cpp:95
bool ValidatePair(int format)
Definition: ExportPCM.cpp:294
wxChoice * mHeaderChoice
Definition: ExportPCM.cpp:118
unsigned int sf_header_index_to_type(int i)
Definition: FileFormats.cpp:59
int sf_num_simple_formats()
const wxChar * name
Definition: ExportPCM.cpp:57
void ExportPCMOptions::PopulateOrExchange ( ShuttleGui S)

Definition at line 180 of file ExportPCM.cpp.

References _(), ShuttleGuiBase::AddChoice(), ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndVerticalLay(), ShuttleGui::Id(), ID_ENCODING_CHOICE, ID_HEADER_CHOICE, mEncodingChoice, mEncodingFromChoice, mEncodingNames, mHeaderChoice, mHeaderFromChoice, mHeaderNames, ShuttleGuiBase::SetStretchyCol(), ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartMultiColumn(), and ShuttleGuiBase::StartVerticalLay().

Referenced by TransferDataFromWindow().

181 {
182  S.StartVerticalLay();
183  {
184  S.StartHorizontalLay(wxCENTER);
185  {
186  S.StartMultiColumn(2, wxCENTER);
187  {
188  S.SetStretchyCol(1);
190  .AddChoice(_("Header:"),
192  &mHeaderNames);
194  .AddChoice(_("Encoding:"),
196  &mEncodingNames);
197  }
198  S.EndMultiColumn();
199  }
200  S.EndHorizontalLay();
201  }
202  S.EndVerticalLay();
203 
204  return;
205 }
wxChoice * mEncodingChoice
Definition: ExportPCM.cpp:119
wxArrayString mEncodingNames
Definition: ExportPCM.cpp:117
void EndMultiColumn()
void EndHorizontalLay()
Definition: ShuttleGui.cpp:975
void EndVerticalLay()
Definition: ShuttleGui.cpp:991
wxArrayString mHeaderNames
Definition: ExportPCM.cpp:116
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
wxChoice * AddChoice(const wxString &Prompt, const wxString &Selected, const wxArrayString *pChoices)
Definition: ShuttleGui.cpp:331
ShuttleGui & Id(int id)
_("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 &)
wxChoice * mHeaderChoice
Definition: ExportPCM.cpp:118
#define ID_HEADER_CHOICE
Definition: ExportPCM.cpp:93
#define ID_ENCODING_CHOICE
Definition: ExportPCM.cpp:94
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:192
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:982
bool ExportPCMOptions::TransferDataFromWindow ( )
override

Definition at line 216 of file ExportPCM.cpp.

References eIsSavingToPrefs, GetFormat(), gPrefs, PopulateOrExchange(), and WriteExportFormatPref().

Referenced by OnHeaderChoice(), and ~ExportPCMOptions().

217 {
218  ShuttleGui S(this, eIsSavingToPrefs);
220 
221  gPrefs->Flush();
222 
224 
225  return true;
226 }
static void WriteExportFormatPref(int format)
Definition: ExportPCM.cpp:83
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: ExportPCM.cpp:180
bool ExportPCMOptions::TransferDataToWindow ( )
override

Definition at line 209 of file ExportPCM.cpp.

210 {
211  return true;
212 }
bool ExportPCMOptions::ValidatePair ( int  format)
private

Calls a libsndfile library function to determine whether the user's choice of sample encoding (e.g. pcm 16-bit or GSM 6.10 compression) is compatible with their choice of file format (e.g. WAV, AIFF) and enables/disables the OK button accordingly.

Definition at line 294 of file ExportPCM.cpp.

References format.

Referenced by OnHeaderChoice().

295 {
296  SF_INFO info;
297  memset(&info, 0, sizeof(info));
298  info.frames = 0;
299  info.samplerate = 44100;
300  info.channels = 1;
301  info.format = format;
302  info.sections = 1;
303  info.seekable = 0;
304 
305  return sf_format_check(&info) != 0 ? true : false;
306 }
int format
Definition: ExportPCM.cpp:56

Member Data Documentation

wxChoice* ExportPCMOptions::mEncodingChoice
private

Definition at line 119 of file ExportPCM.cpp.

Referenced by GetFormat(), OnHeaderChoice(), and PopulateOrExchange().

std::vector<int> ExportPCMOptions::mEncodingFormats
private

Definition at line 122 of file ExportPCM.cpp.

Referenced by GetFormat(), and OnHeaderChoice().

int ExportPCMOptions::mEncodingFromChoice
private

Definition at line 121 of file ExportPCM.cpp.

Referenced by OnHeaderChoice(), and PopulateOrExchange().

wxArrayString ExportPCMOptions::mEncodingNames
private

Definition at line 117 of file ExportPCM.cpp.

Referenced by OnHeaderChoice(), and PopulateOrExchange().

wxChoice* ExportPCMOptions::mHeaderChoice
private

Definition at line 118 of file ExportPCM.cpp.

Referenced by GetFormat(), OnHeaderChoice(), and PopulateOrExchange().

int ExportPCMOptions::mHeaderFromChoice
private

Definition at line 120 of file ExportPCM.cpp.

Referenced by PopulateOrExchange().

wxArrayString ExportPCMOptions::mHeaderNames
private

Definition at line 116 of file ExportPCM.cpp.

Referenced by PopulateOrExchange().


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