Audacity  3.0.3
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ExportPCMOptions Class Referencefinal
Inheritance diagram for ExportPCMOptions:
[legend]
Collaboration diagram for ExportPCMOptions:
[legend]

Public Member Functions

 ExportPCMOptions (wxWindow *parent, int format)
 
virtual ~ExportPCMOptions ()
 
void PopulateOrExchange (ShuttleGui &S)
 
void OnShow (wxShowEvent &evt)
 
void OnHeaderChoice (wxCommandEvent &evt)
 
void OnEncodingChoice (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 TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void GetTypes ()
 
void GetEncodings (int enc=0)
 
void SendSuffixEvent ()
 

Private Attributes

std::vector< int > mHeaderIndexes
 
TranslatableStrings mHeaderNames
 
wxChoice * mHeaderChoice
 
int mHeaderFromChoice
 
std::vector< int > mEncodingIndexes
 
TranslatableStrings mEncodingNames
 
wxChoice * mEncodingChoice
 
int mEncodingFromChoice
 
int mSelFormat
 
int mType
 

Detailed Description

Definition at line 113 of file ExportPCM.cpp.

Constructor & Destructor Documentation

◆ ExportPCMOptions()

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

Definition at line 155 of file ExportPCM.cpp.

156 : wxPanelWrapper(parent, wxID_ANY)
157 {
158  // Remember the selection format
159  mSelFormat = selformat;
160 
161  // Init choices
162  mHeaderFromChoice = 0;
164 
165  if (mSelFormat < FMT_OTHER)
166  {
167  mType = kFormats[selformat].format & SF_FORMAT_TYPEMASK;
168  GetEncodings(mType & SF_FORMAT_SUBMASK);
169  }
170  else
171  {
172  GetTypes();
173  GetEncodings();
174  }
175 
178 
179  parent->Bind(wxEVT_SHOW, &ExportPCMOptions::OnShow, this);
180 }

References eIsCreatingFromPrefs, FMT_OTHER, kFormats, and OnShow().

Here is the call graph for this function:

◆ ~ExportPCMOptions()

ExportPCMOptions::~ExportPCMOptions ( )
virtual

Definition at line 182 of file ExportPCM.cpp.

183 {
184  // Save the encoding
187 }

References mEncodingFromChoice, mEncodingIndexes, mType, SaveEncoding(), SaveOtherFormat(), and sf_encoding_index_to_subtype().

Here is the call graph for this function:

Member Function Documentation

◆ GetEncodings()

void ExportPCMOptions::GetEncodings ( int  enc = 0)
private

Definition at line 319 of file ExportPCM.cpp.

320 {
321  // Setup for queries
322  SF_INFO info = {};
323  info.samplerate = 44100;
324  info.channels = 1;
325  info.sections = 1;
326 
327  // Reset arrays
328  mEncodingIndexes.clear();
329  mEncodingNames.clear();
330 
331  // If the encoding wasn't supplied, look it up
332  if (!(enc & SF_FORMAT_SUBMASK))
333  {
334  enc = LoadEncoding(mType);
335  }
336  enc &= SF_FORMAT_SUBMASK;
337 
338  // Fix for Bug 1218 - AIFF with no encoding should default to 16 bit.
339  if (mType == SF_FORMAT_AIFF && enc == 0)
340  {
341  enc = SF_FORMAT_PCM_16;
342  }
343 
344  // Rebuild the arrays
346  for (int i = 0, num = sf_num_encodings(); i < num; ++i)
347  {
348  int sub = sf_encoding_index_to_subtype(i);
349 
350  // Since we're traversing the subtypes linearly, we have to
351  // make sure it can be paired with our current type.
352  info.format = mType | sub;
353  if (sf_format_check(&info))
354  {
355  // If this subtype matches our last saved encoding, remember
356  // its index so we can set it in the dialog.
357  if (sub == enc)
358  {
360  }
361 
362  // Store index and name
363  mEncodingIndexes.push_back(i);
365  }
366  }
367 }

References LoadEncoding(), mEncodingFromChoice, mEncodingIndexes, mEncodingNames, mType, sf_encoding_index_name(), sf_encoding_index_to_subtype(), sf_num_encodings(), and Verbatim().

Referenced by OnHeaderChoice().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTypes()

void ExportPCMOptions::GetTypes ( )
private

Definition at line 273 of file ExportPCM.cpp.

274 {
275  // Reset arrays
276  mHeaderIndexes.clear();
277  mHeaderNames.clear();
278 
279  // Get the previously saved type. Note that this is ONLY used for
280  // the FMT_OTHER ("Other uncompressed files") types.
281  int typ = LoadOtherFormat() & SF_FORMAT_TYPEMASK;
282 
283  // Rebuild the arrays
284  mHeaderFromChoice = 0;
285  for (int i = 0, num = sf_num_headers(); i < num; ++i)
286  {
287  int type = sf_header_index_to_type(i);
288 
289  switch (type)
290  {
291  // On the Mac, do not include in header list
292 #if defined(__WXMAC__)
293  case SF_FORMAT_AIFF:
294  break;
295 #endif
296 
297  // Do not include in header list
298  case SF_FORMAT_WAV:
299  break;
300 
301  default:
302  // Remember the index if this is the desired type
303  if (type == typ)
304  {
306  }
307 
308  // Store index and name
309  mHeaderIndexes.push_back(i);
311  break;
312  }
313  }
314 
315  // Refresh the current type
317 }

References LoadOtherFormat(), mHeaderFromChoice, mHeaderIndexes, mHeaderNames, mType, sf_header_index_name(), sf_header_index_to_type(), sf_num_headers(), and Verbatim().

Here is the call graph for this function:

◆ OnEncodingChoice()

void ExportPCMOptions::OnEncodingChoice ( wxCommandEvent &  evt)

Definition at line 262 of file ExportPCM.cpp.

263 {
264  evt.Skip();
265 
266  // Remember new selection
267  mEncodingFromChoice = evt.GetInt();
268 
269  // And save it
271 }

References mEncodingFromChoice, mEncodingIndexes, mType, SaveEncoding(), and sf_encoding_index_to_subtype().

Here is the call graph for this function:

◆ OnHeaderChoice()

void ExportPCMOptions::OnHeaderChoice ( wxCommandEvent &  evt)

Definition at line 232 of file ExportPCM.cpp.

233 {
234  evt.Skip();
235 
236  // Remember new selection
237  mHeaderFromChoice = evt.GetInt();
238 
239  // Get the type for this selection
241 
242  // Save the newly selected type
244 
245  // Reload the encodings valid for this new type
246  GetEncodings();
247 
248  // Repopulate the encoding choices
249  mEncodingChoice->Clear();
250  for (int i = 0, num = mEncodingNames.size(); i < num; ++i)
251  {
252  mEncodingChoice->AppendString(mEncodingNames[i].StrippedTranslation());
253  }
254 
255  // Select the desired encoding
256  mEncodingChoice->SetSelection(mEncodingFromChoice);
257 
258  // Send the event indicating a file suffix change.
259  SendSuffixEvent();
260 }

References GetEncodings(), mEncodingChoice, mEncodingFromChoice, mEncodingNames, mHeaderFromChoice, mHeaderIndexes, mType, SaveOtherFormat(), SendSuffixEvent(), and sf_header_index_to_type().

Here is the call graph for this function:

◆ OnShow()

void ExportPCMOptions::OnShow ( wxShowEvent &  evt)

Definition at line 219 of file ExportPCM.cpp.

220 {
221  evt.Skip();
222 
223  // Since the initial file name may not have the "correct" extension,
224  // send off an event to have it changed. Note that this will be
225  // done every time a user changes filters in the dialog.
226  if (evt.IsShown())
227  {
228  SendSuffixEvent();
229  }
230 }

References SendSuffixEvent().

Referenced by ExportPCMOptions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PopulateOrExchange()

void ExportPCMOptions::PopulateOrExchange ( ShuttleGui S)

Definition at line 189 of file ExportPCM.cpp.

190 {
191  S.StartVerticalLay();
192  {
193  S.StartHorizontalLay(wxCENTER);
194  {
195  S.StartMultiColumn(2, wxCENTER);
196  {
197  S.SetStretchyCol(1);
198  if (mSelFormat == FMT_OTHER)
199  {
201  .AddChoice(XXO("Header:"),
202  mHeaderNames,
204  }
206  .AddChoice(XXO("Encoding:"),
209  }
210  S.EndMultiColumn();
211  }
212  S.EndHorizontalLay();
213  }
214  S.EndVerticalLay();
215 
216  return;
217 }

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

Here is the call graph for this function:

◆ SendSuffixEvent()

void ExportPCMOptions::SendSuffixEvent ( )
private

Definition at line 369 of file ExportPCM.cpp.

370 {
371  // Synchronously process a change in suffix.
372  wxCommandEvent evt(AUDACITY_FILE_SUFFIX_EVENT, GetId());
373  evt.SetEventObject(this);
374  evt.SetString(sf_header_extension(mType));
375  ProcessWindowEvent(evt);
376 }

References mType, and sf_header_extension().

Referenced by OnHeaderChoice(), and OnShow().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mEncodingChoice

wxChoice* ExportPCMOptions::mEncodingChoice
private

Definition at line 141 of file ExportPCM.cpp.

Referenced by OnHeaderChoice(), and PopulateOrExchange().

◆ mEncodingFromChoice

int ExportPCMOptions::mEncodingFromChoice
private

◆ mEncodingIndexes

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

Definition at line 139 of file ExportPCM.cpp.

Referenced by GetEncodings(), OnEncodingChoice(), and ~ExportPCMOptions().

◆ mEncodingNames

TranslatableStrings ExportPCMOptions::mEncodingNames
private

Definition at line 140 of file ExportPCM.cpp.

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

◆ mHeaderChoice

wxChoice* ExportPCMOptions::mHeaderChoice
private

Definition at line 136 of file ExportPCM.cpp.

Referenced by PopulateOrExchange().

◆ mHeaderFromChoice

int ExportPCMOptions::mHeaderFromChoice
private

Definition at line 137 of file ExportPCM.cpp.

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

◆ mHeaderIndexes

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

Definition at line 134 of file ExportPCM.cpp.

Referenced by GetTypes(), and OnHeaderChoice().

◆ mHeaderNames

TranslatableStrings ExportPCMOptions::mHeaderNames
private

Definition at line 135 of file ExportPCM.cpp.

Referenced by GetTypes(), and PopulateOrExchange().

◆ mSelFormat

int ExportPCMOptions::mSelFormat
private

Definition at line 144 of file ExportPCM.cpp.

Referenced by PopulateOrExchange().

◆ mType

int ExportPCMOptions::mType
private

The documentation for this class was generated from the following file:
ExportPCMOptions::mEncodingFromChoice
int mEncodingFromChoice
Definition: ExportPCM.cpp:142
ShuttleGuiBase::AddChoice
wxChoice * AddChoice(const TranslatableString &Prompt, const TranslatableStrings &choices, int Selected=-1)
Definition: ShuttleGui.cpp:398
ShuttleGuiBase::StartVerticalLay
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:1184
ExportPCMOptions::GetEncodings
void GetEncodings(int enc=0)
Definition: ExportPCM.cpp:319
ExportPCMOptions::mEncodingIndexes
std::vector< int > mEncodingIndexes
Definition: ExportPCM.cpp:139
ID_HEADER_CHOICE
#define ID_HEADER_CHOICE
Definition: ExportPCM.cpp:110
sf_header_index_to_type
unsigned int sf_header_index_to_type(int i)
Definition: FileFormats.cpp:59
ExportPCMOptions::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S)
Definition: ExportPCM.cpp:189
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1238
LoadEncoding
static int LoadEncoding(int type)
Definition: ExportPCM.cpp:93
sf_encoding_index_to_subtype
unsigned int sf_encoding_index_to_subtype(int i)
Definition: FileFormats.cpp:95
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2274
ExportPCMOptions::mHeaderNames
TranslatableStrings mHeaderNames
Definition: ExportPCM.cpp:135
ExportPCMOptions::mType
int mType
Definition: ExportPCM.cpp:145
XXO
#define XXO(s)
Definition: Internat.h:44
ShuttleGuiBase::EndHorizontalLay
void EndHorizontalLay()
Definition: ShuttleGui.cpp:1177
sf_header_index_name
wxString sf_header_index_name(int format)
Get the name of a container format from libsndfile.
Definition: FileFormats.cpp:47
ExportPCMOptions::mEncodingNames
TranslatableStrings mEncodingNames
Definition: ExportPCM.cpp:140
ShuttleGuiBase::StartHorizontalLay
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:1167
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1229
SaveOtherFormat
static void SaveOtherFormat(int val)
Definition: ExportPCM.cpp:87
ShuttleGuiBase::EndVerticalLay
void EndVerticalLay()
Definition: ShuttleGui.cpp:1203
sf_num_headers
int sf_num_headers()
Get the number of container formats supported by libsndfile.
Definition: FileFormats.cpp:37
ExportPCMOptions::GetTypes
void GetTypes()
Definition: ExportPCM.cpp:273
ExportPCMOptions::mEncodingChoice
wxChoice * mEncodingChoice
Definition: ExportPCM.cpp:141
SaveEncoding
static void SaveEncoding(int type, int val)
Definition: ExportPCM.cpp:99
ID_ENCODING_CHOICE
#define ID_ENCODING_CHOICE
Definition: ExportPCM.cpp:111
sf_num_encodings
int sf_num_encodings()
Get the number of data encodings libsndfile supports (in any container or none.
Definition: FileFormats.cpp:75
LoadOtherFormat
static int LoadOtherFormat(int def=0)
Definition: ExportPCM.cpp:81
kFormats
struct @0 kFormats[]
FMT_OTHER
@ FMT_OTHER
Definition: ExportPCM.cpp:74
wxPanelWrapper::wxPanelWrapper
wxPanelWrapper()
Definition: wxPanelWrapper.h:44
Verbatim
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Definition: TranslatableString.h:321
ExportPCMOptions::SendSuffixEvent
void SendSuffixEvent()
Definition: ExportPCM.cpp:369
ExportPCMOptions::OnShow
void OnShow(wxShowEvent &evt)
Definition: ExportPCM.cpp:219
eIsCreatingFromPrefs
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:47
sf_header_extension
wxString sf_header_extension(int format)
Get the most common file extension for the given format.
Definition: FileFormats.cpp:146
ShuttleGuiBase::SetStretchyCol
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:202
ExportPCMOptions::mHeaderFromChoice
int mHeaderFromChoice
Definition: ExportPCM.cpp:137
ExportPCMOptions::mSelFormat
int mSelFormat
Definition: ExportPCM.cpp:144
sf_encoding_index_name
wxString sf_encoding_index_name(int i)
Get the string name of the data encoding of the requested format.
Definition: FileFormats.cpp:84
ExportPCMOptions::mHeaderChoice
wxChoice * mHeaderChoice
Definition: ExportPCM.cpp:136
ExportPCMOptions::mHeaderIndexes
std::vector< int > mHeaderIndexes
Definition: ExportPCM.cpp:134
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631