Macro extension: Export options


This is my first post here. For anything done wrong, my deepest apologies.

Need: For my everyday work, I discovered the exceptionally useful feature of creating makros to quickly work on several files.
In combination with a script (and the mod-script-pipe) this becomes even more of a feature, that makes work very easy.

My question now is: Could you soon add some options to the export Makro? (I’ve seen this in a quick search in the forum, that you’re planning on adding something like this) I’d desperately need this feature.

Ideally, I’d like to export audio as 24 Bit/48 kHz (or even 32 bits?) with one click at a Makro, or with one send request in the mod-script-pipe.

And if this is already implemented, and I just didn’t see it, could you possibly share the link to the answered question?

That would be great!

Thank’s a lot in advance! You’re doing a wonderful job, by keeping this project going!

Currently Macros support exporting as 16-bit WAV, FLAC, OGG or MP3. Additional options will be added eventually, but not until after the next release. (The next release has mostly “under the hood” updates and bug fixes).

Hi Steve,

Thank you for the fast reply!
It‘d really be great to add this to the next release!
(Fingers crossed)

Is there a usual timeframe for release cycles?
When (as an rough estimate) may I expect the update?

Thank you!

Very roughly, between 1 and 3 releases per year.

Audacity is created, documented and supported by a very small team of enthusiasts in their “spare time”. Right now, I think the major part of the changes for Audacity 2.3.3 are more or less complete, and testing, debugging and bug fixing is under way. Because there have been big changes under the hood, there will be an extended testing / bug fix period for this release.

I’m hoping there will be some updates for Macros in Audacity 2.3.4 (the release after next).

In Audacity 2.3.2 (the current version), there is an option in the Help menu “Check for Updates”. This doesn’t do the update, it just links to the Audacity website where you can quickly check if a new version is available.

Hello Steve,

Thank you. This helps.

What if I really want this feature as soon as possible?
I could then go into the source code released on github and modify it, according to the GPL, for the one version I use locally. Is that correct?
More precisely, I‘m thinking about changing the default value from 16 Bit WAVE to 24 Bit WAVE.

Again, thank you for the fantastic work you all do on this software!

Best regards!

Yes you could do that.

In “FileMenus.cpp”, change:

void OnExportWav(const CommandContext &context)
   auto &project = context.project;
   DoExport(project, "WAV");


void OnExportWav(const CommandContext &context)
   auto &project = context.project;
   DoExport(project, "WAV24");

Oh! That‘s great! :smiley:

Thank you very much!

I will try that.

Have a great day!

This isn’t perfect because there are still some inconsistencies in how the exports act when applied to the current project, but it’s a better solution than just changing the default to 24-bit. It adds two new Macro commands, “Export as WAV (24-bit)” and “Export as WAV (32-bit float)”.

Note that this diff is against the current Audacity 2.3.3 alpha code.
Note also that the current alpha code has some new bugs and is NOT recommended for production work. I think it should be reasonably easy to adapt this to work with the Audacity 2.3.2 source code, or to the release version of 2.3.3 when it comes out.

diff --git a/src/BatchCommands.cpp b/src/BatchCommands.cpp
index e748cf2..aa460ed 100644
--- a/src/BatchCommands.cpp
+++ b/src/BatchCommands.cpp
@@ -71,6 +71,12 @@ static const std::pair<const wxChar*, CommandID> SpecialCommands[] = {
    /* i18n-hint: FLAC names an audio file format */
    { XO("Export as FLAC"),          wxT("ExportFLAC") },
+   /* i18n-hint: WAV (24-bit) names an audio file format */
+   { XO("Export as WAV (24-bit)"),  wxT("ExportWAV_24") },
+   /* i18n-hint: WAV (32-bit float) names an audio file format */
+   { XO("Export as WAV (32-bit float)"),  wxT("ExportWAV_FLT") },
 // MP3 OGG and WAV already handled by menu items.
 #if 0
    /* i18n-hint: MP3 names an audio file format */
@@ -552,6 +558,30 @@ wxString MacroCommands::BuildCleanFileName(const FilePath &fileName,
    return cleanedName;
+bool MacroCommands::WriteWAVFile( const wxString & Name, int bits )
+   wxString type = "WAV";
+   unsigned numChannels = 2;
+   if (IsMono()) {
+      numChannels = 1;
+   }
+   double endTime = GetEndTime();
+   if( endTime <= 0.0f )
+      return false;
+   AudacityProject *project = GetActiveProject();
+   if (bits == 24)
+      type = "WAV24";
+   else if (bits == 32)
+      type = "WAVFLT";
+   bool rc;
+   rc = mExporter.Process(project, numChannels, type, Name, false, 0.0, endTime);
+   return rc;
 // TODO Move this out of Batch Commands
 bool MacroCommands::WriteMp3File( const wxString & Name, int bitrate )
 {  //check if current project is mono or stereo
@@ -624,6 +654,10 @@ bool MacroCommands::ApplySpecialCommand(
    wxString extension; // required for correct message
    if (command == wxT("ExportWAV"))
       extension = wxT(".wav");
+   else if (command == wxT("ExportWAV_24"))
+      extension = wxT(".wav");
+   else if (command == wxT("ExportWAV_FLT"))
+      extension = wxT(".wav");
    else if (command == wxT("ExportOgg"))
       extension = wxT(".ogg");
    else if (command == wxT("ExportFLAC"))
@@ -669,6 +703,12 @@ bool MacroCommands::ApplySpecialCommand(
          return false;
       return mExporter.Process(project, numChannels, wxT("WAV"), filename, false, 0.0, endTime);
+   } else if (command == wxT("ExportWAV_24")) {
+      filename.Replace(wxT(".mp3"), wxT(".wav"), false);
+      return WriteWAVFile(filename, 24);
+   } else if (command == wxT("ExportWAV_FLT")) {
+      filename.Replace(wxT(".mp3"), wxT(".wav"), false);
+      return WriteWAVFile(filename, 32);
    } else if (command == wxT("ExportOgg")) {
       filename.Replace(wxT(".mp3"), wxT(".ogg"), false);
diff --git a/src/BatchCommands.h b/src/BatchCommands.h
index 6428409..2287132 100644
--- a/src/BatchCommands.h
+++ b/src/BatchCommands.h
@@ -82,6 +82,7 @@ class MacroCommands final {
    static wxString BuildCleanFileName(const FilePath &fileName,
       const FileExtension &extension);
    bool WriteMp3File( const wxString & Name, int bitrate );
+   bool WriteWAVFile( const wxString & Name, int bits );
    double GetEndTime();
    static bool IsMono();

So the second code you‘ve shared, would add additional macros, which gives more choice when using macros, right?
Thank you, I‘ll try that, after being more familiar with the source code.
For now changing the default should do the trick.

Thank you very much for the great insights!

That’s correct. It adds two new Macro commands, “Export as WAV (24-bit)” and “Export as WAV (32-bit float)”.