How to run perl script in Audacity

Hi everyone, I’m new to scripting and I want to run a perl script in audacity for some arg thing but I don’t want to go through the hassle of programming or install phyton and waste more time than i have to. (because i already did waste several hours of my life finding something to encrypt audio with) I just want to run the script and invert the audio, do I have to install a plugin or something? Or do I have to convert it to this “nyquist” thing. Here is the perl scrip, any help would be appreciated:

$fs = 48000; # sample rate
$fc = 3729; # carrier frequency
$filter = " sinc -$fc"; # optional LP filter

$fc = freq($fc);

open(IN, “sox scrambled.wav -c 1 -b 16 -e signed -t .raw -|”);
open(OUT,“|sox -r $fs -c 1 -b 16 -e signed -t .raw - descrambled.wav”.

while (not eof IN) {

$acc += $fc;
$acc -= 65536 if ($acc > 32767);

print OUT pack(“s”,unpack(“s”,$a) * sin($acc/32768*3.141592653589793));

sub freq { int(.5 + $_[0] * 65536 / $fs); }

Since you appear to be using SoX, you could invert the audio with:
sox -v -1 input.wav output.wav
The -v option is “volume” on a scale of 0 = silence, 1 = original volume, -1 (negative one) = inverted.

thanks but how do i run it? that was my original question

If you do all of your processing with SoX then you don’t need to run Audacity.

But to answer your original question, mod-script-pipe works with any language that supports “named pipes”, and that includes Perl (Scripting - Audacity Manual).
There’s an old example script here: (though it’s not been maintained for years, so I can’t guarantee that it won’t require a bit of tweaking).

@steve actually, i don’t need your help anymore, because I found one of your scripts that does the job from this post: Spectral Invert (oh and it’s broken in the latest version of Audacity for some reason and I had to go and install a previous version of Audacity) I was just being stubborn not seeing your script and the nyquist prompt. Thanks for your help, but now I want to deinvert the audio now just to make sure it can actually be retrievable. Could you make one please?

This topic was automatically closed after 30 days. New replies are no longer allowed.