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

Member Enumeration Documentation

◆ AskUser

Enumerator
No 
Maybe 
Yes 

Definition at line 693 of file ExportMP3.cpp.

694 {
695 No,
696 Maybe,
697 Yes
698 };

Constructor & Destructor Documentation

◆ MP3Exporter()

MP3Exporter::MP3Exporter ( )

Definition at line 811 of file ExportMP3.cpp.

812{
813// We could use #defines rather than this variable.
814// The idea of the variable is that if we wanted, we could allow
815// a dynamic override of the library, e.g. with a newer faster version,
816// or to fix CVEs in the underlying library.
817// for now though the 'variable' is a constant.
818#ifdef MP3_EXPORT_BUILT_IN
819 mLibIsExternal = false;
820#else
821 mLibIsExternal = true;
822#endif
823
824#ifndef DISABLE_DYNAMIC_LOADING_LAME
825 mLibraryLoaded = false;
826#endif // DISABLE_DYNAMIC_LOADING_LAME
827 mEncoding = false;
828 mGF = NULL;
829
830#ifndef DISABLE_DYNAMIC_LOADING_LAME
831 if (gPrefs) {
832 mLibPath = gPrefs->Read(wxT("/MP3/MP3LibPath"), wxT(""));
833 }
834#endif // DISABLE_DYNAMIC_LOADING_LAME
835
836 mBitrate = 128;
838 mMode = MODE_CBR;
839 //mRoutine = ROUTINE_FAST;
840}
wxT("CloseDown"))
@ QUALITY_2
Definition: ExportMP3.cpp:109
@ MODE_CBR
Definition: ExportMP3.h:22
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
bool mLibIsExternal
Definition: ExportMP3.cpp:749
bool mEncoding
Definition: ExportMP3.cpp:761
lame_global_flags * mGF
Definition: ExportMP3.cpp:798
wxString mLibPath
Definition: ExportMP3.cpp:752
bool mLibraryLoaded
Definition: ExportMP3.cpp:754
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 842 of file ExportMP3.cpp.

843{
844 FreeLibrary();
845}
void FreeLibrary()
Definition: ExportMP3.cpp:1143

References FreeLibrary().

Here is the call graph for this function:

Member Function Documentation

◆ CancelEncoding()

void MP3Exporter::CancelEncoding ( )

Definition at line 1337 of file ExportMP3.cpp.

1338{
1339 mEncoding = false;
1340}

References mEncoding.

◆ EncodeBuffer()

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

Definition at line 1274 of file ExportMP3.cpp.

1275{
1276 if (!mEncoding) {
1277 return -1;
1278 }
1279
1281 outbuffer, mOutBufferSize);
1282}
static const int mOutBufferSize
Definition: ExportMP3.cpp:803
lame_encode_buffer_interleaved_ieee_float_t * lame_encode_buffer_interleaved_ieee_float
Definition: ExportMP3.cpp:772
static const int mSamplesPerChunk
Definition: ExportMP3.cpp:800

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

1296{
1297 if (!mEncoding) {
1298 return -1;
1299 }
1300
1301 return lame_encode_buffer_ieee_float(mGF, inbuffer,inbuffer, mSamplesPerChunk,
1302 outbuffer, mOutBufferSize);
1303}
lame_encode_buffer_ieee_float_t * lame_encode_buffer_ieee_float
Definition: ExportMP3.cpp:771

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

1286{
1287 if (!mEncoding) {
1288 return -1;
1289 }
1290
1291 return lame_encode_buffer_interleaved_ieee_float(mGF, inbuffer, nSamples, outbuffer,
1293}

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

1307{
1308 if (!mEncoding) {
1309 return -1;
1310 }
1311
1312 return lame_encode_buffer_ieee_float(mGF, inbuffer, inbuffer, nSamples, outbuffer,
1314}

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

850{
851 wxString path;
852 wxString name;
853
854 if (!mLibPath.empty()) {
855 wxFileName fn = mLibPath;
856 path = fn.GetPath();
857 name = fn.GetFullName();
858 }
859 else {
860 path = GetLibraryPath();
862 }
863
864 FindDialog fd(parent,
865 path,
866 name,
868
869 if (fd.ShowModal() == wxID_CANCEL) {
870 return false;
871 }
872
873 path = fd.GetLibPath();
874
875 if (!::wxFileExists(path)) {
876 return false;
877 }
878
879 mLibPath = path;
880
881 return (gPrefs->Write(wxT("/MP3/MP3LibPath"), mLibPath) && gPrefs->Flush());
882}
wxString name
Definition: TagsEditor.cpp:166
static const auto fn
wxString GetLibraryName()
Definition: ExportMP3.cpp:1393
FileNames::FileTypes GetLibraryTypes()
Definition: ExportMP3.cpp:1398
wxString GetLibraryPath()
Definition: ExportMP3.cpp:1375
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 1316 of file ExportMP3.cpp.

1317{
1318 if (!mEncoding) {
1319 return -1;
1320 }
1321
1322 mEncoding = false;
1323
1324 int result = lame_encode_flush(mGF, outbuffer, mOutBufferSize);
1325
1326#if defined(DISABLE_DYNAMIC_LOADING_LAME)
1328#else
1331 }
1332#endif
1333
1334 return result;
1335}
unsigned char mInfoTagBuf[2880]
Definition: ExportMP3.cpp:807
size_t mInfoTagLen
Definition: ExportMP3.cpp:808
lame_get_lametag_frame_t * lame_get_lametag_frame
Definition: ExportMP3.cpp:790
lame_encode_flush_t * lame_encode_flush
Definition: ExportMP3.cpp:773

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

1144{
1145 if (mGF) {
1146 lame_close(mGF);
1147 mGF = NULL;
1148 }
1149
1150#ifndef DISABLE_DYNAMIC_LOADING_LAME
1151 lame_lib.Unload();
1152#endif // DISABLE_DYNAMIC_LOADING_LAME
1153
1154 return;
1155}
wxDynamicLibrary lame_lib
Definition: ExportMP3.cpp:753
lame_close_t * lame_close
Definition: ExportMP3.cpp:774

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

1394{
1395 return wxT("lame_enc.dll");
1396}

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

1376{
1377 wxRegKey reg(wxT("HKEY_LOCAL_MACHINE\\Software\\Lame for Audacity"));
1378 wxString path;
1379
1380 if (reg.Exists()) {
1381 wxLogMessage(wxT("LAME registry key exists."));
1382 reg.QueryValue(wxT("InstallPath"), path);
1383 }
1384 else {
1385 wxLogMessage(wxT("LAME registry key does not exist."));
1386 }
1387
1388 wxLogMessage(wxT("Library path is: ") + path);
1389
1390 return path;
1391}
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 1398 of file ExportMP3.cpp.

1399{
1400 return {
1401 { XO("Only lame_enc.dll"), { wxT("lame_enc.dll") } },
1404 };
1405}
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 1157 of file ExportMP3.cpp.

1158{
1159#ifndef DISABLE_DYNAMIC_LOADING_LAME
1160 if (!mLibraryLoaded) {
1161 return wxT("");
1162 }
1163#endif // DISABLE_DYNAMIC_LOADING_LAME
1164
1165 return wxString::Format(wxT("LAME %hs"), get_lame_version());
1166}
get_lame_version_t * get_lame_version
Definition: ExportMP3.cpp:775

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

1267{
1268 if (!mEncoding)
1269 return -1;
1270
1271 return mOutBufferSize;
1272}

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

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

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

970{
972}
bool InitLibraryExternal(wxString libpath)
Definition: ExportMP3.cpp:1026
bool InitLibraryInternal()
Definition: ExportMP3.cpp:974

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

1027{
1028 wxLogMessage(wxT("Loading LAME from %s"), libpath);
1029
1030#ifndef DISABLE_DYNAMIC_LOADING_LAME
1031 if (!lame_lib.Load(libpath, wxDL_LAZY)) {
1032 wxLogMessage(wxT("load failed"));
1033 return false;
1034 }
1035
1036 wxLogMessage(wxT("Actual LAME path %s"),
1037 FileNames::PathFromAddr(lame_lib.GetSymbol(wxT("lame_init"))));
1038
1040 lame_lib.GetSymbol(wxT("lame_init"));
1042 lame_lib.GetSymbol(wxT("get_lame_version"));
1044 lame_lib.GetSymbol(wxT("lame_init_params"));
1046 lame_lib.GetSymbol(wxT("lame_encode_buffer_ieee_float"));
1048 lame_lib.GetSymbol(wxT("lame_encode_buffer_interleaved_ieee_float"));
1050 lame_lib.GetSymbol(wxT("lame_encode_flush"));
1052 lame_lib.GetSymbol(wxT("lame_close"));
1053
1055 lame_lib.GetSymbol(wxT("lame_set_in_samplerate"));
1057 lame_lib.GetSymbol(wxT("lame_set_out_samplerate"));
1059 lame_lib.GetSymbol(wxT("lame_set_num_channels"));
1061 lame_lib.GetSymbol(wxT("lame_set_quality"));
1063 lame_lib.GetSymbol(wxT("lame_set_brate"));
1065 lame_lib.GetSymbol(wxT("lame_set_VBR"));
1067 lame_lib.GetSymbol(wxT("lame_set_VBR_q"));
1069 lame_lib.GetSymbol(wxT("lame_set_VBR_min_bitrate_kbps"));
1071 lame_lib.GetSymbol(wxT("lame_set_mode"));
1073 lame_lib.GetSymbol(wxT("lame_set_preset"));
1075 lame_lib.GetSymbol(wxT("lame_set_error_protection"));
1077 lame_lib.GetSymbol(wxT("lame_set_disable_reservoir"));
1079 lame_lib.GetSymbol(wxT("lame_set_bWriteVbrTag"));
1080
1081 // These are optional
1083 lame_lib.GetSymbol(wxT("lame_get_lametag_frame"));
1085 lame_lib.GetSymbol(wxT("lame_mp3_tags_fid"));
1086#if defined(__WXMSW__)
1088 lame_lib.GetSymbol(wxT("beWriteInfoTag"));
1090 lame_lib.GetSymbol(wxT("beVersion"));
1091#endif
1092
1093 if (!lame_init ||
1099 !lame_close ||
1104 !lame_set_brate ||
1105 !lame_set_VBR ||
1106 !lame_set_VBR_q ||
1107 !lame_set_mode ||
1108 !lame_set_preset ||
1112 {
1113 wxLogMessage(wxT("Failed to find a required symbol in the LAME library."));
1114#if defined(__WXMSW__)
1115 if (beVersion) {
1116 be_version v;
1117 beVersion(&v);
1118
1119 mBladeVersion = XO(
1120"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'.")
1121 .Format(
1124 AUDACITY_VERSION,
1125 AUDACITY_RELEASE,
1126 AUDACITY_REVISION);
1127 }
1128#endif
1129
1130 lame_lib.Unload();
1131 return false;
1132 }
1133#endif // DISABLE_DYNAMIC_LOADING_LAME
1134
1135 mGF = lame_init();
1136 if (mGF == NULL) {
1137 return false;
1138 }
1139
1140 return true;
1141}
int lame_set_VBR_t(lame_global_flags *, vbr_mode)
Definition: ExportMP3.cpp:638
int lame_set_bWriteVbrTag_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:645
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:619
const char * get_lame_version_t(void)
Definition: ExportMP3.cpp:609
int lame_set_VBR_q_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:639
int lame_set_in_samplerate_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:633
int lame_close_t(lame_global_flags *)
Definition: ExportMP3.cpp:631
void lame_mp3_tags_fid_t(lame_global_flags *, FILE *)
Definition: ExportMP3.cpp:647
int lame_set_VBR_min_bitrate_kbps_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:640
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:611
int lame_set_error_protection_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:643
unsigned long beWriteInfoTag_t(lame_global_flags *, char *)
Definition: ExportMP3.cpp:655
int lame_set_out_samplerate_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:634
int lame_set_quality_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:636
void beVersion_t(be_version *)
Definition: ExportMP3.cpp:687
int lame_set_preset_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:642
size_t lame_get_lametag_frame_t(const lame_global_flags *, unsigned char *buffer, size_t size)
Definition: ExportMP3.cpp:646
int lame_set_disable_reservoir_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:644
lame_global_flags * lame_init_t(void)
Definition: ExportMP3.cpp:607
int lame_encode_flush_t(lame_global_flags *gf, unsigned char *mp3buf, int size)
Definition: ExportMP3.cpp:626
int lame_set_num_channels_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:635
int lame_set_mode_t(lame_global_flags *, MPEG_mode)
Definition: ExportMP3.cpp:641
int lame_set_brate_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:637
int lame_init_params_t(lame_global_flags *)
Definition: ExportMP3.cpp:608
lame_mp3_tags_fid_t * lame_mp3_tags_fid
Definition: ExportMP3.cpp:791
lame_init_t * lame_init
Definition: ExportMP3.cpp:769
lame_set_quality_t * lame_set_quality
Definition: ExportMP3.cpp:780
beWriteInfoTag_t * beWriteInfoTag
Definition: ExportMP3.cpp:793
lame_set_VBR_min_bitrate_kbps_t * lame_set_VBR_min_bitrate_kbps
Definition: ExportMP3.cpp:784
TranslatableString mBladeVersion
Definition: ExportMP3.cpp:758
beVersion_t * beVersion
Definition: ExportMP3.cpp:794
FILES_API FilePath PathFromAddr(void *addr)
BYTE byMinorVersion
Definition: ExportMP3.cpp:669
BYTE byMajorVersion
Definition: ExportMP3.cpp:668

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

975{
976 wxLogMessage(wxT("Using internal LAME"));
977
978// The global ::lame_something symbols only exist if LAME is built in.
979// So we don't reference them unless they are.
980#ifdef MP3_EXPORT_BUILT_IN
981
989
1003
1004 // These are optional
1005 //lame_get_lametag_frame = ::lame_get_lametag_frame;
1008
1009#if defined(__WXMSW__)
1010 //beWriteInfoTag = ::beWriteInfoTag;
1011 //beVersion = ::beVersion;
1012 beWriteInfoTag = NULL;
1013 beVersion = NULL;
1014#endif
1015
1016 mGF = lame_init();
1017 if (mGF == NULL) {
1018 return false;
1019 }
1020#endif
1021
1022 return true;
1023}

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

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

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

1343{
1344 if (mGF) {
1345 if (mInfoTagLen > 0) {
1346 // FIXME: TRAP_ERR Seek and writ ein MP3 exporter could fail.
1347 if ( !f.Seek(off, wxFromStart))
1348 return false;
1349 if (mInfoTagLen > f.Write(mInfoTagBuf, mInfoTagLen))
1350 return false;
1351 }
1352#if defined(__WXMSW__)
1353 else if (beWriteInfoTag) {
1354 if ( !f.Flush() )
1355 return false;
1356 // PRL: What is the correct error check on the return value?
1357 beWriteInfoTag(mGF, OSOUTPUT(f.GetName()));
1358 mGF = NULL;
1359 }
1360#endif
1361 else if (lame_mp3_tags_fid != NULL) {
1362 lame_mp3_tags_fid(mGF, f.fp());
1363 }
1364 }
1365
1366 if ( !f.SeekEnd() )
1367 return false;
1368
1369 return true;
1370}
#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 959 of file ExportMP3.cpp.

960{
961 mBitrate = rate;
962}

References mBitrate.

Referenced by MP3ExportProcessor::Initialize().

Here is the caller graph for this function:

◆ SetMode()

void MP3Exporter::SetMode ( int  mode)

Definition at line 954 of file ExportMP3.cpp.

955{
956 mMode = mode;
957}

References mMode.

Referenced by MP3ExportProcessor::Initialize().

Here is the caller graph for this function:

◆ SetQuality()

void MP3Exporter::SetQuality ( int  q)

Definition at line 964 of file ExportMP3.cpp.

965{
966 mQuality = q;
967}

References mQuality.

Referenced by MP3ExportProcessor::Initialize().

Here is the caller graph for this function:

◆ ValidLibraryLoaded()

bool MP3Exporter::ValidLibraryLoaded ( )

Definition at line 947 of file ExportMP3.cpp.

948{
949 return mLibraryLoaded;
950}

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

Referenced by InitLibraryExternal(), and InitLibraryInternal().

◆ beWriteInfoTag

beWriteInfoTag_t* MP3Exporter::beWriteInfoTag
private

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

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

◆ lame_close

lame_close_t* MP3Exporter::lame_close
private

Definition at line 774 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 773 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 790 of file ExportMP3.cpp.

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

◆ lame_init

lame_init_t* MP3Exporter::lame_init
private

Definition at line 769 of file ExportMP3.cpp.

Referenced by InitLibraryExternal(), and InitLibraryInternal().

◆ lame_init_params

lame_init_params_t* MP3Exporter::lame_init_params
private

Definition at line 770 of file ExportMP3.cpp.

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

◆ lame_lib

wxDynamicLibrary MP3Exporter::lame_lib
private

Definition at line 753 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 791 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 781 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 789 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 788 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 787 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 777 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 785 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 779 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 778 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 786 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 780 of file ExportMP3.cpp.

Referenced by InitLibraryExternal(), and InitLibraryInternal().

◆ lame_set_VBR

lame_set_VBR_t* MP3Exporter::lame_set_VBR
private

Definition at line 782 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 784 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 783 of file ExportMP3.cpp.

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

◆ mBitrate

int MP3Exporter::mBitrate
private

Definition at line 763 of file ExportMP3.cpp.

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

◆ mBladeVersion

TranslatableString MP3Exporter::mBladeVersion
private

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

Referenced by FinishStream(), and PutInfoTag().

◆ mInfoTagLen

size_t MP3Exporter::mInfoTagLen
private

Definition at line 808 of file ExportMP3.cpp.

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

◆ mLibIsExternal

bool MP3Exporter::mLibIsExternal
private

Definition at line 749 of file ExportMP3.cpp.

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

◆ mLibPath

wxString MP3Exporter::mLibPath
private

Definition at line 752 of file ExportMP3.cpp.

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

◆ mLibraryLoaded

bool MP3Exporter::mLibraryLoaded
private

◆ mMode

int MP3Exporter::mMode
private

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

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

◆ mQuality

int MP3Exporter::mQuality
private

Definition at line 764 of file ExportMP3.cpp.

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

◆ mSamplesPerChunk

const int MP3Exporter::mSamplesPerChunk = 220500
staticprivate

Definition at line 800 of file ExportMP3.cpp.

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


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