Audacity 3.2.0
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 110 of file ExportPCM.cpp.

Constructor & Destructor Documentation

◆ ExportPCMOptions()

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

Definition at line 152 of file ExportPCM.cpp.

153: wxPanelWrapper(parent, wxID_ANY)
154{
155 // Remember the selection format
156 mSelFormat = selformat;
157
158 // Init choices
161
162 if (mSelFormat < FMT_OTHER)
163 {
164 mType = kFormats[selformat].format & SF_FORMAT_TYPEMASK;
165 GetEncodings(mType & SF_FORMAT_SUBMASK);
166 }
167 else
168 {
169 GetTypes();
170 GetEncodings();
171 }
172
175
176 parent->Bind(wxEVT_SHOW, &ExportPCMOptions::OnShow, this);
177}
@ FMT_OTHER
Definition: ExportPCM.cpp:71
struct @43 kFormats[]
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
#define S(N)
Definition: ToChars.cpp:64
void OnShow(wxShowEvent &evt)
Definition: ExportPCM.cpp:216
void PopulateOrExchange(ShuttleGui &S)
Definition: ExportPCM.cpp:186
void GetEncodings(int enc=0)
Definition: ExportPCM.cpp:316
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:625

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

Here is the call graph for this function:

◆ ~ExportPCMOptions()

ExportPCMOptions::~ExportPCMOptions ( )
virtual

Definition at line 179 of file ExportPCM.cpp.

180{
181 // Save the encoding
184}
static void SaveEncoding(int type, int val)
Definition: ExportPCM.cpp:96
static void SaveOtherFormat(int val)
Definition: ExportPCM.cpp:84
unsigned int sf_encoding_index_to_subtype(int i)
Definition: FileFormats.cpp:94
std::vector< int > mEncodingIndexes
Definition: ExportPCM.cpp:136

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 316 of file ExportPCM.cpp.

317{
318 // Setup for queries
319 SF_INFO info = {};
320 info.samplerate = 44100;
321 info.channels = 1;
322 info.sections = 1;
323
324 // Reset arrays
325 mEncodingIndexes.clear();
326 mEncodingNames.clear();
327
328 // If the encoding wasn't supplied, look it up
329 if (!(enc & SF_FORMAT_SUBMASK))
330 {
331 enc = LoadEncoding(mType);
332 }
333 enc &= SF_FORMAT_SUBMASK;
334
335 // Fix for Bug 1218 - AIFF with no encoding should default to 16 bit.
336 if (mType == SF_FORMAT_AIFF && enc == 0)
337 {
338 enc = SF_FORMAT_PCM_16;
339 }
340
341 // Rebuild the arrays
343 for (int i = 0, num = sf_num_encodings(); i < num; ++i)
344 {
345 int sub = sf_encoding_index_to_subtype(i);
346
347 // Since we're traversing the subtypes linearly, we have to
348 // make sure it can be paired with our current type.
349 info.format = mType | sub;
350 if (sf_format_check(&info))
351 {
352 // If this subtype matches our last saved encoding, remember
353 // its index so we can set it in the dialog.
354 if (sub == enc)
355 {
357 }
358
359 // Store index and name
360 mEncodingIndexes.push_back(i);
362 }
363 }
364}
static int LoadEncoding(int type)
Definition: ExportPCM.cpp:90
wxString sf_encoding_index_name(int i)
Get the string name of the data encoding of the requested format.
Definition: FileFormats.cpp:83
int sf_num_encodings()
Get the number of data encodings libsndfile supports (in any container or none.
Definition: FileFormats.cpp:74
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
TranslatableStrings mEncodingNames
Definition: ExportPCM.cpp:137

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 270 of file ExportPCM.cpp.

271{
272 // Reset arrays
273 mHeaderIndexes.clear();
274 mHeaderNames.clear();
275
276 // Get the previously saved type. Note that this is ONLY used for
277 // the FMT_OTHER ("Other uncompressed files") types.
278 int typ = LoadOtherFormat() & SF_FORMAT_TYPEMASK;
279
280 // Rebuild the arrays
282 for (int i = 0, num = sf_num_headers(); i < num; ++i)
283 {
284 int type = sf_header_index_to_type(i);
285
286 switch (type)
287 {
288 // On the Mac, do not include in header list
289#if defined(__WXMAC__)
290 case SF_FORMAT_AIFF:
291 break;
292#endif
293
294 // Do not include in header list
295 case SF_FORMAT_WAV:
296 break;
297
298 default:
299 // Remember the index if this is the desired type
300 if (type == typ)
301 {
303 }
304
305 // Store index and name
306 mHeaderIndexes.push_back(i);
308 break;
309 }
310 }
311
312 // Refresh the current type
314}
static int LoadOtherFormat(int def=0)
Definition: ExportPCM.cpp:78
wxString sf_header_index_name(int format)
Get the name of a container format from libsndfile.
Definition: FileFormats.cpp:46
unsigned int sf_header_index_to_type(int i)
Definition: FileFormats.cpp:58
int sf_num_headers()
Get the number of container formats supported by libsndfile.
Definition: FileFormats.cpp:36
std::vector< int > mHeaderIndexes
Definition: ExportPCM.cpp:131
TranslatableStrings mHeaderNames
Definition: ExportPCM.cpp:132

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 259 of file ExportPCM.cpp.

260{
261 evt.Skip();
262
263 // Remember new selection
264 mEncodingFromChoice = evt.GetInt();
265
266 // And save it
268}

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 229 of file ExportPCM.cpp.

230{
231 evt.Skip();
232
233 // Remember new selection
234 mHeaderFromChoice = evt.GetInt();
235
236 // Get the type for this selection
238
239 // Save the newly selected type
241
242 // Reload the encodings valid for this new type
243 GetEncodings();
244
245 // Repopulate the encoding choices
246 mEncodingChoice->Clear();
247 for (int i = 0, num = mEncodingNames.size(); i < num; ++i)
248 {
249 mEncodingChoice->AppendString(mEncodingNames[i].StrippedTranslation());
250 }
251
252 // Select the desired encoding
254
255 // Send the event indicating a file suffix change.
257}
void SendSuffixEvent()
Definition: ExportPCM.cpp:366
wxChoice * mEncodingChoice
Definition: ExportPCM.cpp:138

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 216 of file ExportPCM.cpp.

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

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 186 of file ExportPCM.cpp.

187{
188 S.StartVerticalLay();
189 {
190 S.StartHorizontalLay(wxCENTER);
191 {
192 S.StartMultiColumn(2, wxCENTER);
193 {
194 S.SetStretchyCol(1);
195 if (mSelFormat == FMT_OTHER)
196 {
198 .AddChoice(XXO("Header:"),
201 }
203 .AddChoice(XXO("Encoding:"),
206 }
207 S.EndMultiColumn();
208 }
209 S.EndHorizontalLay();
210 }
211 S.EndVerticalLay();
212
213 return;
214}
#define ID_ENCODING_CHOICE
Definition: ExportPCM.cpp:108
#define ID_HEADER_CHOICE
Definition: ExportPCM.cpp:107
XXO("&Cut/Copy/Paste Toolbar")
wxChoice * mHeaderChoice
Definition: ExportPCM.cpp:133

References FMT_OTHER, ID_ENCODING_CHOICE, ID_HEADER_CHOICE, mEncodingChoice, mEncodingFromChoice, mEncodingNames, mHeaderChoice, mHeaderFromChoice, mHeaderNames, mSelFormat, S, and XXO().

Here is the call graph for this function:

◆ SendSuffixEvent()

void ExportPCMOptions::SendSuffixEvent ( )
private

Definition at line 366 of file ExportPCM.cpp.

367{
368 // Synchronously process a change in suffix.
369 wxCommandEvent evt(AUDACITY_FILE_SUFFIX_EVENT, GetId());
370 evt.SetEventObject(this);
371 evt.SetString(sf_header_extension(mType));
372 ProcessWindowEvent(evt);
373}
wxString sf_header_extension(int format)
Get the most common file extension for the given format.

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 138 of file ExportPCM.cpp.

Referenced by OnHeaderChoice(), and PopulateOrExchange().

◆ mEncodingFromChoice

int ExportPCMOptions::mEncodingFromChoice
private

◆ mEncodingIndexes

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

Definition at line 136 of file ExportPCM.cpp.

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

◆ mEncodingNames

TranslatableStrings ExportPCMOptions::mEncodingNames
private

Definition at line 137 of file ExportPCM.cpp.

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

◆ mHeaderChoice

wxChoice* ExportPCMOptions::mHeaderChoice
private

Definition at line 133 of file ExportPCM.cpp.

Referenced by PopulateOrExchange().

◆ mHeaderFromChoice

int ExportPCMOptions::mHeaderFromChoice
private

Definition at line 134 of file ExportPCM.cpp.

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

◆ mHeaderIndexes

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

Definition at line 131 of file ExportPCM.cpp.

Referenced by GetTypes(), and OnHeaderChoice().

◆ mHeaderNames

TranslatableStrings ExportPCMOptions::mHeaderNames
private

Definition at line 132 of file ExportPCM.cpp.

Referenced by GetTypes(), and PopulateOrExchange().

◆ mSelFormat

int ExportPCMOptions::mSelFormat
private

Definition at line 141 of file ExportPCM.cpp.

Referenced by PopulateOrExchange().

◆ mType

int ExportPCMOptions::mType
private

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