How to export in U-law encoding from a macro?

I need to create a macro that can export the audio as WAV format, mono, 8Khz, U-law encoding (yes, g.711 for telecom). I am running Audacity 3.7.7 on Windows 11.

I go to Tools->Manage Macros and create a new macro.

Export as WAV command has no parameters, so I cannot control the encoding.

Export2 only allows parameters of File Name and Number of Channels.

Google Gemini suggest I must first go to File->Export Audio… and set the format, sample rate, and encoding options. Then click Cancel. Then I can create the macro. Is this true? it is not very intuitive. Will my macro behavior change if I export later with a different format? That doesn’t seem very reliable for a macro.

Gemini details

Gemini says:

Steps to Create the WAV u-Law Macro

  1. Configure Export Settings (Required First Step):

    • Open any audio file in Audacity.

    • Go to File > Export Audio….

    • Select WAV (Microsoft) as the format.

    • Click Options and choose U-Law as the encoding (sets 8-bit, 8 kHz).

    • Cancel the export dialog. This ensures the macro remembers this format.

  2. Create the Macro:

    • Go to Tools > Macro Manager.

    • Click New and name your macro (e.g., “Export-WAV-uLaw”).

    • Click Insert and select ExportWav from the command list.

    • Click OK, then Close.

  3. Run the Macro:

    • You can now apply this to your project via Tools > Apply Macro > [Your Macro Name]. [1, 2, 3, 4, 5]

How do I create a macro that can export to WAV in u-law?

I think I must add steps as:

  1. Set project - Rate=8000 - to force the project to the correct sample rate
  2. Mix and Render - to reduce to 1 mono
  3. Export WAV

Is this correct? If I later export with a different format, will my macro’s behavior change?

-- Update -

I tested this. Gemini is close, but wrong. You can’t cancel Export Audio, you must save and do one manual export in your selected format. Then you can apply your macro.

It appears that the Export as Wav macro step will use the last saved settings from File > Export Audio. This means you must remember to do a manual export before running your macro.

Is this correct? It seems a bit crazy.

1 Like

https://forum.audacityteam.org/search?expanded=true&q=u-law+macro

1 Like