25 #include "SoxWindows.H" 30 template<
typename Derived>
32 Matrix<FP_TYPE, Dynamic, Dynamic> output;
33 int ret=sox.
read(output, sampleCount);
34 output.transposeInPlace();
35 const_cast< DenseBase<Derived>&
>(audioData)=output;
41 cerr<<
"Usage: "<<str<<
" -h or --help"<<endl;
42 cerr<<
"Usage: "<<str<<
" fileName.wav rate"<<endl;
43 cerr<<
"\t the fileName can be any readable audio file format."<<endl;
44 cerr<<
"\t the rate can be any number within a reasonable range where 0 < rate < 5 or some reasonable speed."<<endl;
45 cerr<<
"\n Outputs to the file fileName.wav.rate.wav"<<endl;
46 cerr<<
"\n Author : Matt Flax <flatmax@>"<<endl;
50 int main(
int argc,
char *argv[]){
57 if (op.
getArg<
string>(
"h", argc, argv, help, i=0)!=0)
59 if (op.
getArg<
string>(
"help", argc, argv, help, i=0)!=0)
64 cout<<
"using timescale = "<<timeScale<<endl;
66 string fileName(argv[argc-2]);
67 cout<<
"input file = "<<fileName<<endl;
77 fileNameOut=fileName+
'.'+argv[argc-1]+
".wav";
78 cout<<
"output file = "<<fileNameOut<<endl;
84 Matrix<FP_TYPE, Dynamic, Dynamic> audioData;
88 cerr<<
"couldn't read audio, wanted "<<N<<
" got "<<ret<<endl;
93 N=wsola.
process(timeScale, audioData);
97 if (ret!=wsola.
output.cols())
98 cerr<<
"couldn't write audio, tried to write "<<N<<
" wrote "<<ret<<endl;
103 cerr<<
"couldn't read audio, wanted "<<N<<
" got "<<ret<<endl;
void printUsage(const char *str)
#define SOX_READ_MAXSCALE_ERROR
Sox couldn't open the filename.max to read the rescale value for the audio file.
virtual int openWrite(const string &fileName, double fs, int channels, double maxVal)
int getArg(string key, int argc, char *argv[], TYPE &ret, int i)
int openRead(string fileName)
virtual int evaluateError(int errorNum)
#define NO_ERROR
There is no error.
int writeTransposed(const Eigen::DenseBase< Derived > &audioData)
void convertArg(const char *arg, TYPE &ret)
int readAudio(Sox< FP_TYPE > &sox, DenseBase< Derived > const &audioData, int sampleCount)
int getSamplesRequired(void)
void setMaxVal(double newMax)
Array< FP_TYPE, Dynamic, Dynamic > output
The output vector, each row is a channel.
int main(int argc, char *argv[])
int process(FP_TYPE timeScale, const DenseBase< Derived > &input)
int read(Eigen::DenseBase< Derived > &audioData, int count=0)