Update of /cvsroot/audacity/audacity-src/src/export
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv20739
Modified Files:
Export.cpp ExportMultiple.cpp ExportMultiple.h Export.h
Log Message:
ExportMultiple redone to support centralizing format types within Export. (And
I went overboard again... :-))
Removed format settings from preferences.
Index: Export.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/export/Export.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Export.h 6 Apr 2007 10:24:04 -0000 1.7
+++ Export.h 8 Apr 2007 09:11:14 -0000 1.8
@@ -39,12 +39,11 @@
typedef bool (*ExportRoutine)(AudacityProject *project,
int channels,
wxString fName,
- bool selectionOnly,
+ bool selectedOnly,
double t0,
double t1,
MixerSpec *mixerSpec);
-
class ExportType
{
public:
@@ -56,6 +55,7 @@
wxString format,
wxString extension,
int maxchannels,
+ bool canmetadata = false,
wxString description = wxEmptyString);
ExportRoutine GetRoutine();
@@ -65,6 +65,16 @@
wxString GetDescription();
wxString GetMask();
int GetMaxChannels();
+ bool GetCanMetaData();
+
+ bool DisplayOptions(AudacityProject *project = NULL);
+ bool Export(AudacityProject *project,
+ int channels,
+ wxString fName,
+ bool selectedOnly,
+ double t0,
+ double t1,
+ MixerSpec *mixerSpec = NULL);
private:
@@ -74,6 +84,7 @@
wxString mExtension;
wxString mDescription;
int mMaxChannels;
+ bool mCanMetaData;
};
//----------------------------------------------------------------------------
@@ -83,13 +94,15 @@
{
public:
- Export(AudacityProject *project);
+ Export();
virtual ~Export();
- bool Process(bool selectionOnly, double t0, double t1);
+ bool Process(AudacityProject *project, bool selectedOnly, double t0, double
t1);
void DisplayOptions(int index);
+ static ExportTypeArray GetTypes();
+
private:
bool ExamineTracks();
@@ -115,7 +128,7 @@
int mNumRight;
int mNumMono;
int mChannels;
- bool mSelectionOnly;
+ bool mSelectedOnly;
};
//----------------------------------------------------------------------------
@@ -158,7 +171,7 @@
{
public:
// constructors and destructors
- ExportMixerDialog( TrackList * tracks, bool selectionOnly, int
maxNumChannels,
+ ExportMixerDialog( TrackList * tracks, bool selectedOnly, int
maxNumChannels,
wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
Index: Export.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/export/Export.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- Export.cpp 6 Apr 2007 10:24:04 -0000 1.46
+++ Export.cpp 8 Apr 2007 09:11:14 -0000 1.47
@@ -80,6 +80,7 @@
wxString format,
wxString extension,
int maxchannels,
+ bool canmetadata,
wxString description)
{
mRoutine = routine;
@@ -87,6 +88,7 @@
mFormat = format;
mExtension = extension;
mMaxChannels = maxchannels;
+ mCanMetaData = canmetadata;
mDescription = description;
}
@@ -120,6 +122,11 @@
return mMaxChannels;
}
+bool ExportType::GetCanMetaData()
+{
+ return mCanMetaData;
+}
+
wxString ExportType::GetMask()
{
if (mDescription == wxEmptyString) {
@@ -135,54 +142,94 @@
mExtension.c_str());
}
+bool ExportType::DisplayOptions(AudacityProject *project)
+{
+ if (project == NULL) {
+ project = GetActiveProject();
+ }
+
+ if (mOptions) {
+ return mOptions(project);
+ }
+
+ return true;
+}
+
+bool ExportType::Export(AudacityProject *project,
+ int channels,
+ wxString fName,
+ bool selectedOnly,
+ double t0,
+ double t1,
+ MixerSpec *mixerSpec)
+{
+ if (project == NULL) {
+ project = GetActiveProject();
+ }
+
+ if (mRoutine) {
+ return mRoutine(project, channels, fName, selectedOnly, t0, t1,
mixerSpec);
+ }
+
+ return false;
+}
+
//----------------------------------------------------------------------------
// Export
//----------------------------------------------------------------------------
-Export::Export(AudacityProject *project)
+Export::Export()
{
- ExportType et;
-
- mProject = project;
mMixerSpec = NULL;
+ mTypes = GetTypes();
+}
+
+Export::~Export()
+{
+ if (mMixerSpec) {
+ delete mMixerSpec;
+ }
+}
+
+// Static method
+ExportTypeArray Export::GetTypes()
+{
+ ExportTypeArray types;
+ ExportType et;
int format = ReadExportFormatPref();
wxString desc = sf_header_name(format & SF_FORMAT_TYPEMASK);
wxString ext = sf_header_extension(format & SF_FORMAT_TYPEMASK);
- et.Set(ExportPCM, NULL, wxT("WAV"), ext, 2, desc);
- mTypes.Add(et);
+ et.Set(ExportPCM, NULL, wxT("WAV"), ext, 2, false, desc);
+ types.Add(et);
- et.Set(ExportMP3, ExportMP3Options, wxT("MP3"), wxT("mp3"), 2);
- mTypes.Add(et);
+ et.Set(ExportMP3, ExportMP3Options, wxT("MP3"), wxT("mp3"), 2, true);
+ types.Add(et);
#ifdef USE_LIBVORBIS
et.Set(ExportOGG, ExportOGGOptions, wxT("OGG"), wxT("ogg"), 32);
- mTypes.Add(et);
+ types.Add(et);
#endif
#ifdef USE_LIBFLAC
- et.Set(ExportFLAC, ExportFLACOptions, wxT("FLAC"), wxT("flac"), 8);
- mTypes.Add(et);
+ et.Set(ExportFLAC, ExportFLACOptions, wxT("FLAC"), wxT("flac"), 8, true);
+ types.Add(et);
#endif
#if USE_LIBTWOLAME
et.Set(ExportMP2, ExportMP2Options, wxT("MP2"), wxT("mp2"), 2);
- mTypes.Add(et);
+ types.Add(et);
#endif
+ return types;
}
-Export::~Export()
-{
- if (mMixerSpec)
- delete mMixerSpec;
-}
-
-bool Export::Process(bool selectionOnly, double t0, double t1)
+bool Export::Process(AudacityProject *project, bool selectedOnly, double t0,
double t1)
{
// Save parms
- mSelectionOnly = selectionOnly;
+ mProject = project;
+ mSelectedOnly = selectedOnly;
mT0 = t0;
mT1 = t1;
@@ -230,7 +277,7 @@
// information as appropriate.
// Tally how many are right, left, mono, and make sure at
- // least one track is selected (if selectionOnly==true)
+ // least one track is selected (if selectedOnly==true)
float earliestBegin = mT1;
float latestEnd = mT0;
@@ -241,7 +288,7 @@
while (tr) {
if (tr->GetKind() == Track::Wave) {
- if (tr->GetSelected() || !mSelectionOnly) {
+ if (tr->GetSelected() || !mSelectedOnly) {
mNumSelected++;
@@ -282,7 +329,7 @@
tr = iter1.Next();
}
- if (mSelectionOnly && mNumSelected == 0) {
+ if (mSelectedOnly && mNumSelected == 0) {
wxMessageBox(_("No tracks are selected! Use Ctrl-A (Select All)\nChoose
Export... to export all tracks."),
_("Unable to export"),
wxOK | wxICON_INFORMATION);
@@ -309,7 +356,7 @@
mFormat = 0;
wxString maskString;
- wxString defaultFormat = gPrefs->Read(wxT("/DefaultExportFormat"),
+ wxString defaultFormat = gPrefs->Read(wxT("/Export/Format"),
wxT("WAV"));
for (size_t i = 0; i < mTypes.GetCount(); i++) {
@@ -321,7 +368,7 @@
}
maskString.RemoveLast();
- mFilename.SetPath(gPrefs->Read(wxT("/DefaultExportPath"), ::wxGetCwd()));
+ mFilename.SetPath(gPrefs->Read(wxT("/Export/Path"), ::wxGetCwd()));
mFilename.SetName(mProject->GetName());
mFilename.SetExt(mTypes[mFormat].GetExtension());
@@ -338,7 +385,7 @@
fd.SetFilterIndex(mFormat);
- fd.EnableButton(_("Options..."), ExportCallback, this);
+ fd.EnableButton(_("&Options..."), ExportCallback, this);
if (fd.ShowModal() == wxID_CANCEL) {
return false;
@@ -417,8 +464,8 @@
if (!mProject->GetDirManager()->EnsureSafeFilename(wxFileName(mFilename)))
return false;
- gPrefs->Write(wxT("/DefaultExportFormat"), mTypes[mFormat].GetFormat());
- gPrefs->Write(wxT("/DefaultExportPath"), mFilename.GetPath());
+ gPrefs->Write(wxT("/Export/Format"), mTypes[mFormat].GetFormat());
+ gPrefs->Write(wxT("/Export/Path"), mFilename.GetPath());
//
// To be even safer, return a temporary file name based
@@ -493,7 +540,7 @@
else
{
ExportMixerDialog md(mProject->GetTracks(),
- mSelectionOnly,
+ mSelectedOnly,
mTypes[mFormat].GetMaxChannels(),
NULL,
1,
@@ -512,15 +559,13 @@
bool Export::ExportTracks()
{
- ExportRoutine routine = mTypes[mFormat].GetRoutine();
-
- return routine(mProject,
- mChannels,
- mFilename.GetFullPath(),
- mSelectionOnly,
- mT0,
- mT1,
- mMixerSpec);
+ return mTypes[mFormat].Export(mProject,
+ mChannels,
+ mFilename.GetFullPath(),
+ mSelectedOnly,
+ mT0,
+ mT1,
+ mMixerSpec);
}
//----------------------------------------------------------------------------
@@ -789,7 +834,7 @@
EVT_SLIDER( ID_SLIDER_CHANNEL, ExportMixerDialog::OnSlider )
END_EVENT_TABLE()
-ExportMixerDialog::ExportMixerDialog( TrackList *tracks, bool selectionOnly,
+ExportMixerDialog::ExportMixerDialog( TrackList *tracks, bool selectedOnly,
int maxNumChannels, wxWindow *parent, wxWindowID id, const wxString
&title,
const wxPoint &position, const wxSize& size, long style ) :
wxDialog( parent, id, title, position, size, style | wxRESIZE_BORDER )
@@ -798,7 +843,7 @@
TrackListIterator iter( tracks );
for( Track *t = iter.First(); t; t = iter.Next() )
- if( t->GetKind() == Track::Wave && ( t->GetSelected() || !selectionOnly
) )
+ if( t->GetKind() == Track::Wave && ( t->GetSelected() || !selectedOnly )
)
{
numTracks++;
if( t->GetChannel() == Track::LeftChannel )
Index: ExportMultiple.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/export/ExportMultiple.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ExportMultiple.h 31 May 2004 21:11:04 -0000 1.1
+++ ExportMultiple.h 8 Apr 2007 09:11:14 -0000 1.2
@@ -11,8 +11,118 @@
#ifndef __AUDACITY_EXPORT_MULTIPLE__
#define __AUDACITY_EXPORT_MULTIPLE__
+#include <wx/dialog.h>
+#include <wx/string.h>
+
+#include "Export.h"
+#include "../Track.h"
+
+class wxButton;
+class wxCheckBox;
+class wxChoice;
+class wxRadioButton;
+class wxTextCtrl;
+
class AudacityProject;
+class ShuttleGui;
-bool ExportMultiple(AudacityProject *project);
+class ExportMultiple : public wxDialog
+{
+public:
+
+ ExportMultiple(AudacityProject *parent);
+ virtual ~ExportMultiple();
+
+ int ShowModal();
+
+private:
+
+ // Export
+ void CanExport();
+ bool DirOk();
+ bool ExportMultipleByLabel(bool byName, wxString prefix);
+ bool ExportMultipleByTrack(bool byName, wxString prefix);
+ void MakeNameUnique(wxArrayString &otherNames, wxString &newName);
+ bool DoExport(bool stereo,
+ wxString name,
+ bool selectedOnly,
+ double t0,
+ double t1,
+ int trackNumber);
+
+ // Dialog
+ void PopulateOrExchange(ShuttleGui& S);
+ void EnableControls();
+
+ void OnFormat(wxCommandEvent& event);
+ void OnOptions(wxCommandEvent& event);
+ void OnCreate(wxCommandEvent& event);
+ void OnChoose(wxCommandEvent& event);
+ void OnLabel(wxCommandEvent& event);
+ void OnFirst(wxCommandEvent& event);
+ void OnFirstFileName(wxCommandEvent& event);
+ void OnTrack(wxCommandEvent& event);
+ void OnByName(wxCommandEvent& event);
+ void OnByNumber(wxCommandEvent& event);
+ void OnPrefix(wxCommandEvent& event);
+ void OnCancel(wxCommandEvent& event);
+ void OnExport(wxCommandEvent& event);
+
+private:
+ ExportTypeArray mTypes;
+ AudacityProject *mProject;
+ TrackList *mTracks;
+ TrackListIterator mIterator;
+ LabelTrack *mLabels;
+ int mNumLabels;
+ int mNumTracks;
+ wxArrayPtrVoid mSelected;
+ int mFormatIndex;
+ bool mInitialized;
+
+ wxChoice *mFormat;
+ wxButton *mOptions;
+
+ wxTextCtrl *mDir;
+ wxButton *mCreate;
+ wxButton *mChoose;
+
+ wxRadioButton *mLabel;
+ wxStaticText *mLabelLabel;
+
+ wxCheckBox *mFirst;
+ wxStaticText *mFirstFileLabel;
+ wxTextCtrl *mFirstFileName;
+
+ wxRadioButton *mTrack;
+ wxStaticText *mTrackLabel;
+
+ wxRadioButton *mByName;
+ wxStaticText *mByNameLabel;
+
+ wxRadioButton *mByNumber;
+ wxStaticText *mByNumberLabel;
+
+ wxStaticText *mPrefixLabel;
+ wxTextCtrl *mPrefix;
+
+ wxCheckBox *mOverwrite;
+
+ wxButton *mCancel;
+ wxButton *mExport;
+
+ DECLARE_EVENT_TABLE()
+};
#endif
+
+// Indentation settings for Vim and Emacs and unique identifier for Arch, a
+// version control system. Please do not modify past this point.
+//
+// Local Variables:
+// c-basic-offset: 3
+// indent-tabs-mode: nil
+// End:
+//
+// vim: et sts=3 sw=3
+// arch-tag: d6904b91-a320-4194-8d60-caa9175b6bb4
Index: ExportMultiple.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/export/ExportMultiple.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- ExportMultiple.cpp 6 Apr 2007 10:24:04 -0000 1.22
+++ ExportMultiple.cpp 8 Apr 2007 09:11:14 -0000 1.23
@@ -11,7 +11,7 @@
*******************************************************************//**
-\class ExportMultipleDialog
+\class ExportMultiple
\brief Presents a dialog box allowing the user to export multiple files
either by exporting each track as a separate file, or by
exporting each label as a separate file.
@@ -26,22 +26,20 @@
#include <wx/choice.h>
#include <wx/dialog.h>
[...1561 lines suppressed...]
- EndModal(1);
+ // Call the format export routine
+ return mTypes[mFormatIndex].Export(mProject,
+ stereo ? 2 : 1,
+ fn.GetFullPath(),
+ selectedOnly,
+ t0,
+ t1);
}
+// Indentation settings for Vim and Emacs and unique identifier for Arch, a
+// version control system. Please do not modify past this point.
+//
+// Local Variables:
+// c-basic-offset: 3
+// indent-tabs-mode: nil
+// End:
+//
+// vim: et sts=3 sw=3
+// arch-tag: d6904b91-a320-4194-8d60-caa9175b6bb4
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs