From: Takenori Y. <tak...@us...> - 2017-05-24 07:31:48
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv16589 Modified Files: Makefile Added Files: cepstrum_to_negative_derivative_of_phase_spectrum.cc cepstrum_to_negative_derivative_of_phase_spectrum.h Log Message: add a class for c2ndps command --- NEW FILE: cepstrum_to_negative_derivative_of_phase_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-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. // // ----------------------------------------------------------------- // #ifndef SPTK_SRC_CEPSTRUM_TO_NEGATIVE_DERIVATIVE_OF_PHASE_SPECTRUM_H_ #define SPTK_SRC_CEPSTRUM_TO_NEGATIVE_DERIVATIVE_OF_PHASE_SPECTRUM_H_ #include <vector> // std::vector #include "fast_fourier_transform_for_real_sequence.h" #include "sptk_utils.h" namespace sptk { class CepstrumToNegativeDerivativeOfPhaseSpectrum { public: class Buffer { public: Buffer() { } virtual ~Buffer() { } private: FastFourierTransformForRealSequence::Buffer fast_fourier_transform_buffer_; std::vector<double> fast_fourier_transform_input_; std::vector<double> fast_fourier_transform_imaginary_part_output_; friend class CepstrumToNegativeDerivativeOfPhaseSpectrum; DISALLOW_COPY_AND_ASSIGN(Buffer); }; // CepstrumToNegativeDerivativeOfPhaseSpectrum(int num_order, int fft_size); // virtual ~CepstrumToNegativeDerivativeOfPhaseSpectrum() { } // int GetNumOrder() const { return num_order_; } // int GetFftSize() const { return fast_fourier_transform_.GetFftSize(); } // bool IsValid() const { return is_valid_; } // bool Run(const std::vector<double>& cepstrum, std::vector<double>* negative_derivative_of_phase_spectrum, CepstrumToNegativeDerivativeOfPhaseSpectrum::Buffer* buffer) const; private: // const int num_order_; // const FastFourierTransformForRealSequence fast_fourier_transform_; // bool is_valid_; // DISALLOW_COPY_AND_ASSIGN(CepstrumToNegativeDerivativeOfPhaseSpectrum); }; } // namespace sptk #endif // SPTK_SRC_CEPSTRUM_TO_NEGATIVE_DERIVATIVE_OF_PHASE_SPECTRUM_H_ Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Makefile 22 May 2017 03:44:10 -0000 1.32 --- Makefile 24 May 2017 07:31:46 -0000 1.33 *************** *** 50,53 **** --- 50,54 ---- autocorrelation.cc \ cepstrum_to_minimum_phase_impulse_response.cc \ + cepstrum_to_negative_derivative_of_phase_spectrum.cc \ data_windowing.cc \ excitation_generation.cc \ --- NEW FILE: cepstrum_to_negative_derivative_of_phase_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-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 "cepstrum_to_negative_derivative_of_phase_spectrum.h" #include <algorithm> // std::fill #include <cstddef> // std::size_t namespace sptk { CepstrumToNegativeDerivativeOfPhaseSpectrum:: CepstrumToNegativeDerivativeOfPhaseSpectrum(int num_order, int fft_size) : num_order_(num_order), fast_fourier_transform_(fft_size - 1, fft_size), is_valid_(true) { if (num_order < 0 || fft_size < 2 * num_order || !fast_fourier_transform_.IsValid()) { is_valid_ = false; } } bool CepstrumToNegativeDerivativeOfPhaseSpectrum::Run( const std::vector<double>& cepstrum, std::vector<double>* negative_derivative_of_phase_spectrum, CepstrumToNegativeDerivativeOfPhaseSpectrum::Buffer* buffer) const { // check inputs if (!is_valid_ || cepstrum.size() != static_cast<std::size_t>(num_order_ + 1) || NULL == negative_derivative_of_phase_spectrum || NULL == buffer) { return false; } // prepare memories const int fft_size(fast_fourier_transform_.GetFftSize()); if (buffer->fast_fourier_transform_input_.size() < static_cast<std::size_t>(fft_size)) { buffer->fast_fourier_transform_input_.resize(fft_size); } const double* input(&(cepstrum[0])); double* fast_fourier_transform_input( &buffer->fast_fourier_transform_input_[0]); fast_fourier_transform_input[0] = 0.0; for (int i(1); i <= num_order_; ++i) { fast_fourier_transform_input[i] = 0.5 * input[i] * i; } if (fft_size == 2 * num_order_) { fast_fourier_transform_input[num_order_] *= 2.0; } else { std::fill(buffer->fast_fourier_transform_input_.begin() + num_order_ + 1, buffer->fast_fourier_transform_input_.end() - num_order_, 0.0); } for (int i(1); i <= num_order_; ++i) { fast_fourier_transform_input[fft_size - i] = fast_fourier_transform_input[i]; } if (!fast_fourier_transform_.Run( buffer->fast_fourier_transform_input_, negative_derivative_of_phase_spectrum, &buffer->fast_fourier_transform_imaginary_part_output_, &buffer->fast_fourier_transform_buffer_)) { return false; } return true; } } // namespace sptk |