Audacity  3.0.3
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Exporter Class Referencefinal

#include <Export.h>

Inheritance diagram for Exporter:
[legend]
Collaboration diagram for Exporter:
[legend]

Classes

struct  RegisteredExportPlugin
 

Public Types

using ExportPluginFactory = std::function< std::unique_ptr< ExportPlugin >() >
 

Public Member Functions

 Exporter (AudacityProject &project)
 
virtual ~Exporter ()
 
void SetFileDialogTitle (const TranslatableString &DialogTitle)
 
void SetDefaultFormat (const FileExtension &Format)
 
bool Process (bool selectedOnly, double t0, double t1)
 
bool Process (unsigned numChannels, const FileExtension &type, const wxString &filename, bool selectedOnly, double t0, double t1)
 
void DisplayOptions (int index)
 
int FindFormatIndex (int exportindex)
 
const ExportPluginArrayGetPlugins ()
 
bool ProcessFromTimerRecording (bool selectedOnly, double t0, double t1, wxFileName fnFile, int iFormat, int iSubFormat, int iFilterIndex)
 
bool SetAutoExportOptions ()
 
int GetAutoExportFormat ()
 
int GetAutoExportSubFormat ()
 
int GetAutoExportFilterIndex ()
 
wxFileName GetAutoExportFileName ()
 
void OnExtensionChanged (wxCommandEvent &evt)
 
void OnHelp (wxCommandEvent &evt)
 

Static Public Member Functions

static bool DoEditMetadata (AudacityProject &project, const TranslatableString &title, const TranslatableString &shortUndoDescription, bool force)
 

Private Member Functions

bool ExamineTracks ()
 
bool GetFilename ()
 
bool CheckFilename ()
 
bool CheckMix (bool prompt=true)
 
bool ExportTracks ()
 
void CreateUserPane (wxWindow *parent)
 
void OnFilterChanged (wxFileCtrlEvent &evt)
 

Static Private Member Functions

static void CreateUserPaneCallback (wxWindow *parent, wxUIntPtr userdata)
 

Private Attributes

FileExtension mFormatName
 
FileDialogWrappermDialog
 
TranslatableString mFileDialogTitle
 
AudacityProjectmProject
 
std::unique_ptr< MixerSpecmMixerSpec
 
ExportPluginArray mPlugins
 
wxFileName mFilename
 
wxFileName mActualName
 
double mT0
 
double mT1
 
int mFilterIndex
 
int mFormat
 
int mSubFormat
 
int mNumSelected
 
unsigned mNumLeft
 
unsigned mNumRight
 
unsigned mNumMono
 
unsigned mChannels
 
bool mSelectedOnly
 
wxSimplebook * mBook
 

Detailed Description

Definition at line 165 of file Export.h.

Member Typedef Documentation

◆ ExportPluginFactory

using Exporter::ExportPluginFactory = std::function< std::unique_ptr< ExportPlugin >() >

Definition at line 169 of file Export.h.

Constructor & Destructor Documentation

◆ Exporter()

Exporter::Exporter ( AudacityProject project)

Definition at line 320 of file Export.cpp.

321 : mProject{ &project }
322 {
323  using namespace Registry;
324  static OrderingPreferenceInitializer init{
325  PathStart,
326  { {wxT(""), wxT("PCM,MP3,OGG,FLAC,MP2,CommandLine,FFmpeg") } },
327  };
328 
329  mMixerSpec = NULL;
330  mBook = NULL;
331 
332  // build the list of export plugins.
333  for ( const auto &factory : sFactories() )
334  mPlugins.emplace_back( factory() );
335 
336  struct MyVisitor final : Visitor {
337  MyVisitor()
338  {
339  // visit the registry to collect the plug-ins properly
340  // sorted
342  Registry::Visit( *this, &top, &sRegistry() );
343  }
344 
345  void Visit( SingleItem &item, const Path &path ) override
346  {
347  mPlugins.emplace_back(
348  static_cast<ExporterItem&>( item ).mFactory() );
349  }
350 
352  } visitor;
353 
354  mPlugins.swap( visitor.mPlugins );
355 
356  SetFileDialogTitle( XO("Export Audio") );
357 }

◆ ~Exporter()

Exporter::~Exporter ( )
virtual

Definition at line 359 of file Export.cpp.

360 {
361 }

Member Function Documentation

◆ CheckFilename()

bool Exporter::CheckFilename ( )
private

Definition at line 783 of file Export.cpp.

784 {
785  //
786  // To be even safer, return a temporary file name based
787  // on this one...
788  //
789 
791 
792  int suffix = 0;
793  while (mFilename.FileExists()) {
794  mFilename.SetName(mActualName.GetName() +
795  wxString::Format(wxT("%d"), suffix));
796  suffix++;
797  }
798 
799  return true;
800 }

References mActualName, and mFilename.

Referenced by Process(), and ProcessFromTimerRecording().

Here is the caller graph for this function:

◆ CheckMix()

bool Exporter::CheckMix ( bool  prompt = true)
private

Definition at line 832 of file Export.cpp.

833 {
834  // Clean up ... should never happen
835  mMixerSpec.reset();
836 
837  // Determine if exported file will be stereo or mono or multichannel,
838  // and if mixing will occur.
839 
841  int exportedChannels = mPlugins[mFormat]->SetNumExportChannels();
842 
843  if (downMix) {
844  if (mNumRight > 0 || mNumLeft > 0) {
845  mChannels = 2;
846  }
847  else {
848  mChannels = 1;
849  }
851  mPlugins[mFormat]->GetMaxChannels(mSubFormat));
852 
853  auto numLeft = mNumLeft + mNumMono;
854  auto numRight = mNumRight + mNumMono;
855 
856  if (numLeft > 1 || numRight > 1 || mNumLeft + mNumRight + mNumMono > mChannels) {
857  wxString exportFormat = mPlugins[mFormat]->GetFormat(mSubFormat);
858  if (exportFormat != wxT("CL") && exportFormat != wxT("FFMPEG") && exportedChannels == -1)
859  exportedChannels = mChannels;
860 
861  if (prompt) {
862  auto pWindow = ProjectWindow::Find(mProject);
863  if (exportedChannels == 1) {
864  if (ShowWarningDialog(pWindow,
865  wxT("MixMono"),
866  XO("Your tracks will be mixed down and exported as one mono file."),
867  true) == wxID_CANCEL)
868  return false;
869  }
870  else if (exportedChannels == 2) {
871  if (ShowWarningDialog(pWindow,
872  wxT("MixStereo"),
873  XO("Your tracks will be mixed down and exported as one stereo file."),
874  true) == wxID_CANCEL)
875  return false;
876  }
877  else {
878  if (ShowWarningDialog(pWindow,
879  wxT("MixUnknownChannels"),
880  XO("Your tracks will be mixed down to one exported file according to the encoder settings."),
881  true) == wxID_CANCEL)
882  return false;
883  }
884  }
885  }
886  }
887  else
888  {
889  if (exportedChannels < 0)
890  exportedChannels = mPlugins[mFormat]->GetMaxChannels(mSubFormat);
891 
894  exportedChannels,
895  NULL,
896  1,
897  XO("Advanced Mixing Options"));
898  if (prompt) {
899  if (md.ShowModal() != wxID_OK) {
900  return false;
901  }
902  }
903 
904  mMixerSpec = std::make_unique<MixerSpec>(*(md.GetMixerSpec()));
905  mChannels = mMixerSpec->GetNumChannels();
906  }
907 
908  return true;
909 }

References ImportExportPrefs::ExportDownMixSetting, ProjectWindow::Find(), TrackList::Get(), ExportMixerDialog::GetMixerSpec(), mChannels, mFormat, min(), mMixerSpec, mNumLeft, mNumMono, mNumRight, mPlugins, mProject, mSelectedOnly, mSubFormat, EnumSetting< Enum >::ReadEnum(), ShowWarningDialog(), and XO.

Referenced by Process(), and ProcessFromTimerRecording().

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

◆ CreateUserPane()

void Exporter::CreateUserPane ( wxWindow *  parent)
private

Definition at line 967 of file Export.cpp.

968 {
969  ShuttleGui S(parent, eIsCreating);
970 
971  S.StartStatic(XO("Format Options"), 1);
972  {
973  S.StartHorizontalLay(wxEXPAND);
974  {
975  mBook = S.Position(wxEXPAND).StartSimplebook();
976  {
977  for (const auto &pPlugin : mPlugins)
978  {
979  for (int j = 0; j < pPlugin->GetFormatCount(); j++)
980  {
981  // Name of simple book page is not displayed
982  S.StartNotebookPage( {} );
983  {
984  pPlugin->OptionsCreate(S, j);
985  }
986  S.EndNotebookPage();
987  }
988  }
989  }
990  S.EndSimplebook();
991 
992  auto b = safenew wxBitmapButton(S.GetParent(), wxID_HELP, theTheme.Bitmap( bmpHelpIcon ));
993  b->SetToolTip( XO("Help").Translation() );
994  b->SetLabel(XO("Help").Translation()); // for screen readers
995  S.Position(wxALIGN_BOTTOM | wxRIGHT | wxBOTTOM).AddWindow(b);
996  }
997  S.EndHorizontalLay();
998  }
999  S.EndStatic();
1000 
1001  return;
1002 }

References ShuttleGuiBase::AddWindow(), ThemeBase::Bitmap(), eIsCreating, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndNotebookPage(), ShuttleGuiBase::EndSimplebook(), ShuttleGuiBase::EndStatic(), ShuttleGuiBase::GetParent(), mBook, mPlugins, ShuttleGui::Position(), safenew, ShuttleGuiBase::StartHorizontalLay(), ShuttleGuiBase::StartNotebookPage(), ShuttleGuiBase::StartSimplebook(), ShuttleGuiBase::StartStatic(), theTheme, and XO.

Referenced by CreateUserPaneCallback().

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

◆ CreateUserPaneCallback()

void Exporter::CreateUserPaneCallback ( wxWindow *  parent,
wxUIntPtr  userdata 
)
staticprivate

Definition at line 958 of file Export.cpp.

959 {
960  Exporter *self = (Exporter *) userdata;
961  if (self)
962  {
963  self->CreateUserPane(parent);
964  }
965 }

References CreateUserPane().

Referenced by GetFilename().

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

◆ DisplayOptions()

void Exporter::DisplayOptions ( int  index)

Definition at line 802 of file Export.cpp.

803 {
804  int c = 0;
805  int mf = -1, msf = -1;
806  int i = -1;
807  for (const auto &pPlugin : mPlugins)
808  {
809  ++i;
810  for (int j = 0; j < pPlugin->GetFormatCount(); j++)
811  {
812  if (index == c)
813  {
814  mf = i;
815  msf = j;
816  }
817  c++;
818  }
819  }
820  // This shouldn't happen...
821  if (index >= c) {
822  return;
823  }
824 
825 #if defined(__WXMSW__)
826  mPlugins[mf]->DisplayOptions( FindProjectFrame( mProject ), msf);
827 #else
828  mPlugins[mf]->DisplayOptions(mDialog, msf);
829 #endif
830 }

References FindProjectFrame(), mDialog, mPlugins, and mProject.

Here is the call graph for this function:

◆ DoEditMetadata()

bool Exporter::DoEditMetadata ( AudacityProject project,
const TranslatableString title,
const TranslatableString shortUndoDescription,
bool  force 
)
static

Definition at line 399 of file Export.cpp.

402 {
403  auto &settings = ProjectSettings::Get( project );
404  auto &tags = Tags::Get( project );
405 
406  // Back up my tags
407  // Tags (artist name, song properties, MP3 ID3 info, etc.)
408  // The structure may be shared with undo history entries
409  // To keep undo working correctly, always replace this with a NEW duplicate
410  // BEFORE doing any editing of it!
411  auto newTags = tags.Duplicate();
412 
413  if (newTags->ShowEditDialog(&GetProjectFrame( project ), title, force)) {
414  if (tags != *newTags) {
415  // Commit the change to project state only now.
416  Tags::Set( project, newTags );
417  ProjectHistory::Get( project ).PushState( title, shortUndoDescription);
418  }
419  bool bShowInFuture;
420  gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &bShowInFuture, true);
421  settings.SetShowId3Dialog( bShowInFuture );
422  return true;
423  }
424 
425  return false;
426 }

References ProjectHistory::Get(), ProjectSettings::Get(), Tags::Get(), GetProjectFrame(), gPrefs, ProjectHistory::PushState(), Tags::Set(), settings(), and title.

Referenced by EditActions::Handler::OnEditMetadata(), Process(), and SetAutoExportOptions().

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

◆ ExamineTracks()

bool Exporter::ExamineTracks ( )
private

Definition at line 510 of file Export.cpp.

511 {
512  // Init
513  mNumSelected = 0;
514  mNumLeft = 0;
515  mNumRight = 0;
516  mNumMono = 0;
517 
518  // First analyze the selected audio, perform sanity checks, and provide
519  // information as appropriate.
520 
521  // Tally how many are right, left, mono, and make sure at
522  // least one track is selected (if selectedOnly==true)
523 
524  double earliestBegin = mT1;
525  double latestEnd = mT0;
526 
527  auto &tracks = TrackList::Get( *mProject );
528 
529  bool anySolo = !(( tracks.Any<const WaveTrack>() + &WaveTrack::GetSolo ).empty());
530 
531  for (auto tr :
532  tracks.Any< const WaveTrack >()
534  - ( anySolo ? &WaveTrack::GetNotSolo : &WaveTrack::GetMute)
535  ) {
536  mNumSelected++;
537 
538  if (tr->GetChannel() == Track::LeftChannel) {
539  mNumLeft++;
540  }
541  else if (tr->GetChannel() == Track::RightChannel) {
542  mNumRight++;
543  }
544  else if (tr->GetChannel() == Track::MonoChannel) {
545  // It's a mono channel, but it may be panned
546  float pan = tr->GetPan();
547 
548  if (pan == -1.0)
549  mNumLeft++;
550  else if (pan == 1.0)
551  mNumRight++;
552  else if (pan == 0)
553  mNumMono++;
554  else {
555  // Panned partially off-center. Mix as stereo.
556  mNumLeft++;
557  mNumRight++;
558  }
559  }
560 
561  if (tr->GetOffset() < earliestBegin) {
562  earliestBegin = tr->GetOffset();
563  }
564 
565  if (tr->GetEndTime() > latestEnd) {
566  latestEnd = tr->GetEndTime();
567  }
568  }
569 
570  if (mNumSelected == 0) {
571  TranslatableString message;
572  if(mSelectedOnly)
573  message = XO("All selected audio is muted.");
574  else
575  message = XO("All audio is muted.");
577  ":576",
578  message);
579  return false;
580  }
581 
582  // The skipping of silent space could be cleverer and take
583  // into account clips.
584  // As implemented now, it can only skip initial silent space that
585  // has no clip before it, and terminal silent space that has no clip
586  // after it.
587  if (mT0 < earliestBegin){
588  // Bug 1904
589  // Previously we always skipped initial silent space.
590  // Now skipping it is an opt-in option.
591  bool skipSilenceAtBeginning;
592  gPrefs->Read(wxT("/AudioFiles/SkipSilenceAtBeginning"),
593  &skipSilenceAtBeginning, false);
594  if (skipSilenceAtBeginning)
595  mT0 = earliestBegin;
596  }
597 
598  // We still skip silent space at the end
599  if (mT1 > latestEnd)
600  mT1 = latestEnd;
601 
602  return true;
603 }

References Track::Any(), TrackList::Get(), PlayableTrack::GetMute(), PlayableTrack::GetNotSolo(), PlayableTrack::GetSolo(), gPrefs, Track::IsSelected(), Track::LeftChannel, mNumLeft, mNumMono, mNumRight, mNumSelected, Track::MonoChannel, mProject, mSelectedOnly, mT0, mT1, Track::RightChannel, ShowExportErrorDialog(), and XO.

Referenced by Process(), and ProcessFromTimerRecording().

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

◆ ExportTracks()

bool Exporter::ExportTracks ( )
private

Definition at line 911 of file Export.cpp.

912 {
913  // Keep original in case of failure
914  if (mActualName != mFilename) {
915  ::wxRenameFile(mActualName.GetFullPath(), mFilename.GetFullPath());
916  }
917 
918  bool success = false;
919 
920  auto cleanup = finally( [&] {
921  if (mActualName != mFilename) {
922  // Remove backup
923  if ( success )
924  ::wxRemoveFile(mFilename.GetFullPath());
925  else {
926  // Restore original, if needed
927  ::wxRemoveFile(mActualName.GetFullPath());
928  ::wxRenameFile(mFilename.GetFullPath(), mActualName.GetFullPath());
929  }
930  // Restore filename
932  }
933  else {
934  if ( ! success )
935  // Remove any new, and only partially written, file.
936  ::wxRemoveFile(mFilename.GetFullPath());
937  }
938  } );
939 
940  std::unique_ptr<ProgressDialog> pDialog;
941  auto result = mPlugins[mFormat]->Export(mProject,
942  pDialog,
943  mChannels,
944  mActualName.GetFullPath(),
946  mT0,
947  mT1,
948  mMixerSpec.get(),
949  NULL,
950  mSubFormat);
951 
952  success =
953  result == ProgressResult::Success || result == ProgressResult::Stopped;
954 
955  return success;
956 }

References mActualName, mChannels, mFilename, mFormat, mMixerSpec, mPlugins, mProject, mSelectedOnly, mSubFormat, mT0, mT1, and BasicUI::Success.

Referenced by Process(), and ProcessFromTimerRecording().

Here is the caller graph for this function:

◆ FindFormatIndex()

int Exporter::FindFormatIndex ( int  exportindex)

Definition at line 380 of file Export.cpp.

381 {
382  int c = 0;
383  for (const auto &pPlugin : mPlugins)
384  {
385  for (int j = 0; j < pPlugin->GetFormatCount(); j++)
386  {
387  if (exportindex == c) return j;
388  c++;
389  }
390  }
391  return 0;
392 }

References mPlugins.

◆ GetAutoExportFileName()

wxFileName Exporter::GetAutoExportFileName ( )

Definition at line 1097 of file Export.cpp.

1097  {
1098  return mFilename;
1099 }

References mFilename.

◆ GetAutoExportFilterIndex()

int Exporter::GetAutoExportFilterIndex ( )

Definition at line 1093 of file Export.cpp.

1093  {
1094  return mFormat;
1095 }

References mFormat.

◆ GetAutoExportFormat()

int Exporter::GetAutoExportFormat ( )

Definition at line 1085 of file Export.cpp.

1085  {
1086  return mFormat;
1087 }

References mFormat.

◆ GetAutoExportSubFormat()

int Exporter::GetAutoExportSubFormat ( )

Definition at line 1089 of file Export.cpp.

1089  {
1090  return mSubFormat;
1091 }

References mSubFormat.

◆ GetFilename()

bool Exporter::GetFilename ( )
private

Definition at line 605 of file Export.cpp.

606 {
607  mFormat = -1;
608 
609  FileNames::FileTypes fileTypes;
610  auto defaultFormat = mFormatName;
611  if( defaultFormat.empty() )
612  defaultFormat = gPrefs->Read(wxT("/Export/Format"),
613  wxT("WAV"));
614 
615  mFilterIndex = 0;
616 
617  {
618  int i = -1;
619  for (const auto &pPlugin : mPlugins) {
620  ++i;
621  for (int j = 0; j < pPlugin->GetFormatCount(); j++)
622  {
623  auto mask = pPlugin->GetMask(j);
624  fileTypes.insert( fileTypes.end(), mask.begin(), mask.end() );
625  if (mPlugins[i]->GetFormat(j) == defaultFormat) {
626  mFormat = i;
627  mSubFormat = j;
628  }
629  if (mFormat == -1) mFilterIndex++;
630  }
631  }
632  }
633  if (mFormat == -1)
634  {
635  mFormat = 0;
636  mFilterIndex = 0;
637  mSubFormat = 0;
638  }
639  wxString defext = mPlugins[mFormat]->GetExtension(mSubFormat).Lower();
640 
641  //Bug 1304: Set a default path if none was given. For Export.
642  mFilename.SetPath(FileNames::FindDefaultPath(FileNames::Operation::Export));
643  mFilename.SetName(mProject->GetProjectName());
644  if (mFilename.GetName().empty())
645  mFilename.SetName(_("untitled"));
646  while (true) {
647  // Must reset each iteration
648  mBook = NULL;
649 
650  {
651  auto useFileName = mFilename;
652  if (!useFileName.HasExt())
653  useFileName.SetExt(defext);
656  mFilename.GetPath(),
657  useFileName.GetFullName(),
658  fileTypes,
659  wxFD_SAVE | wxRESIZE_BORDER);
660  mDialog = &fd;
661  mDialog->PushEventHandler(this);
662 
663  fd.SetUserPaneCreator(CreateUserPaneCallback, (wxUIntPtr) this);
664  fd.SetFilterIndex(mFilterIndex);
665 
666  int result = fd.ShowModal();
667 
668  mDialog->PopEventHandler();
669 
670  if (result == wxID_CANCEL) {
671  return false;
672  }
673 
674  mFilename = fd.GetPath();
675  if (mFilename == wxT("")) {
676  return false;
677  }
678 
679  mFormat = fd.GetFilterIndex();
680  mFilterIndex = fd.GetFilterIndex();
681  }
682 
683  {
684  int c = 0;
685  int i = -1;
686  for (const auto &pPlugin : mPlugins)
687  {
688  ++i;
689  for (int j = 0; j < pPlugin->GetFormatCount(); j++)
690  {
691  if (mFilterIndex == c)
692  {
693  mFormat = i;
694  mSubFormat = j;
695  }
696  c++;
697  }
698  }
699  }
700 
701  const auto ext = mFilename.GetExt();
702  defext = mPlugins[mFormat]->GetExtension(mSubFormat).Lower();
703 
704  //
705  // Check the extension - add the default if it's not there,
706  // and warn user if it's abnormal.
707  //
708  if (ext.empty()) {
709  //
710  // Make sure the user doesn't accidentally save the file
711  // as an extension with no name, like just plain ".wav".
712  //
713  if (mFilename.GetName().Left(1) == wxT(".")) {
714  auto prompt =
715  XO("Are you sure you want to export the file as \"%s\"?\n")
716  .Format( mFilename.GetFullName() );
717 
718  int action = AudacityMessageBox(
719  prompt,
720  XO("Warning"),
721  wxYES_NO | wxICON_EXCLAMATION);
722  if (action != wxYES) {
723  continue;
724  }
725  }
726 
727  mFilename.SetExt(defext);
728  }
729 
730  if (!mPlugins[mFormat]->CheckFileName(mFilename, mSubFormat))
731  {
732  continue;
733  }
734  else if (!ext.empty() && !mPlugins[mFormat]->IsExtension(ext,mSubFormat) && ext.CmpNoCase(defext)) {
735  auto prompt = XO("You are about to export a %s file with the name \"%s\".\n\nNormally these files end in \".%s\", and some programs will not open files with nonstandard extensions.\n\nAre you sure you want to export the file under this name?")
736  .Format(mPlugins[mFormat]->GetFormat(mSubFormat),
737  mFilename.GetFullName(),
738  defext);
739 
740  int action = AudacityMessageBox(
741  prompt,
742  XO("Warning"),
743  wxYES_NO | wxICON_EXCLAMATION);
744  if (action != wxYES) {
745  continue;
746  }
747  }
748 
749  if (mFilename.GetFullPath().length() >= 256) {
751  XO( "Sorry, pathnames longer than 256 characters not supported.") );
752  continue;
753  }
754 
755 // For Mac, it's handled by the FileDialog
756 #if !defined(__WXMAC__)
757  if (mFilename.FileExists()) {
758  auto prompt = XO("A file named \"%s\" already exists. Replace?")
759  .Format( mFilename.GetFullPath() );
760 
761  int action = AudacityMessageBox(
762  prompt,
763  XO("Warning"),
764  wxYES_NO | wxICON_EXCLAMATION);
765  if (action != wxYES) {
766  continue;
767  }
768  }
769 #endif
770 
771  break;
772  }
773 
774  return true;
775 }

References _, AudacityMessageBox(), CreateUserPaneCallback(), ProjectWindow::Find(), FileNames::FindDefaultPath(), FileDialog::GetFilterIndex(), FileDialog::GetPath(), AudacityProject::GetProjectName(), gPrefs, mBook, mDialog, mFileDialogTitle, mFilename, mFilterIndex, mFormat, mFormatName, mPlugins, mProject, mSubFormat, FileDialog::SetFilterIndex(), FileDialogBase::SetUserPaneCreator(), FileDialog::ShowModal(), and XO.

Referenced by Process(), and SetAutoExportOptions().

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

◆ GetPlugins()

const ExportPluginArray & Exporter::GetPlugins ( )

Definition at line 394 of file Export.cpp.

395 {
396  return mPlugins;
397 }

References mPlugins.

◆ OnExtensionChanged()

void Exporter::OnExtensionChanged ( wxCommandEvent &  evt)

Definition at line 363 of file Export.cpp.

364 {
365  mDialog->SetFileExtension(evt.GetString().BeforeFirst(' ').Lower());
366 }

References mDialog, and FileDialog::SetFileExtension().

Here is the call graph for this function:

◆ OnFilterChanged()

void Exporter::OnFilterChanged ( wxFileCtrlEvent &  evt)
private

Definition at line 1004 of file Export.cpp.

1005 {
1006  int index = evt.GetFilterIndex();
1007 
1008  // On GTK, this event can fire before the userpane is created
1009  if (mBook == NULL || index < 0 || index >= (int) mBook->GetPageCount())
1010  {
1011  return;
1012  }
1013 
1014 #if defined(__WXGTK__)
1015  // On Windows and MacOS, changing the filter in the dialog
1016  // automatically changes the extension of the current file
1017  // name. GTK doesn't, so do it here.
1018  {
1019  FileNames::FileTypes fileTypes;
1020 
1021  int i = -1;
1022  for (const auto &pPlugin : mPlugins)
1023  {
1024  ++i;
1025  for (int j = 0; j < pPlugin->GetFormatCount(); j++)
1026  {
1027  auto mask = pPlugin->GetMask(j);
1028  fileTypes.insert( fileTypes.end(), mask.begin(), mask.end() );
1029  }
1030  }
1031 
1032  if (index < fileTypes.size())
1033  {
1034  mDialog->SetFileExtension(fileTypes[index].extensions[0].Lower());
1035  }
1036  }
1037 #endif
1038 
1039  mBook->ChangeSelection(index);
1040 }

References mBook, mDialog, mPlugins, and FileDialog::SetFileExtension().

Here is the call graph for this function:

◆ OnHelp()

void Exporter::OnHelp ( wxCommandEvent &  evt)

Definition at line 368 of file Export.cpp.

369 {
370  wxWindow * pWin = FindProjectFrame( mProject );
371  HelpSystem::ShowHelp(pWin, L"File_Export_Dialog", true);
372 }

References FindProjectFrame(), mProject, and HelpSystem::ShowHelp().

Here is the call graph for this function:

◆ Process() [1/2]

bool Exporter::Process ( bool  selectedOnly,
double  t0,
double  t1 
)

Definition at line 428 of file Export.cpp.

429 {
430  // Save parms
431  mSelectedOnly = selectedOnly;
432  mT0 = t0;
433  mT1 = t1;
434 
435  // Gather track information
436  if (!ExamineTracks()) {
437  return false;
438  }
439 
440  // Ask user for file name
441  if (!GetFilename()) {
442  return false;
443  }
444 
445  // Check for down mixing
446  if (!CheckMix()) {
447  return false;
448  }
449 
450  // Let user edit MetaData
451  if (mPlugins[mFormat]->GetCanMetaData(mSubFormat)) {
452  if (!DoEditMetadata( *mProject,
453  XO("Edit Metadata Tags"), XO("Exported Tags"),
454  ProjectSettings::Get( *mProject ).GetShowId3Dialog())) {
455  return false;
456  }
457  }
458 
459  // Ensure filename doesn't interfere with project files.
460  if (!CheckFilename()) {
461  return false;
462  }
463 
464  // Export the tracks
465  bool success = ExportTracks();
466 
467  // Get rid of mixerspec
468  mMixerSpec.reset();
469 
470  if (success) {
471  if (mFormatName.empty()) {
472  gPrefs->Write(wxT("/Export/Format"), mPlugins[mFormat]->GetFormat(mSubFormat));
473  }
474 
475  FileNames::UpdateDefaultPath(FileNames::Operation::Export, mFilename.GetPath());
476  }
477 
478  return success;
479 }

References CheckFilename(), CheckMix(), DoEditMetadata(), ExamineTracks(), ExportTracks(), ProjectSettings::Get(), GetFilename(), ProjectSettings::GetShowId3Dialog(), gPrefs, mFilename, mFormat, mFormatName, mMixerSpec, mPlugins, mProject, mSelectedOnly, mSubFormat, mT0, mT1, FileNames::UpdateDefaultPath(), and XO.

Here is the call graph for this function:

◆ Process() [2/2]

bool Exporter::Process ( unsigned  numChannels,
const FileExtension type,
const wxString &  filename,
bool  selectedOnly,
double  t0,
double  t1 
)

Definition at line 481 of file Export.cpp.

484 {
485  // Save parms
486  mChannels = numChannels;
487  mFilename = filename;
488  mSelectedOnly = selectedOnly;
489  mT0 = t0;
490  mT1 = t1;
492 
493  int i = -1;
494  for (const auto &pPlugin : mPlugins) {
495  ++i;
496  for (int j = 0; j < pPlugin->GetFormatCount(); j++)
497  {
498  if (pPlugin->GetFormat(j).IsSameAs(type, false))
499  {
500  mFormat = i;
501  mSubFormat = j;
502  return CheckFilename() && ExportTracks();
503  }
504  }
505  }
506 
507  return false;
508 }

References CheckFilename(), ExportTracks(), mActualName, mChannels, mFilename, mFormat, mPlugins, mSelectedOnly, mSubFormat, mT0, and mT1.

Here is the call graph for this function:

◆ ProcessFromTimerRecording()

bool Exporter::ProcessFromTimerRecording ( bool  selectedOnly,
double  t0,
double  t1,
wxFileName  fnFile,
int  iFormat,
int  iSubFormat,
int  iFilterIndex 
)

Definition at line 1042 of file Export.cpp.

1049 {
1050  // Save parms
1051  mSelectedOnly = selectedOnly;
1052  mT0 = t0;
1053  mT1 = t1;
1054 
1055  // Auto Export Parameters
1056  mFilename = fnFile;
1057  mFormat = iFormat;
1058  mSubFormat = iSubFormat;
1059  mFilterIndex = iFilterIndex;
1060 
1061  // Gather track information
1062  if (!ExamineTracks()) {
1063  return false;
1064  }
1065 
1066  // Check for down mixing
1067  if (!CheckMix(false)) {
1068  return false;
1069  }
1070 
1071  // Ensure filename doesn't interfere with project files.
1072  if (!CheckFilename()) {
1073  return false;
1074  }
1075 
1076  // Export the tracks
1077  bool success = ExportTracks();
1078 
1079  // Get rid of mixerspec
1080  mMixerSpec.reset();
1081 
1082  return success;
1083 }

References CheckFilename(), CheckMix(), ExamineTracks(), ExportTracks(), mFilename, mFilterIndex, mFormat, mMixerSpec, mSelectedOnly, mSubFormat, mT0, and mT1.

Here is the call graph for this function:

◆ SetAutoExportOptions()

bool Exporter::SetAutoExportOptions ( )

Definition at line 1101 of file Export.cpp.

1101  {
1102  mFormat = -1;
1103 
1104  if( GetFilename()==false )
1105  return false;
1106 
1107  // Let user edit MetaData
1108  if (mPlugins[mFormat]->GetCanMetaData(mSubFormat)) {
1109  if (!DoEditMetadata( *mProject,
1110  XO("Edit Metadata Tags"),
1111  XO("Exported Tags"),
1112  ProjectSettings::Get(*mProject).GetShowId3Dialog())) {
1113  return false;
1114  }
1115  }
1116 
1117  return true;
1118 }

References DoEditMetadata(), ProjectSettings::Get(), GetFilename(), ProjectSettings::GetShowId3Dialog(), mFormat, mPlugins, mProject, mSubFormat, and XO.

Here is the call graph for this function:

◆ SetDefaultFormat()

void Exporter::SetDefaultFormat ( const FileExtension Format)
inline

Definition at line 192 of file Export.h.

192 { mFormatName = Format;};

◆ SetFileDialogTitle()

void Exporter::SetFileDialogTitle ( const TranslatableString DialogTitle)

Definition at line 374 of file Export.cpp.

375 {
376  // The default title is "Export File"
377  mFileDialogTitle = DialogTitle;
378 }

References mFileDialogTitle.

Referenced by FileActions::Handler::OnExportSelection().

Here is the caller graph for this function:

Member Data Documentation

◆ mActualName

wxFileName Exporter::mActualName
private

Definition at line 242 of file Export.h.

Referenced by CheckFilename(), ExportTracks(), and Process().

◆ mBook

wxSimplebook* Exporter::mBook
private

Definition at line 256 of file Export.h.

Referenced by CreateUserPane(), GetFilename(), and OnFilterChanged().

◆ mChannels

unsigned Exporter::mChannels
private

Definition at line 253 of file Export.h.

Referenced by CheckMix(), ExportTracks(), and Process().

◆ mDialog

FileDialogWrapper* Exporter::mDialog
private

Definition at line 234 of file Export.h.

Referenced by DisplayOptions(), GetFilename(), OnExtensionChanged(), and OnFilterChanged().

◆ mFileDialogTitle

TranslatableString Exporter::mFileDialogTitle
private

Definition at line 235 of file Export.h.

Referenced by GetFilename(), and SetFileDialogTitle().

◆ mFilename

wxFileName Exporter::mFilename
private

◆ mFilterIndex

int Exporter::mFilterIndex
private

Definition at line 246 of file Export.h.

Referenced by GetFilename(), and ProcessFromTimerRecording().

◆ mFormat

int Exporter::mFormat
private

◆ mFormatName

FileExtension Exporter::mFormatName
private

Definition at line 233 of file Export.h.

Referenced by GetFilename(), and Process().

◆ mMixerSpec

std::unique_ptr<MixerSpec> Exporter::mMixerSpec
private

Definition at line 237 of file Export.h.

Referenced by CheckMix(), ExportTracks(), Process(), and ProcessFromTimerRecording().

◆ mNumLeft

unsigned Exporter::mNumLeft
private

Definition at line 250 of file Export.h.

Referenced by CheckMix(), and ExamineTracks().

◆ mNumMono

unsigned Exporter::mNumMono
private

Definition at line 252 of file Export.h.

Referenced by CheckMix(), and ExamineTracks().

◆ mNumRight

unsigned Exporter::mNumRight
private

Definition at line 251 of file Export.h.

Referenced by CheckMix(), and ExamineTracks().

◆ mNumSelected

int Exporter::mNumSelected
private

Definition at line 249 of file Export.h.

Referenced by ExamineTracks().

◆ mPlugins

ExportPluginArray Exporter::mPlugins
private

◆ mProject

AudacityProject* Exporter::mProject
private

◆ mSelectedOnly

bool Exporter::mSelectedOnly
private

Definition at line 254 of file Export.h.

Referenced by CheckMix(), ExamineTracks(), ExportTracks(), Process(), and ProcessFromTimerRecording().

◆ mSubFormat

int Exporter::mSubFormat
private

◆ mT0

double Exporter::mT0
private

Definition at line 244 of file Export.h.

Referenced by ExamineTracks(), ExportTracks(), Process(), and ProcessFromTimerRecording().

◆ mT1

double Exporter::mT1
private

Definition at line 245 of file Export.h.

Referenced by ExamineTracks(), ExportTracks(), Process(), and ProcessFromTimerRecording().


The documentation for this class was generated from the following files:
Registry::TransparentGroupItem
Definition: Registry.h:210
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
Registry::SingleItem
Definition: Registry.h:120
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:38
Registry
Definition: Menus.h:35
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
BasicUI::ProgressResult::Success
@ Success
PlayableTrack::GetSolo
bool GetSolo() const
Definition: Track.h:861
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
Definition: AudacityMessageBox.cpp:17
PlayableTrack::GetMute
bool GetMute() const
Definition: Track.h:860
FileNames::FindDefaultPath
FILES_API FilePath FindDefaultPath(Operation op)
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
Exporter::SetFileDialogTitle
void SetFileDialogTitle(const TranslatableString &DialogTitle)
Definition: Export.cpp:374
Exporter::GetFilename
bool GetFilename()
Definition: Export.cpp:605
ShowExportErrorDialog
void ShowExportErrorDialog(wxString ErrorCode, TranslatableString message, const TranslatableString &caption)
Definition: Export.cpp:1519
Exporter::CreateUserPane
void CreateUserPane(wxWindow *parent)
Definition: Export.cpp:967
ShowWarningDialog
int ShowWarningDialog(wxWindow *parent, const wxString &internalDialogName, const TranslatableString &message, bool showCancelButton, const TranslatableString &footer)
Definition: Warning.cpp:92
FileNames::UpdateDefaultPath
FILES_API void UpdateDefaultPath(Operation op, const FilePath &path)
Format
Abstract base class used in importing a file.
Exporter::mChannels
unsigned mChannels
Definition: Export.h:253
ImportExportPrefs::ExportDownMixSetting
static EnumSetting< bool > ExportDownMixSetting
Definition: ImportExportPrefs.h:29
Exporter
Definition: Export.h:166
Exporter::mActualName
wxFileName mActualName
Definition: Export.h:242
Exporter::CreateUserPaneCallback
static void CreateUserPaneCallback(wxWindow *parent, wxUIntPtr userdata)
Definition: Export.cpp:958
XO
#define XO(s)
Definition: Internat.h:31
ProjectSettings::Get
static ProjectSettings & Get(AudacityProject &project)
Definition: ProjectSettings.cpp:44
Exporter::CheckFilename
bool CheckFilename()
Definition: Export.cpp:783
Track::Any
bool Any() const
Definition: Track.cpp:370
Exporter::mFormat
int mFormat
Definition: Export.h:247
Exporter::mFilename
wxFileName mFilename
Definition: Export.h:241
HelpSystem::ShowHelp
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:237
Exporter::mSelectedOnly
bool mSelectedOnly
Definition: Export.h:254
Tags::Get
static Tags & Get(AudacityProject &project)
Definition: Tags.cpp:237
ThemeBase::Bitmap
wxBitmap & Bitmap(int iIndex)
Definition: Theme.cpp:1209
Exporter::mNumSelected
int mNumSelected
Definition: Export.h:249
Registry::Visitor
Definition: Registry.h:242
ExportMixerDialog
Dialog for advanced mixing.
Definition: Export.h:299
ExportPluginArray
std::vector< std::unique_ptr< ExportPlugin > > ExportPluginArray
Definition: Export.h:155
Exporter::mSubFormat
int mSubFormat
Definition: Export.h:248
Exporter::mFormatName
FileExtension mFormatName
Definition: Export.h:233
factory
static RegisteredToolbarFactory factory
Definition: ControlToolBar.cpp:817
Exporter::mMixerSpec
std::unique_ptr< MixerSpec > mMixerSpec
Definition: Export.h:237
anonymous_namespace{Export.cpp}::sRegistry
static Registry::GroupItem & sRegistry()
Definition: Export.cpp:286
ProjectSettings::GetShowId3Dialog
bool GetShowId3Dialog() const
Definition: ProjectSettings.h:80
Exporter::mPlugins
ExportPluginArray mPlugins
Definition: Export.h:239
Exporter::mDialog
FileDialogWrapper * mDialog
Definition: Export.h:234
anonymous_namespace{Export.cpp}::sFactories
ExportPluginFactories & sFactories()
Definition: Export.cpp:303
Exporter::mT1
double mT1
Definition: Export.h:245
Track::RightChannel
@ RightChannel
Definition: Track.h:277
Track::IsSelected
bool IsSelected() const
Definition: Track.cpp:373
Exporter::mT0
double mT0
Definition: Export.h:244
PlayableTrack::GetNotSolo
bool GetNotSolo() const
Definition: Track.h:863
Tags::Set
static Tags & Set(AudacityProject &project, const std::shared_ptr< Tags > &tags)
Definition: Tags.cpp:247
theTheme
THEME_API Theme theTheme
Definition: Theme.cpp:79
FileDialogBase::SetUserPaneCreator
virtual void SetUserPaneCreator(UserPaneCreatorFunction creator, wxUIntPtr userdata)
Definition: FileDialog.cpp:30
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
ProjectHistory::PushState
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
Definition: ProjectHistory.cpp:90
Exporter::ExportTracks
bool ExportTracks()
Definition: Export.cpp:911
title
static const auto title
Definition: NoUpdatesAvailableDialog.cpp:22
EnumSetting::ReadEnum
Enum ReadEnum() const
Definition: Prefs.h:373
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:506
Registry::Visit
void Visit(Visitor &visitor, BaseItem *pTopItem, const GroupItem *pRegistry)
Definition: Registry.cpp:713
FileDialogWrapper
Definition: wxPanelWrapper.h:165
_
#define _(s)
Definition: Internat.h:75
Exporter::mFileDialogTitle
TranslatableString mFileDialogTitle
Definition: Export.h:235
Exporter::mBook
wxSimplebook * mBook
Definition: Export.h:256
Track::MonoChannel
@ MonoChannel
Definition: Track.h:278
GetProjectFrame
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
Definition: ProjectWindows.cpp:72
ProjectWindow::Find
static ProjectWindow * Find(AudacityProject *pProject)
Definition: ProjectWindow.cpp:545
FindProjectFrame
wxFrame * FindProjectFrame(AudacityProject *project)
Get a pointer to the window associated with a project, or null if the given pointer is null,...
Definition: ProjectWindows.cpp:88
Exporter::mFilterIndex
int mFilterIndex
Definition: Export.h:246
FileNames::FileTypes
std::vector< FileType > FileTypes
Definition: FileNames.h:76
Exporter::mNumMono
unsigned mNumMono
Definition: Export.h:252
FileDialog::SetFileExtension
virtual void SetFileExtension(const wxString &extension)
Definition: gtk/FileDialogPrivate.cpp:474
safenew
#define safenew
Definition: MemoryX.h:10
settings
static Settings & settings()
Definition: TrackInfo.cpp:86
Exporter::ExamineTracks
bool ExamineTracks()
Definition: Export.cpp:510
Track::LeftChannel
@ LeftChannel
Definition: Track.h:276
Exporter::DoEditMetadata
static bool DoEditMetadata(AudacityProject &project, const TranslatableString &title, const TranslatableString &shortUndoDescription, bool force)
Definition: Export.cpp:399
AudacityProject::GetProjectName
const wxString & GetProjectName() const
Definition: Project.cpp:92
Exporter::CheckMix
bool CheckMix(bool prompt=true)
Definition: Export.cpp:832
ProjectHistory::Get
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26
Exporter::mNumRight
unsigned mNumRight
Definition: Export.h:251
Journal::WindowPaths::Path
Identifier Path
Definition: JournalWindowPaths.h:24
anonymous_namespace{Export.cpp}::PathStart
const auto PathStart
Definition: Export.cpp:284
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
Registry::OrderingPreferenceInitializer
Definition: Registry.h:273
Exporter::mNumLeft
unsigned mNumLeft
Definition: Export.h:250
Exporter::mProject
AudacityProject * mProject
Definition: Export.h:236