From: Takenori Y. <tak...@us...> - 2017-06-19 04:53:01
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7530 Modified Files: c2ndps.cc fft.cc fftr.cc ifft.cc mgc2sp.cc Added Files: ndps2c.cc Log Message: add ndps2c command Index: fft.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fft.cc,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** fft.cc 22 May 2017 03:44:10 -0000 1.15 --- fft.cc 19 Jun 2017 04:52:58 -0000 1.16 *************** *** 88,91 **** --- 88,93 ---- *stream << " stdout:" << std::endl; *stream << " FFT sequence (double)" << std::endl; + *stream << " notice:" << std::endl; + *stream << " value of l must be a power of 2" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; Index: fftr.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fftr.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** fftr.cc 22 May 2017 03:44:10 -0000 1.6 --- fftr.cc 19 Jun 2017 04:52:58 -0000 1.7 *************** *** 90,93 **** --- 90,95 ---- *stream << " stdout:" << std::endl; *stream << " FFT sequence (double)" << std::endl; + *stream << " notice:" << std::endl; + *stream << " value of l must be a power of 2" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; Index: ifft.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/ifft.cc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ifft.cc 22 May 2017 03:44:10 -0000 1.9 --- ifft.cc 19 Jun 2017 04:52:58 -0000 1.10 *************** *** 82,85 **** --- 82,87 ---- *stream << " stdout:" << std::endl; *stream << " inverse FFT sequence (double)" << std::endl; + *stream << " notice:" << std::endl; + *stream << " value of l must be a power of 2" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; Index: c2ndps.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/c2ndps.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** c2ndps.cc 14 Jun 2017 12:28:45 -0000 1.1 --- c2ndps.cc 19 Jun 2017 04:52:58 -0000 1.2 *************** *** 74,80 **** *stream << " c2ndps [ options ] [ infile ] > stdout" << std::endl; *stream << " options:" << std::endl; ! *stream << " -m m : order of cepstrum ( int)[" << std::setw(5) << std::right << kDefaultNumOrder << "][ 0 <= m <= l/2 ]" << std::endl; // NOLINT ! *stream << " -l l : FFT size ( int)[" << std::setw(5) << std::right << kDefaultFftSize << "][ 2m <= l <= ]" << std::endl; // NOLINT ! *stream << " -o o : output format ( int)[" << std::setw(5) << std::right << kDefaultOutputFormat << "][ 0 <= o <= 2 ]" << std::endl; // NOLINT *stream << " 0 (pole and zero parts)" << std::endl; *stream << " 1 (pole part)" << std::endl; --- 74,80 ---- *stream << " c2ndps [ options ] [ infile ] > stdout" << std::endl; *stream << " options:" << std::endl; ! *stream << " -m m : order of cepstrum ( int)[" << std::setw(5) << std::right << kDefaultNumOrder << "][ 0 <= m <= l/2 ]" << std::endl; // NOLINT ! *stream << " -l l : FFT size ( int)[" << std::setw(5) << std::right << kDefaultFftSize << "][ 4 <= l <= ]" << std::endl; // NOLINT ! *stream << " -o o : output format ( int)[" << std::setw(5) << std::right << kDefaultOutputFormat << "][ 0 <= o <= 2 ]" << std::endl; // NOLINT *stream << " 0 (pole and zero parts)" << std::endl; *stream << " 1 (pole part)" << std::endl; *************** *** 86,89 **** --- 86,90 ---- *stream << " negative derivative of phase spectrum (double)" << std::endl; // NOLINT *stream << " notice:" << std::endl; + *stream << " value of l must be a power of 2" << std::endl; *stream << " the output does not contain the information about c(0)" << std::endl; // NOLINT *stream << std::endl; --- NEW FILE: ndps2c.cc --- // ----------------------------------------------------------------- // // The Speech Signal Processing Toolkit (SPTK) // // developed by SPTK Working Group // // http://sp-tk.sourceforge.net/ // // ----------------------------------------------------------------- // // // // Copyright (c) 1984-2007 Tokyo Institute of Technology // // Interdisciplinary Graduate School of // // Science and Engineering // // // // 1996-2017 Nagoya Institute of Technology // // Department of Computer Science // // // // All rights reserved. // // // // Redistribution and use in source and binary forms, with or // // without modification, are permitted provided that the following // // conditions are met: // // // // - Redistributions of source code must retain the above copyright // // notice, this list of conditions and the following disclaimer. // // - Redistributions in binary form must reproduce the above // // copyright notice, this list of conditions and the following // // disclaimer in the documentation and/or other materials provided // // with the distribution. // // - Neither the name of the SPTK working group nor the names of its // // contributors may be used to endorse or promote products derived // // from this software without specific prior written permission. // // // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND // // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, // // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS // // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON // // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // // POSSIBILITY OF SUCH DAMAGE. // // ----------------------------------------------------------------- // #include <getopt.h> #include <fstream> #include <iomanip> #include <iostream> #include <sstream> #include <vector> #include "negative_derivative_of_phase_spectrum_to_cepstrum.h" #include "sptk_utils.h" namespace { const int kDefaultFftSize(256); const int kDefaultNumOrder(25); void PrintUsage(std::ostream* stream) { // clang-format off *stream << std::endl; *stream << " ndps2c - transform negative derivative of phase spectrum to cepstrum" << std::endl; // NOLINT *stream << std::endl; *stream << " usage:" << std::endl; *stream << " ndps2c [ options ] [ infile ] > stdout" << std::endl; *stream << " options:" << std::endl; *stream << " -l l : FFT size ( int)[" << std::setw(5) << std::right << kDefaultFftSize << "][ 4 <= l <= ]" << std::endl; // NOLINT *stream << " -m m : order of cepstrum ( int)[" << std::setw(5) << std::right << kDefaultNumOrder << "][ 0 <= m <= l/2 ]" << std::endl; // NOLINT *stream << " -h : print this message" << std::endl; *stream << " infile:" << std::endl; *stream << " negative derivative of phase spectrum (double)[stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; *stream << " cepstrum (double)" << std::endl; // NOLINT *stream << " notice:" << std::endl; *stream << " value of l must be a power of 2" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; *stream << std::endl; // clang-format on } } // namespace int main(int argc, char* argv[]) { int fft_size(kDefaultFftSize); int num_order(kDefaultNumOrder); for (;;) { const int option_char(getopt_long(argc, argv, "l:m:h", NULL, NULL)); if (-1 == option_char) break; switch (option_char) { case 'l': { if (!sptk::ConvertStringToInteger(optarg, &fft_size)) { std::ostringstream error_message; error_message << "The argument for the -l option must be an integer"; sptk::PrintErrorMessage("ndps2c", error_message); return 1; } break; } case 'm': { if (!sptk::ConvertStringToInteger(optarg, &num_order) || num_order < 0) { std::ostringstream error_message; error_message << "The argument for the -m option must be a " << "non-negative integer"; sptk::PrintErrorMessage("ndps2c", error_message); return 1; } break; } case 'h': { PrintUsage(&std::cout); return 0; } default: { PrintUsage(&std::cerr); return 1; } } } // check order const int half_fft_size(fft_size / 2); if (half_fft_size < num_order) { std::ostringstream error_message; error_message << "The order of cepstrum " << num_order << " must be equal or less than the half of FFT size " << half_fft_size; sptk::PrintErrorMessage("ndps2c", error_message); return 1; } // get input file const char* input_file((optind < argc) ? argv[argc - 1] : NULL); // open stream std::ifstream ifs; ifs.open(input_file, std::ios::in | std::ios::binary); if (ifs.fail() && NULL != input_file) { std::ostringstream error_message; error_message << "Cannot open file " << input_file; sptk::PrintErrorMessage("ndps2c", error_message); return 1; } std::istream& input_stream(ifs.fail() ? std::cin : ifs); // prepare for transformation sptk::NegativeDerivativeOfPhaseSpectrumToCepstrum negative_derivative_of_phase_spectrum_to_cepstrum(fft_size, num_order); sptk::NegativeDerivativeOfPhaseSpectrumToCepstrum::Buffer buffer; if (!negative_derivative_of_phase_spectrum_to_cepstrum.IsValid()) { std::ostringstream error_message; error_message << "FFT size must be a power of 2 and greater than 4"; sptk::PrintErrorMessage("ndps2c", error_message); return 1; } const int input_length(half_fft_size + 1); const int output_length(num_order + 1); std::vector<double> negative_derivative_of_phase_spectrum(input_length); std::vector<double> cepstrum(output_length); while (sptk::ReadStream(false, 0, 0, input_length, &negative_derivative_of_phase_spectrum, &input_stream)) { if (!negative_derivative_of_phase_spectrum_to_cepstrum.Run( negative_derivative_of_phase_spectrum, &cepstrum, &buffer)) { std::ostringstream error_message; error_message << "Failed to transform negative derivative of phase " << "spectrum to cepstrum"; sptk::PrintErrorMessage("ndps2c", error_message); return 1; } if (!sptk::WriteStream(0, output_length, cepstrum, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write cepstrum"; sptk::PrintErrorMessage("ndps2c", error_message); return 1; } } return 0; } Index: mgc2sp.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/mgc2sp.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** mgc2sp.cc 2 May 2017 07:10:22 -0000 1.5 --- mgc2sp.cc 19 Jun 2017 04:52:58 -0000 1.6 *************** *** 106,109 **** --- 106,110 ---- *stream << " spectrum (double)" << std::endl; *stream << " notice:" << std::endl; + *stream << " value of l must be a power of 2" << std::endl; *stream << " value of c must be c >= 1" << std::endl; *stream << " if -u is used without -n, input is regarded as 1+g/mgc[0],g*mgc[1],...,g*mgc[m]" << std::endl; // NOLINT |