From 5b968e8250d83ff42b282adf14976ee8425907b0 Mon Sep 17 00:00:00 2001 From: Steve Daulton Date: Tue, 12 Apr 2016 21:58:08 +0100 Subject: [PATCH] Fix bug 1374 --- src/export/Export.cpp | 28 +++++++++++++++++++++++----- src/export/Export.h | 3 +++ src/export/ExportMP3.cpp | 10 ++++++++++ src/prefs/WarningsPrefs.cpp | 7 +++++-- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/export/Export.cpp b/src/export/Export.cpp index 92cdc69f9..e525f580a 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -748,6 +748,7 @@ bool Exporter::CheckMix() // and if mixing will occur. int downMix = gPrefs->Read(wxT("/FileFormats/ExportDownMix"), true); + int exportedChannels = mPlugins[mFormat]->SetNumExportChannels(); if (downMix) { if (mNumRight > 0 || mNumLeft > 0) { @@ -763,7 +764,18 @@ bool Exporter::CheckMix() int numRight = mNumRight + mNumMono; if (numLeft > 1 || numRight > 1 || mNumLeft + mNumRight + mNumMono > mChannels) { - if (mChannels == 2) { + wxString exportFormat = mPlugins[mFormat]->GetFormat(mSubFormat); + if (exportFormat != wxT("CL") && exportFormat != wxT("FFMPEG") && exportedChannels == -1) + exportedChannels = mChannels; + + if (exportedChannels == 1) { + if (ShowWarningDialog(mProject, + wxT("MixMono"), + _("Your tracks will be mixed down to a single mono channel in the exported file."), + true) == wxID_CANCEL) + return false; + } + else if (exportedChannels == 2) { if (ShowWarningDialog(mProject, wxT("MixStereo"), _("Your tracks will be mixed down to two stereo channels in the exported file."), @@ -772,8 +784,8 @@ bool Exporter::CheckMix() } else { if (ShowWarningDialog(mProject, - wxT("MixMono"), - _("Your tracks will be mixed down to a single mono channel in the exported file."), + wxT("MixUnknownChannels"), + _("Your tracks will be mixed down to one exported file according to the encoder settings."), true) == wxID_CANCEL) return false; } @@ -781,9 +793,12 @@ bool Exporter::CheckMix() } else { + if (exportedChannels == -1) + exportedChannels = mPlugins[mFormat]->GetMaxChannels(mSubFormat); + ExportMixerDialog md(mProject->GetTracks(), mSelectedOnly, - mPlugins[mFormat]->GetMaxChannels(mSubFormat), + exportedChannels, NULL, 1, _("Advanced Mixing Options")); @@ -1259,8 +1274,11 @@ ExportMixerDialog::ExportMixerDialog( const TrackList *tracks, bool selectedOnly // state the number of channels - so we assume there are always at least two. // The downside is that if someone is exporting to a mono device, the dialog // will allow them to output to two channels. Hmm. We may need to revisit this. + if (maxNumChannels < 2 ) - maxNumChannels = 2; + // STF (April 2016): AMR (narrowband) and MP3 may export 1 channel. + // maxNumChannels = 2; + maxNumChannels = 1; if (maxNumChannels > 32) maxNumChannels = 32; diff --git a/src/export/Export.h b/src/export/Export.h index 3244366ee..ff130b2fc 100644 --- a/src/export/Export.h +++ b/src/export/Export.h @@ -90,6 +90,9 @@ public: virtual wxWindow *OptionsCreate(wxWindow *parent, int format) = 0; virtual bool CheckFileName(wxFileName &filename, int format = 0); + /** @brief Exporter plug-ins may override this to specify the number + * of channels in exported file. -1 for unspecified */ + virtual int SetNumExportChannels() { return -1; } /** \brief called to export audio into a file. * diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp index d692afb02..bf5249396 100644 --- a/src/export/ExportMP3.cpp +++ b/src/export/ExportMP3.cpp @@ -1605,6 +1605,7 @@ private: #ifdef USE_LIBID3TAG void AddFrame(struct id3_tag *tp, const wxString & n, const wxString & v, const char *name); #endif + int SetNumExportChannels() override; }; ExportMP3::ExportMP3() @@ -1636,6 +1637,15 @@ bool ExportMP3::CheckFileName(wxFileName & WXUNUSED(filename), int WXUNUSED(form return true; } +int ExportMP3::SetNumExportChannels() +{ + bool mono; + gPrefs->Read(wxT("/FileFormats/MP3ForceMono"), &mono, 0); + + return (mono)? 1 : -1; +} + + int ExportMP3::Export(AudacityProject *project, int channels, const wxString &fName, diff --git a/src/prefs/WarningsPrefs.cpp b/src/prefs/WarningsPrefs.cpp index cb459028e..d6058fa86 100644 --- a/src/prefs/WarningsPrefs.cpp +++ b/src/prefs/WarningsPrefs.cpp @@ -63,11 +63,14 @@ void WarningsPrefs::PopulateOrExchange(ShuttleGui & S) S.TieCheckBox(_("&Low disk space at program start up"), wxT("/Warnings/DiskSpaceWarning"), true); + S.TieCheckBox(_("Mixing down to &mono during export"), + wxT("/Warnings/MixMono"), + true); S.TieCheckBox(_("Mixing down to &stereo during export"), wxT("/Warnings/MixStereo"), true); - S.TieCheckBox(_("Mixing down to &mono during export"), - wxT("/Warnings/MixMono"), + S.TieCheckBox(_("Mixing down on export (Custom FFmpeg or external program)"), + wxT("/Warnings/MixUnknownChannels"), true); S.TieCheckBox(_("&Importing uncompressed audio files"), wxT("/Warnings/CopyOrEditUncompressedDataAsk"),