Audacity 3.2.0
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
ExportCommand Class Reference

Command for exporting audio. More...

#include <ImportExportCommands.h>

Inheritance diagram for ExportCommand:
Collaboration diagram for ExportCommand:

Public Member Functions

ComponentInterfaceSymbol GetSymbol () const override
TranslatableString GetDescription () const override
template<bool Const>
bool VisitSettings (SettingsVisitorBase< Const > &S)
bool VisitSettings (SettingsVisitor &S) override
bool VisitSettings (ConstSettingsVisitor &S) override
void PopulateOrExchange (ShuttleGui &S) override
bool Apply (const CommandContext &context) override
ManualPageID ManualPage () override
- Public Member Functions inherited from AudacityCommand
 AudacityCommand ()
virtual ~AudacityCommand ()
PluginPath GetPath () const override
VendorSymbol GetVendor () const override
wxString GetVersion () const override
ComponentInterfaceSymbol GetSymbol () const override=0
virtual TranslatableString GetDescription () const override
virtual ManualPageID ManualPage ()
virtual bool IsBatchProcessing () const
virtual void SetBatchProcessing (bool start)
virtual bool Apply (const CommandContext &WXUNUSED(context))
bool ShowInterface (wxWindow *parent, bool forceModal=false)
wxDialog * CreateUI (wxWindow *parent, AudacityCommand *client)
bool SaveSettingsAsString (wxString &parms)
bool LoadSettingsFromString (const wxString &parms)
bool DoAudacityCommand (wxWindow *parent, const CommandContext &context, bool shouldPrompt=true)
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
virtual bool Init ()
virtual bool PromptUser (wxWindow *parent)
virtual bool CheckWhetherSkipAudacityCommand ()
virtual void End ()
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
virtual bool TransferDataToWindow ()
virtual bool TransferDataFromWindow ()
virtual bool VisitSettings (SettingsVisitor &)
virtual bool VisitSettings (ConstSettingsVisitor &)
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
virtual PluginPath GetPath () const =0
virtual ComponentInterfaceSymbol GetSymbol () const =0
virtual VendorSymbol GetVendor () const =0
virtual wxString GetVersion () const =0
virtual TranslatableString GetDescription () const =0
TranslatableString GetName () const

Public Attributes

wxString mFileName
int mnChannels

Static Public Attributes

static const ComponentInterfaceSymbol Symbol { XO("Export2") }

Additional Inherited Members

- Public Types inherited from AudacityCommand
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
- Protected Attributes inherited from AudacityCommand
wxDialog * mUIDialog
wxWindow * mUIParent

Detailed Description

Command for exporting audio.

Definition at line 46 of file ImportExportCommands.h.

Member Function Documentation

◆ Apply()

bool ExportCommand::Apply ( const CommandContext context)

Definition at line 113 of file ImportExportCommands.cpp.

115 double t0, t1;
116 auto &selectedRegion = ViewInfo::Get( context.project ).selectedRegion;
117 t0 = selectedRegion.t0();
118 t1 = selectedRegion.t1();
120 // Find the extension and check it's valid
121 int splitAt = mFileName.Find(wxUniChar('.'), true);
122 if (splitAt < 0)
123 {
124 context.Error(wxT("Export filename must have an extension!"));
125 return false;
126 }
127 wxString extension = mFileName.Mid(splitAt+1).MakeUpper();
129 auto [plugin, formatIndex] = ExportPluginRegistry::Get().FindFormat(extension);
131 if(plugin != nullptr)
132 {
133 auto editor = plugin->CreateOptionsEditor(formatIndex, nullptr);
134 editor->Load(*gPrefs);
136 auto builder = ExportTaskBuilder{}
138 .SetNumChannels(std::max(0, mnChannels))
140 .SetPlugin(plugin)
142 .SetRange(t0, t1, true);
144 auto result = ExportResult::Error;
146 {
147 result = ExportProgressUI::Show(builder.Build(context.project));
148 });
149 if (result == ExportResult::Success || result == ExportResult::Stopped)
150 {
151 context.Status(wxString::Format(wxT("Exported to %s format: %s"),
152 extension, mFileName));
153 return true;
154 }
155 }
157 context.Error(wxString::Format(wxT("Could not export to %s format!"), extension));
158 return false;
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
virtual void Error(const wxString &message) const
virtual void Status(const wxString &message, bool bFlush=false) const
AudacityProject & project
std::tuple< ExportPlugin *, int > FindFormat(const wxString &format, bool compareWithCase=false) const
Returns first pair of [exportPlugin, formatIndex], such that: exportPlugin->GetFormatInfo(formatIndex...
static ExportPluginRegistry & Get()
ExportTaskBuilder & SetPlugin(const ExportPlugin *plugin, int format=0) noexcept
Definition: Export.cpp:59
ExportTaskBuilder & SetParameters(ExportProcessor::Parameters parameters) noexcept
Definition: Export.cpp:47
ExportTaskBuilder & SetNumChannels(unsigned numChannels) noexcept
Definition: Export.cpp:53
ExportTaskBuilder & SetSampleRate(double sampleRate) noexcept
Definition: Export.cpp:72
ExportTaskBuilder & SetFileName(const wxFileName &filename)
Definition: Export.cpp:33
ExportTaskBuilder & SetRange(double t0, double t1, bool selectedOnly=false) noexcept
Definition: Export.cpp:39
static ExportProcessor::Parameters ParametersFromEditor(const ExportOptionsEditor &editor)
Definition: ExportUtils.cpp:28
double t0() const
Definition: ViewInfo.h:35
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:28
double GetRate() const
Definition: ProjectRate.cpp:53
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:215
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
ExportResult Show(ExportTask exportTask)
void ExceptionWrappedCall(Callable callable)

References Error, CommandContext::Error(), ExportProgressUI::ExceptionWrappedCall(), ExportPluginRegistry::FindFormat(), ExportPluginRegistry::Get(), ProjectRate::Get(), ViewInfo::Get(), ProjectRate::GetRate(), gPrefs, mFileName, mnChannels, ExportUtils::ParametersFromEditor(), CommandContext::project, ViewInfo::selectedRegion, ExportTaskBuilder::SetFileName(), ExportTaskBuilder::SetNumChannels(), ExportTaskBuilder::SetParameters(), ExportTaskBuilder::SetPlugin(), ExportTaskBuilder::SetRange(), ExportTaskBuilder::SetSampleRate(), ExportProgressUI::Show(), CommandContext::Status(), Stopped, Success, NotifyingSelectedRegion::t0(), and wxT().

Here is the call graph for this function:

◆ GetDescription()

TranslatableString ExportCommand::GetDescription ( ) const

Reimplemented from AudacityCommand.

Definition at line 53 of file ImportExportCommands.h.

53{return XO("Exports to a file.");};

References XO().

Here is the call graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol ExportCommand::GetSymbol ( ) const

Implements AudacityCommand.

Definition at line 52 of file ImportExportCommands.h.

52{return Symbol;};
static const ComponentInterfaceSymbol Symbol

References Symbol.

◆ ManualPage()

ManualPageID ExportCommand::ManualPage ( )

Reimplemented from AudacityCommand.

Definition at line 61 of file ImportExportCommands.h.

61{return L"Extra_Menu:_Scriptables_II#export";}

◆ PopulateOrExchange()

void ExportCommand::PopulateOrExchange ( ShuttleGui S)

Definition at line 101 of file ImportExportCommands.cpp.

103 S.AddSpace(0, 5);
105 S.StartMultiColumn(2, wxALIGN_CENTER);
106 {
107 S.TieTextBox(XXO("File Name:"),mFileName);
108 S.TieTextBox(XXO("Number of Channels:"),mnChannels);
109 }
110 S.EndMultiColumn();
XXO("&Cut/Copy/Paste Toolbar")
#define S(N)
Definition: ToChars.cpp:64

References mFileName, mnChannels, S, and XXO().

Here is the call graph for this function:

◆ VisitSettings() [1/3]

bool ExportCommand::VisitSettings ( ConstSettingsVisitor )

Visit settings, if defined. false means no defined settings. Default implementation returns false

Reimplemented from AudacityCommand.

Definition at line 93 of file ImportExportCommands.cpp.

94 { return VisitSettings<true>(S); }

References S.

◆ VisitSettings() [2/3]

bool ExportCommand::VisitSettings ( SettingsVisitor )

Visit settings, if defined. false means no defined settings. Default implementation returns false

Reimplemented from AudacityCommand.

Definition at line 90 of file ImportExportCommands.cpp.

91 { return VisitSettings<false>(S); }

References S.

◆ VisitSettings() [3/3]

template<bool Const>
bool ExportCommand::VisitSettings ( SettingsVisitorBase< Const > &  S)

Definition at line 82 of file ImportExportCommands.cpp.

82 {
83 wxFileName fn = FileNames::FindDefaultPath(FileNames::Operation::Export);
84 fn.SetName("exported.wav");
85 S.Define(mFileName, wxT("Filename"), fn.GetFullPath());
86 S.Define( mnChannels, wxT("NumChannels"), 1 );
87 return true;
static const auto fn
FILES_API FilePath FindDefaultPath(Operation op)

References FileNames::FindDefaultPath(), fn, mFileName, mnChannels, S, and wxT().

Here is the call graph for this function:

Member Data Documentation

◆ mFileName

wxString ExportCommand::mFileName

Definition at line 63 of file ImportExportCommands.h.

Referenced by Apply(), PopulateOrExchange(), and VisitSettings().

◆ mnChannels

int ExportCommand::mnChannels

Definition at line 64 of file ImportExportCommands.h.

Referenced by Apply(), PopulateOrExchange(), and VisitSettings().

◆ Symbol

const ComponentInterfaceSymbol ExportCommand::Symbol { XO("Export2") }

Definition at line 49 of file ImportExportCommands.h.

Referenced by GetSymbol().

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