Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7746 Modified Files: .clang-format Makefile excitation_generation.cc excitation_generation.h fast_fourier_transform.cc fast_fourier_transform.h fast_fourier_transform_for_real_sequence.cc fast_fourier_transform_for_real_sequence.h generalized_cepstrum_transform.cc generalized_cepstrum_transform.h input_source_from_array.h input_source_from_vector.h levdur.cc levinson_durbin_recursion.cc levinson_durbin_recursion.h m_sequence_generation.cc m_sequence_generation.h mgc2mgc.cc normal_distributed_random_value_generation.cc normal_distributed_random_value_generation.h random_generation_interface.h sptk_utils.cc sptk_utils.h Added Files: generalized_cepstrum_to_spectrum.cc generalized_cepstrum_to_spectrum.h mgc2sp.cc Log Message: add mgc2sp command Index: mgc2mgc.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/mgc2mgc.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mgc2mgc.cc 16 Dec 2016 09:36:32 -0000 1.1 --- mgc2mgc.cc 26 Dec 2016 07:41:20 -0000 1.2 *************** *** 73,97 **** *stream << " mgc2mgc [ options ] [ infile ] > stdout" << std::endl; *stream << " options:" << std::endl; ! *stream << " -m m : order of mel-generalized cepstrum (input) [" << kDefaultInputNumOrder << "]" << std::endl; // NOLINT ! *stream << " -a a : alpha of mel-generalized cepstrum (input) [" << kDefaultInputAlpha << "]" << std::endl; // NOLINT ! *stream << " -g g : gamma of mel-generalized cepstrum (input) [" << kDefaultInputGamma << "]" << std::endl; // NOLINT *stream << " -c c : gamma of mel-generalized cepstrum = -1 / (int) c (input)" << std::endl; // NOLINT ! *stream << " -n : regard input as normalized mel-generalized cepstrum [" << sptk::ConvertBooleanToString(kDefaultInputNormalizationFlag) << "]" << std::endl; // NOLINT ! *stream << " -u : regard input as multiplied by gamma [" << sptk::ConvertBooleanToString(kDefaultInputMultiplicationFlag) << "]" << std::endl; // NOLINT ! *stream << " -M M : order of mel-generalized cepstrum (input) [" << kDefaultOutputNumOrder << "]" << std::endl; // NOLINT ! *stream << " -A A : alpha of mel-generalized cepstrum (input) [" << kDefaultOutputAlpha << "]" << std::endl; // NOLINT ! *stream << " -G G : gamma of mel-generalized cepstrum (input) [" << kDefaultOutputGamma << "]" << std::endl; // NOLINT ! *stream << " -C C : gamma of mel-generalized cepstrum = -1 / (int) C (input)" << std::endl; // NOLINT ! *stream << " -N : regard input as normalized mel-generalized cepstrum [" << sptk::ConvertBooleanToString(kDefaultOutputNormalizationFlag) << "]" << std::endl; // NOLINT ! *stream << " -U : regard input as multiplied by gamma [" << sptk::ConvertBooleanToString(kDefaultOutputMultiplicationFlag) << "]" << std::endl; // NOLINT *stream << " -h : print this message" << std::endl; *stream << " infile:" << std::endl; ! *stream << " mel-generalized cepstrum (double) [stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; *stream << " transformed mel-generalized cepstrum (double)" << std::endl; // NOLINT *stream << " notice:" << std::endl; ! *stream << " value of c must be c >= 1 (double)" << std::endl; ! *stream << " if -u is used without -n, input is regarded as 1+g/c[0],g*c[1],...,g*c[m]" << std::endl; // NOLINT ! *stream << " if -U is used without -N, ouputput is regarded as 1+g/c[0],g*c[1],...,g*c[m]" << std::endl; // NOLINT *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; --- 73,97 ---- *stream << " mgc2mgc [ options ] [ infile ] > stdout" << std::endl; *stream << " options:" << std::endl; ! *stream << " -m m : order of mel-generalized cepstrum (input) [" << kDefaultInputNumOrder << "]" << std::endl; // NOLINT ! *stream << " -a a : alpha of mel-generalized cepstrum (input) [" << kDefaultInputAlpha << "]" << std::endl; // NOLINT ! *stream << " -g g : gamma of mel-generalized cepstrum (input) [" << kDefaultInputGamma << "]" << std::endl; // NOLINT *stream << " -c c : gamma of mel-generalized cepstrum = -1 / (int) c (input)" << std::endl; // NOLINT ! *stream << " -n : regard input as normalized mel-generalized cepstrum [" << sptk::ConvertBooleanToString(kDefaultInputNormalizationFlag) << "]" << std::endl; // NOLINT ! *stream << " -u : regard input as multiplied by gamma [" << sptk::ConvertBooleanToString(kDefaultInputMultiplicationFlag) << "]" << std::endl; // NOLINT ! *stream << " -M M : order of mel-generalized cepstrum (output) [" << kDefaultOutputNumOrder << "]" << std::endl; // NOLINT ! *stream << " -A A : alpha of mel-generalized cepstrum (output) [" << kDefaultOutputAlpha << "]" << std::endl; // NOLINT ! *stream << " -G G : gamma of mel-generalized cepstrum (output) [" << kDefaultOutputGamma << "]" << std::endl; // NOLINT ! *stream << " -C C : gamma of mel-generalized cepstrum = -1 / (int) C (output)" << std::endl; // NOLINT ! *stream << " -N : regard output as normalized mel-generalized cepstrum [" << sptk::ConvertBooleanToString(kDefaultOutputNormalizationFlag) << "]" << std::endl; // NOLINT ! *stream << " -U : regard output as multiplied by gamma [" << sptk::ConvertBooleanToString(kDefaultOutputMultiplicationFlag) << "]" << std::endl; // NOLINT *stream << " -h : print this message" << std::endl; *stream << " infile:" << std::endl; ! *stream << " mel-generalized cepstrum (double) [stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; *stream << " transformed mel-generalized cepstrum (double)" << std::endl; // NOLINT *stream << " notice:" << 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 ! *stream << " if -U is used without -N, output is regarded as 1+g/mgc[0],g*mgc[1],...,g*mgc[m]" << std::endl; // NOLINT *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; *************** *** 250,254 **** if (!generalized_cepstrum_transform.IsValid()) { std::ostringstream error_message; ! error_message << "Failed to set the condition."; sptk::PrintErrorMessage("mgc2mgc", error_message); return 1; --- 250,254 ---- if (!generalized_cepstrum_transform.IsValid()) { std::ostringstream error_message; ! error_message << "Failed to set the condition"; sptk::PrintErrorMessage("mgc2mgc", error_message); return 1; Index: sptk_utils.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/sptk_utils.cc,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** sptk_utils.cc 12 Oct 2016 12:14:38 -0000 1.10 --- sptk_utils.cc 26 Dec 2016 07:41:20 -0000 1.11 *************** *** 171,176 **** } ! bool IsInRange(int value, int min, int max) { ! return (value < min || max < value) ? false : true; } --- 171,182 ---- } ! bool IsInRange(int num, int min, int max) { ! return (num < min || max < num); ! } ! ! // check whether a number is a power of two, 2^p where p is a non-negative ! // integer. ! bool IsPowerOfTwo(int num) { ! return !((num < 1) || (num & (num - 1))); } Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Makefile 22 Dec 2016 16:09:06 -0000 1.22 --- Makefile 26 Dec 2016 07:41:20 -0000 1.23 *************** *** 56,59 **** --- 56,60 ---- generalized_cepstrum_gain_normalization.cc \ generalized_cepstrum_inverse_gain_normalization.cc \ + generalized_cepstrum_to_spectrum.cc \ generalized_cepstrum_transform.cc \ input_source_from_array.cc \ Index: levinson_durbin_recursion.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/levinson_durbin_recursion.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** levinson_durbin_recursion.h 24 Oct 2016 08:20:30 -0000 1.5 --- levinson_durbin_recursion.h 26 Dec 2016 07:41:20 -0000 1.6 *************** *** 90,94 **** bool Run(const std::vector<double>& autocorrelation_sequence, std::vector<double>* linear_predictive_coefficients, ! LevinsonDurbinRecursion::Buffer* buffer, bool* is_stable) const; private: --- 90,94 ---- bool Run(const std::vector<double>& autocorrelation_sequence, std::vector<double>* linear_predictive_coefficients, ! bool* is_stable, LevinsonDurbinRecursion::Buffer* buffer) const; private: Index: levdur.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/levdur.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** levdur.cc 24 Nov 2016 04:16:55 -0000 1.5 --- levdur.cc 26 Dec 2016 07:41:20 -0000 1.6 *************** *** 193,197 **** bool is_stable(false); if (!recursion.Run(autocorrelation_sequence, ! &linear_predictive_coefficients, &buffer, &is_stable)) { std::ostringstream error_message; error_message << "Failed to solve an autocorrelation normal equation"; --- 193,197 ---- bool is_stable(false); if (!recursion.Run(autocorrelation_sequence, ! &linear_predictive_coefficients, &is_stable, &buffer)) { std::ostringstream error_message; error_message << "Failed to solve an autocorrelation normal equation"; --- NEW FILE: generalized_cepstrum_to_spectrum.h --- // ----------------------------------------------------------------- // // 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-2016 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. // // ----------------------------------------------------------------- // #ifndef SPTK_SRC_GENERALIZED_CEPSTRUM_TO_SPECTRUM_H_ #define SPTK_SRC_GENERALIZED_CEPSTRUM_TO_SPECTRUM_H_ #include <vector> // std::vector #include "fast_fourier_transform_for_real_sequence.h" #include "generalized_cepstrum_transform.h" #include "sptk_utils.h" namespace sptk { class GeneralizedCepstrumToSpectrum { public: class Buffer { public: Buffer() { } virtual ~Buffer() { } private: GeneralizedCepstrumTransform::Buffer generalized_cepstrum_transform_buffer_; FastFourierTransformForRealSequence::Buffer fast_fourier_transform_buffer_; std::vector<double> cepstrum_; friend class GeneralizedCepstrumToSpectrum; DISALLOW_COPY_AND_ASSIGN(Buffer); }; // GeneralizedCepstrumToSpectrum(int num_order, double alpha, double gamma, bool is_normalized, bool is_multiplied, int fft_size); // virtual ~GeneralizedCepstrumToSpectrum() { } // int GetNumOrder() const { return generalized_cepstrum_transform_.GetNumInputOrder(); } // double GetAlpha() const { return generalized_cepstrum_transform_.GetInputAlpha(); } // double GetGamma() const { return generalized_cepstrum_transform_.GetInputGamma(); } // bool IsNormalized() const { return generalized_cepstrum_transform_.IsNormalizedInput(); } // bool IsMultiplied() const { return generalized_cepstrum_transform_.IsMultipliedInput(); } // int GetFftSize() const { return fast_fourier_transform_.GetFftSize(); } // bool IsValid() const { return is_valid_; } // bool Run(const std::vector<double>& generalized_cepstrum, std::vector<double>* amplitude_spectrum, std::vector<double>* phase_spectrum, GeneralizedCepstrumToSpectrum::Buffer* buffer) const; private: // const GeneralizedCepstrumTransform generalized_cepstrum_transform_; // const FastFourierTransformForRealSequence fast_fourier_transform_; // bool is_valid_; // DISALLOW_COPY_AND_ASSIGN(GeneralizedCepstrumToSpectrum); }; } // namespace sptk #endif // SPTK_SRC_GENERALIZED_CEPSTRUM_TO_SPECTRUM_H_ Index: normal_distributed_random_value_generation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/normal_distributed_random_value_generation.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** normal_distributed_random_value_generation.h 24 Oct 2016 08:20:30 -0000 1.4 --- normal_distributed_random_value_generation.h 26 Dec 2016 07:41:20 -0000 1.5 *************** *** 67,71 **** // ! bool Get(double *output); private: --- 67,71 ---- // ! bool Get(double* output); private: Index: generalized_cepstrum_transform.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/generalized_cepstrum_transform.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** generalized_cepstrum_transform.h 16 Dec 2016 09:36:32 -0000 1.3 --- generalized_cepstrum_transform.h 26 Dec 2016 07:41:20 -0000 1.4 *************** *** 75,80 **** virtual bool IsValid() const = 0; virtual bool Run( ! const std::vector<double> &input, std::vector<double> *output, ! FrequencyTransform::Buffer *frequency_transform_buffer) const = 0; }; --- 75,80 ---- virtual bool IsValid() const = 0; virtual bool Run( ! const std::vector<double>& input, std::vector<double>* output, ! FrequencyTransform::Buffer* frequency_transform_buffer) const = 0; }; *************** *** 89,93 **** // virtual ~GeneralizedCepstrumTransform() { ! for (std::vector<GeneralizedCepstrumTransform::ModuleInterface *>::iterator itr(modules_.begin()); itr != modules_.end(); ++itr) { --- 89,93 ---- // virtual ~GeneralizedCepstrumTransform() { ! for (std::vector<GeneralizedCepstrumTransform::ModuleInterface*>::iterator itr(modules_.begin()); itr != modules_.end(); ++itr) { *************** *** 152,157 **** // ! bool Run(const std::vector<double> &input, std::vector<double> *output, ! GeneralizedCepstrumTransform::Buffer *buffer) const; private: --- 152,157 ---- // ! bool Run(const std::vector<double>& input, std::vector<double>* output, ! GeneralizedCepstrumTransform::Buffer* buffer) const; private: *************** *** 190,194 **** // ! std::vector<GeneralizedCepstrumTransform::ModuleInterface *> modules_; // --- 190,194 ---- // ! std::vector<GeneralizedCepstrumTransform::ModuleInterface*> modules_; // Index: input_source_from_vector.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_from_vector.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** input_source_from_vector.h 20 Dec 2016 08:23:42 -0000 1.2 --- input_source_from_vector.h 26 Dec 2016 07:41:20 -0000 1.3 *************** *** 46,50 **** #define SPTK_SRC_INPUT_SOURCE_FROM_VECTOR_H_ ! #include <vector> // std::vector #include "input_source_interface.h" --- 46,50 ---- #define SPTK_SRC_INPUT_SOURCE_FROM_VECTOR_H_ ! #include <vector> // std::vector #include "input_source_interface.h" Index: m_sequence_generation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/m_sequence_generation.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** m_sequence_generation.cc 24 Oct 2016 08:20:30 -0000 1.6 --- m_sequence_generation.cc 26 Dec 2016 07:41:20 -0000 1.7 *************** *** 63,67 **** } ! bool MSequenceGeneration::Get(double *output) { // check output if (NULL == output) { --- 63,67 ---- } ! bool MSequenceGeneration::Get(double* output) { // check output if (NULL == output) { Index: fast_fourier_transform_for_real_sequence.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fast_fourier_transform_for_real_sequence.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** fast_fourier_transform_for_real_sequence.h 22 Dec 2016 16:09:06 -0000 1.1 --- fast_fourier_transform_for_real_sequence.h 26 Dec 2016 07:41:20 -0000 1.2 *************** *** 83,87 **** // ! int GetFFTSize() const { return fft_size_; } --- 83,87 ---- // ! int GetFftSize() const { return fft_size_; } Index: levinson_durbin_recursion.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/levinson_durbin_recursion.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** levinson_durbin_recursion.cc 30 Nov 2016 04:23:28 -0000 1.7 --- levinson_durbin_recursion.cc 26 Dec 2016 07:41:20 -0000 1.8 *************** *** 53,57 **** const std::vector<double>& autocorrelation_sequence, std::vector<double>* linear_predictive_coefficients, ! LevinsonDurbinRecursion::Buffer* buffer, bool* is_stable) const { // check inputs if (autocorrelation_sequence.empty() || --- 53,57 ---- const std::vector<double>& autocorrelation_sequence, std::vector<double>* linear_predictive_coefficients, ! bool* is_stable, LevinsonDurbinRecursion::Buffer* buffer) const { // check inputs if (autocorrelation_sequence.empty() || Index: sptk_utils.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/sptk_utils.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** sptk_utils.h 12 Oct 2016 12:14:38 -0000 1.7 --- sptk_utils.h 26 Dec 2016 07:41:20 -0000 1.8 *************** *** 60,63 **** --- 60,65 ---- static const char* const kVersion("4.0"); + static const double kPi(3.141592653589793); + static const double kNp(8.685889638065035); // 1 Np = 20 / ln(10) dB bool ReadStream(double* data_to_read, std::istream* input_stream); *************** *** 71,75 **** bool ConvertStringToInteger(const std::string& input, int* output); bool ConvertStringToDouble(const std::string& input, double* output); ! bool IsInRange(int value, int min, int max); void PrintErrorMessage(const std::string& program_name, const std::ostringstream& message); --- 73,78 ---- bool ConvertStringToInteger(const std::string& input, int* output); bool ConvertStringToDouble(const std::string& input, double* output); ! bool IsInRange(int num, int min, int max); ! bool IsPowerOfTwo(int num); void PrintErrorMessage(const std::string& program_name, const std::ostringstream& message); --- NEW FILE: mgc2sp.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-2016 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 <unistd.h> #include <algorithm> #include <cmath> #include <fstream> #include <functional> #include <iostream> #include <sstream> #include <vector> #include "generalized_cepstrum_to_spectrum.h" #include "sptk_utils.h" namespace { enum OutputFormats { kLogAmplitudeSpectrumInDecibels = 0, kLogAmplitudeSpectrum, kAmplitudeSpectrum, kPowerSpectrum, kPhaseSpectrumInNormalizedRadians, kPhaseSpectrumInRadians, kPhaseSpectrumInDegrees, kNumOutputFormats }; const int kDefaultNumOrder(25); const double kDefaultAlpha(0.0); const double kDefaultGamma(0.0); const bool kDefaultNormalizationFlag(false); const bool kDefaultMultiplicationFlag(false); const int kDefaultFftSize(256); void PrintUsage(std::ostream* stream) { // clang-format off *stream << std::endl; *stream << " mgc2sp - transform mel-generalized cepstral to spectrum" << std::endl; // NOLINT *stream << std::endl; *stream << " usage:" << std::endl; *stream << " mgc2sp [ options ] [ infile ] > stdout" << std::endl; *stream << " options:" << std::endl; *stream << " -m m : order of mel-generalized cepstrum [" << kDefaultNumOrder << "]" << std::endl; // NOLINT *stream << " -a a : alpha of mel-generalized cepstrum [" << kDefaultAlpha << "]" << std::endl; // NOLINT *stream << " -g g : gamma of mel-generalized cepstrum [" << kDefaultGamma << "]" << std::endl; // NOLINT *stream << " -c c : gamma of mel-generalized cepstrum = -1 / (int) c" << std::endl; // NOLINT *stream << " -n : regard input as normalized [" << sptk::ConvertBooleanToString(kDefaultNormalizationFlag) << "]" << std::endl; // NOLINT *stream << " mel-generalized cepstrum" << std::endl; *stream << " -u : regard input as multiplied by gamma [" << sptk::ConvertBooleanToString(kDefaultMultiplicationFlag) << "]" << std::endl; // NOLINT *stream << " -l l : FFT size [" << kDefaultFftSize << "]" << std::endl; // NOLINT *stream << " -o o : output format [0]" << std::endl; // NOLINT *stream << " 0 (20*log|H(z)|)" << std::endl; *stream << " 1 (ln|H(z)|)" << std::endl; *stream << " 2 (|H(z)|)" << std::endl; *stream << " 3 (|H(z)|^2)" << std::endl; *stream << " 4 (arg|H(z)|/pi)" << std::endl; *stream << " 5 (arg|H(z)|)" << std::endl; *stream << " 6 (arg|H(z)|*180/pi)" << std::endl; *stream << " -h : print this message" << std::endl; *stream << " infile:" << std::endl; *stream << " mel-generalized cepstrum (double) [stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; *stream << " spectrum (double)" << std::endl; *stream << " notice:" << 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 *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; *stream << std::endl; // clang-format on } } // namespace int main(int argc, char* argv[]) { int num_order(kDefaultNumOrder); double alpha(kDefaultAlpha); double gamma(kDefaultGamma); bool normalization_flag(kDefaultNormalizationFlag); bool multiplication_flag(kDefaultMultiplicationFlag); int fft_size(kDefaultFftSize); OutputFormats output_format(kLogAmplitudeSpectrumInDecibels); for (;;) { const char option_char(getopt(argc, argv, "m:a:g:c:nul:o:h")); if (-1 == option_char) break; switch (option_char) { 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("mgc2sp", error_message); return 1; } break; } case 'a': { if (!sptk::ConvertStringToDouble(optarg, &alpha)) { std::ostringstream error_message; error_message << "The argument for the -a option must be numeric"; sptk::PrintErrorMessage("mgc2sp", error_message); return 1; } break; } case 'g': { if (!sptk::ConvertStringToDouble(optarg, &gamma)) { std::ostringstream error_message; error_message << "The argument for the -g option must be numeric"; sptk::PrintErrorMessage("mgc2sp", error_message); return 1; } break; } case 'c': { int tmp; if (!sptk::ConvertStringToInteger(optarg, &tmp) || tmp < 1) { std::ostringstream error_message; error_message << "The argument for the -c option must be a " << "positive integer"; sptk::PrintErrorMessage("mgc2sp", error_message); return 1; } gamma = -1.0 / tmp; break; } case 'n': { normalization_flag = true; break; } case 'u': { multiplication_flag = true; break; } 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("fft", error_message); return 1; } break; } case 'o': { int tmp; if (!sptk::ConvertStringToInteger(optarg, &tmp)) { std::ostringstream error_message; error_message << "The argument for the -o option must be an integer"; sptk::PrintErrorMessage("mgc2sp", error_message); return 1; } const int min(0); const int max(static_cast<int>(kNumOutputFormats) - 1); if (!sptk::IsInRange(tmp, min, max)) { std::ostringstream error_message; error_message << "The argument for the -o option must be in range" << " (" << min << " .. " << max << ")"; sptk::PrintErrorMessage("mgc2sp", error_message); return 1; } output_format = static_cast<OutputFormats>(tmp); break; } case 'h': { PrintUsage(&std::cout); return 0; } default: { PrintUsage(&std::cerr); 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("mgc2sp", error_message); return 1; } std::istream& input_stream(ifs.fail() ? std::cin : ifs); // prepare for gain normalization sptk::GeneralizedCepstrumToSpectrum generalized_cepstrum_to_spectrum( num_order, alpha, gamma, normalization_flag, multiplication_flag, fft_size); sptk::GeneralizedCepstrumToSpectrum::Buffer buffer; if (!generalized_cepstrum_to_spectrum.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the condition"; sptk::PrintErrorMessage("mgc2sp", error_message); return 1; } const int input_length(num_order + 1); const int output_length(fft_size / 2 + 1); std::vector<double> generalized_cepstrum(input_length); std::vector<double> amplitude_spectrum(fft_size); std::vector<double> phase_spectrum(fft_size); while (sptk::ReadStream(false, input_length, &generalized_cepstrum, &input_stream)) { // input modification if (!normalization_flag && multiplication_flag) { (*generalized_cepstrum.begin()) = (*(generalized_cepstrum.begin()) - 1.0) / gamma; } // transform if (!generalized_cepstrum_to_spectrum.Run(generalized_cepstrum, &litude_spectrum, &phase_spectrum, &buffer)) { std::ostringstream error_message; error_message << "Failed to transform"; sptk::PrintErrorMessage("mgc2sp", error_message); return 1; } switch (output_format) { case kLogAmplitudeSpectrumInDecibels: { std::transform(amplitude_spectrum.begin(), amplitude_spectrum.begin() + output_length, amplitude_spectrum.begin(), std::bind1st(std::multiplies<double>(), sptk::kNp)); break; } case kLogAmplitudeSpectrum: { // nothing to do break; } case kAmplitudeSpectrum: { std::transform(amplitude_spectrum.begin(), amplitude_spectrum.begin() + output_length, amplitude_spectrum.begin(), std::ptr_fun<double, double>(std::exp)); break; } case kPowerSpectrum: { std::transform(amplitude_spectrum.begin(), amplitude_spectrum.begin() + output_length, amplitude_spectrum.begin(), std::ptr_fun<double, double>( [](double x) { return std::exp(2.0 * x); })); break; } case kPhaseSpectrumInNormalizedRadians: { std::transform( phase_spectrum.begin(), phase_spectrum.begin() + output_length, phase_spectrum.begin(), std::bind1st(std::multiplies<double>(), 1.0 / sptk::kPi)); break; } case kPhaseSpectrumInRadians: { // nothing to do break; } case kPhaseSpectrumInDegrees: { std::transform( phase_spectrum.begin(), phase_spectrum.begin() + output_length, phase_spectrum.begin(), std::bind1st(std::multiplies<double>(), 180.0 / sptk::kPi)); break; } default: { break; } } switch (output_format) { case kLogAmplitudeSpectrumInDecibels: case kLogAmplitudeSpectrum: case kAmplitudeSpectrum: case kPowerSpectrum: { if (!sptk::WriteStream(output_length, amplitude_spectrum, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write amplitude spectrum"; sptk::PrintErrorMessage("mgc2sp", error_message); return 1; } break; } case kPhaseSpectrumInNormalizedRadians: case kPhaseSpectrumInRadians: case kPhaseSpectrumInDegrees: { if (!sptk::WriteStream(output_length, phase_spectrum, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write phase spectrum"; sptk::PrintErrorMessage("mgc2sp", error_message); return 1; } break; } default: { break; } } } return 0; } Index: fast_fourier_transform.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fast_fourier_transform.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** fast_fourier_transform.h 24 Oct 2016 08:20:30 -0000 1.7 --- fast_fourier_transform.h 26 Dec 2016 07:41:20 -0000 1.8 *************** *** 55,60 **** public: // ! FastFourierTransform() : num_dimension_(0), inverse_(false) { ! } // --- 55,59 ---- public: // ! FastFourierTransform(int num_order, int fft_size, bool inverse); // *************** *** 62,76 **** } - // Set the number of dimensions and prepare the sine table. - bool SetNumDimension(int num_dimension); - // ! void SetInverseFlag(bool inverse) { ! inverse_ = inverse; } // ! int GetNumDimension() const { ! return num_dimension_; } --- 61,72 ---- } // ! int GetNumOrder() const { ! return num_order_; } // ! int GetFftSize() const { ! return fft_size_; } *************** *** 81,84 **** --- 77,85 ---- // + bool IsValid() const { + return is_valid_; + } + + // bool Run(const std::vector<double>& real_part_input, const std::vector<double>& imaginary_part_input, *************** *** 88,95 **** private: // ! int num_dimension_; // ! bool inverse_; // --- 89,105 ---- private: // ! const int num_order_; // ! const int fft_size_; ! ! // ! const int half_fft_size_; ! ! // ! const bool inverse_; ! ! // ! bool is_valid_; // Index: excitation_generation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/excitation_generation.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** excitation_generation.h 24 Oct 2016 08:20:30 -0000 1.5 --- excitation_generation.h 26 Dec 2016 07:41:20 -0000 1.6 *************** *** 55,60 **** public: // ! ExcitationGeneration(InputSourceInterpolationWithMagicNumber *input_source, ! RandomGenerationInterface *random_generation); // --- 55,60 ---- public: // ! ExcitationGeneration(InputSourceInterpolationWithMagicNumber* input_source, ! RandomGenerationInterface* random_generation); // *************** *** 68,79 **** // ! bool Get(double *excitation, double *pulse, double *noise, double *pitch); private: // ! InputSourceInterpolationWithMagicNumber *input_source_; // ! RandomGenerationInterface *random_generation_; // --- 68,79 ---- // ! bool Get(double* excitation, double* pulse, double* noise, double* pitch); private: // ! InputSourceInterpolationWithMagicNumber* input_source_; // ! RandomGenerationInterface* random_generation_; // Index: fast_fourier_transform.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fast_fourier_transform.cc,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** fast_fourier_transform.cc 30 Nov 2016 04:23:28 -0000 1.10 --- fast_fourier_transform.cc 26 Dec 2016 07:41:20 -0000 1.11 *************** *** 51,73 **** namespace sptk { ! bool FastFourierTransform::SetNumDimension(const int num_dimension) { ! if (num_dimension < 4 || num_dimension & (num_dimension - 1)) { ! return false; } ! const int table_size(num_dimension - num_dimension / 4 + 1); ! const double argument(M_PI / num_dimension * 2); ! ! if (sine_table_.size() != static_cast<std::size_t>(table_size)) { ! sine_table_.resize(table_size); ! for (int i(0); i < table_size; ++i) { ! sine_table_[i] = std::sin(argument * i); ! } ! sine_table_[num_dimension / 2] = 0.0; } ! ! num_dimension_ = num_dimension; ! ! return true; } --- 51,74 ---- namespace sptk { ! FastFourierTransform::FastFourierTransform(int num_order, int fft_size, ! bool inverse) ! : num_order_(num_order), ! fft_size_(fft_size), ! half_fft_size_(fft_size / 2), ! inverse_(inverse), ! is_valid_(true) { ! if (fft_size < 4 || !IsPowerOfTwo(fft_size) || fft_size <= num_order || ! num_order < 0) { ! is_valid_ = false; ! return; } ! const int table_size(fft_size - fft_size / 4 + 1); ! const double argument(sptk::kPi / fft_size * 2); ! sine_table_.resize(table_size); ! for (int i(0); i < table_size; ++i) { ! sine_table_[i] = std::sin(argument * i); } ! sine_table_[fft_size / 2] = 0.0; } *************** *** 77,97 **** std::vector<double>* real_part_output, std::vector<double>* imaginary_part_output) const { ! // check sine table and input ! if (sine_table_.empty() || NULL == real_part_output || ! NULL == imaginary_part_output) { return false; } // prepare memories ! if (real_part_output->size() != static_cast<std::size_t>(num_dimension_)) { ! real_part_output->resize(num_dimension_); ! } ! if (imaginary_part_output->size() != ! static_cast<std::size_t>(num_dimension_)) { ! imaginary_part_output->resize(num_dimension_); } ! if (real_part_output->size() < real_part_input.size() || ! imaginary_part_output->size() < imaginary_part_input.size()) { ! return false; } --- 78,95 ---- std::vector<double>* real_part_output, std::vector<double>* imaginary_part_output) const { ! // check inputs ! if (!is_valid_ || ! real_part_input.size() != static_cast<std::size_t>(num_order_ + 1) || ! imaginary_part_input.size() != static_cast<std::size_t>(num_order_ + 1) || ! NULL == real_part_output || NULL == imaginary_part_output) { return false; } // prepare memories ! if (real_part_output->size() < static_cast<std::size_t>(fft_size_)) { ! real_part_output->resize(fft_size_); } ! if (imaginary_part_output->size() < static_cast<std::size_t>(fft_size_)) { ! imaginary_part_output->resize(fft_size_); } *************** *** 106,135 **** imaginary_part_output->end(), 0.0); ! double* x; ! double* y; ! if (inverse_) { ! x = &((*imaginary_part_output)[0]); ! y = &((*real_part_output)[0]); ! } else { ! x = &((*real_part_output)[0]); ! y = &((*imaginary_part_output)[0]); ! } ! ! // set values ! const int half_num_dimension(num_dimension_ / 2); ! const int dec_num_dimension(num_dimension_ - 1); ! const double inverse_num_dimension(1.0 / num_dimension_); ! int lix(num_dimension_); ! int lmx(half_num_dimension); int lf(1); - while (1 < lmx) { double* sinp(const_cast<double*>(&(sine_table_[0]))); ! double* cosp(const_cast<double*>(&(sine_table_[0])) + num_dimension_ / 4); for (int i(0); i < lmx; ++i) { double* xpi(&(x[i])); double* ypi(&(y[i])); ! for (int li(lix); li <= num_dimension_; li += lix) { const double t1(*(xpi) - *(xpi + lmx)); const double t2(*(ypi) - *(ypi + lmx)); --- 104,122 ---- imaginary_part_output->end(), 0.0); ! double* x(inverse_ ? &((*imaginary_part_output)[0]) ! : &((*real_part_output)[0])); ! double* y(inverse_ ? &((*real_part_output)[0]) ! : &((*imaginary_part_output)[0])); ! int lix(fft_size_); ! int lmx(half_fft_size_); int lf(1); while (1 < lmx) { double* sinp(const_cast<double*>(&(sine_table_[0]))); ! double* cosp(const_cast<double*>(&(sine_table_[0])) + fft_size_ / 4); for (int i(0); i < lmx; ++i) { double* xpi(&(x[i])); double* ypi(&(y[i])); ! for (int li(lix); li <= fft_size_; li += lix) { const double t1(*(xpi) - *(xpi + lmx)); const double t2(*(ypi) - *(ypi + lmx)); *************** *** 151,156 **** double* xp(x); double* yp(y); ! ! for (int li(half_num_dimension); li--; xp += 2, yp += 2) { const double t1(*(xp) - *(xp + 1)); const double t2(*(yp) - *(yp + 1)); --- 138,142 ---- double* xp(x); double* yp(y); ! for (int li(half_fft_size_); li--; xp += 2, yp += 2) { const double t1(*(xp) - *(xp + 1)); const double t2(*(yp) - *(yp + 1)); *************** *** 161,169 **** } xp = x; yp = y; ! ! // bit reversal ! for (int lmx(0), j(0); lmx < dec_num_dimension; ++lmx) { const int lmxj(lmx - j); if (lmxj < 0) { --- 147,155 ---- } + // bit reversal xp = x; yp = y; ! const int dec_fft_size(fft_size_ - 1); ! for (int lmx(0), j(0); lmx < dec_fft_size; ++lmx) { const int lmxj(lmx - j); if (lmxj < 0) { *************** *** 176,180 **** } ! int li(half_num_dimension); while (li <= j) { j -= li; --- 162,166 ---- } ! int li(half_fft_size_); while (li <= j) { j -= li; *************** *** 190,196 **** xp = x; yp = y; ! for (int i(0); i < num_dimension_; ++i) { ! *(xp + i) *= inverse_num_dimension; ! *(yp + i) *= inverse_num_dimension; } } --- 176,183 ---- xp = x; yp = y; ! const double inverse_fft_size(1.0 / fft_size_); ! for (int i(0); i < fft_size_; ++i) { ! *xp++ *= inverse_fft_size; ! *yp++ *= inverse_fft_size; } } Index: m_sequence_generation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/m_sequence_generation.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** m_sequence_generation.h 24 Oct 2016 08:20:30 -0000 1.5 --- m_sequence_generation.h 26 Dec 2016 07:41:20 -0000 1.6 *************** *** 64,68 **** // ! virtual bool Get(double *output); private: --- 64,68 ---- // ! virtual bool Get(double* output); private: Index: generalized_cepstrum_transform.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/generalized_cepstrum_transform.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** generalized_cepstrum_transform.cc 16 Dec 2016 09:36:31 -0000 1.4 --- generalized_cepstrum_transform.cc 26 Dec 2016 07:41:20 -0000 1.5 *************** *** 65,70 **** } virtual bool Run( ! const std::vector<double> &input, std::vector<double> *output, ! sptk::FrequencyTransform::Buffer *frequency_transform_buffer) const { if (!generalized_cepstrum_gain_normalization_.Run(input, output)) { return false; --- 65,70 ---- } virtual bool Run( ! const std::vector<double>& input, std::vector<double>* output, ! sptk::FrequencyTransform::Buffer* frequency_transform_buffer) const { if (!generalized_cepstrum_gain_normalization_.Run(input, output)) { return false; *************** *** 90,95 **** } virtual bool Run( ! const std::vector<double> &input, std::vector<double> *output, ! sptk::FrequencyTransform::Buffer *frequency_transform_buffer) const { if (!generalized_cepstrum_inverse_gain_normalization_.Run(input, output)) { return false; --- 90,95 ---- } virtual bool Run( ! const std::vector<double>& input, std::vector<double>* output, ! sptk::FrequencyTransform::Buffer* frequency_transform_buffer) const { if (!generalized_cepstrum_inverse_gain_normalization_.Run(input, output)) { return false; *************** *** 118,123 **** } virtual bool Run( ! const std::vector<double> &input, std::vector<double> *output, ! sptk::FrequencyTransform::Buffer *frequency_transform_buffer) const { if (!frequency_transform_.Run(input, output, frequency_transform_buffer)) { return false; --- 118,123 ---- } virtual bool Run( ! const std::vector<double>& input, std::vector<double>* output, ! sptk::FrequencyTransform::Buffer* frequency_transform_buffer) const { if (!frequency_transform_.Run(input, output, frequency_transform_buffer)) { return false; *************** *** 146,156 **** } virtual bool Run( ! const std::vector<double> &input, std::vector<double> *output, ! sptk::FrequencyTransform::Buffer *frequency_transform_buffer) const { if (output->size() != static_cast<std::size_t>(num_output_order_ + 1)) { output->resize(num_output_order_ + 1); } ! const double *c1(&(input)[0]); ! double *c2(&((*output)[0])); c2[0] = c1[0]; --- 146,156 ---- } virtual bool Run( ! const std::vector<double>& input, std::vector<double>* output, ! sptk::FrequencyTransform::Buffer* frequency_transform_buffer) const { if (output->size() != static_cast<std::size_t>(num_output_order_ + 1)) { output->resize(num_output_order_ + 1); } ! const double* c1(&(input)[0]); ! double* c2(&((*output)[0])); c2[0] = c1[0]; *************** *** 191,196 **** } virtual bool Run( ! const std::vector<double> &input, std::vector<double> *output, ! sptk::FrequencyTransform::Buffer *frequency_transform_buffer) const { if (output->size() != static_cast<std::size_t>(num_order_ + 1)) { output->resize(num_order_ + 1); --- 191,196 ---- } virtual bool Run( ! const std::vector<double>& input, std::vector<double>* output, ! sptk::FrequencyTransform::Buffer* frequency_transform_buffer) const { if (output->size() != static_cast<std::size_t>(num_order_ + 1)) { output->resize(num_order_ + 1); *************** *** 220,225 **** } virtual bool Run( ! const std::vector<double> &input, std::vector<double> *output, ! sptk::FrequencyTransform::Buffer *frequency_transform_buffer) const { if (output->size() != static_cast<std::size_t>(num_order_ + 1)) { output->resize(num_order_ + 1); --- 220,225 ---- } virtual bool Run( ! const std::vector<double>& input, std::vector<double>* output, ! sptk::FrequencyTransform::Buffer* frequency_transform_buffer) const { if (output->size() != static_cast<std::size_t>(num_order_ + 1)) { output->resize(num_order_ + 1); *************** *** 404,408 **** } ! for (std::vector<GeneralizedCepstrumTransform::ModuleInterface *>::iterator itr(modules_.begin()); itr != modules_.end(); ++itr) { --- 404,408 ---- } ! for (std::vector<GeneralizedCepstrumTransform::ModuleInterface*>::iterator itr(modules_.begin()); itr != modules_.end(); ++itr) { *************** *** 415,420 **** bool GeneralizedCepstrumTransform::Run( ! const std::vector<double> &input, std::vector<double> *output, ! GeneralizedCepstrumTransform::Buffer *buffer) const { if (!is_valid_ || static_cast<std::size_t>(num_input_order_ + 1) != input.size() || --- 415,420 ---- bool GeneralizedCepstrumTransform::Run( ! const std::vector<double>& input, std::vector<double>* output, ! GeneralizedCepstrumTransform::Buffer* buffer) const { if (!is_valid_ || static_cast<std::size_t>(num_input_order_ + 1) != input.size() || *************** *** 431,436 **** } ! for (std::vector<GeneralizedCepstrumTransform::ModuleInterface ! *>::const_iterator itr(modules_.begin()); itr != modules_.end(); ++itr) { if (itr != modules_.begin()) { --- 431,436 ---- } ! for (std::vector<GeneralizedCepstrumTransform::ModuleInterface*>:: ! const_iterator itr(modules_.begin()); itr != modules_.end(); ++itr) { if (itr != modules_.begin()) { Index: normal_distributed_random_value_generation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/normal_distributed_random_value_generation.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** normal_distributed_random_value_generation.cc 12 Oct 2016 12:14:38 -0000 1.4 --- normal_distributed_random_value_generation.cc 26 Dec 2016 07:41:20 -0000 1.5 *************** *** 50,54 **** // pseudorandom generation ! double PseudoRandomGeneration(std::uint64_t *next) { if (NULL == next) { return 0.0; --- 50,54 ---- // pseudorandom generation ! double PseudoRandomGeneration(std::uint64_t* next) { if (NULL == next) { return 0.0; *************** *** 76,80 **** } ! bool NormalDistributedRandomValueGeneration::Get(double *output) { // check output if (NULL == output) { --- 76,80 ---- } ! bool NormalDistributedRandomValueGeneration::Get(double* output) { // check output if (NULL == output) { Index: random_generation_interface.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/random_generation_interface.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** random_generation_interface.h 24 Oct 2016 08:20:30 -0000 1.2 --- random_generation_interface.h 26 Dec 2016 07:41:20 -0000 1.3 *************** *** 60,64 **** // ! virtual bool Get(double *output) = 0; }; --- 60,64 ---- // ! virtual bool Get(double* output) = 0; }; Index: excitation_generation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/excitation_generation.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** excitation_generation.cc 12 Oct 2016 12:14:38 -0000 1.4 --- excitation_generation.cc 26 Dec 2016 07:41:20 -0000 1.5 *************** *** 51,56 **** ExcitationGeneration::ExcitationGeneration( ! InputSourceInterpolationWithMagicNumber *input_source, ! RandomGenerationInterface *random_generation) : input_source_(input_source), random_generation_(random_generation), --- 51,56 ---- ExcitationGeneration::ExcitationGeneration( ! InputSourceInterpolationWithMagicNumber* input_source, ! RandomGenerationInterface* random_generation) : input_source_(input_source), random_generation_(random_generation), *************** *** 63,68 **** } ! bool ExcitationGeneration::Get(double *excitation, double *pulse, double *noise, ! double *pitch) { if (!is_valid_) { return false; --- 63,68 ---- } ! bool ExcitationGeneration::Get(double* excitation, double* pulse, double* noise, ! double* pitch) { if (!is_valid_) { return false; Index: .clang-format =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/.clang-format,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** .clang-format 24 Oct 2016 08:20:30 -0000 1.2 --- .clang-format 26 Dec 2016 07:41:20 -0000 1.3 *************** *** 2,3 **** --- 2,5 ---- AllowShortBlocksOnASingleLine: false AllowShortFunctionsOnASingleLine: false + DerivePointerAlignment: false + PointerAlignment: Left --- NEW FILE: generalized_cepstrum_to_spectrum.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-2016 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 "generalized_cepstrum_to_spectrum.h" namespace sptk { GeneralizedCepstrumToSpectrum::GeneralizedCepstrumToSpectrum( int num_order, double alpha, double gamma, bool is_normalized, bool is_multiplied, int fft_size) : generalized_cepstrum_transform_(num_order, alpha, gamma, is_normalized, is_multiplied, fft_size / 2, 0.0, 0.0, false, false), fast_fourier_transform_(fft_size / 2, fft_size, false), is_valid_(true) { if (!generalized_cepstrum_transform_.IsValid() || !fast_fourier_transform_.IsValid()) { is_valid_ = false; } } bool GeneralizedCepstrumToSpectrum::Run( const std::vector<double>& generalized_cepstrum, std::vector<double>* amplitude_spectrum, std::vector<double>* phase_spectrum, GeneralizedCepstrumToSpectrum::Buffer* buffer) const { if (!is_valid_ || generalized_cepstrum.size() != static_cast<std::size_t>(GetNumOrder() + 1) || NULL == amplitude_spectrum || NULL == phase_spectrum || NULL == buffer) { return false; } if (!generalized_cepstrum_transform_.Run( generalized_cepstrum, &buffer->cepstrum_, &buffer->generalized_cepstrum_transform_buffer_) || !fast_fourier_transform_.Run(buffer->cepstrum_, amplitude_spectrum, phase_spectrum, &buffer->fast_fourier_transform_buffer_)) { return false; } return true; } } // namespace sptk Index: fast_fourier_transform_for_real_sequence.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fast_fourier_transform_for_real_sequence.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** fast_fourier_transform_for_real_sequence.cc 22 Dec 2016 16:09:06 -0000 1.1 -... [truncated message content] |