Audacity 3.2.0
Classes | Public Types | 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  ExporterItem
 
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)
 
bool Process (unsigned numChannels, const FileExtension &type, const wxString &filename, bool selectedOnly, double t0, double t1, std::unique_ptr< BasicUI::ProgressDialog > &progressDialog)
 
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)
 

Private Member Functions

bool ExamineTracks ()
 
bool GetFilename ()
 
bool CheckFilename ()
 
bool CheckMix (bool prompt=true)
 
bool ExportTracks (std::unique_ptr< BasicUI::ProgressDialog > &progressDialog)
 
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 {}
 
bool mMono {}
 
unsigned mNumMono
 
unsigned mChannels
 
bool mSelectedOnly
 
wxSimplebook * mBook
 

Detailed Description

Definition at line 171 of file Export.h.

Member Typedef Documentation

◆ ExportPluginFactory

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

Definition at line 176 of file Export.h.

Constructor & Destructor Documentation

◆ Exporter()

Exporter::Exporter ( AudacityProject project)

Definition at line 324 of file Export.cpp.

325: mProject{ &project }
326{
327 using namespace Registry;
329 PathStart,
330 { {wxT(""), wxT("PCM,MP3,OGG,FLAC,MP2,CommandLine,FFmpeg") } },
331 };
332
333 mMixerSpec = NULL;
334 mBook = NULL;
335
336 // build the list of export plugins.
337 for ( const auto &factory : sFactories() )
338 mPlugins.emplace_back( factory() );
339
340 struct MyVisitor final : Visitor {
341 MyVisitor()
342 {
343 // visit the registry to collect the plug-ins properly
344 // sorted
346 Registry::Visit( *this, &top, &ExporterItem::Registry() );
347 }
348
349 void Visit( SingleItem &item, const Path &path ) override
350 {
351 mPlugins.emplace_back(
352 static_cast<ExporterItem&>( item ).mFactory() );
353 }
354
356 } visitor;
357
358 mPlugins.swap( visitor.mPlugins );
359
360 SetFileDialogTitle( XO("Export Audio") );
361}
wxT("CloseDown"))
std::vector< std::unique_ptr< ExportPlugin > > ExportPluginArray
Definition: Export.h:161
XO("Cut/Copy/Paste")
const auto project
void SetFileDialogTitle(const TranslatableString &DialogTitle)
Definition: Export.cpp:378
wxSimplebook * mBook
Definition: Export.h:272
std::unique_ptr< MixerSpec > mMixerSpec
Definition: Export.h:254
ExportPluginArray mPlugins
Definition: Export.h:256
AudacityProject * mProject
Definition: Export.h:253
Definition: Menus.h:35
void Visit(Visitor &visitor, BaseItem *pTopItem, const GroupItemBase *pRegistry)
Definition: Registry.cpp:739
ExportPluginFactories & sFactories()
Definition: Export.cpp:294
static RegisteredToolbarFactory factory
static Registry::GroupItemBase & Registry()
Definition: Export.cpp:301
Common abstract base class for items that are not groups.
Definition: Registry.h:162

References cloud::factory, mBook, mMixerSpec, mPlugins, anonymous_namespace{Export.cpp}::PathStart, Exporter::ExporterItem::Registry(), SetFileDialogTitle(), anonymous_namespace{Export.cpp}::sFactories(), Registry::Visit(), wxT(), and XO().

Here is the call graph for this function:

◆ ~Exporter()

Exporter::~Exporter ( )
virtual

Definition at line 363 of file Export.cpp.

364{
365}

Member Function Documentation

◆ CheckFilename()

bool Exporter::CheckFilename ( )
private

Definition at line 748 of file Export.cpp.

749{
750 //
751 // To be even safer, return a temporary file name based
752 // on this one...
753 //
754
756
757 int suffix = 0;
758 while (mFilename.FileExists()) {
759 mFilename.SetName(mActualName.GetName() +
760 wxString::Format(wxT("%d"), suffix));
761 suffix++;
762 }
763
764 return true;
765}
wxFileName mActualName
Definition: Export.h:259
wxFileName mFilename
Definition: Export.h:258

References mActualName, mFilename, and wxT().

Referenced by Process(), and ProcessFromTimerRecording().

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

◆ CheckMix()

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

Definition at line 797 of file Export.cpp.

798{
799 // Clean up ... should never happen
800 mMixerSpec.reset();
801
802 // Determine if exported file will be stereo or mono or multichannel,
803 // and if mixing will occur.
804
806 int exportedChannels = mPlugins[mFormat]->SetNumExportChannels();
807
808 if (downMix) {
809 unsigned channels = mMono ? 1 : 2;
810 mChannels =
811 std::min(channels, mPlugins[mFormat]->GetMaxChannels(mSubFormat));
812
813 if (mNumSelected > 1 || channels > mChannels) {
814 // May give a message about mixing-down
815 wxString exportFormat = mPlugins[mFormat]->GetFormat(mSubFormat);
816 if (exportFormat != wxT("CL") && exportFormat != wxT("FFMPEG") && exportedChannels == -1)
817 exportedChannels = mChannels;
818
819 if (prompt) {
820 auto pWindow = ProjectWindow::Find(mProject);
821 if (exportedChannels == 1) {
822 if (ShowWarningDialog(pWindow,
823 wxT("MixMono"),
824 XO("Your tracks will be mixed down and exported as one mono file."),
825 true) == wxID_CANCEL)
826 return false;
827 }
828 else if (exportedChannels == 2) {
829 if (ShowWarningDialog(pWindow,
830 wxT("MixStereo"),
831 XO("Your tracks will be mixed down and exported as one stereo file."),
832 true) == wxID_CANCEL)
833 return false;
834 }
835 else {
836 if (ShowWarningDialog(pWindow,
837 wxT("MixUnknownChannels"),
838 XO("Your tracks will be mixed down to one exported file according to the encoder settings."),
839 true) == wxID_CANCEL)
840 return false;
841 }
842 }
843 }
844 }
845 else
846 {
847 if (exportedChannels < 0)
848 exportedChannels = mPlugins[mFormat]->GetMaxChannels(mSubFormat);
849
852 exportedChannels,
853 NULL,
854 1,
855 XO("Advanced Mixing Options"));
856 if (prompt) {
857 if (md.ShowModal() != wxID_OK) {
858 return false;
859 }
860 }
861
862 mMixerSpec = std::make_unique<MixerSpec>(*(md.GetMixerSpec()));
863 mChannels = mMixerSpec->GetNumChannels();
864 }
865
866 return true;
867}
int min(int a, int b)
int ShowWarningDialog(wxWindow *parent, const wxString &internalDialogName, const TranslatableString &message, bool showCancelButton, const TranslatableString &footer)
Definition: Warning.cpp:90
Enum ReadEnum() const
Definition: Prefs.h:527
Dialog for advanced mixing.
Definition: Export.h:315
int mFormat
Definition: Export.h:264
unsigned mChannels
Definition: Export.h:269
bool mSelectedOnly
Definition: Export.h:270
int mNumSelected
Definition: Export.h:266
int mSubFormat
Definition: Export.h:265
bool mMono
Definition: Export.h:267
static EnumSetting< bool > ExportDownMixSetting
static ProjectWindow * Find(AudacityProject *pProject)
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:374

References ImportExportPrefs::ExportDownMixSetting, ProjectWindow::Find(), TrackList::Get(), ExportMixerDialog::GetMixerSpec(), mChannels, mFormat, min(), mMixerSpec, mMono, mNumSelected, mPlugins, mProject, mSelectedOnly, mSubFormat, EnumSetting< Enum >::ReadEnum(), ShowWarningDialog(), wxT(), 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 925 of file Export.cpp.

926{
927 ShuttleGui S(parent, eIsCreating);
928
929 S.StartStatic(XO("Format Options"), 1);
930 {
931 S.StartHorizontalLay(wxEXPAND);
932 {
933 mBook = S.Position(wxEXPAND).StartSimplebook();
934 {
935 for (const auto &pPlugin : mPlugins)
936 {
937 for (int j = 0; j < pPlugin->GetFormatCount(); j++)
938 {
939 // Name of simple book page is not displayed
940 S.StartNotebookPage( {} );
941 {
942 pPlugin->OptionsCreate(S, j);
943 }
944 S.EndNotebookPage();
945 }
946 }
947 }
948 S.EndSimplebook();
949
950 auto b = safenew wxBitmapButton(S.GetParent(), wxID_HELP, theTheme.Bitmap( bmpHelpIcon ));
951 b->SetToolTip( XO("Help").Translation() );
952 b->SetLabel(XO("Help").Translation()); // for screen readers
953 S.Position(wxALIGN_BOTTOM | wxRIGHT | wxBOTTOM).AddWindow(b);
954 }
955 S.EndHorizontalLay();
956 }
957 S.EndStatic();
958
959 return;
960}
#define safenew
Definition: MemoryX.h:10
@ eIsCreating
Definition: ShuttleGui.h:37
THEME_API Theme theTheme
Definition: Theme.cpp:82
#define S(N)
Definition: ToChars.cpp:64
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:625
wxBitmap & Bitmap(int iIndex)

References ThemeBase::Bitmap(), eIsCreating, mBook, mPlugins, S, safenew, 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 916 of file Export.cpp.

917{
918 Exporter *self = (Exporter *) userdata;
919 if (self)
920 {
921 self->CreateUserPane(parent);
922 }
923}
void CreateUserPane(wxWindow *parent)
Definition: Export.cpp:925

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 767 of file Export.cpp.

768{
769 int c = 0;
770 int mf = -1, msf = -1;
771 int i = -1;
772 for (const auto &pPlugin : mPlugins)
773 {
774 ++i;
775 for (int j = 0; j < pPlugin->GetFormatCount(); j++)
776 {
777 if (index == c)
778 {
779 mf = i;
780 msf = j;
781 }
782 c++;
783 }
784 }
785 // This shouldn't happen...
786 if (index >= c) {
787 return;
788 }
789
790#if defined(__WXMSW__)
791 mPlugins[mf]->DisplayOptions( FindProjectFrame( mProject ), msf);
792#else
793 mPlugins[mf]->DisplayOptions(mDialog, msf);
794#endif
795}
wxFrame * FindProjectFrame(AudacityProject *project)
Get a pointer to the window associated with a project, or null if the given pointer is null,...
FileDialogWrapper * mDialog
Definition: Export.h:251

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

Here is the call graph for this function:

◆ ExamineTracks()

bool Exporter::ExamineTracks ( )
private

Definition at line 496 of file Export.cpp.

497{
498 // Init
499 mNumSelected = 0;
500
501 // First analyze the selected audio, perform sanity checks, and provide
502 // information as appropriate.
503
504 // Tally how many are right, left, mono, and make sure at
505 // least one track is selected (if selectedOnly==true)
506
507 double earliestBegin = mT1;
508 double latestEnd = mT0;
509
511
512 bool anySolo =
513 !(tracks.Leaders<const WaveTrack>() + &WaveTrack::GetSolo).empty();
514
515 const auto range = tracks.Leaders<const WaveTrack>()
518
519 mMono = std::all_of(range.begin(), range.end(), [](const WaveTrack *pTrack){
520 return IsMono(*pTrack) && pTrack->GetPan() == 0.0;
521 });
522
523 for (auto tr : range) {
524 mNumSelected++;
525
526 if (tr->GetOffset() < earliestBegin) {
527 earliestBegin = tr->GetOffset();
528 }
529
530 if (tr->GetEndTime() > latestEnd) {
531 latestEnd = tr->GetEndTime();
532 }
533 }
534
535 if (mNumSelected == 0) {
536 TranslatableString message;
537 if(mSelectedOnly)
538 message = XO("All selected audio is muted.");
539 else
540 message = XO("All audio is muted.");
542 ":576",
543 message, AudacityExportCaptionStr(), false);
544 return false;
545 }
546
547 // The skipping of silent space could be cleverer and take
548 // into account clips.
549 // As implemented now, it can only skip initial silent space that
550 // has no clip before it, and terminal silent space that has no clip
551 // after it.
552 if (mT0 < earliestBegin){
553 // Bug 1904
554 // Previously we always skipped initial silent space.
555 // Now skipping it is an opt-in option.
556 bool skipSilenceAtBeginning;
557 gPrefs->Read(wxT("/AudioFiles/SkipSilenceAtBeginning"),
558 &skipSilenceAtBeginning, false);
559 if (skipSilenceAtBeginning)
560 mT0 = earliestBegin;
561 }
562
563 // We still skip silent space at the end
564 if (mT1 > latestEnd)
565 mT1 = latestEnd;
566
567 return true;
568}
void ShowExportErrorDialog(wxString ErrorCode, TranslatableString message, const TranslatableString &caption, bool allowReporting)
Definition: Export.cpp:1480
TranslatableString AudacityExportCaptionStr()
Definition: Export.cpp:1463
FileConfig * gPrefs
Definition: Prefs.cpp:70
const auto tracks
double mT0
Definition: Export.h:261
double mT1
Definition: Export.h:262
bool GetNotSolo() const
Definition: PlayableTrack.h:50
bool IsSelected() const
Definition: Track.cpp:316
bool Any() const
Definition: Track.cpp:313
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
Definition: WaveTrack.h:59
bool GetMute() const override
May vary asynchronously.
Definition: WaveTrack.cpp:1930
bool GetSolo() const override
May vary asynchronously.
Definition: WaveTrack.cpp:1935

References Track::Any(), AudacityExportCaptionStr(), TrackList::Get(), WaveTrack::GetMute(), PlayableTrack::GetNotSolo(), WaveTrack::GetSolo(), gPrefs, Track::IsSelected(), mMono, mNumSelected, mProject, mSelectedOnly, mT0, mT1, ShowExportErrorDialog(), tracks, wxT(), 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 ( std::unique_ptr< BasicUI::ProgressDialog > &  progressDialog)
private

Definition at line 869 of file Export.cpp.

871{
872 // Keep original in case of failure
873 if (mActualName != mFilename) {
874 ::wxRenameFile(mActualName.GetFullPath(), mFilename.GetFullPath());
875 }
876
877 bool success = false;
878
879 auto cleanup = finally( [&] {
880 if (mActualName != mFilename) {
881 // Remove backup
882 if ( success )
883 ::wxRemoveFile(mFilename.GetFullPath());
884 else {
885 // Restore original, if needed
886 ::wxRemoveFile(mActualName.GetFullPath());
887 ::wxRenameFile(mFilename.GetFullPath(), mActualName.GetFullPath());
888 }
889 // Restore filename
891 }
892 else {
893 if ( ! success )
894 // Remove any new, and only partially written, file.
895 ::wxRemoveFile(mFilename.GetFullPath());
896 }
897 } );
898
899 auto result = mPlugins[mFormat]->Export(mProject,
900 progressDialog,
901 mChannels,
902 mActualName.GetFullPath(),
904 mT0,
905 mT1,
906 mMixerSpec.get(),
907 NULL,
908 mSubFormat);
909
910 success =
911 result == ProgressResult::Success || result == ProgressResult::Stopped;
912
913 return success;
914}

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 384 of file Export.cpp.

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

References mPlugins.

◆ GetAutoExportFileName()

wxFileName Exporter::GetAutoExportFileName ( )

Definition at line 1056 of file Export.cpp.

1056 {
1057 return mFilename;
1058}

References mFilename.

◆ GetAutoExportFilterIndex()

int Exporter::GetAutoExportFilterIndex ( )

Definition at line 1052 of file Export.cpp.

1052 {
1053 return mFormat;
1054}

References mFormat.

◆ GetAutoExportFormat()

int Exporter::GetAutoExportFormat ( )

Definition at line 1044 of file Export.cpp.

1044 {
1045 return mFormat;
1046}

References mFormat.

◆ GetAutoExportSubFormat()

int Exporter::GetAutoExportSubFormat ( )

Definition at line 1048 of file Export.cpp.

1048 {
1049 return mSubFormat;
1050}

References mSubFormat.

◆ GetFilename()

bool Exporter::GetFilename ( )
private

Definition at line 570 of file Export.cpp.

571{
572 mFormat = -1;
573
574 FileNames::FileTypes fileTypes;
575 auto defaultFormat = mFormatName;
576 if( defaultFormat.empty() )
577 defaultFormat = gPrefs->Read(wxT("/Export/Format"),
578 wxT("WAV"));
579
580 mFilterIndex = 0;
581
582 {
583 int i = -1;
584 for (const auto &pPlugin : mPlugins) {
585 ++i;
586 for (int j = 0; j < pPlugin->GetFormatCount(); j++)
587 {
588 auto mask = pPlugin->GetMask(j);
589 fileTypes.insert( fileTypes.end(), mask.begin(), mask.end() );
590 if (mPlugins[i]->GetFormat(j) == defaultFormat) {
591 mFormat = i;
592 mSubFormat = j;
593 }
594 if (mFormat == -1) mFilterIndex++;
595 }
596 }
597 }
598 if (mFormat == -1)
599 {
600 mFormat = 0;
601 mFilterIndex = 0;
602 mSubFormat = 0;
603 }
604 wxString defext = mPlugins[mFormat]->GetExtension(mSubFormat).Lower();
605
606 //Bug 1304: Set a default path if none was given. For Export.
607 mFilename.SetPath(FileNames::FindDefaultPath(FileNames::Operation::Export));
609 if (mFilename.GetName().empty())
610 mFilename.SetName(_("untitled"));
611 while (true) {
612 // Must reset each iteration
613 mBook = NULL;
614
615 {
616 auto useFileName = mFilename;
617 if (!useFileName.HasExt())
618 useFileName.SetExt(defext);
621 mFilename.GetPath(),
622 useFileName.GetFullName(),
623 fileTypes,
624 wxFD_SAVE | wxRESIZE_BORDER);
625 mDialog = &fd;
626 mDialog->PushEventHandler(this);
627
628 fd.SetUserPaneCreator(CreateUserPaneCallback, (wxUIntPtr) this);
629 fd.SetFilterIndex(mFilterIndex);
630
631 int result = fd.ShowModal();
632
633 mDialog->PopEventHandler();
634
635 if (result == wxID_CANCEL) {
636 return false;
637 }
638
639 mFilename = fd.GetPath();
640 if (mFilename == wxT("")) {
641 return false;
642 }
643
644 mFormat = fd.GetFilterIndex();
645 mFilterIndex = fd.GetFilterIndex();
646 }
647
648 {
649 int c = 0;
650 int i = -1;
651 for (const auto &pPlugin : mPlugins)
652 {
653 ++i;
654 for (int j = 0; j < pPlugin->GetFormatCount(); j++)
655 {
656 if (mFilterIndex == c)
657 {
658 mFormat = i;
659 mSubFormat = j;
660 }
661 c++;
662 }
663 }
664 }
665
666 const auto ext = mFilename.GetExt();
667 defext = mPlugins[mFormat]->GetExtension(mSubFormat).Lower();
668
669 //
670 // Check the extension - add the default if it's not there,
671 // and warn user if it's abnormal.
672 //
673 if (ext.empty()) {
674 //
675 // Make sure the user doesn't accidentally save the file
676 // as an extension with no name, like just plain ".wav".
677 //
678 if (mFilename.GetName().Left(1) == wxT(".")) {
679 auto prompt =
680 XO("Are you sure you want to export the file as \"%s\"?\n")
681 .Format( mFilename.GetFullName() );
682
683 int action = AudacityMessageBox(
684 prompt,
685 XO("Warning"),
686 wxYES_NO | wxICON_EXCLAMATION);
687 if (action != wxYES) {
688 continue;
689 }
690 }
691
692 mFilename.SetExt(defext);
693 }
694
695 if (!mPlugins[mFormat]->CheckFileName(mFilename, mSubFormat))
696 {
697 continue;
698 }
699 else if (!ext.empty() && !mPlugins[mFormat]->IsExtension(ext,mSubFormat) && ext.CmpNoCase(defext)) {
700 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?")
701 .Format(mPlugins[mFormat]->GetFormat(mSubFormat),
702 mFilename.GetFullName(),
703 defext);
704
705 int action = AudacityMessageBox(
706 prompt,
707 XO("Warning"),
708 wxYES_NO | wxICON_EXCLAMATION);
709 if (action != wxYES) {
710 continue;
711 }
712 }
713
714 if (mFilename.GetFullPath().length() >= 256) {
716 XO( "Sorry, pathnames longer than 256 characters not supported.") );
717 continue;
718 }
719
720// For Mac, it's handled by the FileDialog
721#if !defined(__WXMAC__)
722 if (mFilename.FileExists()) {
723 auto prompt = XO("A file named \"%s\" already exists. Replace?")
724 .Format( mFilename.GetFullPath() );
725
726 int action = AudacityMessageBox(
727 prompt,
728 XO("Warning"),
729 wxYES_NO | wxICON_EXCLAMATION);
730 if (action != wxYES) {
731 continue;
732 }
733 }
734#endif
735
736 break;
737 }
738
739 return true;
740}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
#define _(s)
Definition: Internat.h:73
const wxString & GetProjectName() const
Definition: Project.cpp:100
FileExtension mFormatName
Definition: Export.h:250
static void CreateUserPaneCallback(wxWindow *parent, wxUIntPtr userdata)
Definition: Export.cpp:916
int mFilterIndex
Definition: Export.h:263
TranslatableString mFileDialogTitle
Definition: Export.h:252
virtual void SetUserPaneCreator(UserPaneCreatorFunction creator, wxUIntPtr userdata)
Definition: FileDialog.cpp:30
std::vector< FileType > FileTypes
Definition: FileNames.h:75
FILES_API FilePath FindDefaultPath(Operation op)

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(), wxT(), 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 398 of file Export.cpp.

399{
400 return mPlugins;
401}

References mPlugins.

◆ OnExtensionChanged()

void Exporter::OnExtensionChanged ( wxCommandEvent &  evt)

Definition at line 367 of file Export.cpp.

368{
369 mDialog->SetFileExtension(evt.GetString().BeforeFirst(' ').Lower());
370}
virtual void SetFileExtension(const wxString &extension)

References mDialog, and FileDialog::SetFileExtension().

Here is the call graph for this function:

◆ OnFilterChanged()

void Exporter::OnFilterChanged ( wxFileCtrlEvent &  evt)
private

Definition at line 962 of file Export.cpp.

963{
964 int index = evt.GetFilterIndex();
965
966 // On GTK, this event can fire before the userpane is created
967 if (mBook == NULL || index < 0 || index >= (int) mBook->GetPageCount())
968 {
969 return;
970 }
971
972#if defined(__WXGTK__)
973 // On Windows and MacOS, changing the filter in the dialog
974 // automatically changes the extension of the current file
975 // name. GTK doesn't, so do it here.
976 {
977 FileNames::FileTypes fileTypes;
978
979 int i = -1;
980 for (const auto &pPlugin : mPlugins)
981 {
982 ++i;
983 for (int j = 0; j < pPlugin->GetFormatCount(); j++)
984 {
985 auto mask = pPlugin->GetMask(j);
986 fileTypes.insert( fileTypes.end(), mask.begin(), mask.end() );
987 }
988 }
989
990 if (index < fileTypes.size())
991 {
992 mDialog->SetFileExtension(fileTypes[index].extensions[0].Lower());
993 }
994 }
995#endif
996
997 mBook->ChangeSelection(index);
998}

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

Here is the call graph for this function:

◆ OnHelp()

void Exporter::OnHelp ( wxCommandEvent &  evt)

Definition at line 372 of file Export.cpp.

373{
374 wxWindow * pWin = FindProjectFrame( mProject );
375 HelpSystem::ShowHelp(pWin, L"File_Export_Dialog", true);
376}
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:233

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

Here is the call graph for this function:

◆ Process() [1/3]

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

Definition at line 403 of file Export.cpp.

404{
405 // Save parms
406 mSelectedOnly = selectedOnly;
407 mT0 = t0;
408 mT1 = t1;
409
410 // Gather track information
411 if (!ExamineTracks()) {
412 return false;
413 }
414
415 // Ask user for file name
416 if (!GetFilename()) {
417 return false;
418 }
419
420 // Check for down mixing
421 if (!CheckMix()) {
422 return false;
423 }
424
425 // Let user edit MetaData
426 if (mPlugins[mFormat]->GetCanMetaData(mSubFormat)) {
428 XO("Edit Metadata Tags"), XO("Exported Tags"),
429 ProjectSettings::Get( *mProject ).GetShowId3Dialog())) {
430 return false;
431 }
432 }
433
434 // Ensure filename doesn't interfere with project files.
435 if (!CheckFilename()) {
436 return false;
437 }
438
439 // Export the tracks
440 std::unique_ptr<BasicUI::ProgressDialog> pDialog;
441 bool success = ExportTracks(pDialog);
442
443 // Get rid of mixerspec
444 mMixerSpec.reset();
445
446 if (success) {
447 if (mFormatName.empty()) {
448 gPrefs->Write(wxT("/Export/Format"), mPlugins[mFormat]->GetFormat(mSubFormat));
449 }
450
451 FileNames::UpdateDefaultPath(FileNames::Operation::Export, mFilename.GetPath());
452 }
453
454 return success;
455}
bool ExamineTracks()
Definition: Export.cpp:496
bool ExportTracks(std::unique_ptr< BasicUI::ProgressDialog > &progressDialog)
Definition: Export.cpp:869
bool CheckMix(bool prompt=true)
Definition: Export.cpp:797
bool GetFilename()
Definition: Export.cpp:570
bool CheckFilename()
Definition: Export.cpp:748
static ProjectSettings & Get(AudacityProject &project)
bool GetShowId3Dialog() const
static AUDACITY_DLL_API bool DoEditMetadata(AudacityProject &project, const TranslatableString &title, const TranslatableString &shortUndoDescription, bool force)
Definition: TagsEditor.cpp:952
FILES_API void UpdateDefaultPath(Operation op, const FilePath &path)

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

Referenced by Process().

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

◆ Process() [2/3]

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

Definition at line 457 of file Export.cpp.

460{
461 std::unique_ptr<BasicUI::ProgressDialog> pDialog;
462 return Process(numChannels, type, filename, selectedOnly, t0, t1, pDialog);
463}
bool Process(bool selectedOnly, double t0, double t1)
Definition: Export.cpp:403

References Process().

Here is the call graph for this function:

◆ Process() [3/3]

bool Exporter::Process ( unsigned  numChannels,
const FileExtension type,
const wxString &  filename,
bool  selectedOnly,
double  t0,
double  t1,
std::unique_ptr< BasicUI::ProgressDialog > &  progressDialog 
)

Definition at line 465 of file Export.cpp.

469{
470 // Save parms
471 mChannels = numChannels;
472 mFilename = filename;
473 mSelectedOnly = selectedOnly;
474 mT0 = t0;
475 mT1 = t1;
477
478 int i = -1;
479 for (const auto& pPlugin : mPlugins)
480 {
481 ++i;
482 for (int j = 0; j < pPlugin->GetFormatCount(); j++)
483 {
484 if (pPlugin->GetFormat(j).IsSameAs(type, false))
485 {
486 mFormat = i;
487 mSubFormat = j;
488 return CheckFilename() && ExportTracks(progressDialog);
489 }
490 }
491 }
492
493 return false;
494}

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 1000 of file Export.cpp.

1007{
1008 // Save parms
1009 mSelectedOnly = selectedOnly;
1010 mT0 = t0;
1011 mT1 = t1;
1012
1013 // Auto Export Parameters
1014 mFilename = fnFile;
1015 mFormat = iFormat;
1016 mSubFormat = iSubFormat;
1017 mFilterIndex = iFilterIndex;
1018
1019 // Gather track information
1020 if (!ExamineTracks()) {
1021 return false;
1022 }
1023
1024 // Check for down mixing
1025 if (!CheckMix(false)) {
1026 return false;
1027 }
1028
1029 // Ensure filename doesn't interfere with project files.
1030 if (!CheckFilename()) {
1031 return false;
1032 }
1033
1034 // Export the tracks
1035 std::unique_ptr<BasicUI::ProgressDialog> pDialog;
1036 bool success = ExportTracks(pDialog);
1037
1038 // Get rid of mixerspec
1039 mMixerSpec.reset();
1040
1041 return success;
1042}

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 1060 of file Export.cpp.

1060 {
1061 mFormat = -1;
1062
1063 if( GetFilename()==false )
1064 return false;
1065
1066 // Let user edit MetaData
1067 if (mPlugins[mFormat]->GetCanMetaData(mSubFormat)) {
1069 XO("Edit Metadata Tags"),
1070 XO("Exported Tags"),
1071 ProjectSettings::Get(*mProject).GetShowId3Dialog())) {
1072 return false;
1073 }
1074 }
1075
1076 return true;
1077}

References TagsEditorDialog::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 197 of file Export.h.

197{ mFormatName = Format;};
Abstract base class used in importing a file.

◆ SetFileDialogTitle()

void Exporter::SetFileDialogTitle ( const TranslatableString DialogTitle)

Definition at line 378 of file Export.cpp.

379{
380 // The default title is "Export File"
381 mFileDialogTitle = DialogTitle;
382}

References mFileDialogTitle.

Referenced by Exporter().

Here is the caller graph for this function:

Member Data Documentation

◆ mActualName

wxFileName Exporter::mActualName
private

Definition at line 259 of file Export.h.

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

◆ mBook

wxSimplebook* Exporter::mBook
private

Definition at line 272 of file Export.h.

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

◆ mChannels

unsigned Exporter::mChannels
private

Definition at line 269 of file Export.h.

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

◆ mDialog

FileDialogWrapper* Exporter::mDialog
private

Definition at line 251 of file Export.h.

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

◆ mFileDialogTitle

TranslatableString Exporter::mFileDialogTitle
private

Definition at line 252 of file Export.h.

Referenced by GetFilename(), and SetFileDialogTitle().

◆ mFilename

wxFileName Exporter::mFilename
private

◆ mFilterIndex

int Exporter::mFilterIndex
private

Definition at line 263 of file Export.h.

Referenced by GetFilename(), and ProcessFromTimerRecording().

◆ mFormat

int Exporter::mFormat
private

◆ mFormatName

FileExtension Exporter::mFormatName
private

Definition at line 250 of file Export.h.

Referenced by GetFilename(), and Process().

◆ mMixerSpec

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

Definition at line 254 of file Export.h.

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

◆ mMono

bool Exporter::mMono {}
private

Definition at line 267 of file Export.h.

Referenced by CheckMix(), and ExamineTracks().

◆ mNumMono

unsigned Exporter::mNumMono
private

Definition at line 268 of file Export.h.

◆ mNumSelected

int Exporter::mNumSelected {}
private

Definition at line 266 of file Export.h.

Referenced by CheckMix(), and ExamineTracks().

◆ mPlugins

ExportPluginArray Exporter::mPlugins
private

◆ mProject

AudacityProject* Exporter::mProject
private

◆ mSelectedOnly

bool Exporter::mSelectedOnly
private

Definition at line 270 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 261 of file Export.h.

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

◆ mT1

double Exporter::mT1
private

Definition at line 262 of file Export.h.

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


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