Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
anonymous_namespace{ExportPCM.cpp}::ExportOptionsSFEditor Class Referencefinal
Inheritance diagram for anonymous_namespace{ExportPCM.cpp}::ExportOptionsSFEditor:
[legend]
Collaboration diagram for anonymous_namespace{ExportPCM.cpp}::ExportOptionsSFEditor:
[legend]

Public Member Functions

 ExportOptionsSFEditor (Listener *listener)
 
int GetOptionsCount () const override
 
bool GetOption (int index, ExportOption &option) const override
 
bool GetValue (ExportOptionID id, ExportValue &value) const override
 
bool SetValue (ExportOptionID id, const ExportValue &value) override
 
SampleRateList GetSampleRateList () const override
 
void Load (const audacity::BasicSettings &config) override
 
void Store (audacity::BasicSettings &config) const override
 
- Public Member Functions inherited from ExportOptionsEditor
virtual ~ExportOptionsEditor ()
 
virtual int GetOptionsCount () const =0
 
virtual bool GetOption (int index, ExportOption &option) const =0
 
virtual bool GetValue (ExportOptionID id, ExportValue &value) const =0
 
virtual bool SetValue (ExportOptionID id, const ExportValue &value)=0
 
virtual SampleRateList GetSampleRateList () const =0
 
virtual void Store (audacity::BasicSettings &settings) const =0
 
virtual void Load (const audacity::BasicSettings &config)=0
 

Private Member Functions

bool IsValidType (const ExportValue &typeValue) const
 

Private Attributes

Listener *const mListener
 
int mType
 
std::unordered_map< int, int > mEncodings
 
std::vector< ExportOptionmOptions
 

Additional Inherited Members

- Public Types inherited from ExportOptionsEditor
using SampleRateList = std::vector< int >
 

Detailed Description

Definition at line 185 of file ExportPCM.cpp.

Constructor & Destructor Documentation

◆ ExportOptionsSFEditor()

anonymous_namespace{ExportPCM.cpp}::ExportOptionsSFEditor::ExportOptionsSFEditor ( Listener listener)
inlineexplicit

Definition at line 208 of file ExportPCM.cpp.

209 : mListener(listener)
210 {
211 ExportOption typeOption {
212 OptionIDSFType, XO("Header"),
213 0,
215 };
216
217 auto hasDefaultType = false;
218 for (int i = 0, num = sf_num_headers(); i < num; ++i)
219 {
220 const auto type = static_cast<int>(sf_header_index_to_type(i));
221 switch (type)
222 {
223 // On the Mac, do not include in header list
224#if defined(__WXMAC__)
225 case SF_FORMAT_AIFF: break;
226#endif
227 // Do not include in header list
228 case SF_FORMAT_WAV: break;
229 default:
230 {
231 typeOption.values.emplace_back(type);
232 typeOption.names.push_back(Verbatim(sf_header_index_name(i)));
233 ExportOption encodingOption {
234 type,
235 XO("Encoding"),
236 0,
238 };
239 GetEncodings(type, encodingOption.values, encodingOption.names);
240 encodingOption.defaultValue = encodingOption.values[0];
241 if(!hasDefaultType)
242 {
243 mType = type;
244 typeOption.defaultValue = type;
245 hasDefaultType = true;
246 }
247 else
248 encodingOption.flags |= ExportOption::Hidden;
249 mOptions.push_back(std::move(encodingOption));
250 mEncodings[type] = *std::get_if<int>(&encodingOption.defaultValue);
251 } break;
252 }
253 }
254 typeOption.defaultValue = typeOption.values[0];
255 mOptions.insert(mOptions.begin(), std::move(typeOption));
256 }
wxString sf_header_index_name(int format)
Get the name of a container format from libsndfile.
Definition: FileFormats.cpp:42
unsigned int sf_header_index_to_type(int i)
Definition: FileFormats.cpp:54
int sf_num_headers()
Get the number of container formats supported by libsndfile.
Definition: FileFormats.cpp:32
XO("Cut/Copy/Paste")
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
void GetEncodings(int type, std::vector< ExportValue > &values, TranslatableStrings &names)
Definition: ExportPCM.cpp:92
A type that provides a description of an exporting option. Isn't allowed to change except non-type re...
Definition: ExportTypes.h:43
@ TypeEnum
List/enum option. values holds items, and names text to be displayed.
Definition: ExportTypes.h:48
@ Hidden
Option is not used and may be hidden from the user.
Definition: ExportTypes.h:51

References anonymous_namespace{ExportPCM.cpp}::GetEncodings(), ExportOption::Hidden, anonymous_namespace{ExportPCM.cpp}::OptionIDSFType, sf_header_index_name(), sf_header_index_to_type(), sf_num_headers(), ExportOption::TypeEnum, Verbatim(), and XO().

Here is the call graph for this function:

Member Function Documentation

◆ GetOption()

bool anonymous_namespace{ExportPCM.cpp}::ExportOptionsSFEditor::GetOption ( int  index,
ExportOption option 
) const
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 263 of file ExportPCM.cpp.

264 {
265 if (index >= 0 && index < static_cast<int>(mOptions.size()))
266 {
267 option = mOptions[index];
268 return true;
269 }
270 return false;
271 }

◆ GetOptionsCount()

int anonymous_namespace{ExportPCM.cpp}::ExportOptionsSFEditor::GetOptionsCount ( ) const
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 258 of file ExportPCM.cpp.

259 {
260 return static_cast<int>(mOptions.size());
261 }

◆ GetSampleRateList()

SampleRateList anonymous_namespace{ExportPCM.cpp}::ExportOptionsSFEditor::GetSampleRateList ( ) const
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 335 of file ExportPCM.cpp.

336 {
337 return {};
338 }

◆ GetValue()

bool anonymous_namespace{ExportPCM.cpp}::ExportOptionsSFEditor::GetValue ( ExportOptionID  id,
ExportValue value 
) const
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 273 of file ExportPCM.cpp.

274 {
275 if(id == OptionIDSFType)
276 {
277 value = mType;
278 return true;
279 }
280 auto it = mEncodings.find(id);
281 if(it != mEncodings.end())
282 {
283 value = it->second;
284 return true;
285 }
286 return false;
287 }

References anonymous_namespace{ExportPCM.cpp}::OptionIDSFType.

◆ IsValidType()

bool anonymous_namespace{ExportPCM.cpp}::ExportOptionsSFEditor::IsValidType ( const ExportValue typeValue) const
inlineprivate

Definition at line 193 of file ExportPCM.cpp.

194 {
195 if(std::holds_alternative<int>(typeValue))
196 {
197 const auto& typeOption = mOptions.front();
198 return std::find(typeOption.values.begin(),
199 typeOption.values.end(),
200 typeValue) != typeOption.values.end();
201 }
202 return false;
203 }

◆ Load()

void anonymous_namespace{ExportPCM.cpp}::ExportOptionsSFEditor::Load ( const audacity::BasicSettings config)
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 340 of file ExportPCM.cpp.

341 {
342 mType = LoadOtherFormat(config, mType);
343 for(auto& p : mEncodings)
344 p.second = LoadEncoding(config, p.first, p.second);
345
346 // Prior to v2.4.0, sf_format will include the subtype.
347 if (mType & SF_FORMAT_SUBMASK)
348 {
349 const auto type = mType & SF_FORMAT_TYPEMASK;
350 const auto enc = mType & SF_FORMAT_SUBMASK;
351 mEncodings[type] = enc;
352 mType = type;
353 }
354
355 for(auto& option : mOptions)
356 {
357 const auto it = mEncodings.find(option.id);
358 if(it == mEncodings.end())
359 continue;
360
361 if(mType == it->first)
362 option.flags &= ~ExportOption::Hidden;
363 else
364 option.flags |= ExportOption::Hidden;
365 }
366 }
int LoadEncoding(const audacity::BasicSettings &config, int type, int def)
Definition: ExportPCM.cpp:80
int LoadOtherFormat(const audacity::BasicSettings &config, int def)
Definition: ExportPCM.cpp:70
int flags
A set of flag that desc.
Definition: ExportTypes.h:59

References ExportOption::flags, ExportOption::Hidden, anonymous_namespace{ExportPCM.cpp}::LoadEncoding(), and anonymous_namespace{ExportPCM.cpp}::LoadOtherFormat().

Here is the call graph for this function:

◆ SetValue()

bool anonymous_namespace{ExportPCM.cpp}::ExportOptionsSFEditor::SetValue ( ExportOptionID  id,
const ExportValue value 
)
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 289 of file ExportPCM.cpp.

290 {
291 if(id == OptionIDSFType && IsValidType(value))
292 {
293 const auto newType = *std::get_if<int>(&value);
294 if(newType == mType)
295 return true;
296
297 if(mListener)
299
300 for(auto& option : mOptions)
301 {
302 if(option.id == mType)
303 {
304 option.flags |= ExportOption::Hidden;
305 if(mListener)
307 }
308 else if(option.id == newType)
309 {
310 option.flags &= ~ExportOption::Hidden;
311 if(mListener)
313 }
314 }
315 mType = newType;
316 Store(*gPrefs);
317 if(mListener)
318 {
321 }
322 return true;
323 }
324
325 auto it = mEncodings.find(id);
326 if(it != mEncodings.end() && std::holds_alternative<int>(value))
327 {
328 it->second = *std::get_if<int>(&value);
329 Store(*gPrefs);
330 return true;
331 }
332 return false;
333 }
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
virtual void OnExportOptionChangeEnd()=0
Called after OnExportOptionChange
virtual void OnFormatInfoChange()=0
Called when format extension change (usually in response parameter change)
virtual void OnExportOptionChangeBegin()=0
Called before OnExportOptionChange
virtual void OnExportOptionChange(const ExportOption &option)=0
Called when option change.
void Store(audacity::BasicSettings &config) const override
Definition: ExportPCM.cpp:368
bool IsValidType(const ExportValue &typeValue) const
Definition: ExportPCM.cpp:193

References gPrefs, ExportOption::Hidden, ExportOptionsEditor::Listener::OnExportOptionChange(), ExportOptionsEditor::Listener::OnExportOptionChangeBegin(), ExportOptionsEditor::Listener::OnExportOptionChangeEnd(), ExportOptionsEditor::Listener::OnFormatInfoChange(), and anonymous_namespace{ExportPCM.cpp}::OptionIDSFType.

Here is the call graph for this function:

◆ Store()

void anonymous_namespace{ExportPCM.cpp}::ExportOptionsSFEditor::Store ( audacity::BasicSettings config) const
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 368 of file ExportPCM.cpp.

369 {
370 SaveOtherFormat(config, mType);
371 for(auto& [type, encoding] : mEncodings)
372 SaveEncoding(config, type, encoding);
373 }
void SaveEncoding(audacity::BasicSettings &config, int type, int val)
Definition: ExportPCM.cpp:86
void SaveOtherFormat(audacity::BasicSettings &config, int val)
Definition: ExportPCM.cpp:75

References anonymous_namespace{ExportPCM.cpp}::SaveEncoding(), and anonymous_namespace{ExportPCM.cpp}::SaveOtherFormat().

Here is the call graph for this function:

Member Data Documentation

◆ mEncodings

std::unordered_map<int, int> anonymous_namespace{ExportPCM.cpp}::ExportOptionsSFEditor::mEncodings
private

Definition at line 189 of file ExportPCM.cpp.

◆ mListener

Listener* const anonymous_namespace{ExportPCM.cpp}::ExportOptionsSFEditor::mListener
private

Definition at line 187 of file ExportPCM.cpp.

◆ mOptions

std::vector<ExportOption> anonymous_namespace{ExportPCM.cpp}::ExportOptionsSFEditor::mOptions
private

Definition at line 191 of file ExportPCM.cpp.

◆ mType

int anonymous_namespace{ExportPCM.cpp}::ExportOptionsSFEditor::mType
private

Definition at line 188 of file ExportPCM.cpp.


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