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 1631 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 1753 of file ExportMP3.cpp.

1754{
1755#ifndef DISABLE_DYNAMIC_LOADING_LAME
1756 MP3Exporter exporter;
1757
1758 if (!exporter.LoadLibrary(wxTheApp->GetTopWindow(), MP3Exporter::Maybe)) {
1759 BasicUI::ShowMessageBox(XO("Could not open MP3 encoding library!"),
1761 .IconStyle(BasicUI::Icon::Error)
1762 .Caption(XO("Error")));
1763 gPrefs->Write(wxT("/MP3/MP3LibPath"), wxString(wxT("")));
1764 gPrefs->Flush();
1765
1766 return false;
1767 }
1768#endif // DISABLE_DYNAMIC_LOADING_LAME
1769
1770 return true;
1771}
wxT("CloseDown"))
XO("Cut/Copy/Paste")
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
Class used to export MP3 files.
Definition: ExportMP3.cpp:691
bool LoadLibrary(wxWindow *parent, AskUser askuser)
Definition: ExportMP3.cpp:884
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:287

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 1668 of file ExportMP3.cpp.

1669{
1670 return std::make_unique<MP3ExportOptionsEditor>(listener);
1671}

◆ 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 1673 of file ExportMP3.cpp.

1674{
1675 return std::make_unique<MP3ExportProcessor>();
1676}

◆ GetFormatCount()

int ExportMP3::GetFormatCount ( ) const
overridevirtual

Implements ExportPlugin.

Definition at line 1655 of file ExportMP3.cpp.

1656{
1657 return 1;
1658}

◆ 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 1660 of file ExportMP3.cpp.

1661{
1662 return {
1663 wxT("MP3"), XO("MP3 Files"), { wxT("mp3") }, 2u, true
1664 };
1665}

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 1678 of file ExportMP3.cpp.

1679{
1680 return { "audio/mpeg" };
1681}

◆ 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 1683 of file ExportMP3.cpp.

1686{
1687 if (!document.IsObject())
1688 return false;
1689
1690 MP3OptionID qualityMode;
1691
1692 if (document.HasMember("mode"))
1693 {
1694 auto& mode = document["mode"];
1695 if (!mode.IsString())
1696 return false;
1697
1698 auto value = mode.GetString();
1699
1700 if (value == std::string_view { "SET" })
1701 qualityMode = MP3OptionIDQualitySET;
1702 else if (value == std::string_view { "VBR" })
1703 qualityMode = MP3OptionIDQualityVBR;
1704 else if (value == std::string_view { "ABR" })
1705 qualityMode = MP3OptionIDQualityABR;
1706 else if (value == std::string_view { "CBR" })
1707 qualityMode = MP3OptionIDQualityCBR;
1708 else
1709 return false;
1710
1711 parameters.push_back(std::make_tuple(MP3OptionIDMode, value));
1712 }
1713 else
1714 return false;
1715
1716 if (document.HasMember("quality"))
1717 {
1718 auto& qualityMember = document["quality"];
1719
1720 if (!qualityMember.IsInt())
1721 return false;
1722
1723 const auto quality = qualityMember.GetInt();
1724
1725 if (qualityMode == MP3OptionIDQualitySET && (quality < 0 || quality > 3))
1726 return false;
1727 else if (
1728 qualityMode == MP3OptionIDQualityVBR && (quality < 0 || quality > 9))
1729 return false;
1730 else if (
1731 qualityMode == MP3OptionIDQualityABR &&
1732 std::find(
1733 fixRateValues.begin(), fixRateValues.end(),
1734 ExportValue { quality }) ==
1735 fixRateValues.end())
1736 return false;
1737 else if (
1738 qualityMode == MP3OptionIDQualityCBR &&
1739 std::find(
1740 fixRateValues.begin(), fixRateValues.end(),
1741 ExportValue { quality }) ==
1742 fixRateValues.end())
1743 return false;
1744
1745 parameters.push_back(std::make_tuple(qualityMode, quality));
1746 }
1747 else
1748 return false;
1749
1750 return true;
1751}
static const std::vector< ExportValue > fixRateValues
Definition: ExportMP3.cpp:144
MP3OptionID
Definition: ExportMP3.cpp:209
@ MP3OptionIDQualityABR
Definition: ExportMP3.cpp:213
@ MP3OptionIDQualityVBR
Definition: ExportMP3.cpp:212
@ MP3OptionIDQualityCBR
Definition: ExportMP3.cpp:214
@ MP3OptionIDQualitySET
Definition: ExportMP3.cpp:211
@ MP3OptionIDMode
Definition: ExportMP3.cpp:210
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: