Would it be possible to add to the Tools>Macros insert function commands of “Export as uLaw” and “Export as aLaw”? Both outputs being 8 bit header-less raw files.
I realize that most people use Audacity for high fidelity audio production, but I spend a lot of my time in the legacy telephone PCM world. Having these two options for output would be very helpful to me (not sure how useful it would be to others).
For uLaw, you can try this plug-in (below).
Note that this plug-in is not able to create the “macro-output” folder, so you will need to ensure that it exists before using the plug-in.
I’ve written this plug-in specifically for use in macros, so it runs silently with no options and no confirmation message. To see where the file was exported, look in “Help menu > Diagnostics > Show log”.
This is a Nyquist plug-in. Installation instructions for Windows are here: https://manual.audacityteam.org/man/installing_effect_generator_and_analyzer_plug_ins_on_windows.html#nyquist_install
Export-uLaw.ny (1.66 KB)
When installed and enabled, it will appear as “Export uLaw” in the “Tools” menu.
I’ve only tested on Linux and Windows 10. It should also work on macOS, but I’ve not tested on Mac.
Terrific. Thank you Steve! I’ll give it a try.
I’ve been out of town for a week, so I just got back to this now.
I’ve been able to download the Export ULaw plugin, and that works well. But my current problem is that the uLaw output I’m getting is at 44100 rather than 8000 samples per second.
It seems that when I use MACROS to process my files the output “rate” is determined by the rate of the recorded source files, and not the rate specified in the “Project Rate (Hz)” box in the lower left of the main Audacity window, like it would be if I was manually exporting ULaw files from the File>Export>ExportAudio menu. I’ve done my source file recording at 44100 to have source files with good fidelity, because somewhere down the road I may want to have output that is “better” than standard telcom uLaw 8000 s/s. I don’t see a way to do rate conversion in Audacity Macros. Is there some other way (while staying in Audacity and not jumping to SoX) to get uLaw 8000 s/s output from Audacity macros when processing source files recorded at 44100?
For normal export, the export sample rate does indeed come from the Project Rate.
For the “Export-uLaw.ny” plug-in it is a little different. The sample rate is from the track’s sample rate. To ensure that the track is exported at 8000 Hz, Resample the track to 8000 Hz before exporting.
Thank you Steve. That makes sense.
I do see the menu command Tracks>Resample for doing the resampling one-at-a-time. But I don’t see a Macro Command for resampling. Is there a plugin I should be using for that, since there doesn’t seem to be a Macro resample command?
I forgot the resample command is not available for macros, but that doesn’t matter because resampling is basically the same as “rendering” to a different sample rate. To do that:
- Change the Project Rate to 8000 (with the “Set Project” command)
- Mix and Render
Thanks. I’ve added “Mix and Render” to my Macro script.
The Macro script is currently
- Mix and Render
- Stereo to Mono
- Export uLaw
I set the “Project Rate (Hz)” to 8000 and then on the Macro screen click Files and then double-click on one source file (WAV Stereo 44100). The Macro runs (very fast) but at some point during the Macro run process (or at the end of the process) the Project Rate value is returned to 44100. And I find that the Macro produced RAW file output only sounds correct (and has the correct run length time) when I import it back into Audacity as uLaw 8 bit RAW at 44100.
Is it possible/likely that when the macro opens the source file (WAV 44100) that Audacity over-rides my choice of 8000 Project Rate and sets the Project Rate to 44100?
I didn’t read your note carefully enough.
I’ve now added the “Set Project” command to the Macro (as command 1) with the rate set to 8000 and it all seems to work correctly!
Thank you so much. Without your assistance I would have been totally stuck, and now all is good.