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

Public Member Functions

 ExportMP3 ()
 
bool CheckFileName (wxFileName &filename, int format) const override
 
int GetFormatCount () const override
 
FormatInfo GetFormatInfo (int) const override
 Returns FormatInfo structure for given index if it's valid, or a default one. FormatInfo::format isn't guaranteed to be unique. More...
 
std::unique_ptr< ExportOptionsEditorCreateOptionsEditor (int, ExportOptionsEditor::Listener *listener) const override
 Creates format-dependent options editor, that is used to create a valid set of parameters to be used in exporting. More...
 
std::unique_ptr< ExportProcessorCreateProcessor (int format) const override
 
std::vector< std::string > GetMimeTypes (int) const override
 
bool ParseConfig (int formatIndex, const rapidjson::Value &document, ExportProcessor::Parameters &parameters) const override
 Attempt to parse configuration JSON object and produce a suitable set of parameters. Configuration is format dependent. More...
 
- Public Member Functions inherited from ExportPlugin
 ExportPlugin ()
 
virtual ~ExportPlugin ()
 
virtual int GetFormatCount () const =0
 
virtual FormatInfo GetFormatInfo (int index) const =0
 Returns FormatInfo structure for given index if it's valid, or a default one. FormatInfo::format isn't guaranteed to be unique. More...
 
virtual std::unique_ptr< ExportOptionsEditorCreateOptionsEditor (int formatIndex, ExportOptionsEditor::Listener *listener) const =0
 Creates format-dependent options editor, that is used to create a valid set of parameters to be used in exporting. More...
 
virtual std::vector< std::string > GetMimeTypes (int formatIndex) const
 
virtual bool ParseConfig (int formatIndex, const rapidjson::Value &config, ExportProcessor::Parameters &parameters) const
 Attempt to parse configuration JSON object and produce a suitable set of parameters. Configuration is format dependent. More...
 
virtual bool CheckFileName (wxFileName &filename, int format=0) const
 
virtual std::unique_ptr< ExportProcessorCreateProcessor (int format) const =0
 

Detailed Description

Definition at line 1635 of file ExportMP3.cpp.

Constructor & Destructor Documentation

◆ ExportMP3()

ExportMP3::ExportMP3 ( )
default

Member Function Documentation

◆ CheckFileName()

bool ExportMP3::CheckFileName ( wxFileName &  filename,
int  format 
) const
overridevirtual

Reimplemented from ExportPlugin.

Definition at line 1757 of file ExportMP3.cpp.

1758{
1759#ifndef DISABLE_DYNAMIC_LOADING_LAME
1760 MP3Exporter exporter;
1761
1762 if (!exporter.LoadLibrary(wxTheApp->GetTopWindow(), MP3Exporter::Maybe)) {
1763 BasicUI::ShowMessageBox(XO("Could not open MP3 encoding library!"),
1765 .IconStyle(BasicUI::Icon::Error)
1766 .Caption(XO("Error")));
1767 gPrefs->Write(wxT("/MP3/MP3LibPath"), wxString(wxT("")));
1768 gPrefs->Flush();
1769
1770 return false;
1771 }
1772#endif // DISABLE_DYNAMIC_LOADING_LAME
1773
1774 return true;
1775}
wxT("CloseDown"))
XO("Cut/Copy/Paste")
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
Class used to export MP3 files.
Definition: ExportMP3.cpp:695
bool LoadLibrary(wxWindow *parent, AskUser askuser)
Definition: ExportMP3.cpp:888
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
Definition: BasicUI.h:277

References BasicUI::Error, audacity::BasicSettings::Flush(), gPrefs, MP3Exporter::LoadLibrary(), MP3Exporter::Maybe, BasicUI::ShowMessageBox(), audacity::BasicSettings::Write(), wxT(), and XO().

Here is the call graph for this function:

◆ CreateOptionsEditor()

std::unique_ptr< ExportOptionsEditor > ExportMP3::CreateOptionsEditor ( int  formatIndex,
ExportOptionsEditor::Listener listener 
) const
overridevirtual

Creates format-dependent options editor, that is used to create a valid set of parameters to be used in exporting.

Parameters
listenerOption listener object that could be used by the editor to report on option changes.

Implements ExportPlugin.

Definition at line 1672 of file ExportMP3.cpp.

1673{
1674 return std::make_unique<MP3ExportOptionsEditor>(listener);
1675}

◆ CreateProcessor()

std::unique_ptr< ExportProcessor > ExportMP3::CreateProcessor ( int  format) const
overridevirtual
Parameters
formatControl which of the multiple formats this exporter is capable of exporting should be used. Used where a single export plug-in handles a number of related formats, but they have separate entries in the Format drop-down list box. For example, the options to export to "Other PCM", "AIFF 16 Bit" and "WAV 16 Bit" are all the same libsndfile export plug-in, but with subformat set to 0, 1, and 2 respectively.

Implements ExportPlugin.

Definition at line 1677 of file ExportMP3.cpp.

1678{
1679 return std::make_unique<MP3ExportProcessor>();
1680}

◆ GetFormatCount()

int ExportMP3::GetFormatCount ( ) const
overridevirtual

Implements ExportPlugin.

Definition at line 1659 of file ExportMP3.cpp.

1660{
1661 return 1;
1662}

◆ GetFormatInfo()

FormatInfo ExportMP3::GetFormatInfo ( int  index) const
overridevirtual

Returns FormatInfo structure for given index if it's valid, or a default one. FormatInfo::format isn't guaranteed to be unique.

Parameters
indexShould not exceed the number of formats provided by GetFormatCount()

Implements ExportPlugin.

Definition at line 1664 of file ExportMP3.cpp.

1665{
1666 return {
1667 wxT("MP3"), XO("MP3 Files"), { wxT("mp3") }, 2u, true
1668 };
1669}

References wxT(), and XO().

Here is the call graph for this function:

◆ GetMimeTypes()

std::vector< std::string > ExportMP3::GetMimeTypes ( int  formatIndex) const
overridevirtual
Returns
Mime type(s) supported by the format.

Reimplemented from ExportPlugin.

Definition at line 1682 of file ExportMP3.cpp.

1683{
1684 return { "audio/mpeg" };
1685}

◆ ParseConfig()

bool ExportMP3::ParseConfig ( int  formatIndex,
const rapidjson::Value &  config,
ExportProcessor::Parameters parameters 
) const
overridevirtual

Attempt to parse configuration JSON object and produce a suitable set of parameters. Configuration is format dependent.

Parameters
formatIndexInternal format index
configConfiguration JSON object
parametersWhere to put parameters
Returns
Whether the parsing was successful

Reimplemented from ExportPlugin.

Definition at line 1687 of file ExportMP3.cpp.

1690{
1691 if (!document.IsObject())
1692 return false;
1693
1694 MP3OptionID qualityMode;
1695
1696 if (document.HasMember("mode"))
1697 {
1698 auto& mode = document["mode"];
1699 if (!mode.IsString())
1700 return false;
1701
1702 auto value = mode.GetString();
1703
1704 if (value == std::string_view { "SET" })
1705 qualityMode = MP3OptionIDQualitySET;
1706 else if (value == std::string_view { "VBR" })
1707 qualityMode = MP3OptionIDQualityVBR;
1708 else if (value == std::string_view { "ABR" })
1709 qualityMode = MP3OptionIDQualityABR;
1710 else if (value == std::string_view { "CBR" })
1711 qualityMode = MP3OptionIDQualityCBR;
1712 else
1713 return false;
1714
1715 parameters.push_back(std::make_tuple(MP3OptionIDMode, value));
1716 }
1717 else
1718 return false;
1719
1720 if (document.HasMember("quality"))
1721 {
1722 auto& qualityMember = document["quality"];
1723
1724 if (!qualityMember.IsInt())
1725 return false;
1726
1727 const auto quality = qualityMember.GetInt();
1728
1729 if (qualityMode == MP3OptionIDQualitySET && (quality < 0 || quality > 3))
1730 return false;
1731 else if (
1732 qualityMode == MP3OptionIDQualityVBR && (quality < 0 || quality > 9))
1733 return false;
1734 else if (
1735 qualityMode == MP3OptionIDQualityABR &&
1736 std::find(
1737 fixRateValues.begin(), fixRateValues.end(),
1738 ExportValue { quality }) ==
1739 fixRateValues.end())
1740 return false;
1741 else if (
1742 qualityMode == MP3OptionIDQualityCBR &&
1743 std::find(
1744 fixRateValues.begin(), fixRateValues.end(),
1745 ExportValue { quality }) ==
1746 fixRateValues.end())
1747 return false;
1748
1749 parameters.push_back(std::make_tuple(qualityMode, quality));
1750 }
1751 else
1752 return false;
1753
1754 return true;
1755}
static const std::vector< ExportValue > fixRateValues
Definition: ExportMP3.cpp:146
MP3OptionID
Definition: ExportMP3.cpp:213
@ MP3OptionIDQualityABR
Definition: ExportMP3.cpp:217
@ MP3OptionIDQualityVBR
Definition: ExportMP3.cpp:216
@ MP3OptionIDQualityCBR
Definition: ExportMP3.cpp:218
@ MP3OptionIDQualitySET
Definition: ExportMP3.cpp:215
@ MP3OptionIDMode
Definition: ExportMP3.cpp:214
std::variant< bool, int, double, std::string > ExportValue
A type of option values (parameters) used by exporting plugins.
Definition: ExportTypes.h:38

References fixRateValues, MP3OptionIDMode, MP3OptionIDQualityABR, MP3OptionIDQualityCBR, MP3OptionIDQualitySET, and MP3OptionIDQualityVBR.


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