Audacity 3.2.0
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions | Variables
ExportMP3.cpp File Reference
#include "ExportMP3.h"
#include <wx/app.h>
#include <wx/defs.h>
#include <wx/dynlib.h>
#include <wx/ffile.h>
#include <wx/log.h>
#include <wx/mimetype.h>
#include <wx/textctrl.h>
#include <wx/choice.h>
#include <rapidjson/document.h>
#include "FileNames.h"
#include "float_cast.h"
#include "HelpSystem.h"
#include "Mix.h"
#include "Prefs.h"
#include "Tags.h"
#include "Track.h"
#include "wxFileNameWrapper.h"
#include "wxPanelWrapper.h"
#include "Project.h"
#include "Export.h"
#include "BasicUI.h"
#include <lame/lame.h>
#include "ExportOptionsEditor.h"
#include "ExportPluginHelpers.h"
#include "ExportPluginRegistry.h"
#include "SelectFile.h"
#include "ShuttleGui.h"
Include dependency graph for ExportMP3.cpp:

Go to the source code of this file.

Classes

class  MP3ExportOptionsEditor
 
class  FindDialog
 
struct  be_version
 
class  MP3Exporter
 Class used to export MP3 files. More...
 
class  MP3ExportProcessor
 
class  ExportMP3
 

Namespaces

namespace  anonymous_namespace{ExportMP3.cpp}
 

Macros

#define ID_BROWSE   5000
 
#define ID_DLOAD   5001
 

Typedefs

typedef lame_global_flagslame_init_t(void)
 
typedef int lame_init_params_t(lame_global_flags *)
 
typedef const char * get_lame_version_t(void)
 
typedef int CDECL lame_encode_buffer_ieee_float_t(lame_t gfp, const float pcm_l[], const float pcm_r[], const int nsamples, unsigned char *mp3buf, const int mp3buf_size)
 
typedef int CDECL lame_encode_buffer_interleaved_ieee_float_t(lame_t gfp, const float pcm[], const int nsamples, unsigned char *mp3buf, const int mp3buf_size)
 
typedef int lame_encode_flush_t(lame_global_flags *gf, unsigned char *mp3buf, int size)
 
typedef int lame_close_t(lame_global_flags *)
 
typedef int lame_set_in_samplerate_t(lame_global_flags *, int)
 
typedef int lame_set_out_samplerate_t(lame_global_flags *, int)
 
typedef int lame_set_num_channels_t(lame_global_flags *, int)
 
typedef int lame_set_quality_t(lame_global_flags *, int)
 
typedef int lame_set_brate_t(lame_global_flags *, int)
 
typedef int lame_set_VBR_t(lame_global_flags *, vbr_mode)
 
typedef int lame_set_VBR_q_t(lame_global_flags *, int)
 
typedef int lame_set_VBR_min_bitrate_kbps_t(lame_global_flags *, int)
 
typedef int lame_set_mode_t(lame_global_flags *, MPEG_mode)
 
typedef int lame_set_preset_t(lame_global_flags *, int)
 
typedef int lame_set_error_protection_t(lame_global_flags *, int)
 
typedef int lame_set_disable_reservoir_t(lame_global_flags *, int)
 
typedef int lame_set_bWriteVbrTag_t(lame_global_flags *, int)
 
typedef size_t lame_get_lametag_frame_t(const lame_global_flags *, unsigned char *buffer, size_t size)
 
typedef void lame_mp3_tags_fid_t(lame_global_flags *, FILE *)
 
typedef unsigned long beWriteInfoTag_t(lame_global_flags *, char *)
 
typedef void beVersion_t(be_version *)
 

Enumerations

enum  : int {
  QUALITY_2 = 2 , PRESET_INSANE = 0 , PRESET_EXTREME = 1 , PRESET_STANDARD = 2 ,
  PRESET_MEDIUM = 3
}
 
enum  MP3OptionID : int {
  MP3OptionIDMode = 0 , MP3OptionIDQualitySET , MP3OptionIDQualityVBR , MP3OptionIDQualityABR ,
  MP3OptionIDQualityCBR
}
 

Functions

TranslatableString n_kbps (int n)
 
int anonymous_namespace{ExportMP3.cpp}::ValidateValue (int nValues, int value, int defaultValue)
 
int anonymous_namespace{ExportMP3.cpp}::ValidateValue (const std::vector< int > &values, int value, int defaultValue)
 
int anonymous_namespace{ExportMP3.cpp}::ValidateIndex (const std::vector< int > &values, int value, int defaultIndex)
 
TranslatableString GetMP3Version (wxWindow *parent, bool prompt)
 

Variables

static const TranslatableStrings fixRateNames
 
static const std::vector< ExportValuefixRateValues
 
static const TranslatableStrings varRateNames
 
static const TranslatableStrings setRateNames
 
static const TranslatableStrings setRateNamesShort
 
static const std::vector< int > sampRates
 
const std::initializer_list< ExportOptionMP3Options
 
static ExportPluginRegistry::RegisteredPlugin sRegisteredPlugin
 

Macro Definition Documentation

◆ ID_BROWSE

#define ID_BROWSE   5000

Definition at line 471 of file ExportMP3.cpp.

◆ ID_DLOAD

#define ID_DLOAD   5001

Definition at line 472 of file ExportMP3.cpp.

Typedef Documentation

◆ beVersion_t

typedef void beVersion_t(be_version *)

Definition at line 687 of file ExportMP3.cpp.

◆ beWriteInfoTag_t

typedef unsigned long beWriteInfoTag_t(lame_global_flags *, char *)

Definition at line 655 of file ExportMP3.cpp.

◆ get_lame_version_t

typedef const char * get_lame_version_t(void)

Definition at line 609 of file ExportMP3.cpp.

◆ lame_close_t

typedef int lame_close_t(lame_global_flags *)

Definition at line 631 of file ExportMP3.cpp.

◆ lame_encode_buffer_ieee_float_t

typedef int CDECL lame_encode_buffer_ieee_float_t(lame_t gfp, const float pcm_l[], const float pcm_r[], const int nsamples, unsigned char *mp3buf, const int mp3buf_size)

Definition at line 611 of file ExportMP3.cpp.

◆ lame_encode_buffer_interleaved_ieee_float_t

typedef int CDECL lame_encode_buffer_interleaved_ieee_float_t(lame_t gfp, const float pcm[], const int nsamples, unsigned char *mp3buf, const int mp3buf_size)

Definition at line 619 of file ExportMP3.cpp.

◆ lame_encode_flush_t

typedef int lame_encode_flush_t(lame_global_flags *gf, unsigned char *mp3buf, int size)

Definition at line 626 of file ExportMP3.cpp.

◆ lame_get_lametag_frame_t

typedef size_t lame_get_lametag_frame_t(const lame_global_flags *, unsigned char *buffer, size_t size)

Definition at line 646 of file ExportMP3.cpp.

◆ lame_init_params_t

typedef int lame_init_params_t(lame_global_flags *)

Definition at line 608 of file ExportMP3.cpp.

◆ lame_init_t

typedef lame_global_flags * lame_init_t(void)

Definition at line 607 of file ExportMP3.cpp.

◆ lame_mp3_tags_fid_t

typedef void lame_mp3_tags_fid_t(lame_global_flags *, FILE *)

Definition at line 647 of file ExportMP3.cpp.

◆ lame_set_brate_t

typedef int lame_set_brate_t(lame_global_flags *, int)

Definition at line 637 of file ExportMP3.cpp.

◆ lame_set_bWriteVbrTag_t

typedef int lame_set_bWriteVbrTag_t(lame_global_flags *, int)

Definition at line 645 of file ExportMP3.cpp.

◆ lame_set_disable_reservoir_t

typedef int lame_set_disable_reservoir_t(lame_global_flags *, int)

Definition at line 644 of file ExportMP3.cpp.

◆ lame_set_error_protection_t

typedef int lame_set_error_protection_t(lame_global_flags *, int)

Definition at line 643 of file ExportMP3.cpp.

◆ lame_set_in_samplerate_t

typedef int lame_set_in_samplerate_t(lame_global_flags *, int)

Definition at line 633 of file ExportMP3.cpp.

◆ lame_set_mode_t

typedef int lame_set_mode_t(lame_global_flags *, MPEG_mode)

Definition at line 641 of file ExportMP3.cpp.

◆ lame_set_num_channels_t

typedef int lame_set_num_channels_t(lame_global_flags *, int)

Definition at line 635 of file ExportMP3.cpp.

◆ lame_set_out_samplerate_t

typedef int lame_set_out_samplerate_t(lame_global_flags *, int)

Definition at line 634 of file ExportMP3.cpp.

◆ lame_set_preset_t

typedef int lame_set_preset_t(lame_global_flags *, int)

Definition at line 642 of file ExportMP3.cpp.

◆ lame_set_quality_t

typedef int lame_set_quality_t(lame_global_flags *, int)

Definition at line 636 of file ExportMP3.cpp.

◆ lame_set_VBR_min_bitrate_kbps_t

typedef int lame_set_VBR_min_bitrate_kbps_t(lame_global_flags *, int)

Definition at line 640 of file ExportMP3.cpp.

◆ lame_set_VBR_q_t

typedef int lame_set_VBR_q_t(lame_global_flags *, int)

Definition at line 639 of file ExportMP3.cpp.

◆ lame_set_VBR_t

typedef int lame_set_VBR_t(lame_global_flags *, vbr_mode)

Definition at line 638 of file ExportMP3.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum : int
Enumerator
QUALITY_2 
PRESET_INSANE 
PRESET_EXTREME 
PRESET_STANDARD 
PRESET_MEDIUM 

Definition at line 108 of file ExportMP3.cpp.

108 : int {
109 QUALITY_2 = 2,
110
111 //ROUTINE_FAST = 0,
112 //ROUTINE_STANDARD = 1,
113
114 PRESET_INSANE = 0,
115 PRESET_EXTREME = 1,
116 PRESET_STANDARD = 2,
117 PRESET_MEDIUM = 3,
118};
@ QUALITY_2
Definition: ExportMP3.cpp:109
@ PRESET_EXTREME
Definition: ExportMP3.cpp:115
@ PRESET_INSANE
Definition: ExportMP3.cpp:114
@ PRESET_STANDARD
Definition: ExportMP3.cpp:116
@ PRESET_MEDIUM
Definition: ExportMP3.cpp:117

◆ MP3OptionID

enum MP3OptionID : int
Enumerator
MP3OptionIDMode 
MP3OptionIDQualitySET 
MP3OptionIDQualityVBR 
MP3OptionIDQualityABR 
MP3OptionIDQualityCBR 

Definition at line 209 of file ExportMP3.cpp.

209 : int {
210 MP3OptionIDMode = 0,
215};
@ 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

Function Documentation

◆ GetMP3Version()

TranslatableString GetMP3Version ( wxWindow *  parent,
bool  prompt 
)

Definition at line 2234 of file ExportMP3.cpp.

2235{
2236 MP3Exporter exporter;
2237 auto versionString = XO("MP3 export library not found");
2238
2239#ifndef DISABLE_DYNAMIC_LOADING_LAME
2240 if (prompt) {
2241 exporter.FindLibrary(parent);
2242 }
2243
2244 if (exporter.LoadLibrary(parent, prompt ? MP3Exporter::Yes : MP3Exporter::No)) {
2245#endif // DISABLE_DYNAMIC_LOADING_LAME
2246 versionString = Verbatim( exporter.GetLibraryVersion() );
2247#ifdef MP3_EXPORT_BUILT_IN
2248 versionString.Join( XO("(Built-in)"), " " );
2249#endif
2250
2251#ifndef DISABLE_DYNAMIC_LOADING_LAME
2252 }
2253#endif // DISABLE_DYNAMIC_LOADING_LAME
2254
2255 return versionString;
2256}
XO("Cut/Copy/Paste")
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Class used to export MP3 files.
Definition: ExportMP3.cpp:691
wxString GetLibraryVersion()
Definition: ExportMP3.cpp:1157
bool FindLibrary(wxWindow *parent)
Definition: ExportMP3.cpp:849
bool LoadLibrary(wxWindow *parent, AskUser askuser)
Definition: ExportMP3.cpp:884

References MP3Exporter::FindLibrary(), MP3Exporter::GetLibraryVersion(), MP3Exporter::LoadLibrary(), MP3Exporter::No, Verbatim(), XO(), and MP3Exporter::Yes.

Referenced by anonymous_namespace{MP3Prefs.cpp}::AddControls().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ n_kbps()

TranslatableString n_kbps ( int  n)
inline

Definition at line 121 of file ExportMP3.cpp.

121{ return XO("%d kbps").Format( n ); }

References XO().

Here is the call graph for this function:

Variable Documentation

◆ fixRateNames

const TranslatableStrings fixRateNames
static
Initial value:
{
n_kbps(320),
n_kbps(256),
n_kbps(224),
n_kbps(192),
n_kbps(160),
n_kbps(144),
n_kbps(128),
n_kbps(112),
n_kbps(96),
n_kbps(80),
n_kbps(64),
n_kbps(56),
n_kbps(48),
n_kbps(40),
n_kbps(32),
n_kbps(24),
n_kbps(16),
n_kbps(8),
}
TranslatableString n_kbps(int n)
Definition: ExportMP3.cpp:121

Definition at line 123 of file ExportMP3.cpp.

◆ fixRateValues

const std::vector<ExportValue> fixRateValues
static
Initial value:
{
320,
256,
224,
192,
160,
144,
128,
112,
96,
80,
64,
56,
48,
40,
32,
24,
16,
8,
}

Definition at line 144 of file ExportMP3.cpp.

Referenced by ExportMP3::ParseConfig().

◆ MP3Options

const std::initializer_list<ExportOption> MP3Options

Definition at line 218 of file ExportMP3.cpp.

◆ sampRates

const std::vector< int > sampRates
static
Initial value:
{
8000,
11025,
12000,
16000,
22050,
24000,
32000,
44100,
48000,
}

Definition at line 197 of file ExportMP3.cpp.

Referenced by MP3ExportProcessor::AskResample(), FFmpegExporter::AskResample(), FFmpegExporter::CheckSampleRate(), MP3ExportOptionsEditor::GetSampleRateList(), and MP3ExportProcessor::Initialize().

◆ setRateNames

const TranslatableStrings setRateNames
static
Initial value:
{
XO("Excessive, 320 kbps"),
XO("Extreme, 220-260 kbps"),
XO("Standard, 170-210 kbps"),
XO("Medium, 145-185 kbps"),
}

Definition at line 183 of file ExportMP3.cpp.

◆ setRateNamesShort

const TranslatableStrings setRateNamesShort
static
Initial value:
{
XO("Excessive"),
XO("Extreme"),
XO("Standard"),
XO("Medium"),
}

Definition at line 190 of file ExportMP3.cpp.

Referenced by MP3ExportProcessor::Initialize().

◆ sRegisteredPlugin

ExportPluginRegistry::RegisteredPlugin sRegisteredPlugin
static
Initial value:
{ "MP3",
[]{ return std::make_unique< ExportMP3 >(); }
}

Definition at line 2226 of file ExportMP3.cpp.

◆ varRateNames

const TranslatableStrings varRateNames
static
Initial value:
{
XO("220-260 kbps (Best Quality)"),
XO("200-250 kbps"),
XO("170-210 kbps"),
XO("155-195 kbps"),
XO("145-185 kbps"),
XO("110-150 kbps"),
XO("95-135 kbps"),
XO("80-120 kbps"),
XO("65-105 kbps"),
XO("45-85 kbps (Smaller files)"),
}

Definition at line 165 of file ExportMP3.cpp.

Referenced by MP3ExportProcessor::Initialize().