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/choice.h>
#include <wx/checkbox.h>
#include <wx/dynlib.h>
#include <wx/ffile.h>
#include <wx/intl.h>
#include <wx/log.h>
#include <wx/mimetype.h>
#include <wx/radiobut.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/timer.h>
#include <wx/utils.h>
#include <wx/window.h>
#include "FileNames.h"
#include "float_cast.h"
#include "Mix.h"
#include "Prefs.h"
#include "ProjectRate.h"
#include "../ProjectSettings.h"
#include "../ProjectWindow.h"
#include "../SelectFile.h"
#include "../ShuttleGui.h"
#include "../Tags.h"
#include "Track.h"
#include "../widgets/HelpSystem.h"
#include "../widgets/AudacityMessageBox.h"
#include "../widgets/ProgressDialog.h"
#include "wxFileNameWrapper.h"
#include "Project.h"
#include "Export.h"
#include <lame/lame.h>
Include dependency graph for ExportMP3.cpp:

Go to the source code of this file.

Classes

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

Namespaces

namespace  anonymous_namespace{ExportMP3.cpp}
 

Macros

#define ID_SET   7000
 
#define ID_VBR   7001
 
#define ID_ABR   7002
 
#define ID_CBR   7003
 
#define ID_QUALITY   7004
 
#define ID_MONO   7005
 
#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  MP3ChannelMode : unsigned { CHANNEL_JOINT = 0 , CHANNEL_STEREO = 1 , CHANNEL_MONO = 2 }
 
enum  : int {
  QUALITY_2 = 2 , PRESET_INSANE = 0 , PRESET_EXTREME = 1 , PRESET_STANDARD = 2 ,
  PRESET_MEDIUM = 3
}
 

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< int > fixRateValues
 
static const TranslatableStrings varRateNames
 
static const TranslatableStrings setRateNames
 
static const TranslatableStrings setRateNamesShort
 
static const std::vector< int > sampRates
 
EnumSetting< MP3RateModeMP3RateModeSetting
 
static EnumSetting< MP3ChannelModeMP3ChannelModeSetting
 
static Exporter::RegisteredExportPlugin sRegisteredPlugin
 

Macro Definition Documentation

◆ ID_ABR

#define ID_ABR   7002

Definition at line 222 of file ExportMP3.cpp.

◆ ID_BROWSE

#define ID_BROWSE   5000

Definition at line 582 of file ExportMP3.cpp.

◆ ID_CBR

#define ID_CBR   7003

Definition at line 223 of file ExportMP3.cpp.

◆ ID_DLOAD

#define ID_DLOAD   5001

Definition at line 583 of file ExportMP3.cpp.

◆ ID_MONO

#define ID_MONO   7005

Definition at line 225 of file ExportMP3.cpp.

◆ ID_QUALITY

#define ID_QUALITY   7004

Definition at line 224 of file ExportMP3.cpp.

◆ ID_SET

#define ID_SET   7000

Definition at line 220 of file ExportMP3.cpp.

◆ ID_VBR

#define ID_VBR   7001

Definition at line 221 of file ExportMP3.cpp.

Typedef Documentation

◆ beVersion_t

typedef void beVersion_t(be_version *)

Definition at line 798 of file ExportMP3.cpp.

◆ beWriteInfoTag_t

typedef unsigned long beWriteInfoTag_t(lame_global_flags *, char *)

Definition at line 766 of file ExportMP3.cpp.

◆ get_lame_version_t

typedef const char * get_lame_version_t(void)

Definition at line 720 of file ExportMP3.cpp.

◆ lame_close_t

typedef int lame_close_t(lame_global_flags *)

Definition at line 742 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 722 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 730 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 737 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 757 of file ExportMP3.cpp.

◆ lame_init_params_t

typedef int lame_init_params_t(lame_global_flags *)

Definition at line 719 of file ExportMP3.cpp.

◆ lame_init_t

typedef lame_global_flags * lame_init_t(void)

Definition at line 718 of file ExportMP3.cpp.

◆ lame_mp3_tags_fid_t

typedef void lame_mp3_tags_fid_t(lame_global_flags *, FILE *)

Definition at line 758 of file ExportMP3.cpp.

◆ lame_set_brate_t

typedef int lame_set_brate_t(lame_global_flags *, int)

Definition at line 748 of file ExportMP3.cpp.

◆ lame_set_bWriteVbrTag_t

typedef int lame_set_bWriteVbrTag_t(lame_global_flags *, int)

Definition at line 756 of file ExportMP3.cpp.

◆ lame_set_disable_reservoir_t

typedef int lame_set_disable_reservoir_t(lame_global_flags *, int)

Definition at line 755 of file ExportMP3.cpp.

◆ lame_set_error_protection_t

typedef int lame_set_error_protection_t(lame_global_flags *, int)

Definition at line 754 of file ExportMP3.cpp.

◆ lame_set_in_samplerate_t

typedef int lame_set_in_samplerate_t(lame_global_flags *, int)

Definition at line 744 of file ExportMP3.cpp.

◆ lame_set_mode_t

typedef int lame_set_mode_t(lame_global_flags *, MPEG_mode)

Definition at line 752 of file ExportMP3.cpp.

◆ lame_set_num_channels_t

typedef int lame_set_num_channels_t(lame_global_flags *, int)

Definition at line 746 of file ExportMP3.cpp.

◆ lame_set_out_samplerate_t

typedef int lame_set_out_samplerate_t(lame_global_flags *, int)

Definition at line 745 of file ExportMP3.cpp.

◆ lame_set_preset_t

typedef int lame_set_preset_t(lame_global_flags *, int)

Definition at line 753 of file ExportMP3.cpp.

◆ lame_set_quality_t

typedef int lame_set_quality_t(lame_global_flags *, int)

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

◆ lame_set_VBR_q_t

typedef int lame_set_VBR_q_t(lame_global_flags *, int)

Definition at line 750 of file ExportMP3.cpp.

◆ lame_set_VBR_t

typedef int lame_set_VBR_t(lame_global_flags *, vbr_mode)

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

117 : int {
118 QUALITY_2 = 2,
119
120 //ROUTINE_FAST = 0,
121 //ROUTINE_STANDARD = 1,
122
123 PRESET_INSANE = 0,
124 PRESET_EXTREME = 1,
125 PRESET_STANDARD = 2,
126 PRESET_MEDIUM = 3,
127};
@ QUALITY_2
Definition: ExportMP3.cpp:118
@ PRESET_EXTREME
Definition: ExportMP3.cpp:124
@ PRESET_INSANE
Definition: ExportMP3.cpp:123
@ PRESET_STANDARD
Definition: ExportMP3.cpp:125
@ PRESET_MEDIUM
Definition: ExportMP3.cpp:126

◆ MP3ChannelMode

enum MP3ChannelMode : unsigned
Enumerator
CHANNEL_JOINT 
CHANNEL_STEREO 
CHANNEL_MONO 

Definition at line 111 of file ExportMP3.cpp.

111 : unsigned {
112 CHANNEL_JOINT = 0,
113 CHANNEL_STEREO = 1,
114 CHANNEL_MONO = 2,
115};
@ CHANNEL_MONO
Definition: ExportMP3.cpp:114
@ CHANNEL_JOINT
Definition: ExportMP3.cpp:112
@ CHANNEL_STEREO
Definition: ExportMP3.cpp:113

Function Documentation

◆ GetMP3Version()

TranslatableString GetMP3Version ( wxWindow *  parent,
bool  prompt 
)

Definition at line 2255 of file ExportMP3.cpp.

2256{
2257 MP3Exporter exporter;
2258 auto versionString = XO("MP3 export library not found");
2259
2260#ifndef DISABLE_DYNAMIC_LOADING_LAME
2261 if (prompt) {
2262 exporter.FindLibrary(parent);
2263 }
2264
2265 if (exporter.LoadLibrary(parent, prompt ? MP3Exporter::Yes : MP3Exporter::No)) {
2266#endif // DISABLE_DYNAMIC_LOADING_LAME
2267 versionString = Verbatim( exporter.GetLibraryVersion() );
2268#ifdef MP3_EXPORT_BUILT_IN
2269 versionString.Join( XO("(Built-in)"), " " );
2270#endif
2271
2272#ifndef DISABLE_DYNAMIC_LOADING_LAME
2273 }
2274#endif // DISABLE_DYNAMIC_LOADING_LAME
2275
2276 return versionString;
2277}
#define XO(s)
Definition: Internat.h:31
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:802
wxString GetLibraryVersion()
Definition: ExportMP3.cpp:1277
bool FindLibrary(wxWindow *parent)
Definition: ExportMP3.cpp:963
bool LoadLibrary(wxWindow *parent, AskUser askuser)
Definition: ExportMP3.cpp:998

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

Referenced by LibraryPrefs::SetMP3VersionText().

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

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

References XO.

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:130

Definition at line 132 of file ExportMP3.cpp.

Referenced by ExportMP3Options::OnABR(), ExportMP3Options::OnCBR(), and ExportMP3Options::PopulateOrExchange().

◆ fixRateValues

const std::vector<int> 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 153 of file ExportMP3.cpp.

Referenced by ExportMP3::Export(), ExportMP3Options::OnABR(), ExportMP3Options::OnCBR(), ExportMP3Options::OnQuality(), and ExportMP3Options::PopulateOrExchange().

◆ MP3ChannelModeSetting

EnumSetting< MP3ChannelMode > MP3ChannelModeSetting
static
Initial value:
{
wxT("/FileFormats/MP3ChannelModeChoice"),
{
EnumValueSymbol{ wxT("JOINT"), XXO("Joint Stereo") },
EnumValueSymbol{ wxT("STEREO"), XXO("Stereo") },
},
0,
{
},
wxT("/FileFormats/MP3ChannelMode"),
}
#define XXO(s)
Definition: Internat.h:44
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...

Definition at line 314 of file ExportMP3.cpp.

Referenced by ExportMP3::Export(), and ExportMP3Options::PopulateOrExchange().

◆ MP3RateModeSetting

EnumSetting< MP3RateMode > MP3RateModeSetting
Initial value:
{
wxT("/FileFormats/MP3RateModeChoice"),
{
{ wxT("SET"), XXO("Preset") },
{ wxT("VBR"), XXO("Variable") },
{ wxT("ABR"), XXO("Average") },
{ wxT("CBR"), XXO("Constant") },
},
0,
{
},
wxT("/FileFormats/MP3RateMode"),
}
@ MODE_SET
Definition: ExportMP3.h:19
@ MODE_ABR
Definition: ExportMP3.h:21
@ MODE_VBR
Definition: ExportMP3.h:20
@ MODE_CBR
Definition: ExportMP3.h:22

Definition at line 297 of file ExportMP3.cpp.

Referenced by ExportMP3::Export(), and ExportMP3Options::PopulateOrExchange().

◆ sampRates

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

Definition at line 208 of file ExportMP3.cpp.

Referenced by ExportMP3::AskResample(), ExportFFmpeg::AskResample(), ExportFFmpeg::CheckSampleRate(), and ExportMP3::Export().

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

Referenced by ExportMP3::Export(), ExportMP3Options::OnSET(), and ExportMP3Options::PopulateOrExchange().

◆ setRateNamesShort

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

Definition at line 200 of file ExportMP3.cpp.

Referenced by ExportMP3::Export().

◆ sRegisteredPlugin

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

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

Referenced by ExportMP3::Export(), ExportMP3Options::OnVBR(), and ExportMP3Options::PopulateOrExchange().