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

Public Member Functions

 MP2ExportOptionsEditor (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 Store (audacity::BasicSettings &config) const override
 
void Load (const audacity::BasicSettings &config) override
 
void OnVersionChanged ()
 
- 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 Attributes

std::vector< ExportOptionmOptions {MP2Options }
 
std::unordered_map< ExportOptionID, ExportValuemValues
 
ListenermListener {}
 

Additional Inherited Members

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

Detailed Description

Definition at line 143 of file ExportMP2.cpp.

Constructor & Destructor Documentation

◆ MP2ExportOptionsEditor()

MP2ExportOptionsEditor::MP2ExportOptionsEditor ( Listener listener)
inline

Definition at line 149 of file ExportMP2.cpp.

150 : mListener(listener)
151 {
152 for(auto& option : mOptions)
153 mValues[option.id] = option.defaultValue;
154 }
std::vector< ExportOption > mOptions
Definition: ExportMP2.cpp:145
std::unordered_map< ExportOptionID, ExportValue > mValues
Definition: ExportMP2.cpp:146

References mOptions, and mValues.

Member Function Documentation

◆ GetOption()

bool MP2ExportOptionsEditor::GetOption ( int  index,
ExportOption option 
) const
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 160 of file ExportMP2.cpp.

161 {
162 if(index >= 0 && index < mOptions.size())
163 {
164 option = mOptions[index];
165 return true;
166 }
167 return false;
168 }

References mOptions.

◆ GetOptionsCount()

int MP2ExportOptionsEditor::GetOptionsCount ( ) const
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 156 of file ExportMP2.cpp.

157 {
158 return static_cast<int>(mOptions.size());
159 }

References mOptions.

◆ GetSampleRateList()

SampleRateList MP2ExportOptionsEditor::GetSampleRateList ( ) const
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 203 of file ExportMP2.cpp.

204 {
205 auto it = mValues.find(MP2OptionIDVersion);
206 if(*std::get_if<int>(&it->second) == TWOLAME_MPEG1)
207 return { 32000, 44100, 48000 };
208 return {16000, 22050, 24000 };
209 }

References anonymous_namespace{ExportMP2.cpp}::MP2OptionIDVersion, and mValues.

◆ GetValue()

bool MP2ExportOptionsEditor::GetValue ( ExportOptionID  id,
ExportValue value 
) const
inlineoverride

Definition at line 169 of file ExportMP2.cpp.

170 {
171 const auto it = mValues.find(id);
172 if(it != mValues.end())
173 {
174 value = it->second;
175 return true;
176 }
177 return false;
178 }

References mValues.

◆ Load()

void MP2ExportOptionsEditor::Load ( const audacity::BasicSettings config)
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 220 of file ExportMP2.cpp.

221 {
222 config.Read(wxT("/FileFormats/MP2Version"), std::get_if<int>(&mValues[MP2OptionIDVersion]));
223 config.Read(wxT("/FileFormats/MP2BitrateMPEG1"), std::get_if<int>(&mValues[MP2OptionIDBitRateMPEG1]));
224 config.Read(wxT("/FileFormats/MP2BitrateMPEG2"), std::get_if<int>(&mValues[MP2OptionIDBitRateMPEG2]));
226 }
wxT("CloseDown"))
virtual bool Read(const wxString &key, bool *value) const =0

References anonymous_namespace{ExportMP2.cpp}::MP2OptionIDBitRateMPEG1, anonymous_namespace{ExportMP2.cpp}::MP2OptionIDBitRateMPEG2, anonymous_namespace{ExportMP2.cpp}::MP2OptionIDVersion, mValues, OnVersionChanged(), audacity::BasicSettings::Read(), and wxT().

Here is the call graph for this function:

◆ OnVersionChanged()

void MP2ExportOptionsEditor::OnVersionChanged ( )
inline

Definition at line 228 of file ExportMP2.cpp.

229 {
230 if(*std::get_if<int>(&mValues[MP2OptionIDVersion]) == TWOLAME_MPEG1)
231 {
234 }
235 else
236 {
239 }
240 }
A type that provides a description of an exporting option. Isn't allowed to change except non-type re...
Definition: ExportTypes.h:43
@ Hidden
Option is not used and may be hidden from the user.
Definition: ExportTypes.h:51

References ExportOption::Hidden, mOptions, anonymous_namespace{ExportMP2.cpp}::MP2OptionIDBitRateMPEG1, anonymous_namespace{ExportMP2.cpp}::MP2OptionIDBitRateMPEG2, anonymous_namespace{ExportMP2.cpp}::MP2OptionIDVersion, and mValues.

Referenced by Load(), and SetValue().

Here is the caller graph for this function:

◆ SetValue()

bool MP2ExportOptionsEditor::SetValue ( ExportOptionID  id,
const ExportValue value 
)
inlineoverride

Definition at line 179 of file ExportMP2.cpp.

180 {
181 auto it = mValues.find(id);
182 if(it == mValues.end() || it->second.index() != value.index())
183 return false;
184
185 it->second = value;
186
187 if(id == MP2OptionIDVersion)
188 {
190
191 if(mListener != nullptr)
192 {
197
199 }
200 }
201 return true;
202 }
virtual void OnExportOptionChangeEnd()=0
Called after OnExportOptionChange
virtual void OnExportOptionChangeBegin()=0
Called before OnExportOptionChange
virtual void OnExportOptionChange(const ExportOption &option)=0
Called when option change.
virtual void OnSampleRateListChange()=0

References mListener, mOptions, anonymous_namespace{ExportMP2.cpp}::MP2OptionIDBitRateMPEG1, anonymous_namespace{ExportMP2.cpp}::MP2OptionIDBitRateMPEG2, anonymous_namespace{ExportMP2.cpp}::MP2OptionIDVersion, mValues, ExportOptionsEditor::Listener::OnExportOptionChange(), ExportOptionsEditor::Listener::OnExportOptionChangeBegin(), ExportOptionsEditor::Listener::OnExportOptionChangeEnd(), ExportOptionsEditor::Listener::OnSampleRateListChange(), and OnVersionChanged().

Here is the call graph for this function:

◆ Store()

void MP2ExportOptionsEditor::Store ( audacity::BasicSettings config) const
inlineoverridevirtual

Implements ExportOptionsEditor.

Definition at line 210 of file ExportMP2.cpp.

211 {
212 auto it = mValues.find(MP2OptionIDVersion);
213 config.Write(wxT("/FileFormats/MP2Version"), *std::get_if<int>(&it->second));
215 config.Write(wxT("/FileFormats/MP2BitrateMPEG1"), *std::get_if<int>(&it->second));
217 config.Write(wxT("/FileFormats/MP2BitrateMPEG2"), *std::get_if<int>(&it->second));
218 }
virtual bool Write(const wxString &key, bool value)=0

References anonymous_namespace{ExportMP2.cpp}::MP2OptionIDBitRateMPEG1, anonymous_namespace{ExportMP2.cpp}::MP2OptionIDBitRateMPEG2, anonymous_namespace{ExportMP2.cpp}::MP2OptionIDVersion, mValues, audacity::BasicSettings::Write(), and wxT().

Here is the call graph for this function:

Member Data Documentation

◆ mListener

Listener* MP2ExportOptionsEditor::mListener {}
private

Definition at line 147 of file ExportMP2.cpp.

Referenced by SetValue().

◆ mOptions

std::vector<ExportOption> MP2ExportOptionsEditor::mOptions {MP2Options }
private

◆ mValues

std::unordered_map<ExportOptionID, ExportValue> MP2ExportOptionsEditor::mValues
private

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