Audacity  3.0.3
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:
[legend]
Collaboration diagram for ExportCommand:
[legend]

Public Member Functions

ComponentInterfaceSymbol GetSymbol () override
 
TranslatableString GetDescription () override
 
bool DefineParams (ShuttleParams &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 () override
 
VendorSymbol GetVendor () override
 
wxString GetVersion () override
 
virtual bool IsBatchProcessing ()
 
virtual void SetBatchProcessing (bool start)
 
virtual bool Apply (const CommandContext &WXUNUSED(context))
 
bool ShowInterface (wxWindow *parent, bool forceModal=false)
 
virtual void SetHostUI (EffectUIHostInterface *WXUNUSED(host))
 
wxDialog * CreateUI (wxWindow *parent, AudacityCommand *client)
 
virtual bool GetAutomationParameters (wxString &parms)
 
virtual bool SetAutomationParameters (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 ()
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
TranslatableString GetName ()
 
virtual bool DefineParams (ShuttleParams &WXUNUSED(S))
 

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 }
 
using VetoDialogHook = bool(*)(wxDialog *)
 
- Static Public Member Functions inherited from AudacityCommand
static VetoDialogHook SetVetoDialogHook (VetoDialogHook hook)
 
- Protected Attributes inherited from AudacityCommand
ProgressDialogmProgress
 
wxDialog * mUIDialog
 
wxWindow * mUIParent
 
int mUIResultID
 

Detailed Description

Command for exporting audio.

Definition at line 44 of file ImportExportCommands.h.

Member Function Documentation

◆ Apply()

bool ExportCommand::Apply ( const CommandContext context)
override

Definition at line 93 of file ImportExportCommands.cpp.

94 {
95  double t0, t1;
96  auto &selectedRegion = ViewInfo::Get( context.project ).selectedRegion;
97  t0 = selectedRegion.t0();
98  t1 = selectedRegion.t1();
99 
100  // Find the extension and check it's valid
101  int splitAt = mFileName.Find(wxUniChar('.'), true);
102  if (splitAt < 0)
103  {
104  context.Error(wxT("Export filename must have an extension!"));
105  return false;
106  }
107  wxString extension = mFileName.Mid(splitAt+1).MakeUpper();
108 
109  Exporter exporter{ context.project };
110 
111  bool exportSuccess = exporter.Process(std::max(0, mnChannels),
112  extension, mFileName,
113  true, t0, t1);
114 
115  if (exportSuccess)
116  {
117  context.Status(wxString::Format(wxT("Exported to %s format: %s"),
118  extension, mFileName));
119  return true;
120  }
121 
122  context.Error(wxString::Format(wxT("Could not export to %s format!"), extension));
123  return false;
124 }

References CommandContext::Error(), ViewInfo::Get(), mFileName, mnChannels, CommandContext::project, ViewInfo::selectedRegion, CommandContext::Status(), and NotifyingSelectedRegion::t0().

Here is the call graph for this function:

◆ DefineParams()

bool ExportCommand::DefineParams ( ShuttleParams S)
override

Definition at line 68 of file ImportExportCommands.cpp.

68  {
69  wxFileName fn = FileNames::FindDefaultPath(FileNames::Operation::Export);
70  fn.SetName("exported.wav");
71  S.Define(mFileName, wxT("Filename"), fn.GetFullPath());
72  S.Define( mnChannels, wxT("NumChannels"), 1 );
73  return true;
74 }

References ShuttleParams::Define(), FileNames::FindDefaultPath(), fn, mFileName, and mnChannels.

Here is the call graph for this function:

◆ GetDescription()

TranslatableString ExportCommand::GetDescription ( )
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 51 of file ImportExportCommands.h.

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

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol ExportCommand::GetSymbol ( )
inlineoverridevirtual

Implements AudacityCommand.

Definition at line 50 of file ImportExportCommands.h.

50 {return Symbol;};

References Symbol.

◆ ManualPage()

ManualPageID ExportCommand::ManualPage ( )
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 57 of file ImportExportCommands.h.

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

◆ PopulateOrExchange()

void ExportCommand::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 81 of file ImportExportCommands.cpp.

82 {
83  S.AddSpace(0, 5);
84 
85  S.StartMultiColumn(2, wxALIGN_CENTER);
86  {
87  S.TieTextBox(XXO("File Name:"),mFileName);
88  S.TieTextBox(XXO("Number of Channels:"),mnChannels);
89  }
90  S.EndMultiColumn();
91 }

References ShuttleGui::AddSpace(), ShuttleGuiBase::EndMultiColumn(), mFileName, mnChannels, ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::TieTextBox(), and XXO.

Here is the call graph for this function:

Member Data Documentation

◆ mFileName

wxString ExportCommand::mFileName

Definition at line 59 of file ImportExportCommands.h.

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

◆ mnChannels

int ExportCommand::mnChannels

Definition at line 60 of file ImportExportCommands.h.

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

◆ Symbol

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

Definition at line 47 of file ImportExportCommands.h.

Referenced by GetSymbol().


The documentation for this class was generated from the following files:
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:161
fn
static const auto fn
Definition: WaveformView.cpp:1113
FileNames::FindDefaultPath
FILES_API FilePath FindDefaultPath(Operation op)
ExportCommand::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: ImportExportCommands.h:47
Exporter
Definition: Export.h:166
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2459
XO
#define XO(s)
Definition: Internat.h:31
ExportCommand::mnChannels
int mnChannels
Definition: ImportExportCommands.h:60
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1238
ShuttleGuiBase::TieTextBox
wxTextCtrl * TieTextBox(const TranslatableString &Caption, wxString &Value, const int nChars=0)
Definition: ShuttleGui.cpp:1652
CommandContext::Status
virtual void Status(const wxString &message, bool bFlush=false) const
Definition: CommandContext.cpp:63
ViewInfo::selectedRegion
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:196
XXO
#define XXO(s)
Definition: Internat.h:44
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1229
ExportCommand::mFileName
wxString mFileName
Definition: ImportExportCommands.h:59
CommandContext::Error
virtual void Error(const wxString &message) const
Definition: CommandContext.cpp:73
NotifyingSelectedRegion::t0
double t0() const
Definition: ViewInfo.h:47
ShuttleParams::Define
virtual void Define(bool &var, const wxChar *key, const bool vdefault, const bool vmin=false, const bool vmax=false, const bool vscl=false)
Definition: Shuttle.cpp:332
CommandContext::project
AudacityProject & project
Definition: CommandContext.h:64