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

Member Enumeration Documentation

◆ AskUser

Enumerator
No 
Maybe 
Yes 

Definition at line 695 of file ExportMP3.cpp.

696 {
697 No,
698 Maybe,
699 Yes
700 };

Constructor & Destructor Documentation

◆ MP3Exporter()

MP3Exporter::MP3Exporter ( )

Definition at line 813 of file ExportMP3.cpp.

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

845{
846 FreeLibrary();
847}
void FreeLibrary()
Definition: ExportMP3.cpp:1145

References FreeLibrary().

Here is the call graph for this function:

Member Function Documentation

◆ CancelEncoding()

void MP3Exporter::CancelEncoding ( )

Definition at line 1339 of file ExportMP3.cpp.

1340{
1341 mEncoding = false;
1342}

References mEncoding.

◆ EncodeBuffer()

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

Definition at line 1276 of file ExportMP3.cpp.

1277{
1278 if (!mEncoding) {
1279 return -1;
1280 }
1281
1283 outbuffer, mOutBufferSize);
1284}
static const int mOutBufferSize
Definition: ExportMP3.cpp:805
lame_encode_buffer_interleaved_ieee_float_t * lame_encode_buffer_interleaved_ieee_float
Definition: ExportMP3.cpp:774
static const int mSamplesPerChunk
Definition: ExportMP3.cpp:802

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

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

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

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

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

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

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

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

1319{
1320 if (!mEncoding) {
1321 return -1;
1322 }
1323
1324 mEncoding = false;
1325
1326 int result = lame_encode_flush(mGF, outbuffer, mOutBufferSize);
1327
1328#if defined(DISABLE_DYNAMIC_LOADING_LAME)
1330#else
1333 }
1334#endif
1335
1336 return result;
1337}
unsigned char mInfoTagBuf[2880]
Definition: ExportMP3.cpp:809
size_t mInfoTagLen
Definition: ExportMP3.cpp:810
lame_get_lametag_frame_t * lame_get_lametag_frame
Definition: ExportMP3.cpp:792
lame_encode_flush_t * lame_encode_flush
Definition: ExportMP3.cpp:775

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

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

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

1396{
1397 return wxT("lame_enc.dll");
1398}

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

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

1401{
1402 return {
1403 { XO("Only lame_enc.dll"), { wxT("lame_enc.dll") } },
1406 };
1407}
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 1159 of file ExportMP3.cpp.

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

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

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

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

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

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

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

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

1029{
1030 wxLogMessage(wxT("Loading LAME from %s"), libpath);
1031
1032#ifndef DISABLE_DYNAMIC_LOADING_LAME
1033 if (!lame_lib.Load(libpath, wxDL_LAZY)) {
1034 wxLogMessage(wxT("load failed"));
1035 return false;
1036 }
1037
1038 wxLogMessage(wxT("Actual LAME path %s"),
1039 FileNames::PathFromAddr(lame_lib.GetSymbol(wxT("lame_init"))));
1040
1042 lame_lib.GetSymbol(wxT("lame_init"));
1044 lame_lib.GetSymbol(wxT("get_lame_version"));
1046 lame_lib.GetSymbol(wxT("lame_init_params"));
1048 lame_lib.GetSymbol(wxT("lame_encode_buffer_ieee_float"));
1050 lame_lib.GetSymbol(wxT("lame_encode_buffer_interleaved_ieee_float"));
1052 lame_lib.GetSymbol(wxT("lame_encode_flush"));
1054 lame_lib.GetSymbol(wxT("lame_close"));
1055
1057 lame_lib.GetSymbol(wxT("lame_set_in_samplerate"));
1059 lame_lib.GetSymbol(wxT("lame_set_out_samplerate"));
1061 lame_lib.GetSymbol(wxT("lame_set_num_channels"));
1063 lame_lib.GetSymbol(wxT("lame_set_quality"));
1065 lame_lib.GetSymbol(wxT("lame_set_brate"));
1067 lame_lib.GetSymbol(wxT("lame_set_VBR"));
1069 lame_lib.GetSymbol(wxT("lame_set_VBR_q"));
1071 lame_lib.GetSymbol(wxT("lame_set_VBR_min_bitrate_kbps"));
1073 lame_lib.GetSymbol(wxT("lame_set_mode"));
1075 lame_lib.GetSymbol(wxT("lame_set_preset"));
1077 lame_lib.GetSymbol(wxT("lame_set_error_protection"));
1079 lame_lib.GetSymbol(wxT("lame_set_disable_reservoir"));
1081 lame_lib.GetSymbol(wxT("lame_set_bWriteVbrTag"));
1082
1083 // These are optional
1085 lame_lib.GetSymbol(wxT("lame_get_lametag_frame"));
1087 lame_lib.GetSymbol(wxT("lame_mp3_tags_fid"));
1088#if defined(__WXMSW__)
1090 lame_lib.GetSymbol(wxT("beWriteInfoTag"));
1092 lame_lib.GetSymbol(wxT("beVersion"));
1093#endif
1094
1095 if (!lame_init ||
1101 !lame_close ||
1106 !lame_set_brate ||
1107 !lame_set_VBR ||
1108 !lame_set_VBR_q ||
1109 !lame_set_mode ||
1110 !lame_set_preset ||
1114 {
1115 wxLogMessage(wxT("Failed to find a required symbol in the LAME library."));
1116#if defined(__WXMSW__)
1117 if (beVersion) {
1118 be_version v;
1119 beVersion(&v);
1120
1121 mBladeVersion = XO(
1122"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'.")
1123 .Format(
1126 AUDACITY_VERSION,
1127 AUDACITY_RELEASE,
1128 AUDACITY_REVISION);
1129 }
1130#endif
1131
1132 lame_lib.Unload();
1133 return false;
1134 }
1135#endif // DISABLE_DYNAMIC_LOADING_LAME
1136
1137 mGF = lame_init();
1138 if (mGF == NULL) {
1139 return false;
1140 }
1141
1142 return true;
1143}
int lame_set_VBR_t(lame_global_flags *, vbr_mode)
Definition: ExportMP3.cpp:640
int lame_set_bWriteVbrTag_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:647
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:621
const char * get_lame_version_t(void)
Definition: ExportMP3.cpp:611
int lame_set_VBR_q_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:641
int lame_set_in_samplerate_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:635
int lame_close_t(lame_global_flags *)
Definition: ExportMP3.cpp:633
void lame_mp3_tags_fid_t(lame_global_flags *, FILE *)
Definition: ExportMP3.cpp:649
int lame_set_VBR_min_bitrate_kbps_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:642
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:613
int lame_set_error_protection_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:645
unsigned long beWriteInfoTag_t(lame_global_flags *, char *)
Definition: ExportMP3.cpp:657
int lame_set_out_samplerate_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:636
int lame_set_quality_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:638
void beVersion_t(be_version *)
Definition: ExportMP3.cpp:689
int lame_set_preset_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:644
size_t lame_get_lametag_frame_t(const lame_global_flags *, unsigned char *buffer, size_t size)
Definition: ExportMP3.cpp:648
int lame_set_disable_reservoir_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:646
lame_global_flags * lame_init_t(void)
Definition: ExportMP3.cpp:609
int lame_encode_flush_t(lame_global_flags *gf, unsigned char *mp3buf, int size)
Definition: ExportMP3.cpp:628
int lame_set_num_channels_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:637
int lame_set_mode_t(lame_global_flags *, MPEG_mode)
Definition: ExportMP3.cpp:643
int lame_set_brate_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:639
int lame_init_params_t(lame_global_flags *)
Definition: ExportMP3.cpp:610
lame_mp3_tags_fid_t * lame_mp3_tags_fid
Definition: ExportMP3.cpp:793
lame_init_t * lame_init
Definition: ExportMP3.cpp:771
lame_set_quality_t * lame_set_quality
Definition: ExportMP3.cpp:782
beWriteInfoTag_t * beWriteInfoTag
Definition: ExportMP3.cpp:795
lame_set_VBR_min_bitrate_kbps_t * lame_set_VBR_min_bitrate_kbps
Definition: ExportMP3.cpp:786
TranslatableString mBladeVersion
Definition: ExportMP3.cpp:760
beVersion_t * beVersion
Definition: ExportMP3.cpp:796
FILES_API FilePath PathFromAddr(void *addr)
BYTE byMinorVersion
Definition: ExportMP3.cpp:671
BYTE byMajorVersion
Definition: ExportMP3.cpp:670

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

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

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

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

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

962{
963 mBitrate = rate;
964}

References mBitrate.

Referenced by MP3ExportProcessor::Initialize().

Here is the caller graph for this function:

◆ SetMode()

void MP3Exporter::SetMode ( int  mode)

Definition at line 956 of file ExportMP3.cpp.

957{
958 mMode = mode;
959}

References mMode.

Referenced by MP3ExportProcessor::Initialize().

Here is the caller graph for this function:

◆ SetQuality()

void MP3Exporter::SetQuality ( int  q)

Definition at line 966 of file ExportMP3.cpp.

967{
968 mQuality = q;
969}

References mQuality.

Referenced by MP3ExportProcessor::Initialize().

Here is the caller graph for this function:

◆ ValidLibraryLoaded()

bool MP3Exporter::ValidLibraryLoaded ( )

Definition at line 949 of file ExportMP3.cpp.

950{
951 return mLibraryLoaded;
952}

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

Referenced by InitLibraryExternal(), and InitLibraryInternal().

◆ beWriteInfoTag

beWriteInfoTag_t* MP3Exporter::beWriteInfoTag
private

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

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

◆ lame_close

lame_close_t* MP3Exporter::lame_close
private

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

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

◆ lame_init

lame_init_t* MP3Exporter::lame_init
private

Definition at line 771 of file ExportMP3.cpp.

Referenced by InitLibraryExternal(), and InitLibraryInternal().

◆ lame_init_params

lame_init_params_t* MP3Exporter::lame_init_params
private

Definition at line 772 of file ExportMP3.cpp.

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

◆ lame_lib

wxDynamicLibrary MP3Exporter::lame_lib
private

Definition at line 755 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 793 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 783 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 791 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 790 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 789 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 779 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 787 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 781 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 780 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 788 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 782 of file ExportMP3.cpp.

Referenced by InitLibraryExternal(), and InitLibraryInternal().

◆ lame_set_VBR

lame_set_VBR_t* MP3Exporter::lame_set_VBR
private

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

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

◆ mBitrate

int MP3Exporter::mBitrate
private

Definition at line 765 of file ExportMP3.cpp.

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

◆ mBladeVersion

TranslatableString MP3Exporter::mBladeVersion
private

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

Referenced by FinishStream(), and PutInfoTag().

◆ mInfoTagLen

size_t MP3Exporter::mInfoTagLen
private

Definition at line 810 of file ExportMP3.cpp.

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

◆ mLibIsExternal

bool MP3Exporter::mLibIsExternal
private

Definition at line 751 of file ExportMP3.cpp.

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

◆ mLibPath

wxString MP3Exporter::mLibPath
private

Definition at line 754 of file ExportMP3.cpp.

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

◆ mLibraryLoaded

bool MP3Exporter::mLibraryLoaded
private

◆ mMode

int MP3Exporter::mMode
private

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

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

◆ mQuality

int MP3Exporter::mQuality
private

Definition at line 766 of file ExportMP3.cpp.

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

◆ mSamplesPerChunk

const int MP3Exporter::mSamplesPerChunk = 220500
staticprivate

Definition at line 802 of file ExportMP3.cpp.

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


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