#!/usr/bin/perl
# The line above tells the shell that this is a Perl script. Don't delete it.
# Text following a `#' character on a line will be ignored by Perl.

# ------------------------------------------------------------------- FILES ---
$input_file = "/snd/Public_Sounds/jimiPopDN.aiff";
$input_chan = 0;              # numbered from 1; 0 means to use all input chans
$begintime = 3.6;
$endtime = 4.55;              # 0 means end of file

# PVC writes sound files in NeXT/Sun format.
$output_file = "/snd/myuserid/simple_time_scale.snd";

# ---------------------------------------------------------------- ANALYSIS ---
# You can leave these next two alone.
$fft_length = 1024;           # makes 512 (fft_length / 2) frequency bins
$frames_per_second = 200;     # number of windows (frames) per second

# ------------------------------------------------------------- RESYNTHESIS ---
# Gain change in dB.
# 0 means no change; positive numbers raise gain; negative numbers lower it.
# Lower the gain if you see clipping in the peak amp stats.
$gain = 0;

# Time compression / expansion factor
# 1.0 means no change; 2.0 doubles duration; 0.5 halves duration
$time_scale_factor = 10.0;

# ----------------------------------------------------------------- DISPLAY ---
# This just controls the screen output when running the job.
$print_amp_stats = 1;                # 0: no, 1: yes
$amp_stats_time_interval = .25;      # print peak amp every .25 seconds



#==============================================================================
# COMMAND LINE SETUP -- OFFICE USE ONLY

# Adjust frame rate by scale factor, but can't be > sampling rate.
$frames_per_second = $time_scale_factor * $frames_per_second;
if ($frames_per_second > 44100) {
   $frames_per_second = 44100;
}

# Build argument string from vars defined above.
# Type "plainpv" at the shell prompt to see a description of all the args.
$pvflags = 
" -N$fft_length" .
" -M0" .
" -w2" .
" -D$frames_per_second" .
" -I$time_scale_factor" .
" -A$gain" .
" -C$input_chan" .
" -b$begintime" .
" -e$endtime" .
" -p$print_amp_stats" .
" -i$amp_stats_time_interval";

# Build command line.
$cmd = "plainpv $pvflags $input_file $output_file";

# Print command line for reference.
print $cmd, "\n\n";

# Execute command.
`$cmd`;

