Audacity 3.2.0
Public Types | Public Member Functions | Private Attributes | Static Private Attributes | List of all members
MP3Exporter Class Reference

Class used to export MP3 files. More...

Collaboration diagram for MP3Exporter:
[legend]

Public Types

enum  AskUser { No , Maybe , Yes }
 

Public Member Functions

 MP3Exporter ()
 
 ~MP3Exporter ()
 
bool FindLibrary (wxWindow *parent)
 
bool LoadLibrary (wxWindow *parent, AskUser askuser)
 
bool ValidLibraryLoaded ()
 
void SetMode (int mode)
 
void SetBitrate (int rate)
 
void SetQuality (int q)
 
bool InitLibrary (wxString libpath)
 
bool InitLibraryInternal ()
 
bool InitLibraryExternal (wxString libpath)
 
void FreeLibrary ()
 
wxString GetLibraryVersion ()
 
wxString GetLibraryName ()
 
wxString GetLibraryPath ()
 
FileNames::FileTypes GetLibraryTypes ()
 
int InitializeStream (unsigned channels, int sampleRate)
 
int GetOutBufferSize ()
 
int EncodeBuffer (float inbuffer[], unsigned char outbuffer[])
 
int EncodeRemainder (float inbuffer[], int nSamples, unsigned char outbuffer[])
 
int EncodeBufferMono (float inbuffer[], unsigned char outbuffer[])
 
int EncodeRemainderMono (float inbuffer[], int nSamples, unsigned char outbuffer[])
 
int FinishStream (unsigned char outbuffer[])
 
void CancelEncoding ()
 
bool PutInfoTag (wxFFile &f, wxFileOffset off)
 

Private Attributes

bool mLibIsExternal
 
wxString mLibPath
 
wxDynamicLibrary lame_lib
 
bool mLibraryLoaded
 
TranslatableString mBladeVersion
 
bool mEncoding
 
int mMode
 
int mBitrate
 
int mQuality
 
lame_init_tlame_init
 
lame_init_params_tlame_init_params
 
lame_encode_buffer_ieee_float_tlame_encode_buffer_ieee_float
 
lame_encode_buffer_interleaved_ieee_float_tlame_encode_buffer_interleaved_ieee_float
 
lame_encode_flush_tlame_encode_flush
 
lame_close_tlame_close
 
get_lame_version_tget_lame_version
 
lame_set_in_samplerate_tlame_set_in_samplerate
 
lame_set_out_samplerate_tlame_set_out_samplerate
 
lame_set_num_channels_tlame_set_num_channels
 
lame_set_quality_tlame_set_quality
 
lame_set_brate_tlame_set_brate
 
lame_set_VBR_tlame_set_VBR
 
lame_set_VBR_q_tlame_set_VBR_q
 
lame_set_VBR_min_bitrate_kbps_tlame_set_VBR_min_bitrate_kbps
 
lame_set_mode_tlame_set_mode
 
lame_set_preset_tlame_set_preset
 
lame_set_error_protection_tlame_set_error_protection
 
lame_set_disable_reservoir_tlame_set_disable_reservoir
 
lame_set_bWriteVbrTag_tlame_set_bWriteVbrTag
 
lame_get_lametag_frame_tlame_get_lametag_frame
 
lame_mp3_tags_fid_tlame_mp3_tags_fid
 
beWriteInfoTag_tbeWriteInfoTag
 
beVersion_tbeVersion
 
lame_global_flagsmGF
 
unsigned char mInfoTagBuf [2880]
 
size_t mInfoTagLen
 

Static Private Attributes

static const int mSamplesPerChunk = 220500
 
static const int mOutBufferSize
 

Detailed Description

Class used to export MP3 files.

Definition at line 694 of file ExportMP3.cpp.

Member Enumeration Documentation

◆ AskUser

Enumerator
No 
Maybe 
Yes 

Definition at line 697 of file ExportMP3.cpp.

698 {
699 No,
700 Maybe,
701 Yes
702 };

Constructor & Destructor Documentation

◆ MP3Exporter()

MP3Exporter::MP3Exporter ( )

Definition at line 815 of file ExportMP3.cpp.

816{
817// We could use #defines rather than this variable.
818// The idea of the variable is that if we wanted, we could allow
819// a dynamic override of the library, e.g. with a newer faster version,
820// or to fix CVEs in the underlying library.
821// for now though the 'variable' is a constant.
822#ifdef MP3_EXPORT_BUILT_IN
823 mLibIsExternal = false;
824#else
825 mLibIsExternal = true;
826#endif
827
828#ifndef DISABLE_DYNAMIC_LOADING_LAME
829 mLibraryLoaded = false;
830#endif // DISABLE_DYNAMIC_LOADING_LAME
831 mEncoding = false;
832 mGF = NULL;
833
834#ifndef DISABLE_DYNAMIC_LOADING_LAME
835 if (gPrefs) {
836 mLibPath = gPrefs->Read(wxT("/MP3/MP3LibPath"), wxT(""));
837 }
838#endif // DISABLE_DYNAMIC_LOADING_LAME
839
840 mBitrate = 128;
842 mMode = MODE_CBR;
843 //mRoutine = ROUTINE_FAST;
844}
wxT("CloseDown"))
@ QUALITY_2
Definition: ExportMP3.cpp:111
@ MODE_CBR
Definition: ExportMP3.h:22
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
bool mLibIsExternal
Definition: ExportMP3.cpp:753
bool mEncoding
Definition: ExportMP3.cpp:765
lame_global_flags * mGF
Definition: ExportMP3.cpp:802
wxString mLibPath
Definition: ExportMP3.cpp:756
bool mLibraryLoaded
Definition: ExportMP3.cpp:758
virtual bool Read(const wxString &key, bool *value) const =0

References gPrefs, mBitrate, mEncoding, mGF, mLibIsExternal, mLibPath, mLibraryLoaded, mMode, MODE_CBR, mQuality, QUALITY_2, audacity::BasicSettings::Read(), and wxT().

Here is the call graph for this function:

◆ ~MP3Exporter()

MP3Exporter::~MP3Exporter ( )

Definition at line 846 of file ExportMP3.cpp.

847{
848 FreeLibrary();
849}
void FreeLibrary()
Definition: ExportMP3.cpp:1147

References FreeLibrary().

Here is the call graph for this function:

Member Function Documentation

◆ CancelEncoding()

void MP3Exporter::CancelEncoding ( )

Definition at line 1341 of file ExportMP3.cpp.

1342{
1343 mEncoding = false;
1344}

References mEncoding.

◆ EncodeBuffer()

int MP3Exporter::EncodeBuffer ( float  inbuffer[],
unsigned char  outbuffer[] 
)

Definition at line 1278 of file ExportMP3.cpp.

1279{
1280 if (!mEncoding) {
1281 return -1;
1282 }
1283
1285 outbuffer, mOutBufferSize);
1286}
static const int mOutBufferSize
Definition: ExportMP3.cpp:807
lame_encode_buffer_interleaved_ieee_float_t * lame_encode_buffer_interleaved_ieee_float
Definition: ExportMP3.cpp:776
static const int mSamplesPerChunk
Definition: ExportMP3.cpp:804

References lame_encode_buffer_interleaved_ieee_float, mEncoding, mGF, mOutBufferSize, and mSamplesPerChunk.

Referenced by MP3ExportProcessor::Process().

Here is the caller graph for this function:

◆ EncodeBufferMono()

int MP3Exporter::EncodeBufferMono ( float  inbuffer[],
unsigned char  outbuffer[] 
)

Definition at line 1299 of file ExportMP3.cpp.

1300{
1301 if (!mEncoding) {
1302 return -1;
1303 }
1304
1305 return lame_encode_buffer_ieee_float(mGF, inbuffer,inbuffer, mSamplesPerChunk,
1306 outbuffer, mOutBufferSize);
1307}
lame_encode_buffer_ieee_float_t * lame_encode_buffer_ieee_float
Definition: ExportMP3.cpp:775

References lame_encode_buffer_ieee_float, mEncoding, mGF, mOutBufferSize, and mSamplesPerChunk.

Referenced by MP3ExportProcessor::Process().

Here is the caller graph for this function:

◆ EncodeRemainder()

int MP3Exporter::EncodeRemainder ( float  inbuffer[],
int  nSamples,
unsigned char  outbuffer[] 
)

Definition at line 1288 of file ExportMP3.cpp.

1290{
1291 if (!mEncoding) {
1292 return -1;
1293 }
1294
1295 return lame_encode_buffer_interleaved_ieee_float(mGF, inbuffer, nSamples, outbuffer,
1297}

References lame_encode_buffer_interleaved_ieee_float, mEncoding, mGF, and mOutBufferSize.

Referenced by MP3ExportProcessor::Process().

Here is the caller graph for this function:

◆ EncodeRemainderMono()

int MP3Exporter::EncodeRemainderMono ( float  inbuffer[],
int  nSamples,
unsigned char  outbuffer[] 
)

Definition at line 1309 of file ExportMP3.cpp.

1311{
1312 if (!mEncoding) {
1313 return -1;
1314 }
1315
1316 return lame_encode_buffer_ieee_float(mGF, inbuffer, inbuffer, nSamples, outbuffer,
1318}

References lame_encode_buffer_ieee_float, mEncoding, mGF, and mOutBufferSize.

Referenced by MP3ExportProcessor::Process().

Here is the caller graph for this function:

◆ FindLibrary()

bool MP3Exporter::FindLibrary ( wxWindow *  parent)

Definition at line 853 of file ExportMP3.cpp.

854{
855 wxString path;
856 wxString name;
857
858 if (!mLibPath.empty()) {
859 wxFileName fn = mLibPath;
860 path = fn.GetPath();
861 name = fn.GetFullName();
862 }
863 else {
864 path = GetLibraryPath();
866 }
867
868 FindDialog fd(parent,
869 path,
870 name,
872
873 if (fd.ShowModal() == wxID_CANCEL) {
874 return false;
875 }
876
877 path = fd.GetLibPath();
878
879 if (!::wxFileExists(path)) {
880 return false;
881 }
882
883 mLibPath = path;
884
885 return (gPrefs->Write(wxT("/MP3/MP3LibPath"), mLibPath) && gPrefs->Flush());
886}
const TranslatableString name
Definition: Distortion.cpp:76
static const auto fn
wxString GetLibraryName()
Definition: ExportMP3.cpp:1397
FileNames::FileTypes GetLibraryTypes()
Definition: ExportMP3.cpp:1402
wxString GetLibraryPath()
Definition: ExportMP3.cpp:1379
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0

References audacity::BasicSettings::Flush(), fn, FindDialog::GetLibPath(), GetLibraryName(), GetLibraryPath(), GetLibraryTypes(), gPrefs, mLibPath, name, audacity::BasicSettings::Write(), and wxT().

Referenced by GetMP3Version(), and LoadLibrary().

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

◆ FinishStream()

int MP3Exporter::FinishStream ( unsigned char  outbuffer[])

Definition at line 1320 of file ExportMP3.cpp.

1321{
1322 if (!mEncoding) {
1323 return -1;
1324 }
1325
1326 mEncoding = false;
1327
1328 int result = lame_encode_flush(mGF, outbuffer, mOutBufferSize);
1329
1330#if defined(DISABLE_DYNAMIC_LOADING_LAME)
1332#else
1335 }
1336#endif
1337
1338 return result;
1339}
unsigned char mInfoTagBuf[2880]
Definition: ExportMP3.cpp:811
size_t mInfoTagLen
Definition: ExportMP3.cpp:812
lame_get_lametag_frame_t * lame_get_lametag_frame
Definition: ExportMP3.cpp:794
lame_encode_flush_t * lame_encode_flush
Definition: ExportMP3.cpp:777

References lame_encode_flush, lame_get_lametag_frame, mEncoding, mGF, mInfoTagBuf, mInfoTagLen, and mOutBufferSize.

Referenced by MP3ExportProcessor::Process().

Here is the caller graph for this function:

◆ FreeLibrary()

void MP3Exporter::FreeLibrary ( )

Definition at line 1147 of file ExportMP3.cpp.

1148{
1149 if (mGF) {
1150 lame_close(mGF);
1151 mGF = NULL;
1152 }
1153
1154#ifndef DISABLE_DYNAMIC_LOADING_LAME
1155 lame_lib.Unload();
1156#endif // DISABLE_DYNAMIC_LOADING_LAME
1157
1158 return;
1159}
wxDynamicLibrary lame_lib
Definition: ExportMP3.cpp:757
lame_close_t * lame_close
Definition: ExportMP3.cpp:778

References lame_close, lame_lib, and mGF.

Referenced by LoadLibrary(), and ~MP3Exporter().

Here is the caller graph for this function:

◆ GetLibraryName()

wxString MP3Exporter::GetLibraryName ( )

Definition at line 1397 of file ExportMP3.cpp.

1398{
1399 return wxT("lame_enc.dll");
1400}

References wxT().

Referenced by FindLibrary(), and LoadLibrary().

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

◆ GetLibraryPath()

wxString MP3Exporter::GetLibraryPath ( )

Definition at line 1379 of file ExportMP3.cpp.

1380{
1381 wxRegKey reg(wxT("HKEY_LOCAL_MACHINE\\Software\\Lame for Audacity"));
1382 wxString path;
1383
1384 if (reg.Exists()) {
1385 wxLogMessage(wxT("LAME registry key exists."));
1386 reg.QueryValue(wxT("InstallPath"), path);
1387 }
1388 else {
1389 wxLogMessage(wxT("LAME registry key does not exist."));
1390 }
1391
1392 wxLogMessage(wxT("Library path is: ") + path);
1393
1394 return path;
1395}
BuiltinCommandsModule::Registration< CompareAudioCommand > reg

References anonymous_namespace{CompareAudioCommand.cpp}::reg, and wxT().

Referenced by FindLibrary(), and LoadLibrary().

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

◆ GetLibraryTypes()

FileNames::FileTypes MP3Exporter::GetLibraryTypes ( )

Definition at line 1402 of file ExportMP3.cpp.

1403{
1404 return {
1405 { XO("Only lame_enc.dll"), { wxT("lame_enc.dll") } },
1408 };
1409}
XO("Cut/Copy/Paste")
FILES_API const FileType AllFiles
Definition: FileNames.h:70
FILES_API const FileType DynamicLibraries
Definition: FileNames.h:72

References FileNames::AllFiles, FileNames::DynamicLibraries, wxT(), and XO().

Referenced by FindLibrary().

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

◆ GetLibraryVersion()

wxString MP3Exporter::GetLibraryVersion ( )

Definition at line 1161 of file ExportMP3.cpp.

1162{
1163#ifndef DISABLE_DYNAMIC_LOADING_LAME
1164 if (!mLibraryLoaded) {
1165 return wxT("");
1166 }
1167#endif // DISABLE_DYNAMIC_LOADING_LAME
1168
1169 return wxString::Format(wxT("LAME %hs"), get_lame_version());
1170}
get_lame_version_t * get_lame_version
Definition: ExportMP3.cpp:779

References get_lame_version, mLibraryLoaded, and wxT().

Referenced by GetMP3Version().

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

◆ GetOutBufferSize()

int MP3Exporter::GetOutBufferSize ( )

Definition at line 1270 of file ExportMP3.cpp.

1271{
1272 if (!mEncoding)
1273 return -1;
1274
1275 return mOutBufferSize;
1276}

References mEncoding, and mOutBufferSize.

Referenced by MP3ExportProcessor::Initialize().

Here is the caller graph for this function:

◆ InitializeStream()

int MP3Exporter::InitializeStream ( unsigned  channels,
int  sampleRate 
)

Definition at line 1172 of file ExportMP3.cpp.

1173{
1174#ifndef DISABLE_DYNAMIC_LOADING_LAME
1175 if (!mLibraryLoaded) {
1176 return -1;
1177 }
1178#endif // DISABLE_DYNAMIC_LOADING_LAME
1179
1180 if (channels > 2) {
1181 return -1;
1182 }
1183
1185 lame_set_num_channels(mGF, channels);
1189 // Add the VbrTag for all types. For ABR/VBR, a Xing tag will be created.
1190 // For CBR, it will be a Lame Info tag.
1192
1193 // Set the VBR quality or ABR/CBR bitrate
1194 switch (mMode) {
1195 case MODE_SET:
1196 {
1197 int preset;
1198
1199 if (mQuality == PRESET_INSANE) {
1200 preset = INSANE;
1201 }
1202 //else if (mRoutine == ROUTINE_FAST) {
1203 else if (mQuality == PRESET_EXTREME) {
1204 preset = EXTREME_FAST;
1205 }
1206 else if (mQuality == PRESET_STANDARD) {
1207 preset = STANDARD_FAST;
1208 }
1209 else {
1210 preset = 1007; // Not defined until 3.96
1211 }
1212 //}
1213 /*
1214 else {
1215 if (mQuality == PRESET_EXTREME) {
1216 preset = EXTREME;
1217 }
1218 else if (mQuality == PRESET_STANDARD) {
1219 preset = STANDARD;
1220 }
1221 else {
1222 preset = 1006; // Not defined until 3.96
1223 }
1224 }
1225 */
1227 }
1228 break;
1229
1230 case MODE_VBR:
1231 lame_set_VBR(mGF, vbr_mtrh );
1233 break;
1234
1235 case MODE_ABR:
1237 break;
1238
1239 default:
1240 lame_set_VBR(mGF, vbr_off);
1242 break;
1243 }
1244
1245 // Set the channel mode
1246 MPEG_mode mode;
1247
1248 if (channels == 1)
1249 mode = MONO;
1250 else
1251 mode = JOINT_STEREO;
1252
1253 lame_set_mode(mGF, mode);
1254
1255 int rc = lame_init_params(mGF);
1256 if (rc < 0) {
1257 return rc;
1258 }
1259
1260#if 0
1261 dump_config(mGF);
1262#endif
1263
1264 mInfoTagLen = 0;
1265 mEncoding = true;
1266
1267 return mSamplesPerChunk;
1268}
@ PRESET_EXTREME
Definition: ExportMP3.cpp:117
@ PRESET_INSANE
Definition: ExportMP3.cpp:116
@ PRESET_STANDARD
Definition: ExportMP3.cpp:118
@ MODE_SET
Definition: ExportMP3.h:19
@ MODE_ABR
Definition: ExportMP3.h:21
@ MODE_VBR
Definition: ExportMP3.h:20
EffectReverbSettings preset
Definition: Reverb.cpp:44
lame_set_VBR_q_t * lame_set_VBR_q
Definition: ExportMP3.cpp:787
lame_set_in_samplerate_t * lame_set_in_samplerate
Definition: ExportMP3.cpp:781
lame_set_disable_reservoir_t * lame_set_disable_reservoir
Definition: ExportMP3.cpp:792
lame_set_brate_t * lame_set_brate
Definition: ExportMP3.cpp:785
lame_set_num_channels_t * lame_set_num_channels
Definition: ExportMP3.cpp:783
lame_set_VBR_t * lame_set_VBR
Definition: ExportMP3.cpp:786
lame_set_error_protection_t * lame_set_error_protection
Definition: ExportMP3.cpp:791
lame_set_out_samplerate_t * lame_set_out_samplerate
Definition: ExportMP3.cpp:782
lame_set_mode_t * lame_set_mode
Definition: ExportMP3.cpp:789
lame_set_bWriteVbrTag_t * lame_set_bWriteVbrTag
Definition: ExportMP3.cpp:793
lame_init_params_t * lame_init_params
Definition: ExportMP3.cpp:774
lame_set_preset_t * lame_set_preset
Definition: ExportMP3.cpp:790

References lame_init_params, lame_set_brate, lame_set_bWriteVbrTag, lame_set_disable_reservoir, lame_set_error_protection, lame_set_in_samplerate, lame_set_mode, lame_set_num_channels, lame_set_out_samplerate, lame_set_preset, lame_set_VBR, lame_set_VBR_q, mBitrate, mEncoding, mGF, mInfoTagLen, mLibraryLoaded, mMode, MODE_ABR, MODE_SET, MODE_VBR, mQuality, mSamplesPerChunk, preset, PRESET_EXTREME, PRESET_INSANE, PRESET_STANDARD, and anonymous_namespace{ClipSegmentTest.cpp}::sampleRate.

Referenced by MP3ExportProcessor::Initialize().

Here is the caller graph for this function:

◆ InitLibrary()

bool MP3Exporter::InitLibrary ( wxString  libpath)

Definition at line 973 of file ExportMP3.cpp.

974{
976}
bool InitLibraryExternal(wxString libpath)
Definition: ExportMP3.cpp:1030
bool InitLibraryInternal()
Definition: ExportMP3.cpp:978

References InitLibraryExternal(), InitLibraryInternal(), and mLibIsExternal.

Referenced by MP3ExportProcessor::Initialize(), and LoadLibrary().

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

◆ InitLibraryExternal()

bool MP3Exporter::InitLibraryExternal ( wxString  libpath)

Definition at line 1030 of file ExportMP3.cpp.

1031{
1032 wxLogMessage(wxT("Loading LAME from %s"), libpath);
1033
1034#ifndef DISABLE_DYNAMIC_LOADING_LAME
1035 if (!lame_lib.Load(libpath, wxDL_LAZY)) {
1036 wxLogMessage(wxT("load failed"));
1037 return false;
1038 }
1039
1040 wxLogMessage(wxT("Actual LAME path %s"),
1041 FileNames::PathFromAddr(lame_lib.GetSymbol(wxT("lame_init"))));
1042
1044 lame_lib.GetSymbol(wxT("lame_init"));
1046 lame_lib.GetSymbol(wxT("get_lame_version"));
1048 lame_lib.GetSymbol(wxT("lame_init_params"));
1050 lame_lib.GetSymbol(wxT("lame_encode_buffer_ieee_float"));
1052 lame_lib.GetSymbol(wxT("lame_encode_buffer_interleaved_ieee_float"));
1054 lame_lib.GetSymbol(wxT("lame_encode_flush"));
1056 lame_lib.GetSymbol(wxT("lame_close"));
1057
1059 lame_lib.GetSymbol(wxT("lame_set_in_samplerate"));
1061 lame_lib.GetSymbol(wxT("lame_set_out_samplerate"));
1063 lame_lib.GetSymbol(wxT("lame_set_num_channels"));
1065 lame_lib.GetSymbol(wxT("lame_set_quality"));
1067 lame_lib.GetSymbol(wxT("lame_set_brate"));
1069 lame_lib.GetSymbol(wxT("lame_set_VBR"));
1071 lame_lib.GetSymbol(wxT("lame_set_VBR_q"));
1073 lame_lib.GetSymbol(wxT("lame_set_VBR_min_bitrate_kbps"));
1075 lame_lib.GetSymbol(wxT("lame_set_mode"));
1077 lame_lib.GetSymbol(wxT("lame_set_preset"));
1079 lame_lib.GetSymbol(wxT("lame_set_error_protection"));
1081 lame_lib.GetSymbol(wxT("lame_set_disable_reservoir"));
1083 lame_lib.GetSymbol(wxT("lame_set_bWriteVbrTag"));
1084
1085 // These are optional
1087 lame_lib.GetSymbol(wxT("lame_get_lametag_frame"));
1089 lame_lib.GetSymbol(wxT("lame_mp3_tags_fid"));
1090#if defined(__WXMSW__)
1092 lame_lib.GetSymbol(wxT("beWriteInfoTag"));
1094 lame_lib.GetSymbol(wxT("beVersion"));
1095#endif
1096
1097 if (!lame_init ||
1103 !lame_close ||
1108 !lame_set_brate ||
1109 !lame_set_VBR ||
1110 !lame_set_VBR_q ||
1111 !lame_set_mode ||
1112 !lame_set_preset ||
1116 {
1117 wxLogMessage(wxT("Failed to find a required symbol in the LAME library."));
1118#if defined(__WXMSW__)
1119 if (beVersion) {
1120 be_version v;
1121 beVersion(&v);
1122
1123 mBladeVersion = XO(
1124"You are linking to lame_enc.dll v%d.%d. This version is not compatible with Audacity %d.%d.%d.\nPlease download the latest version of 'LAME for Audacity'.")
1125 .Format(
1128 AUDACITY_VERSION,
1129 AUDACITY_RELEASE,
1130 AUDACITY_REVISION);
1131 }
1132#endif
1133
1134 lame_lib.Unload();
1135 return false;
1136 }
1137#endif // DISABLE_DYNAMIC_LOADING_LAME
1138
1139 mGF = lame_init();
1140 if (mGF == NULL) {
1141 return false;
1142 }
1143
1144 return true;
1145}
int lame_set_VBR_t(lame_global_flags *, vbr_mode)
Definition: ExportMP3.cpp:642
int lame_set_bWriteVbrTag_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:649
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: ExportMP3.cpp:623
const char * get_lame_version_t(void)
Definition: ExportMP3.cpp:613
int lame_set_VBR_q_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:643
int lame_set_in_samplerate_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:637
int lame_close_t(lame_global_flags *)
Definition: ExportMP3.cpp:635
void lame_mp3_tags_fid_t(lame_global_flags *, FILE *)
Definition: ExportMP3.cpp:651
int lame_set_VBR_min_bitrate_kbps_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:644
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: ExportMP3.cpp:615
int lame_set_error_protection_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:647
unsigned long beWriteInfoTag_t(lame_global_flags *, char *)
Definition: ExportMP3.cpp:659
int lame_set_out_samplerate_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:638
int lame_set_quality_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:640
void beVersion_t(be_version *)
Definition: ExportMP3.cpp:691
int lame_set_preset_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:646
size_t lame_get_lametag_frame_t(const lame_global_flags *, unsigned char *buffer, size_t size)
Definition: ExportMP3.cpp:650
int lame_set_disable_reservoir_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:648
lame_global_flags * lame_init_t(void)
Definition: ExportMP3.cpp:611
int lame_encode_flush_t(lame_global_flags *gf, unsigned char *mp3buf, int size)
Definition: ExportMP3.cpp:630
int lame_set_num_channels_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:639
int lame_set_mode_t(lame_global_flags *, MPEG_mode)
Definition: ExportMP3.cpp:645
int lame_set_brate_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:641
int lame_init_params_t(lame_global_flags *)
Definition: ExportMP3.cpp:612
lame_mp3_tags_fid_t * lame_mp3_tags_fid
Definition: ExportMP3.cpp:795
lame_init_t * lame_init
Definition: ExportMP3.cpp:773
lame_set_quality_t * lame_set_quality
Definition: ExportMP3.cpp:784
beWriteInfoTag_t * beWriteInfoTag
Definition: ExportMP3.cpp:797
lame_set_VBR_min_bitrate_kbps_t * lame_set_VBR_min_bitrate_kbps
Definition: ExportMP3.cpp:788
TranslatableString mBladeVersion
Definition: ExportMP3.cpp:762
beVersion_t * beVersion
Definition: ExportMP3.cpp:798
FILES_API FilePath PathFromAddr(void *addr)
BYTE byMinorVersion
Definition: ExportMP3.cpp:673
BYTE byMajorVersion
Definition: ExportMP3.cpp:672

References beVersion, beWriteInfoTag, be_version::byMajorVersion, be_version::byMinorVersion, get_lame_version, lame_close, lame_encode_buffer_ieee_float, lame_encode_buffer_interleaved_ieee_float, lame_encode_flush, lame_get_lametag_frame, lame_init, lame_init_params, lame_lib, lame_mp3_tags_fid, lame_set_brate, lame_set_bWriteVbrTag, lame_set_disable_reservoir, lame_set_error_protection, lame_set_in_samplerate, lame_set_mode, lame_set_num_channels, lame_set_out_samplerate, lame_set_preset, lame_set_quality, lame_set_VBR, lame_set_VBR_min_bitrate_kbps, lame_set_VBR_q, mBladeVersion, mGF, FileNames::PathFromAddr(), wxT(), and XO().

Referenced by InitLibrary().

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

◆ InitLibraryInternal()

bool MP3Exporter::InitLibraryInternal ( )

Definition at line 978 of file ExportMP3.cpp.

979{
980 wxLogMessage(wxT("Using internal LAME"));
981
982// The global ::lame_something symbols only exist if LAME is built in.
983// So we don't reference them unless they are.
984#ifdef MP3_EXPORT_BUILT_IN
985
993
1007
1008 // These are optional
1009 //lame_get_lametag_frame = ::lame_get_lametag_frame;
1012
1013#if defined(__WXMSW__)
1014 //beWriteInfoTag = ::beWriteInfoTag;
1015 //beVersion = ::beVersion;
1016 beWriteInfoTag = NULL;
1017 beVersion = NULL;
1018#endif
1019
1020 mGF = lame_init();
1021 if (mGF == NULL) {
1022 return false;
1023 }
1024#endif
1025
1026 return true;
1027}

References beVersion, beWriteInfoTag, get_lame_version, lame_close, lame_encode_buffer_ieee_float, lame_encode_buffer_interleaved_ieee_float, lame_encode_flush, lame_get_lametag_frame, lame_init, lame_init_params, lame_mp3_tags_fid, lame_set_brate, lame_set_bWriteVbrTag, lame_set_disable_reservoir, lame_set_error_protection, lame_set_in_samplerate, lame_set_mode, lame_set_num_channels, lame_set_out_samplerate, lame_set_preset, lame_set_quality, lame_set_VBR, lame_set_VBR_min_bitrate_kbps, lame_set_VBR_q, mGF, and wxT().

Referenced by InitLibrary(), and LoadLibrary().

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

◆ LoadLibrary()

bool MP3Exporter::LoadLibrary ( wxWindow *  parent,
AskUser  askuser 
)

Definition at line 888 of file ExportMP3.cpp.

889{
890
891 if (ValidLibraryLoaded()) {
892 FreeLibrary();
893 mLibraryLoaded = false;
894 }
895
896#if defined(__WXMSW__)
897 mBladeVersion = {};
898#endif
899
900 if( !mLibIsExternal ){
902 return mLibraryLoaded;
903 }
904
905 // First try loading it from a previously located path
906 if (!mLibPath.empty()) {
907 wxLogMessage(wxT("Attempting to load LAME from previously defined path"));
909 }
910
911 // If not successful, try loading using system search paths
912 if (!ValidLibraryLoaded()) {
913 wxLogMessage(wxT("Attempting to load LAME from system search paths"));
916 }
917
918 // If not successful, try loading using compiled in path
919 if (!ValidLibraryLoaded()) {
920 wxLogMessage(wxT("Attempting to load LAME from builtin path"));
921 wxFileName fn(GetLibraryPath(), GetLibraryName());
922 mLibPath = fn.GetFullPath();
924 }
925
926 // If not successful, must ask the user
927 if (!ValidLibraryLoaded()) {
928 wxLogMessage(wxT("(Maybe) ask user for library"));
929 if (askuser == MP3Exporter::Maybe && FindLibrary(parent)) {
931 }
932 }
933
934 // Oh well, just give up
935 if (!ValidLibraryLoaded()) {
936#if defined(__WXMSW__)
937 if (askuser && !mBladeVersion.empty()) {
939 }
940#endif
941 wxLogMessage(wxT("Failed to locate LAME library"));
942
943 return false;
944 }
945
946 wxLogMessage(wxT("LAME library successfully loaded"));
947
948 return true;
949}
bool ValidLibraryLoaded()
Definition: ExportMP3.cpp:951
bool FindLibrary(wxWindow *parent)
Definition: ExportMP3.cpp:853
bool InitLibrary(wxString libpath)
Definition: ExportMP3.cpp:973
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:279

References TranslatableString::empty(), FindLibrary(), fn, FreeLibrary(), GetLibraryName(), GetLibraryPath(), InitLibrary(), InitLibraryInternal(), Maybe, mBladeVersion, mLibIsExternal, mLibPath, mLibraryLoaded, BasicUI::ShowMessageBox(), ValidLibraryLoaded(), and wxT().

Referenced by ExportMP3::CheckFileName(), GetMP3Version(), and MP3ExportProcessor::Initialize().

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

◆ PutInfoTag()

bool MP3Exporter::PutInfoTag ( wxFFile &  f,
wxFileOffset  off 
)

Definition at line 1346 of file ExportMP3.cpp.

1347{
1348 if (mGF) {
1349 if (mInfoTagLen > 0) {
1350 // FIXME: TRAP_ERR Seek and writ ein MP3 exporter could fail.
1351 if ( !f.Seek(off, wxFromStart))
1352 return false;
1353 if (mInfoTagLen > f.Write(mInfoTagBuf, mInfoTagLen))
1354 return false;
1355 }
1356#if defined(__WXMSW__)
1357 else if (beWriteInfoTag) {
1358 if ( !f.Flush() )
1359 return false;
1360 // PRL: What is the correct error check on the return value?
1361 beWriteInfoTag(mGF, OSOUTPUT(f.GetName()));
1362 mGF = NULL;
1363 }
1364#endif
1365 else if (lame_mp3_tags_fid != NULL) {
1366 lame_mp3_tags_fid(mGF, f.fp());
1367 }
1368 }
1369
1370 if ( !f.SeekEnd() )
1371 return false;
1372
1373 return true;
1374}
#define OSOUTPUT(X)
Definition: SelectFile.h:48

References beWriteInfoTag, lame_mp3_tags_fid, mGF, mInfoTagBuf, mInfoTagLen, and OSOUTPUT.

Referenced by MP3ExportProcessor::Process().

Here is the caller graph for this function:

◆ SetBitrate()

void MP3Exporter::SetBitrate ( int  rate)

Definition at line 963 of file ExportMP3.cpp.

964{
965 mBitrate = rate;
966}

References mBitrate.

Referenced by MP3ExportProcessor::Initialize().

Here is the caller graph for this function:

◆ SetMode()

void MP3Exporter::SetMode ( int  mode)

Definition at line 958 of file ExportMP3.cpp.

959{
960 mMode = mode;
961}

References mMode.

Referenced by MP3ExportProcessor::Initialize().

Here is the caller graph for this function:

◆ SetQuality()

void MP3Exporter::SetQuality ( int  q)

Definition at line 968 of file ExportMP3.cpp.

969{
970 mQuality = q;
971}

References mQuality.

Referenced by MP3ExportProcessor::Initialize().

Here is the caller graph for this function:

◆ ValidLibraryLoaded()

bool MP3Exporter::ValidLibraryLoaded ( )

Definition at line 951 of file ExportMP3.cpp.

952{
953 return mLibraryLoaded;
954}

References mLibraryLoaded.

Referenced by MP3ExportProcessor::Initialize(), and LoadLibrary().

Here is the caller graph for this function:

Member Data Documentation

◆ beVersion

beVersion_t* MP3Exporter::beVersion
private

Definition at line 798 of file ExportMP3.cpp.

Referenced by InitLibraryExternal(), and InitLibraryInternal().

◆ beWriteInfoTag

beWriteInfoTag_t* MP3Exporter::beWriteInfoTag
private

Definition at line 797 of file ExportMP3.cpp.

Referenced by InitLibraryExternal(), InitLibraryInternal(), and PutInfoTag().

◆ get_lame_version

get_lame_version_t* MP3Exporter::get_lame_version
private

Definition at line 779 of file ExportMP3.cpp.

Referenced by GetLibraryVersion(), InitLibraryExternal(), and InitLibraryInternal().

◆ lame_close

lame_close_t* MP3Exporter::lame_close
private

Definition at line 778 of file ExportMP3.cpp.

Referenced by FreeLibrary(), InitLibraryExternal(), and InitLibraryInternal().

◆ lame_encode_buffer_ieee_float

lame_encode_buffer_ieee_float_t* MP3Exporter::lame_encode_buffer_ieee_float
private

◆ lame_encode_buffer_interleaved_ieee_float

lame_encode_buffer_interleaved_ieee_float_t* MP3Exporter::lame_encode_buffer_interleaved_ieee_float
private

◆ lame_encode_flush

lame_encode_flush_t* MP3Exporter::lame_encode_flush
private

Definition at line 777 of file ExportMP3.cpp.

Referenced by FinishStream(), InitLibraryExternal(), and InitLibraryInternal().

◆ lame_get_lametag_frame

lame_get_lametag_frame_t* MP3Exporter::lame_get_lametag_frame
private

Definition at line 794 of file ExportMP3.cpp.

Referenced by FinishStream(), InitLibraryExternal(), and InitLibraryInternal().

◆ lame_init

lame_init_t* MP3Exporter::lame_init
private

Definition at line 773 of file ExportMP3.cpp.

Referenced by InitLibraryExternal(), and InitLibraryInternal().

◆ lame_init_params

lame_init_params_t* MP3Exporter::lame_init_params
private

Definition at line 774 of file ExportMP3.cpp.

Referenced by InitializeStream(), InitLibraryExternal(), and InitLibraryInternal().

◆ lame_lib

wxDynamicLibrary MP3Exporter::lame_lib
private

Definition at line 757 of file ExportMP3.cpp.

Referenced by FreeLibrary(), and InitLibraryExternal().

◆ lame_mp3_tags_fid

lame_mp3_tags_fid_t* MP3Exporter::lame_mp3_tags_fid
private

Definition at line 795 of file ExportMP3.cpp.

Referenced by InitLibraryExternal(), InitLibraryInternal(), and PutInfoTag().

◆ lame_set_brate

lame_set_brate_t* MP3Exporter::lame_set_brate
private

Definition at line 785 of file ExportMP3.cpp.

Referenced by InitializeStream(), InitLibraryExternal(), and InitLibraryInternal().

◆ lame_set_bWriteVbrTag

lame_set_bWriteVbrTag_t* MP3Exporter::lame_set_bWriteVbrTag
private

Definition at line 793 of file ExportMP3.cpp.

Referenced by InitializeStream(), InitLibraryExternal(), and InitLibraryInternal().

◆ lame_set_disable_reservoir

lame_set_disable_reservoir_t* MP3Exporter::lame_set_disable_reservoir
private

Definition at line 792 of file ExportMP3.cpp.

Referenced by InitializeStream(), InitLibraryExternal(), and InitLibraryInternal().

◆ lame_set_error_protection

lame_set_error_protection_t* MP3Exporter::lame_set_error_protection
private

Definition at line 791 of file ExportMP3.cpp.

Referenced by InitializeStream(), InitLibraryExternal(), and InitLibraryInternal().

◆ lame_set_in_samplerate

lame_set_in_samplerate_t* MP3Exporter::lame_set_in_samplerate
private

Definition at line 781 of file ExportMP3.cpp.

Referenced by InitializeStream(), InitLibraryExternal(), and InitLibraryInternal().

◆ lame_set_mode

lame_set_mode_t* MP3Exporter::lame_set_mode
private

Definition at line 789 of file ExportMP3.cpp.

Referenced by InitializeStream(), InitLibraryExternal(), and InitLibraryInternal().

◆ lame_set_num_channels

lame_set_num_channels_t* MP3Exporter::lame_set_num_channels
private

Definition at line 783 of file ExportMP3.cpp.

Referenced by InitializeStream(), InitLibraryExternal(), and InitLibraryInternal().

◆ lame_set_out_samplerate

lame_set_out_samplerate_t* MP3Exporter::lame_set_out_samplerate
private

Definition at line 782 of file ExportMP3.cpp.

Referenced by InitializeStream(), InitLibraryExternal(), and InitLibraryInternal().

◆ lame_set_preset

lame_set_preset_t* MP3Exporter::lame_set_preset
private

Definition at line 790 of file ExportMP3.cpp.

Referenced by InitializeStream(), InitLibraryExternal(), and InitLibraryInternal().

◆ lame_set_quality

lame_set_quality_t* MP3Exporter::lame_set_quality
private

Definition at line 784 of file ExportMP3.cpp.

Referenced by InitLibraryExternal(), and InitLibraryInternal().

◆ lame_set_VBR

lame_set_VBR_t* MP3Exporter::lame_set_VBR
private

Definition at line 786 of file ExportMP3.cpp.

Referenced by InitializeStream(), InitLibraryExternal(), and InitLibraryInternal().

◆ lame_set_VBR_min_bitrate_kbps

lame_set_VBR_min_bitrate_kbps_t* MP3Exporter::lame_set_VBR_min_bitrate_kbps
private

Definition at line 788 of file ExportMP3.cpp.

Referenced by InitLibraryExternal(), and InitLibraryInternal().

◆ lame_set_VBR_q

lame_set_VBR_q_t* MP3Exporter::lame_set_VBR_q
private

Definition at line 787 of file ExportMP3.cpp.

Referenced by InitializeStream(), InitLibraryExternal(), and InitLibraryInternal().

◆ mBitrate

int MP3Exporter::mBitrate
private

Definition at line 767 of file ExportMP3.cpp.

Referenced by InitializeStream(), MP3Exporter(), and SetBitrate().

◆ mBladeVersion

TranslatableString MP3Exporter::mBladeVersion
private

Definition at line 762 of file ExportMP3.cpp.

Referenced by InitLibraryExternal(), and LoadLibrary().

◆ mEncoding

bool MP3Exporter::mEncoding
private

◆ mGF

lame_global_flags* MP3Exporter::mGF
private

◆ mInfoTagBuf

unsigned char MP3Exporter::mInfoTagBuf[2880]
private

Definition at line 811 of file ExportMP3.cpp.

Referenced by FinishStream(), and PutInfoTag().

◆ mInfoTagLen

size_t MP3Exporter::mInfoTagLen
private

Definition at line 812 of file ExportMP3.cpp.

Referenced by FinishStream(), InitializeStream(), and PutInfoTag().

◆ mLibIsExternal

bool MP3Exporter::mLibIsExternal
private

Definition at line 753 of file ExportMP3.cpp.

Referenced by InitLibrary(), LoadLibrary(), and MP3Exporter().

◆ mLibPath

wxString MP3Exporter::mLibPath
private

Definition at line 756 of file ExportMP3.cpp.

Referenced by FindLibrary(), LoadLibrary(), and MP3Exporter().

◆ mLibraryLoaded

bool MP3Exporter::mLibraryLoaded
private

◆ mMode

int MP3Exporter::mMode
private

Definition at line 766 of file ExportMP3.cpp.

Referenced by InitializeStream(), MP3Exporter(), and SetMode().

◆ mOutBufferSize

const int MP3Exporter::mOutBufferSize
staticprivate
Initial value:
=
mSamplesPerChunk * (320 / 8) / 8 + 4 * 1152 * (320 / 8) / 8 + 512

Definition at line 807 of file ExportMP3.cpp.

Referenced by EncodeBuffer(), EncodeBufferMono(), EncodeRemainder(), EncodeRemainderMono(), FinishStream(), and GetOutBufferSize().

◆ mQuality

int MP3Exporter::mQuality
private

Definition at line 768 of file ExportMP3.cpp.

Referenced by InitializeStream(), MP3Exporter(), and SetQuality().

◆ mSamplesPerChunk

const int MP3Exporter::mSamplesPerChunk = 220500
staticprivate

Definition at line 804 of file ExportMP3.cpp.

Referenced by EncodeBuffer(), EncodeBufferMono(), and InitializeStream().


The documentation for this class was generated from the following file: