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 "Mix.h"
#include "Prefs.h"
#include "Tags.h"
#include "Track.h"
#include "HelpSystem.h"
#include "wxFileNameWrapper.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 "ProjectWindows.h"
#include <wx/frame.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 475 of file ExportMP3.cpp.

◆ ID_DLOAD

#define ID_DLOAD   5001

Definition at line 476 of file ExportMP3.cpp.

Typedef Documentation

◆ beVersion_t

typedef void beVersion_t(be_version *)

Definition at line 691 of file ExportMP3.cpp.

◆ beWriteInfoTag_t

typedef unsigned long beWriteInfoTag_t(lame_global_flags *, char *)

Definition at line 659 of file ExportMP3.cpp.

◆ get_lame_version_t

typedef const char * get_lame_version_t(void)

Definition at line 613 of file ExportMP3.cpp.

◆ lame_close_t

typedef int lame_close_t(lame_global_flags *)

Definition at line 635 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 615 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 623 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 630 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 650 of file ExportMP3.cpp.

◆ lame_init_params_t

typedef int lame_init_params_t(lame_global_flags *)

Definition at line 612 of file ExportMP3.cpp.

◆ lame_init_t

typedef lame_global_flags * lame_init_t(void)

Definition at line 611 of file ExportMP3.cpp.

◆ lame_mp3_tags_fid_t

typedef void lame_mp3_tags_fid_t(lame_global_flags *, FILE *)

Definition at line 651 of file ExportMP3.cpp.

◆ lame_set_brate_t

typedef int lame_set_brate_t(lame_global_flags *, int)

Definition at line 641 of file ExportMP3.cpp.

◆ lame_set_bWriteVbrTag_t

typedef int lame_set_bWriteVbrTag_t(lame_global_flags *, int)

Definition at line 649 of file ExportMP3.cpp.

◆ lame_set_disable_reservoir_t

typedef int lame_set_disable_reservoir_t(lame_global_flags *, int)

Definition at line 648 of file ExportMP3.cpp.

◆ lame_set_error_protection_t

typedef int lame_set_error_protection_t(lame_global_flags *, int)

Definition at line 647 of file ExportMP3.cpp.

◆ lame_set_in_samplerate_t

typedef int lame_set_in_samplerate_t(lame_global_flags *, int)

Definition at line 637 of file ExportMP3.cpp.

◆ lame_set_mode_t

typedef int lame_set_mode_t(lame_global_flags *, MPEG_mode)

Definition at line 645 of file ExportMP3.cpp.

◆ lame_set_num_channels_t

typedef int lame_set_num_channels_t(lame_global_flags *, int)

Definition at line 639 of file ExportMP3.cpp.

◆ lame_set_out_samplerate_t

typedef int lame_set_out_samplerate_t(lame_global_flags *, int)

Definition at line 638 of file ExportMP3.cpp.

◆ lame_set_preset_t

typedef int lame_set_preset_t(lame_global_flags *, int)

Definition at line 646 of file ExportMP3.cpp.

◆ lame_set_quality_t

typedef int lame_set_quality_t(lame_global_flags *, int)

Definition at line 640 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 644 of file ExportMP3.cpp.

◆ lame_set_VBR_q_t

typedef int lame_set_VBR_q_t(lame_global_flags *, int)

Definition at line 643 of file ExportMP3.cpp.

◆ lame_set_VBR_t

typedef int lame_set_VBR_t(lame_global_flags *, vbr_mode)

Definition at line 642 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 110 of file ExportMP3.cpp.

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

◆ MP3OptionID

enum MP3OptionID : int
Enumerator
MP3OptionIDMode 
MP3OptionIDQualitySET 
MP3OptionIDQualityVBR 
MP3OptionIDQualityABR 
MP3OptionIDQualityCBR 

Definition at line 213 of file ExportMP3.cpp.

213 : int {
214 MP3OptionIDMode = 0,
219};
@ 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

Function Documentation

◆ GetMP3Version()

TranslatableString GetMP3Version ( wxWindow *  parent,
bool  prompt 
)

Definition at line 2243 of file ExportMP3.cpp.

2244{
2245 MP3Exporter exporter;
2246 auto versionString = XO("MP3 export library not found");
2247
2248#ifndef DISABLE_DYNAMIC_LOADING_LAME
2249 if (prompt) {
2250 exporter.FindLibrary(parent);
2251 }
2252
2253 if (exporter.LoadLibrary(parent, prompt ? MP3Exporter::Yes : MP3Exporter::No)) {
2254#endif // DISABLE_DYNAMIC_LOADING_LAME
2255 versionString = Verbatim( exporter.GetLibraryVersion() );
2256#ifdef MP3_EXPORT_BUILT_IN
2257 versionString.Join( XO("(Built-in)"), " " );
2258#endif
2259
2260#ifndef DISABLE_DYNAMIC_LOADING_LAME
2261 }
2262#endif // DISABLE_DYNAMIC_LOADING_LAME
2263
2264 return versionString;
2265}
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:695
wxString GetLibraryVersion()
Definition: ExportMP3.cpp:1161
bool FindLibrary(wxWindow *parent)
Definition: ExportMP3.cpp:853
bool LoadLibrary(wxWindow *parent, AskUser askuser)
Definition: ExportMP3.cpp:888

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

123{ 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:123

Definition at line 125 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 146 of file ExportMP3.cpp.

Referenced by ExportMP3::ParseConfig().

◆ MP3Options

const std::initializer_list<ExportOption> MP3Options

Definition at line 222 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 201 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("Insane, 320 kbps"),
XO("Extreme, 220-260 kbps"),
XO("Standard, 170-210 kbps"),
XO("Medium, 145-185 kbps"),
}

Definition at line 185 of file ExportMP3.cpp.

◆ setRateNamesShort

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

Definition at line 193 of file ExportMP3.cpp.

Referenced by MP3ExportProcessor::Initialize().

◆ sRegisteredPlugin

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

Definition at line 2235 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 167 of file ExportMP3.cpp.

Referenced by MP3ExportProcessor::Initialize().