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

Class used to export MP3 files. More...

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, int r)
 
void SetChannel (int mode)
 
bool InitLibrary (wxString libpath)
 
void FreeLibrary ()
 
wxString GetLibraryVersion ()
 
wxString GetLibraryName ()
 
wxString GetLibraryPath ()
 WXMAC More...
 
wxString GetLibraryTypeString ()
 
int InitializeStream (unsigned channels, int sampleRate)
 
int GetOutBufferSize ()
 
int EncodeBuffer (short int inbuffer[], unsigned char outbuffer[])
 
int EncodeRemainder (short int inbuffer[], int nSamples, unsigned char outbuffer[])
 
int EncodeBufferMono (short int inbuffer[], unsigned char outbuffer[])
 
int EncodeRemainderMono (short int inbuffer[], int nSamples, unsigned char outbuffer[])
 
int FinishStream (unsigned char outbuffer[])
 
void CancelEncoding ()
 
bool PutInfoTag (wxFFile &f, wxFileOffset off)
 

Private Attributes

wxString mLibPath
 
wxDynamicLibrary lame_lib
 
bool mLibraryLoaded
 
bool mEncoding
 
int mMode
 
int mBitrate
 
int mQuality
 
int mRoutine
 
int mChannel
 
lame_init_tlame_init
 
lame_init_params_tlame_init_params
 
lame_encode_buffer_tlame_encode_buffer
 
lame_encode_buffer_interleaved_tlame_encode_buffer_interleaved
 
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_padding_type_tlame_set_padding_type
 
lame_set_bWriteVbrTag_tlame_set_bWriteVbrTag
 
lame_get_lametag_frame_tlame_get_lametag_frame
 
lame_mp3_tags_fid_tlame_mp3_tags_fid
 
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 797 of file ExportMP3.cpp.

Member Enumeration Documentation

Enumerator
No 
Maybe 
Yes 

Definition at line 800 of file ExportMP3.cpp.

801  {
802  No,
803  Maybe,
804  Yes
805  };

Constructor & Destructor Documentation

MP3Exporter::MP3Exporter ( )

Definition at line 918 of file ExportMP3.cpp.

References CHANNEL_STEREO, gPrefs, mBitrate, mChannel, mEncoding, mGF, mLibPath, mLibraryLoaded, mMode, MODE_CBR, mQuality, mRoutine, QUALITY_2, and ROUTINE_FAST.

919 {
920 #ifndef DISABLE_DYNAMIC_LOADING_LAME
921  mLibraryLoaded = false;
922 #endif // DISABLE_DYNAMIC_LOADING_LAME
923  mEncoding = false;
924  mGF = NULL;
925 
926 #ifndef DISABLE_DYNAMIC_LOADING_LAME
927  if (gPrefs) {
928  mLibPath = gPrefs->Read(wxT("/MP3/MP3LibPath"), wxT(""));
929  }
930 #endif // DISABLE_DYNAMIC_LOADING_LAME
931 
932  mBitrate = 128;
935  mMode = MODE_CBR;
937 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
#define QUALITY_2
Definition: ExportMP3.cpp:119
bool mLibraryLoaded
Definition: ExportMP3.cpp:859
wxString mLibPath
Definition: ExportMP3.cpp:857
bool mEncoding
Definition: ExportMP3.cpp:866
#define ROUTINE_FAST
Definition: ExportMP3.cpp:128
#define CHANNEL_STEREO
Definition: ExportMP3.cpp:114
#define MODE_CBR
Definition: ExportMP3.cpp:111
lame_global_flags * mGF
Definition: ExportMP3.cpp:905
MP3Exporter::~MP3Exporter ( )

Definition at line 939 of file ExportMP3.cpp.

References FreeLibrary().

940 {
941  FreeLibrary();
942 }
void FreeLibrary()
Definition: ExportMP3.cpp:1184

Member Function Documentation

void MP3Exporter::CancelEncoding ( )

Definition at line 1386 of file ExportMP3.cpp.

References mEncoding.

1387 {
1388  mEncoding = false;
1389 }
bool mEncoding
Definition: ExportMP3.cpp:866
int MP3Exporter::EncodeBuffer ( short int  inbuffer[],
unsigned char  outbuffer[] 
)

Definition at line 1323 of file ExportMP3.cpp.

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

Referenced by ExportMP3::Export().

1324 {
1325  if (!mEncoding) {
1326  return -1;
1327  }
1328 
1330  outbuffer, mOutBufferSize);
1331 }
static const int mSamplesPerChunk
Definition: ExportMP3.cpp:907
static const int mOutBufferSize
Definition: ExportMP3.cpp:910
bool mEncoding
Definition: ExportMP3.cpp:866
lame_encode_buffer_interleaved_t * lame_encode_buffer_interleaved
Definition: ExportMP3.cpp:878
lame_global_flags * mGF
Definition: ExportMP3.cpp:905
int MP3Exporter::EncodeBufferMono ( short int  inbuffer[],
unsigned char  outbuffer[] 
)

Definition at line 1344 of file ExportMP3.cpp.

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

Referenced by ExportMP3::Export().

1345 {
1346  if (!mEncoding) {
1347  return -1;
1348  }
1349 
1350  return lame_encode_buffer(mGF, inbuffer,inbuffer, mSamplesPerChunk,
1351  outbuffer, mOutBufferSize);
1352 }
static const int mSamplesPerChunk
Definition: ExportMP3.cpp:907
static const int mOutBufferSize
Definition: ExportMP3.cpp:910
lame_encode_buffer_t * lame_encode_buffer
Definition: ExportMP3.cpp:877
bool mEncoding
Definition: ExportMP3.cpp:866
lame_global_flags * mGF
Definition: ExportMP3.cpp:905
int MP3Exporter::EncodeRemainder ( short int  inbuffer[],
int  nSamples,
unsigned char  outbuffer[] 
)

Definition at line 1333 of file ExportMP3.cpp.

References lame_encode_buffer_interleaved, mEncoding, mGF, and mOutBufferSize.

Referenced by ExportMP3::Export().

1335 {
1336  if (!mEncoding) {
1337  return -1;
1338  }
1339 
1340  return lame_encode_buffer_interleaved(mGF, inbuffer, nSamples, outbuffer,
1341  mOutBufferSize);
1342 }
static const int mOutBufferSize
Definition: ExportMP3.cpp:910
bool mEncoding
Definition: ExportMP3.cpp:866
lame_encode_buffer_interleaved_t * lame_encode_buffer_interleaved
Definition: ExportMP3.cpp:878
lame_global_flags * mGF
Definition: ExportMP3.cpp:905
int MP3Exporter::EncodeRemainderMono ( short int  inbuffer[],
int  nSamples,
unsigned char  outbuffer[] 
)

Definition at line 1354 of file ExportMP3.cpp.

References lame_encode_buffer, mEncoding, mGF, and mOutBufferSize.

Referenced by ExportMP3::Export().

1356 {
1357  if (!mEncoding) {
1358  return -1;
1359  }
1360 
1361  return lame_encode_buffer(mGF, inbuffer, inbuffer, nSamples, outbuffer,
1362  mOutBufferSize);
1363 }
static const int mOutBufferSize
Definition: ExportMP3.cpp:910
lame_encode_buffer_t * lame_encode_buffer
Definition: ExportMP3.cpp:877
bool mEncoding
Definition: ExportMP3.cpp:866
lame_global_flags * mGF
Definition: ExportMP3.cpp:905
bool MP3Exporter::FindLibrary ( wxWindow *  parent)

Definition at line 946 of file ExportMP3.cpp.

References FindDialog::GetLibPath(), GetLibraryName(), GetLibraryPath(), GetLibraryTypeString(), gPrefs, mLibPath, and name.

Referenced by GetMP3Version(), and LoadLibrary().

947 {
948  wxString path;
949  wxString name;
950 
951  if (!mLibPath.IsEmpty()) {
952  wxFileName fn = mLibPath;
953  path = fn.GetPath();
954  name = fn.GetFullName();
955  }
956  else {
957  path = GetLibraryPath();
958  name = GetLibraryName();
959  }
960 
961  FindDialog fd(parent,
962  path,
963  name,
965 
966  if (fd.ShowModal() == wxID_CANCEL) {
967  return false;
968  }
969 
970  path = fd.GetLibPath();
971 
972  if (!::wxFileExists(path)) {
973  return false;
974  }
975 
976  mLibPath = path;
977 
978  return (gPrefs->Write(wxT("/MP3/MP3LibPath"), mLibPath) && gPrefs->Flush());
979 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
wxString GetLibraryTypeString()
Definition: ExportMP3.cpp:1497
wxString GetLibraryPath()
WXMAC
Definition: ExportMP3.cpp:1487
wxString GetLibraryName()
Definition: ExportMP3.cpp:1492
wxString mLibPath
Definition: ExportMP3.cpp:857
const wxChar * name
Definition: Distortion.cpp:94
int MP3Exporter::FinishStream ( unsigned char  outbuffer[])

Definition at line 1365 of file ExportMP3.cpp.

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

Referenced by ExportMP3::Export().

1366 {
1367  if (!mEncoding) {
1368  return -1;
1369  }
1370 
1371  mEncoding = false;
1372 
1373  int result = lame_encode_flush(mGF, outbuffer, mOutBufferSize);
1374 
1375 #if defined(DISABLE_DYNAMIC_LOADING_LAME)
1377 #else
1378  if (lame_get_lametag_frame) {
1380  }
1381 #endif
1382 
1383  return result;
1384 }
static const int mOutBufferSize
Definition: ExportMP3.cpp:910
size_t mInfoTagLen
Definition: ExportMP3.cpp:915
unsigned char mInfoTagBuf[2880]
Definition: ExportMP3.cpp:914
bool mEncoding
Definition: ExportMP3.cpp:866
lame_get_lametag_frame_t * lame_get_lametag_frame
Definition: ExportMP3.cpp:897
lame_encode_flush_t * lame_encode_flush
Definition: ExportMP3.cpp:879
lame_global_flags * mGF
Definition: ExportMP3.cpp:905
void MP3Exporter::FreeLibrary ( )

Definition at line 1184 of file ExportMP3.cpp.

References lame_close, lame_lib, and mGF.

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

1185 {
1186  if (mGF) {
1187  lame_close(mGF);
1188  mGF = NULL;
1189  }
1190 
1191 #ifndef DISABLE_DYNAMIC_LOADING_LAME
1192  lame_lib.Unload();
1193 #endif // DISABLE_DYNAMIC_LOADING_LAME
1194 
1195  return;
1196 }
lame_close_t * lame_close
Definition: ExportMP3.cpp:880
wxDynamicLibrary lame_lib
Definition: ExportMP3.cpp:858
lame_global_flags * mGF
Definition: ExportMP3.cpp:905
wxString MP3Exporter::GetLibraryName ( )

Definition at line 1492 of file ExportMP3.cpp.

Referenced by FindLibrary(), and LoadLibrary().

1493 {
1494  return wxT("libmp3lame.so.0");
1495 }
wxString MP3Exporter::GetLibraryPath ( )

WXMAC

Definition at line 1487 of file ExportMP3.cpp.

Referenced by FindLibrary(), and LoadLibrary().

1488 {
1489  return wxT(LIBDIR);
1490 }
wxString MP3Exporter::GetLibraryTypeString ( )

Definition at line 1497 of file ExportMP3.cpp.

References _().

Referenced by FindLibrary().

1498 {
1499  return wxString(_("Only libmp3lame.so.0|libmp3lame.so.0|Primary Shared Object files (*.so)|*.so|Extended Libraries (*.so*)|*.so*|All Files (*)|*"));
1500 }
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxString MP3Exporter::GetLibraryVersion ( )

Definition at line 1198 of file ExportMP3.cpp.

References get_lame_version, and mLibraryLoaded.

Referenced by GetMP3Version().

1199 {
1200 #ifndef DISABLE_DYNAMIC_LOADING_LAME
1201  if (!mLibraryLoaded) {
1202  return wxT("");
1203  }
1204 #endif // DISABLE_DYNAMIC_LOADING_LAME
1205 
1206  return wxString::Format(wxT("LAME %hs"), get_lame_version());
1207 }
bool mLibraryLoaded
Definition: ExportMP3.cpp:859
get_lame_version_t * get_lame_version
Definition: ExportMP3.cpp:881
int MP3Exporter::GetOutBufferSize ( )

Definition at line 1315 of file ExportMP3.cpp.

References mEncoding, and mOutBufferSize.

Referenced by ExportMP3::Export().

1316 {
1317  if (!mEncoding)
1318  return -1;
1319 
1320  return mOutBufferSize;
1321 }
static const int mOutBufferSize
Definition: ExportMP3.cpp:910
bool mEncoding
Definition: ExportMP3.cpp:866
int MP3Exporter::InitializeStream ( unsigned  channels,
int  sampleRate 
)

Definition at line 1209 of file ExportMP3.cpp.

References CHANNEL_JOINT, CHANNEL_MONO, 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_padding_type, lame_set_preset, lame_set_VBR, lame_set_VBR_q, mBitrate, mChannel, mEncoding, mGF, mInfoTagLen, mLibraryLoaded, mMode, MODE_ABR, MODE_SET, MODE_VBR, mQuality, mRoutine, mSamplesPerChunk, PRESET_EXTREME, PRESET_INSANE, PRESET_STANDARD, ROUTINE_FAST, and ROUTINE_STANDARD.

Referenced by ExportMP3::Export().

1210 {
1211 #ifndef DISABLE_DYNAMIC_LOADING_LAME
1212  if (!mLibraryLoaded) {
1213  return -1;
1214  }
1215 #endif // DISABLE_DYNAMIC_LOADING_LAME
1216 
1217  if (channels > 2) {
1218  return -1;
1219  }
1220 
1222  lame_set_num_channels(mGF, channels);
1223  lame_set_in_samplerate(mGF, sampleRate);
1224  lame_set_out_samplerate(mGF, sampleRate);
1226 #ifndef DISABLE_DYNAMIC_LOADING_LAME
1227 // TODO: Make this configurable (detect the existance of this function)
1228  lame_set_padding_type(mGF, PAD_NO);
1229 #endif // DISABLE_DYNAMIC_LOADING_LAME
1230 
1231  // Add the VbrTag for all types. For ABR/VBR, a Xing tag will be created.
1232  // For CBR, it will be a Lame Info tag.
1233  lame_set_bWriteVbrTag(mGF, true);
1234 
1235  // Set the VBR quality or ABR/CBR bitrate
1236  switch (mMode) {
1237  case MODE_SET:
1238  {
1239  int preset;
1240 
1241  if (mQuality == PRESET_INSANE) {
1242  preset = INSANE;
1243  }
1244  else if (mRoutine == ROUTINE_FAST) {
1245  if (mQuality == PRESET_EXTREME) {
1246  preset = EXTREME_FAST;
1247  }
1248  else if (mQuality == PRESET_STANDARD) {
1249  preset = STANDARD_FAST;
1250  }
1251  else {
1252  preset = 1007; // Not defined until 3.96
1253  }
1254  }
1255  else {
1256  if (mQuality == PRESET_EXTREME) {
1257  preset = EXTREME;
1258  }
1259  else if (mQuality == PRESET_STANDARD) {
1260  preset = STANDARD;
1261  }
1262  else {
1263  preset = 1006; // Not defined until 3.96
1264  }
1265  }
1266 
1267  lame_set_preset(mGF, preset);
1268  }
1269  break;
1270 
1271  case MODE_VBR:
1272  lame_set_VBR(mGF, (mRoutine == ROUTINE_STANDARD ? vbr_rh : vbr_mtrh ));
1274  break;
1275 
1276  case MODE_ABR:
1278  break;
1279 
1280  default:
1281  lame_set_VBR(mGF, vbr_off);
1283  break;
1284  }
1285 
1286  // Set the channel mode
1287  MPEG_mode mode;
1288 
1289  if (channels == 1 || mChannel == CHANNEL_MONO) {
1290  mode = MONO;
1291  }
1292  else if (mChannel == CHANNEL_JOINT) {
1293  mode = JOINT_STEREO;
1294  }
1295  else {
1296  mode = STEREO;
1297  }
1298  lame_set_mode(mGF, mode);
1299 
1300  int rc = lame_init_params(mGF);
1301  if (rc < 0) {
1302  return rc;
1303  }
1304 
1305 #if 0
1306  dump_config(mGF);
1307 #endif
1308 
1309  mInfoTagLen = 0;
1310  mEncoding = true;
1311 
1312  return mSamplesPerChunk;
1313 }
static const int mSamplesPerChunk
Definition: ExportMP3.cpp:907
#define PRESET_INSANE
Definition: ExportMP3.cpp:131
size_t mInfoTagLen
Definition: ExportMP3.cpp:915
#define CHANNEL_JOINT
Definition: ExportMP3.cpp:113
#define PRESET_EXTREME
Definition: ExportMP3.cpp:132
bool mLibraryLoaded
Definition: ExportMP3.cpp:859
#define MODE_VBR
Definition: ExportMP3.cpp:109
lame_set_in_samplerate_t * lame_set_in_samplerate
Definition: ExportMP3.cpp:883
lame_set_out_samplerate_t * lame_set_out_samplerate
Definition: ExportMP3.cpp:884
lame_init_params_t * lame_init_params
Definition: ExportMP3.cpp:876
lame_set_bWriteVbrTag_t * lame_set_bWriteVbrTag
Definition: ExportMP3.cpp:896
#define PRESET_STANDARD
Definition: ExportMP3.cpp:133
lame_set_preset_t * lame_set_preset
Definition: ExportMP3.cpp:892
lame_set_num_channels_t * lame_set_num_channels
Definition: ExportMP3.cpp:885
#define MODE_ABR
Definition: ExportMP3.cpp:110
lame_set_brate_t * lame_set_brate
Definition: ExportMP3.cpp:887
bool mEncoding
Definition: ExportMP3.cpp:866
#define ROUTINE_FAST
Definition: ExportMP3.cpp:128
lame_set_disable_reservoir_t * lame_set_disable_reservoir
Definition: ExportMP3.cpp:894
#define MODE_SET
Definition: ExportMP3.cpp:108
lame_set_padding_type_t * lame_set_padding_type
Definition: ExportMP3.cpp:895
lame_set_mode_t * lame_set_mode
Definition: ExportMP3.cpp:891
lame_set_error_protection_t * lame_set_error_protection
Definition: ExportMP3.cpp:893
lame_set_VBR_t * lame_set_VBR
Definition: ExportMP3.cpp:888
#define CHANNEL_MONO
Definition: ExportMP3.cpp:115
lame_set_VBR_q_t * lame_set_VBR_q
Definition: ExportMP3.cpp:889
lame_global_flags * mGF
Definition: ExportMP3.cpp:905
#define ROUTINE_STANDARD
Definition: ExportMP3.cpp:129
bool MP3Exporter::InitLibrary ( wxString  libpath)

Definition at line 1066 of file ExportMP3.cpp.

References _(), AUDACITY_RELEASE, AUDACITY_REVISION, AUDACITY_VERSION, get_lame_version, lame_close, lame_encode_buffer, lame_encode_buffer_interleaved, 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_padding_type, lame_set_preset, lame_set_quality, lame_set_VBR, lame_set_VBR_min_bitrate_kbps, lame_set_VBR_q, mGF, and FileNames::PathFromAddr().

Referenced by ExportMP3::Export(), and LoadLibrary().

1067 {
1068  wxLogMessage(wxT("Loading LAME from %s"), libpath);
1069 
1070 #ifndef DISABLE_DYNAMIC_LOADING_LAME
1071  if (!lame_lib.Load(libpath, wxDL_LAZY)) {
1072  wxLogMessage(wxT("load failed"));
1073  return false;
1074  }
1075 
1076  wxLogMessage(wxT("Actual LAME path %s"),
1077  FileNames::PathFromAddr(lame_lib.GetSymbol(wxT("lame_init"))));
1078 
1079  lame_init = (lame_init_t *)
1080  lame_lib.GetSymbol(wxT("lame_init"));
1082  lame_lib.GetSymbol(wxT("get_lame_version"));
1084  lame_lib.GetSymbol(wxT("lame_init_params"));
1086  lame_lib.GetSymbol(wxT("lame_encode_buffer"));
1088  lame_lib.GetSymbol(wxT("lame_encode_buffer_interleaved"));
1090  lame_lib.GetSymbol(wxT("lame_encode_flush"));
1091  lame_close = (lame_close_t *)
1092  lame_lib.GetSymbol(wxT("lame_close"));
1093 
1095  lame_lib.GetSymbol(wxT("lame_set_in_samplerate"));
1097  lame_lib.GetSymbol(wxT("lame_set_out_samplerate"));
1099  lame_lib.GetSymbol(wxT("lame_set_num_channels"));
1101  lame_lib.GetSymbol(wxT("lame_set_quality"));
1103  lame_lib.GetSymbol(wxT("lame_set_brate"));
1105  lame_lib.GetSymbol(wxT("lame_set_VBR"));
1107  lame_lib.GetSymbol(wxT("lame_set_VBR_q"));
1109  lame_lib.GetSymbol(wxT("lame_set_VBR_min_bitrate_kbps"));
1111  lame_lib.GetSymbol(wxT("lame_set_mode"));
1113  lame_lib.GetSymbol(wxT("lame_set_preset"));
1115  lame_lib.GetSymbol(wxT("lame_set_error_protection"));
1117  lame_lib.GetSymbol(wxT("lame_set_disable_reservoir"));
1119  lame_lib.GetSymbol(wxT("lame_set_padding_type"));
1121  lame_lib.GetSymbol(wxT("lame_set_bWriteVbrTag"));
1122 
1123  // These are optional
1125  lame_lib.GetSymbol(wxT("lame_get_lametag_frame"));
1127  lame_lib.GetSymbol(wxT("lame_mp3_tags_fid"));
1128 #if defined(__WXMSW__)
1129  beWriteInfoTag = (beWriteInfoTag_t *)
1130  lame_lib.GetSymbol(wxT("beWriteInfoTag"));
1131  beVersion = (beVersion_t *)
1132  lame_lib.GetSymbol(wxT("beVersion"));
1133 #endif
1134 
1135  if (!lame_init ||
1136  !get_lame_version ||
1137  !lame_init_params ||
1138  !lame_encode_buffer ||
1140  !lame_encode_flush ||
1141  !lame_close ||
1145  !lame_set_quality ||
1146  !lame_set_brate ||
1147  !lame_set_VBR ||
1148  !lame_set_VBR_q ||
1149  !lame_set_mode ||
1150  !lame_set_preset ||
1155  {
1156  wxLogMessage(wxT("Failed to find a required symbol in the LAME library."));
1157 #if defined(__WXMSW__)
1158  if (beVersion) {
1159  be_version v;
1160  beVersion(&v);
1161 
1162  mBladeVersion.Printf(_("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 the LAME MP3 library."),
1163  v.byMajorVersion,
1164  v.byMinorVersion,
1168  }
1169 #endif
1170 
1171  lame_lib.Unload();
1172  return false;
1173  }
1174 #endif // DISABLE_DYNAMIC_LOADING_LAME
1175 
1176  mGF = lame_init();
1177  if (mGF == NULL) {
1178  return false;
1179  }
1180 
1181  return true;
1182 }
#define AUDACITY_REVISION
Definition: Audacity.h:65
lame_close_t * lame_close
Definition: ExportMP3.cpp:880
int lame_set_bWriteVbrTag_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:752
int lame_set_padding_type_t(lame_global_flags *, Padding_type)
Definition: ExportMP3.cpp:751
lame_set_in_samplerate_t * lame_set_in_samplerate
Definition: ExportMP3.cpp:883
lame_set_out_samplerate_t * lame_set_out_samplerate
Definition: ExportMP3.cpp:884
wxDynamicLibrary lame_lib
Definition: ExportMP3.cpp:858
int lame_set_out_samplerate_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:740
size_t lame_get_lametag_frame_t(const lame_global_flags *, unsigned char *buffer, size_t size)
Definition: ExportMP3.cpp:753
lame_init_params_t * lame_init_params
Definition: ExportMP3.cpp:876
#define AUDACITY_VERSION
Definition: Audacity.h:63
int lame_set_error_protection_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:749
static wxString PathFromAddr(void *addr)
Definition: FileNames.cpp:305
lame_set_bWriteVbrTag_t * lame_set_bWriteVbrTag
Definition: ExportMP3.cpp:896
const char * get_lame_version_t(void)
Definition: ExportMP3.cpp:715
lame_encode_buffer_t * lame_encode_buffer
Definition: ExportMP3.cpp:877
int lame_set_VBR_t(lame_global_flags *, vbr_mode)
Definition: ExportMP3.cpp:744
int lame_set_num_channels_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:741
lame_set_preset_t * lame_set_preset
Definition: ExportMP3.cpp:892
int lame_set_mode_t(lame_global_flags *, MPEG_mode)
Definition: ExportMP3.cpp:747
int lame_set_VBR_q_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:745
lame_set_VBR_min_bitrate_kbps_t * lame_set_VBR_min_bitrate_kbps
Definition: ExportMP3.cpp:890
lame_set_num_channels_t * lame_set_num_channels
Definition: ExportMP3.cpp:885
int lame_set_preset_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:748
int lame_set_disable_reservoir_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:750
#define AUDACITY_RELEASE
Definition: Audacity.h:64
lame_set_brate_t * lame_set_brate
Definition: ExportMP3.cpp:887
int lame_close_t(lame_global_flags *)
Definition: ExportMP3.cpp:737
void lame_mp3_tags_fid_t(lame_global_flags *, FILE *)
Definition: ExportMP3.cpp:754
int lame_set_quality_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:742
lame_mp3_tags_fid_t * lame_mp3_tags_fid
Definition: ExportMP3.cpp:898
lame_get_lametag_frame_t * lame_get_lametag_frame
Definition: ExportMP3.cpp:897
int lame_set_in_samplerate_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:739
int lame_encode_flush_t(lame_global_flags *gf, unsigned char *mp3buf, int size)
Definition: ExportMP3.cpp:732
lame_set_disable_reservoir_t * lame_set_disable_reservoir
Definition: ExportMP3.cpp:894
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
lame_encode_flush_t * lame_encode_flush
Definition: ExportMP3.cpp:879
int lame_encode_buffer_interleaved_t(lame_global_flags *gf, short int pcm[], int num_samples, unsigned char *mp3buf, int mp3buf_size)
Definition: ExportMP3.cpp:725
lame_set_padding_type_t * lame_set_padding_type
Definition: ExportMP3.cpp:895
lame_encode_buffer_interleaved_t * lame_encode_buffer_interleaved
Definition: ExportMP3.cpp:878
lame_set_mode_t * lame_set_mode
Definition: ExportMP3.cpp:891
lame_global_flags * lame_init_t(void)
Definition: ExportMP3.cpp:713
lame_set_error_protection_t * lame_set_error_protection
Definition: ExportMP3.cpp:893
lame_set_VBR_t * lame_set_VBR
Definition: ExportMP3.cpp:888
int lame_set_brate_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:743
get_lame_version_t * get_lame_version
Definition: ExportMP3.cpp:881
lame_init_t * lame_init
Definition: ExportMP3.cpp:875
lame_set_quality_t * lame_set_quality
Definition: ExportMP3.cpp:886
int lame_set_VBR_min_bitrate_kbps_t(lame_global_flags *, int)
Definition: ExportMP3.cpp:746
lame_set_VBR_q_t * lame_set_VBR_q
Definition: ExportMP3.cpp:889
int lame_encode_buffer_t(lame_global_flags *gf, const short int buffer_l[], const short int buffer_r[], const int nsamples, unsigned char *mp3buf, const int mp3buf_size)
Definition: ExportMP3.cpp:717
lame_global_flags * mGF
Definition: ExportMP3.cpp:905
int lame_init_params_t(lame_global_flags *)
Definition: ExportMP3.cpp:714
bool MP3Exporter::LoadLibrary ( wxWindow *  parent,
AskUser  askuser 
)

Definition at line 981 of file ExportMP3.cpp.

References AudacityMessageBox(), FindLibrary(), FreeLibrary(), GetLibraryName(), GetLibraryPath(), InitLibrary(), Maybe, mLibPath, mLibraryLoaded, and ValidLibraryLoaded().

Referenced by ExportMP3::CheckFileName(), ExportMP3::Export(), and GetMP3Version().

982 {
983  if (ValidLibraryLoaded()) {
984  FreeLibrary();
985  mLibraryLoaded = false;
986  }
987 
988 #if defined(__WXMSW__)
989  mBladeVersion.Empty();
990 #endif
991 
992  // First try loading it from a previously located path
993  if (!mLibPath.IsEmpty()) {
994  wxLogMessage(wxT("Attempting to load LAME from previously defined path"));
996  }
997 
998  // If not successful, try loading using system search paths
999  if (!ValidLibraryLoaded()) {
1000  wxLogMessage(wxT("Attempting to load LAME from system search paths"));
1003  }
1004 
1005  // If not successful, try loading using compiled in path
1006  if (!ValidLibraryLoaded()) {
1007  wxLogMessage(wxT("Attempting to load LAME from builtin path"));
1008  wxFileName fn(GetLibraryPath(), GetLibraryName());
1009  mLibPath = fn.GetFullPath();
1011  }
1012 
1013  // If not successful, must ask the user
1014  if (!ValidLibraryLoaded()) {
1015  wxLogMessage(wxT("(Maybe) ask user for library"));
1016  if (askuser == MP3Exporter::Maybe && FindLibrary(parent)) {
1018  }
1019  }
1020 
1021  // Oh well, just give up
1022  if (!ValidLibraryLoaded()) {
1023 #if defined(__WXMSW__)
1024  if (askuser && !mBladeVersion.IsEmpty()) {
1025  AudacityMessageBox(mBladeVersion);
1026  }
1027 #endif
1028  wxLogMessage(wxT("Failed to locate LAME library"));
1029 
1030  return false;
1031  }
1032 
1033  wxLogMessage(wxT("LAME library successfully loaded"));
1034 
1035  return true;
1036 }
bool InitLibrary(wxString libpath)
Definition: ExportMP3.cpp:1066
bool mLibraryLoaded
Definition: ExportMP3.cpp:859
int AudacityMessageBox(const wxString &message, const wxString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: ErrorDialog.h:92
void FreeLibrary()
Definition: ExportMP3.cpp:1184
bool ValidLibraryLoaded()
Definition: ExportMP3.cpp:1038
wxString GetLibraryPath()
WXMAC
Definition: ExportMP3.cpp:1487
wxString GetLibraryName()
Definition: ExportMP3.cpp:1492
wxString mLibPath
Definition: ExportMP3.cpp:857
bool FindLibrary(wxWindow *parent)
Definition: ExportMP3.cpp:946
bool MP3Exporter::PutInfoTag ( wxFFile &  f,
wxFileOffset  off 
)

Definition at line 1391 of file ExportMP3.cpp.

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

Referenced by ExportMP3::Export().

1392 {
1393  if (mGF) {
1394  if (mInfoTagLen > 0) {
1395  // FIXME: TRAP_ERR Seek and writ ein MP3 exporter could fail.
1396  if ( !f.Seek(off, wxFromStart))
1397  return false;
1398  if (mInfoTagLen > f.Write(mInfoTagBuf, mInfoTagLen))
1399  return false;
1400  }
1401 #if defined(__WXMSW__)
1402  else if (beWriteInfoTag) {
1403  if ( !f.Flush() )
1404  return false;
1405  // PRL: What is the correct error check on the return value?
1406  beWriteInfoTag(mGF, OSOUTPUT(f.GetName()));
1407  mGF = NULL;
1408  }
1409 #endif
1410  else if (lame_mp3_tags_fid != NULL) {
1411  lame_mp3_tags_fid(mGF, f.fp());
1412  }
1413  }
1414 
1415  if ( !f.SeekEnd() )
1416  return false;
1417 
1418  return true;
1419 }
#define OSOUTPUT(X)
Definition: Internat.h:175
size_t mInfoTagLen
Definition: ExportMP3.cpp:915
unsigned char mInfoTagBuf[2880]
Definition: ExportMP3.cpp:914
lame_mp3_tags_fid_t * lame_mp3_tags_fid
Definition: ExportMP3.cpp:898
lame_global_flags * mGF
Definition: ExportMP3.cpp:905
void MP3Exporter::SetBitrate ( int  rate)

Definition at line 1050 of file ExportMP3.cpp.

References mBitrate.

Referenced by ExportMP3::Export().

1051 {
1052  mBitrate = rate;
1053 }
void MP3Exporter::SetChannel ( int  mode)

Definition at line 1061 of file ExportMP3.cpp.

References mChannel.

Referenced by ExportMP3::Export().

1062 {
1063  mChannel = mode;
1064 }
void MP3Exporter::SetMode ( int  mode)

Definition at line 1045 of file ExportMP3.cpp.

References mMode.

Referenced by ExportMP3::Export().

1046 {
1047  mMode = mode;
1048 }
void MP3Exporter::SetQuality ( int  q,
int  r 
)

Definition at line 1055 of file ExportMP3.cpp.

References mQuality, and mRoutine.

Referenced by ExportMP3::Export().

1056 {
1057  mQuality = q;
1058  mRoutine = r;
1059 }
bool MP3Exporter::ValidLibraryLoaded ( )

Definition at line 1038 of file ExportMP3.cpp.

References mLibraryLoaded.

Referenced by ExportMP3::Export(), and LoadLibrary().

1039 {
1040  return mLibraryLoaded;
1041 }
bool mLibraryLoaded
Definition: ExportMP3.cpp:859

Member Data Documentation

get_lame_version_t* MP3Exporter::get_lame_version
private

Definition at line 881 of file ExportMP3.cpp.

Referenced by GetLibraryVersion(), and InitLibrary().

lame_close_t* MP3Exporter::lame_close
private

Definition at line 880 of file ExportMP3.cpp.

Referenced by FreeLibrary(), and InitLibrary().

lame_encode_buffer_t* MP3Exporter::lame_encode_buffer
private

Definition at line 877 of file ExportMP3.cpp.

Referenced by EncodeBufferMono(), EncodeRemainderMono(), and InitLibrary().

lame_encode_buffer_interleaved_t* MP3Exporter::lame_encode_buffer_interleaved
private

Definition at line 878 of file ExportMP3.cpp.

Referenced by EncodeBuffer(), EncodeRemainder(), and InitLibrary().

lame_encode_flush_t* MP3Exporter::lame_encode_flush
private

Definition at line 879 of file ExportMP3.cpp.

Referenced by FinishStream(), and InitLibrary().

lame_get_lametag_frame_t* MP3Exporter::lame_get_lametag_frame
private

Definition at line 897 of file ExportMP3.cpp.

Referenced by FinishStream(), and InitLibrary().

lame_init_t* MP3Exporter::lame_init
private

Definition at line 875 of file ExportMP3.cpp.

Referenced by InitLibrary().

lame_init_params_t* MP3Exporter::lame_init_params
private

Definition at line 876 of file ExportMP3.cpp.

Referenced by InitializeStream(), and InitLibrary().

wxDynamicLibrary MP3Exporter::lame_lib
private

Definition at line 858 of file ExportMP3.cpp.

Referenced by FreeLibrary(), and InitLibrary().

lame_mp3_tags_fid_t* MP3Exporter::lame_mp3_tags_fid
private

Definition at line 898 of file ExportMP3.cpp.

Referenced by InitLibrary(), and PutInfoTag().

lame_set_brate_t* MP3Exporter::lame_set_brate
private

Definition at line 887 of file ExportMP3.cpp.

Referenced by InitializeStream(), and InitLibrary().

lame_set_bWriteVbrTag_t* MP3Exporter::lame_set_bWriteVbrTag
private

Definition at line 896 of file ExportMP3.cpp.

Referenced by InitializeStream(), and InitLibrary().

lame_set_disable_reservoir_t* MP3Exporter::lame_set_disable_reservoir
private

Definition at line 894 of file ExportMP3.cpp.

Referenced by InitializeStream(), and InitLibrary().

lame_set_error_protection_t* MP3Exporter::lame_set_error_protection
private

Definition at line 893 of file ExportMP3.cpp.

Referenced by InitializeStream(), and InitLibrary().

lame_set_in_samplerate_t* MP3Exporter::lame_set_in_samplerate
private

Definition at line 883 of file ExportMP3.cpp.

Referenced by InitializeStream(), and InitLibrary().

lame_set_mode_t* MP3Exporter::lame_set_mode
private

Definition at line 891 of file ExportMP3.cpp.

Referenced by InitializeStream(), and InitLibrary().

lame_set_num_channels_t* MP3Exporter::lame_set_num_channels
private

Definition at line 885 of file ExportMP3.cpp.

Referenced by InitializeStream(), and InitLibrary().

lame_set_out_samplerate_t* MP3Exporter::lame_set_out_samplerate
private

Definition at line 884 of file ExportMP3.cpp.

Referenced by InitializeStream(), and InitLibrary().

lame_set_padding_type_t* MP3Exporter::lame_set_padding_type
private

Definition at line 895 of file ExportMP3.cpp.

Referenced by InitializeStream(), and InitLibrary().

lame_set_preset_t* MP3Exporter::lame_set_preset
private

Definition at line 892 of file ExportMP3.cpp.

Referenced by InitializeStream(), and InitLibrary().

lame_set_quality_t* MP3Exporter::lame_set_quality
private

Definition at line 886 of file ExportMP3.cpp.

Referenced by InitLibrary().

lame_set_VBR_t* MP3Exporter::lame_set_VBR
private

Definition at line 888 of file ExportMP3.cpp.

Referenced by InitializeStream(), and InitLibrary().

lame_set_VBR_min_bitrate_kbps_t* MP3Exporter::lame_set_VBR_min_bitrate_kbps
private

Definition at line 890 of file ExportMP3.cpp.

Referenced by InitLibrary().

lame_set_VBR_q_t* MP3Exporter::lame_set_VBR_q
private

Definition at line 889 of file ExportMP3.cpp.

Referenced by InitializeStream(), and InitLibrary().

int MP3Exporter::mBitrate
private

Definition at line 868 of file ExportMP3.cpp.

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

int MP3Exporter::mChannel
private

Definition at line 871 of file ExportMP3.cpp.

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

bool MP3Exporter::mEncoding
private
lame_global_flags* MP3Exporter::mGF
private
unsigned char MP3Exporter::mInfoTagBuf[2880]
private

Definition at line 914 of file ExportMP3.cpp.

Referenced by FinishStream(), and PutInfoTag().

size_t MP3Exporter::mInfoTagLen
private

Definition at line 915 of file ExportMP3.cpp.

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

wxString MP3Exporter::mLibPath
private

Definition at line 857 of file ExportMP3.cpp.

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

bool MP3Exporter::mLibraryLoaded
private
int MP3Exporter::mMode
private

Definition at line 867 of file ExportMP3.cpp.

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

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

Definition at line 910 of file ExportMP3.cpp.

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

int MP3Exporter::mQuality
private

Definition at line 869 of file ExportMP3.cpp.

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

int MP3Exporter::mRoutine
private

Definition at line 870 of file ExportMP3.cpp.

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

const int MP3Exporter::mSamplesPerChunk = 220500
staticprivate

Definition at line 907 of file ExportMP3.cpp.

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


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