1
General Board / Re: how to get txt for FOFS?
« Last post by Robert Fraser on Today at 11:07:37 AM »The PSOW (FOF) programs require a pitch-trace breakpoint file extracted using PTOBRK WITHZEROS. And that requires a pitch file (.frq) extracted from a frequency analysis file (.ana), using REPITCH GETPITCH 1. This is all better put in a little script (Windows CMD batch file or MacOS bash shell script).
Here are two similar scripts: the first kindly supplied by Richard Dobson for bash, and my own batch file (PC) based on Soundshaper. Both make use of arguments supplied on the commandline - particularly the infile and outfile names. Bash scripts have variables $1, $2 and so on, referring to the first, second etc. arguments; the equivalent in CMD batch files is %1, %2, etc. Both scripts assume a mono input sound.
First, Richard's bash script frqtotext: note the usage "frqtotxt insndfile outtextfile", where outtextfile is the name of the pitch-trace file.
#!/bin/bash
echo frqtotxt.sh - shell script to prepare pitch-brkpnt-data file for
echo use with a FOF-source file: lengths must match.
if [ $# -ne 2 ]
then
echo usage: frqtotxt insndfile outtextfile
exit 1
fi
echo
echo pvoc anal 1 $1 infile.ana
pvoc anal 1 $1 infile.ana
echo repitch getpitch 1 infile.ana infilepchdummy.aiff infile.frq
repitch getpitch 1 infile.ana infilepchdummy.aiff infile.frq
echo ptobrk withzeros infile.frq $2 20
ptobrk withzeros infile.frq $2 20
echo Delete \(temporary\) files no longer needed:
echo rm infile.ana
rm infile.ana
echo rm infilepchdummy.aiff
rm infilepchdummy.aiff
echo rm infile.frq
rm infile.frq
Now the BAT version, which adds parameter values for the application PSOW STRETCH. In this example the file suffixes are in the script, so would not be supplied on the commandline:
REM %1 is input wav (just the name without .wav); %2 is the output wav (also without .wav)
REM %3 is amount of stretch; %4 is no. of grains
echo ***** PSOW STRETCH BATCH SCRIPT (PC) *****
echo off
REM Convert wav to ana
pvoc anal 1 %1.wav %1.ana -c1024 -o3
REM Extract pitch
repitch getpitch 1 %1.ana %1pch.ana %1.frq
REM erase unwanted pitch file
erase %1pch.ana
REM Create pitch-trace text file
ptobrk withzeros %1.frq %1.pch 20
REM Stretch the input sound
psow stretch %1.wav %2.wav %1.pch %3 %4
REM Erase intermediate files...
if exist %1.ana erase %1.ana
if exist %1.frq erase %1.frq
if exist %1.brk erase %1.brk
REM Optionally play the output
if exist %2.wav paplay -i %2.wav
A typical commandline for this might be fofstretch my mystr 2.0 20. For test purposes, put the script in the same folder as the input file.
Here are two similar scripts: the first kindly supplied by Richard Dobson for bash, and my own batch file (PC) based on Soundshaper. Both make use of arguments supplied on the commandline - particularly the infile and outfile names. Bash scripts have variables $1, $2 and so on, referring to the first, second etc. arguments; the equivalent in CMD batch files is %1, %2, etc. Both scripts assume a mono input sound.
First, Richard's bash script frqtotext: note the usage "frqtotxt insndfile outtextfile", where outtextfile is the name of the pitch-trace file.
#!/bin/bash
echo frqtotxt.sh - shell script to prepare pitch-brkpnt-data file for
echo use with a FOF-source file: lengths must match.
if [ $# -ne 2 ]
then
echo usage: frqtotxt insndfile outtextfile
exit 1
fi
echo
echo pvoc anal 1 $1 infile.ana
pvoc anal 1 $1 infile.ana
echo repitch getpitch 1 infile.ana infilepchdummy.aiff infile.frq
repitch getpitch 1 infile.ana infilepchdummy.aiff infile.frq
echo ptobrk withzeros infile.frq $2 20
ptobrk withzeros infile.frq $2 20
echo Delete \(temporary\) files no longer needed:
echo rm infile.ana
rm infile.ana
echo rm infilepchdummy.aiff
rm infilepchdummy.aiff
echo rm infile.frq
rm infile.frq
Now the BAT version, which adds parameter values for the application PSOW STRETCH. In this example the file suffixes are in the script, so would not be supplied on the commandline:
REM %1 is input wav (just the name without .wav); %2 is the output wav (also without .wav)
REM %3 is amount of stretch; %4 is no. of grains
echo ***** PSOW STRETCH BATCH SCRIPT (PC) *****
echo off
REM Convert wav to ana
pvoc anal 1 %1.wav %1.ana -c1024 -o3
REM Extract pitch
repitch getpitch 1 %1.ana %1pch.ana %1.frq
REM erase unwanted pitch file
erase %1pch.ana
REM Create pitch-trace text file
ptobrk withzeros %1.frq %1.pch 20
REM Stretch the input sound
psow stretch %1.wav %2.wav %1.pch %3 %4
REM Erase intermediate files...
if exist %1.ana erase %1.ana
if exist %1.frq erase %1.frq
if exist %1.brk erase %1.brk
REM Optionally play the output
if exist %2.wav paplay -i %2.wav
A typical commandline for this might be fofstretch my mystr 2.0 20. For test purposes, put the script in the same folder as the input file.