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 108 of file ImportExportCommands.cpp.

110 double t0, t1;
111 auto &selectedRegion = ViewInfo::Get( context.project ).selectedRegion;
112 t0 = selectedRegion.t0();
113 t1 = selectedRegion.t1();
115 // Find the extension and check it's valid
116 int splitAt = mFileName.Find(wxUniChar('.'), true);
117 if (splitAt < 0)
118 {
119 context.Error(wxT("Export filename must have an extension!"));
120 return false;
121 }
122 wxString extension = mFileName.Mid(splitAt+1).MakeUpper();
124 Exporter exporter{ context.project };
126 bool exportSuccess = exporter.Process(std::max(0, mnChannels),
127 extension, mFileName,
128 true, t0, t1);
130 if (exportSuccess)
131 {
132 context.Status(wxString::Format(wxT("Exported to %s format: %s"),
133 extension, mFileName));
134 return true;
135 }
137 context.Error(wxString::Format(wxT("Could not export to %s format!"), extension));
138 return false;
virtual void Error(const wxString &message) const
virtual void Status(const wxString &message, bool bFlush=false) const
AudacityProject & project
double t0() const
Definition: ViewInfo.h:35
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:219
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References CommandContext::Error(), ViewInfo::Get(), mFileName, mnChannels, CommandContext::project, ViewInfo::selectedRegion, CommandContext::Status(), 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 96 of file ImportExportCommands.cpp.

98 S.AddSpace(0, 5);
100 S.StartMultiColumn(2, wxALIGN_CENTER);
101 {
102 S.TieTextBox(XXO("File Name:"),mFileName);
103 S.TieTextBox(XXO("Number of Channels:"),mnChannels);
104 }
105 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 88 of file ImportExportCommands.cpp.

89 { 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 85 of file ImportExportCommands.cpp.

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

References S.

◆ VisitSettings() [3/3]

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

Definition at line 77 of file ImportExportCommands.cpp.

77 {
78 wxFileName fn = FileNames::FindDefaultPath(FileNames::Operation::Export);
79 fn.SetName("exported.wav");
80 S.Define(mFileName, wxT("Filename"), fn.GetFullPath());
81 S.Define( mnChannels, wxT("NumChannels"), 1 );
82 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: