65 std::vector<std::string> args;
67 for(
int32 i = 1; i < argc; ++i)
69 args.push_back(argv[i]);
73 uint32 specific_n_bands = 0;
76 boolean verbose =
false;
78 std::vector<std::string>::iterator itor;
79 std::vector<std::string>::iterator end;
80 std::vector<std::string> files;
82 for(itor = args.begin(), end = args.end();
86 if(*itor ==
"-h" || *itor ==
"--help")
91 if(*itor ==
"-m" || *itor ==
"--fmax")
93 std::stringstream ss(*(itor + 1));
98 if(*itor ==
"-n" || *itor ==
"--bands")
100 std::stringstream ss(*(itor + 1));
101 ss >> specific_n_bands;
105 if(*itor ==
"-w" || *itor ==
"--window")
107 std::stringstream ss(*(itor + 1));
108 ss >> specific_window;
112 if(*itor ==
"-v" || *itor ==
"--verbose")
118 files.push_back(*itor);
122 if(files.size() != 3)
124 cerr <<
"Wrong number of arguments!\n";
128 std::string voice_file = files[0];
129 std::string carrier_file = files[1];
130 std::string output_file = files[2];
134 cerr <<
"ns_vocoder: can't find the file \"" << voice_file
142 cerr <<
"ns_vocoder: can't find the file \"" << voice_file
152 float64 sr1 = voice.getSampleRate();
153 float64 sr2 = carrier.getSampleRate();
161 carrier.resample2(sr1);
166 voice.resample2(sr2);
176 if(specific_window > 0)
178 window = specific_window;
181 if(specific_n_bands > 0)
183 n_bands = specific_n_bands;
186 if(specific_fmax > 0)
188 fmax = specific_fmax;
193 cout <<
"voice wav = " << voice_file << endl
194 <<
"carrier wav = " << carrier_file << endl
195 <<
"output wav = " << output_file << endl
196 <<
"n bands = " << n_bands << endl
197 <<
"window sec = " << window << endl
198 <<
"fmax = " << fmax << endl;
201 Vocoder vocoder(sr, window, n_bands, fmax);
205 for(
uint32 i = 0; i < carrier.getNChannels(); ++i)
218 temp << vocoder.filter(*v, *c);
232 output >> output_file.c_str();
A circulator iterator for class Buffer.
boolean file_exists(const std::string filename)
void normalize()
Multiplies the Buffer by a constant gain so the peak sample has magnitude 1.0.
A Buffer for storing audio samples.
FloatVector::iterator iterator