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/log.h>
#include <wx/mimetype.h>
#include <wx/radiobut.h>
#include <wx/stattext.h>
#include <wx/textctrl.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 "HelpSystem.h"
#include "AudacityMessageBox.h"
#include "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 219 of file ExportMP3.cpp.

◆ ID_BROWSE

#define ID_BROWSE   5000

Definition at line 581 of file ExportMP3.cpp.

◆ ID_CBR

#define ID_CBR   7003

Definition at line 220 of file ExportMP3.cpp.

◆ ID_DLOAD

#define ID_DLOAD   5001

Definition at line 582 of file ExportMP3.cpp.

◆ ID_MONO

#define ID_MONO   7005

Definition at line 222 of file ExportMP3.cpp.

◆ ID_QUALITY

#define ID_QUALITY   7004

Definition at line 221 of file ExportMP3.cpp.

◆ ID_SET

#define ID_SET   7000

Definition at line 217 of file ExportMP3.cpp.

◆ ID_VBR

#define ID_VBR   7001

Definition at line 218 of file ExportMP3.cpp.

Typedef Documentation

◆ beVersion_t

typedef void beVersion_t(be_version *)

Definition at line 797 of file ExportMP3.cpp.

◆ beWriteInfoTag_t

typedef unsigned long beWriteInfoTag_t(lame_global_flags *, char *)

Definition at line 765 of file ExportMP3.cpp.

◆ get_lame_version_t

typedef const char * get_lame_version_t(void)

Definition at line 719 of file ExportMP3.cpp.

◆ lame_close_t

typedef int lame_close_t(lame_global_flags *)

Definition at line 741 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 721 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 729 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 736 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 756 of file ExportMP3.cpp.

◆ lame_init_params_t

typedef int lame_init_params_t(lame_global_flags *)

Definition at line 718 of file ExportMP3.cpp.

◆ lame_init_t

typedef lame_global_flags * lame_init_t(void)

Definition at line 717 of file ExportMP3.cpp.

◆ lame_mp3_tags_fid_t

typedef void lame_mp3_tags_fid_t(lame_global_flags *, FILE *)

Definition at line 757 of file ExportMP3.cpp.

◆ lame_set_brate_t

typedef int lame_set_brate_t(lame_global_flags *, int)

Definition at line 747 of file ExportMP3.cpp.

◆ lame_set_bWriteVbrTag_t

typedef int lame_set_bWriteVbrTag_t(lame_global_flags *, int)

Definition at line 755 of file ExportMP3.cpp.

◆ lame_set_disable_reservoir_t

typedef int lame_set_disable_reservoir_t(lame_global_flags *, int)

Definition at line 754 of file ExportMP3.cpp.

◆ lame_set_error_protection_t

typedef int lame_set_error_protection_t(lame_global_flags *, int)

Definition at line 753 of file ExportMP3.cpp.

◆ lame_set_in_samplerate_t

typedef int lame_set_in_samplerate_t(lame_global_flags *, int)

Definition at line 743 of file ExportMP3.cpp.

◆ lame_set_mode_t

typedef int lame_set_mode_t(lame_global_flags *, MPEG_mode)

Definition at line 751 of file ExportMP3.cpp.

◆ lame_set_num_channels_t

typedef int lame_set_num_channels_t(lame_global_flags *, int)

Definition at line 745 of file ExportMP3.cpp.

◆ lame_set_out_samplerate_t

typedef int lame_set_out_samplerate_t(lame_global_flags *, int)

Definition at line 744 of file ExportMP3.cpp.

◆ lame_set_preset_t

typedef int lame_set_preset_t(lame_global_flags *, int)

Definition at line 752 of file ExportMP3.cpp.

◆ lame_set_quality_t

typedef int lame_set_quality_t(lame_global_flags *, int)

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

◆ lame_set_VBR_q_t

typedef int lame_set_VBR_q_t(lame_global_flags *, int)

Definition at line 749 of file ExportMP3.cpp.

◆ lame_set_VBR_t

typedef int lame_set_VBR_t(lame_global_flags *, vbr_mode)

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

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

◆ MP3ChannelMode

enum MP3ChannelMode : unsigned
Enumerator
CHANNEL_JOINT 
CHANNEL_STEREO 
CHANNEL_MONO 

Definition at line 108 of file ExportMP3.cpp.

108 : unsigned {
109 CHANNEL_JOINT = 0,
110 CHANNEL_STEREO = 1,
111 CHANNEL_MONO = 2,
112};
@ CHANNEL_MONO
Definition: ExportMP3.cpp:111
@ CHANNEL_JOINT
Definition: ExportMP3.cpp:109
@ CHANNEL_STEREO
Definition: ExportMP3.cpp:110

Function Documentation

◆ GetMP3Version()

TranslatableString GetMP3Version ( wxWindow *  parent,
bool  prompt 
)

Definition at line 2252 of file ExportMP3.cpp.

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

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

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

Definition at line 129 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 150 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"),
}
wxT("CloseDown"))
XXO("&Cut/Copy/Paste Toolbar")
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...

Definition at line 311 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 294 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 205 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 189 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 197 of file ExportMP3.cpp.

Referenced by ExportMP3::Export().

◆ sRegisteredPlugin

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

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

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