Update of /cvsroot/audacity/audacity-src/src/export
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv23520
Modified Files:
Export.cpp ExportPCM.h ExportPCM.cpp Export.h
Log Message:
Move WAV format options to Options dialog.
Index: Export.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/export/Export.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Export.h 8 Apr 2007 09:11:14 -0000 1.8
+++ Export.h 14 Apr 2007 06:58:30 -0000 1.9
@@ -52,21 +52,28 @@
void Set(ExportRoutine routine,
ExportOptions options,
- wxString format,
wxString extension,
int maxchannels,
- bool canmetadata = false,
- wxString description = wxEmptyString);
+ bool canmetadata = false);
+
+ void Set(ExportRoutine routine,
+ ExportOptions options,
+ wxArrayString extensions,
+ wxString extension,
+ int maxchannels,
+ bool canmetadata = false);
ExportRoutine GetRoutine();
ExportOptions GetOptions();
wxString GetFormat();
wxString GetExtension();
- wxString GetDescription();
+ wxArrayString GetExtensions();
wxString GetMask();
int GetMaxChannels();
bool GetCanMetaData();
+ bool IsExtension(wxString & ext);
+
bool DisplayOptions(AudacityProject *project = NULL);
bool Export(AudacityProject *project,
int channels,
@@ -82,7 +89,7 @@
ExportOptions mOptions;
wxString mFormat;
wxString mExtension;
- wxString mDescription;
+ wxArrayString mExtensions;
int mMaxChannels;
bool mCanMetaData;
};
Index: Export.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/export/Export.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- Export.cpp 10 Apr 2007 02:21:35 -0000 1.48
+++ Export.cpp 14 Apr 2007 06:58:30 -0000 1.49
@@ -8,6 +8,16 @@
*******************************************************************//**
+\class Export
+\brief Main class to control the export function.
+
+*//****************************************************************//**
+
+\class ExportType
+\brief Container for information about supported export types.
+
+*//****************************************************************//**
+
\class ExportMixerDialog
\brief Dialog for advanced mixing.
@@ -77,19 +87,31 @@
void ExportType::Set(ExportRoutine routine,
ExportOptions options,
- wxString format,
+ wxArrayString extensions,
wxString extension,
int maxchannels,
- bool canmetadata,
- wxString description)
+ bool canmetadata)
+{
+ mExtensions = extensions;
+ Set(routine, options, extension, maxchannels, canmetadata);
+}
+
+void ExportType::Set(ExportRoutine routine,
+ ExportOptions options,
+ wxString extension,
+ int maxchannels,
+ bool canmetadata)
{
mRoutine = routine;
mOptions = options;
- mFormat = format;
- mExtension = extension;
+ mFormat = extension.MakeUpper();
+ mExtension = extension.MakeLower();
mMaxChannels = maxchannels;
mCanMetaData = canmetadata;
- mDescription = description;
+
+ if (mExtensions.GetCount() == 0) {
+ mExtensions.Add(mExtension);
+ }
}
ExportRoutine ExportType::GetRoutine()
@@ -112,9 +134,9 @@
return mExtension;
}
-wxString ExportType::GetDescription()
+wxArrayString ExportType::GetExtensions()
{
- return mDescription;
+ return mExtensions;
}
int ExportType::GetMaxChannels()
@@ -129,17 +151,24 @@
wxString ExportType::GetMask()
{
- if (mDescription == wxEmptyString) {
- return wxString::Format(wxT("%s files (*.%s)|*.%s"),
- mFormat.c_str(),
- mExtension.c_str(),
- mExtension.c_str());
+ wxString mask = mFormat + wxT(" files|");
+ size_t i;
+
+ // Build the mask, but cater to the Mac FileDialog and put the default
+ // extension at the end of the mask.
+
+ for (i = 0; i < mExtensions.GetCount(); i++) {
+ if (mExtension != mExtensions[i]) {
+ mask += wxT("*.") + mExtensions[i] + wxT(";");
+ }
}
- return wxString::Format(wxT("%s files (*.%s)|*.%s"),
- mDescription.c_str(),
- mExtension.c_str(),
- mExtension.c_str());
+ return mask + wxT("*.") + mExtension;
+}
+
+bool ExportType::IsExtension(wxString & ext)
+{
+ return mExtensions.Index(ext, false) != wxNOT_FOUND;
}
bool ExportType::DisplayOptions(AudacityProject *project)
@@ -197,28 +226,24 @@
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, false, desc);
+ et.Set(ExportPCM, ExportPCMOptions, sf_get_all_extensions(), wxT("wav"), 2);
types.Add(et);
- et.Set(ExportMP3, ExportMP3Options, wxT("MP3"), wxT("mp3"), 2, true);
+ et.Set(ExportMP3, ExportMP3Options, wxT("mp3"), 2, true);
types.Add(et);
#ifdef USE_LIBVORBIS
- et.Set(ExportOGG, ExportOGGOptions, wxT("OGG"), wxT("ogg"), 32);
+ et.Set(ExportOGG, ExportOGGOptions, wxT("ogg"), 32);
types.Add(et);
#endif
#ifdef USE_LIBFLAC
- et.Set(ExportFLAC, ExportFLACOptions, wxT("FLAC"), wxT("flac"), 8, true);
+ et.Set(ExportFLAC, ExportFLACOptions, wxT("flac"), 8, true);
types.Add(et);
#endif
#if USE_LIBTWOLAME
- et.Set(ExportMP2, ExportMP2Options, wxT("MP2"), wxT("mp2"), 2);
+ et.Set(ExportMP2, ExportMP2Options, wxT("mp2"), 2);
types.Add(et);
#endif
@@ -436,7 +461,7 @@
mFilename.SetExt(defext);
}
- else if (ext.CmpNoCase(mTypes[mFormat].GetExtension()) &&
ext.CmpNoCase(defext)) {
+ else if (!mTypes[mFormat].IsExtension(ext) && ext.CmpNoCase(defext)) {
wxString prompt;
prompt.Printf(_("You are about to save 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 save the file
under this name?"),
mTypes[mFormat].GetFormat().c_str(),
Index: ExportPCM.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/export/ExportPCM.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- ExportPCM.cpp 28 Mar 2007 04:14:04 -0000 1.28
+++ ExportPCM.cpp 14 Apr 2007 06:58:30 -0000 1.29
@@ -8,13 +8,14 @@
**********************************************************************/
-#include <wx/textctrl.h>
-#include <wx/string.h>
-#include <wx/window.h>
+#include <wx/choice.h>
+#include <wx/intl.h>
+#include <wx/timer.h>
#include <wx/msgdlg.h>
#include <wx/progdlg.h>
-#include <wx/timer.h>
-#include <wx/intl.h>
+#include <wx/string.h>
+#include <wx/textctrl.h>
+#include <wx/window.h>
#include "sndfile.h"
@@ -41,6 +42,17 @@
# endif
#endif
+static int ReadExportFormatPref()
+{
+ return gPrefs->Read(wxT("/FileFormats/ExportFormat_SF1"),
+ (long int)(SF_FORMAT_WAV | SF_FORMAT_PCM_16));
+}
+
+void WriteExportFormatPref(int format)
+{
+ gPrefs->Write(wxT("/FileFormats/ExportFormat_SF1"), (long int)format);
+}
+
bool ExportPCM(AudacityProject *project,
int numChannels, wxString fName,
bool selectionOnly, double t0, double t1, MixerSpec *mixerSpec)
@@ -158,6 +170,221 @@
return !cancelling;
}
+#define ID_FORMAT_CHOICE 7101
+#define ID_HEADER_CHOICE 7102
+#define ID_ENCODING_CHOICE 7103
+
+class PCMOptionsDialog : public wxDialog
+{
+public:
+
+ ///
+ ///
+ PCMOptionsDialog(wxWindow *parent)
+ : wxDialog(NULL, wxID_ANY, wxString(_("Specify WAV Options")),
+ wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP)
+ {
+ int format = ReadExportFormatPref();
+
+ //----- Gather our strings used in choices.
+
+ int i;
+ int num = sf_num_simple_formats();
+ int sel = num;
+ for (i = 0; i < num; i++) {
+ SF_FORMAT_INFO *info = sf_simple_format(i);
+ mFormatNames.Add(LAT1CTOWX(info->name));
+ if (format == info->format) {
+ sel = i;
+ }
+ }
+ mFormatNames.Add(_("Other..."));
+ mFormatFromChoice = sel;
+
+ num = sf_num_headers();
+ sel = 0;
+ for (i = 0; i < num; i++) {
+ mHeaderNames.Add(sf_header_index_name(i));
+ if ((format & SF_FORMAT_TYPEMASK) == sf_header_index_to_type(i)) {
+ sel = i;
+ }
+ }
+ mHeaderFromChoice = sel;
+
+ num = sf_num_encodings();
+ sel = 0;
+ for (i = 0; i < num; i++) {
+ mEncodingNames.Add(sf_encoding_index_name(i));
+ if ((format & SF_FORMAT_SUBMASK) == sf_encoding_index_to_subtype(i)) {
+ sel = i;
+ }
+ }
+ mEncodingFromChoice = sel;
+
+ ShuttleGui S(this, eIsCreatingFromPrefs);
+
+ PopulateOrExchange(S);
+
+ GetSizer()->AddSpacer(5);
+ Layout();
+ Fit();
+ Center();
+ }
+
+ ///
+ ///
+ void PopulateOrExchange(ShuttleGui & S)
+ {
+ S.StartHorizontalLay(wxEXPAND, true);
+ {
+ S.StartStatic(_("Uncompressed Export Setup"), true);
+ {
+ S.StartMultiColumn(2, wxEXPAND);
+ {
+ S.SetStretchyCol(1);
+ mFormatChoice = S.Id(ID_FORMAT_CHOICE)
+ .AddChoice(_("Format:"),
+ mFormatNames[mFormatFromChoice],
+ &mFormatNames);
+ mHeaderChoice = S.Id(ID_HEADER_CHOICE)
+ .AddChoice(_("Header:"),
+ mHeaderNames[mHeaderFromChoice],
+ &mHeaderNames);
+ mEncodingChoice = S.Id(ID_ENCODING_CHOICE)
+ .AddChoice(_("Encoding:"),
+ mEncodingNames[mEncodingFromChoice],
+ &mEncodingNames);
+ }
+ S.EndMultiColumn();
+ S.AddFixedText(_("(Not all combinations of headers and encodings
are possible.)"));
+ }
+ S.EndStatic();
+ }
+ S.EndHorizontalLay();
+ S.StartHorizontalLay(wxALIGN_CENTER, false);
+ {
+#if defined(__WXGTK20__) || defined(__WXMAC__)
+ S.Id(wxID_CANCEL).AddButton(_("&Cancel"));
+ mOk = S.Id(wxID_OK).AddButton(_("&OK"));
+#else
+ mOk = S.Id(wxID_OK).AddButton(_("&OK"));
+ S.Id(wxID_CANCEL).AddButton(_("&Cancel"));
+#endif
+ mOk->SetDefault();
+ }
+
+ ValidateChoices();
+
+ return;
+ }
+
+ ///
+ ///
+ void OnFormatChoice(wxCommandEvent & evt)
+ {
+ int format = sf_simple_format(mFormatChoice->GetSelection())->format;
+ int num;
+ int i;
+
+ num = sf_num_headers();
+ for (i = 0; i < num; i++) {
+ if ((format & SF_FORMAT_TYPEMASK) == sf_header_index_to_type(i)) {
+ mHeaderChoice->SetSelection(i);
+ break;
+ }
+ }
+
+ num = sf_num_encodings();
+ for (i = 0; i < num; i++) {
+ if ((format & SF_FORMAT_SUBMASK) == sf_encoding_index_to_subtype(i)) {
+ mEncodingChoice->SetSelection(i);
+ break;
+ }
+ }
+
+ ValidateChoices();
+ }
+
+ ///
+ ///
+ void OnChoice(wxCommandEvent & event)
+ {
+ ValidateChoices();
+ }
+
+ ///
+ ///
+ void OnOK(wxCommandEvent& event)
+ {
+ WriteExportFormatPref(GetFormat());
+
+ EndModal(wxID_OK);
+
+ return;
+ }
+
+private:
+ /// Calls a libsndfile library function to determine whether the user's
+ /// choice of sample encoding (e.g. pcm 16-bit or GSM 6.10 compression)
+ /// is compatible with their choice of file format (e.g. WAV, AIFF)
+ /// and enables/disables the OK button accordingly.
+ void ValidateChoices()
+ {
+ SF_INFO info;
+ memset(&info, 0, sizeof(info));
+ info.frames = 0;
+ info.samplerate = 44100;
+ info.channels = 1;
+ info.format = GetFormat();
+ info.sections = 1;
+ info.seekable = 0;
+
+ mOk->Enable(sf_format_check(&info) ? true : false);
+
+ bool enable = mFormatChoice->GetSelection() ==
+ (mFormatChoice->GetCount() - 1);
+
+ mHeaderChoice->Enable(enable);
+ mEncodingChoice->Enable(enable);
+ }
+
+ int GetFormat()
+ {
+ return sf_header_index_to_type(mHeaderChoice->GetSelection()) |
+ sf_encoding_index_to_subtype(mEncodingChoice->GetSelection());
+ }
+
+ wxArrayString mFormatNames;
+ wxArrayString mHeaderNames;
+ wxArrayString mEncodingNames;
+ wxChoice *mFormatChoice;
+ wxChoice *mHeaderChoice;
+ wxChoice *mEncodingChoice;
+ wxButton *mOk;
+ int mFormat;
+ int mFormatFromChoice;
+ int mHeaderFromChoice;
+ int mEncodingFromChoice;
+
+ DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE(PCMOptionsDialog, wxDialog)
+ EVT_CHOICE(ID_FORMAT_CHOICE, PCMOptionsDialog::OnFormatChoice)
+ EVT_CHOICE(ID_HEADER_CHOICE, PCMOptionsDialog::OnChoice)
+ EVT_CHOICE(ID_ENCODING_CHOICE, PCMOptionsDialog::OnChoice)
+ EVT_BUTTON(wxID_OK, PCMOptionsDialog::OnOK)
+END_EVENT_TABLE()
+
+bool ExportPCMOptions(AudacityProject *project)
+{
+ PCMOptionsDialog od(project);
+
+ od.ShowModal();
+
+ return true;
+}
+
// Indentation settings for Vim and Emacs and unique identifier for Arch, a
// version control system. Please do not modify past this point.
//
Index: ExportPCM.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/export/ExportPCM.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ExportPCM.h 14 Apr 2006 18:12:51 -0000 1.5
+++ ExportPCM.h 14 Apr 2007 06:58:30 -0000 1.6
@@ -23,6 +23,7 @@
bool selectionOnly, double t0, double t1,
MixerSpec *mixerSpec = NULL);
+bool ExportPCMOptions(AudacityProject *project);
#endif
-------------------------------------------------------------------------
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