Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv23028 Modified Files: c2mpir.cc cepstrum_to_minimum_phase_impulse_response.cc cepstrum_to_minimum_phase_impulse_response.h excitation_generation.cc excitation_generation.h excite.cc input_source_interpolation_with_magic_number.cc input_source_interpolation_with_magic_number.h m_sequence_generation.cc m_sequence_generation.h mseq.cc normal_distributed_random_value_generation.cc normal_distributed_random_value_generation.h nrand.cc Log Message: format source codes and fix minor bugs Index: excitation_generation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/excitation_generation.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** excitation_generation.h 11 Oct 2016 05:31:10 -0000 1.1 --- excitation_generation.h 12 Oct 2016 04:31:24 -0000 1.2 *************** *** 55,59 **** public: // ! ExcitationGeneration(InputSourceInterpolationWithMagicNumber *input_source, RandomGenerationInterface *random_generation); --- 55,60 ---- public: // ! ExcitationGeneration( ! InputSourceInterpolationWithMagicNumber *input_source, RandomGenerationInterface *random_generation); Index: cepstrum_to_minimum_phase_impulse_response.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/cepstrum_to_minimum_phase_impulse_response.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cepstrum_to_minimum_phase_impulse_response.h 7 Oct 2016 01:03:25 -0000 1.3 --- cepstrum_to_minimum_phase_impulse_response.h 12 Oct 2016 04:31:24 -0000 1.4 *************** *** 56,64 **** // CepstrumToMinimumPhaseImpulseResponse(int num_input_order, ! int num_output_order) : ! num_input_order_(num_input_order), num_output_order_(num_output_order), ! is_valid_(true) { ! if (num_input_order_ < 0 || num_output_order_ < 0) is_valid_ = false; } --- 56,65 ---- // CepstrumToMinimumPhaseImpulseResponse(int num_input_order, ! int num_output_order) ! : num_input_order_(num_input_order), num_output_order_(num_output_order), ! is_valid_(true) { ! if (num_input_order_ < 0 || num_output_order_ < 0) { is_valid_ = false; + } } Index: m_sequence_generation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/m_sequence_generation.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** m_sequence_generation.h 7 Oct 2016 06:50:32 -0000 1.3 --- m_sequence_generation.h 12 Oct 2016 04:31:24 -0000 1.4 *************** *** 60,67 **** // ! void Reset(); // ! bool Get(double *output); private: --- 60,67 ---- // ! virtual void Reset(); // ! virtual bool Get(double *output); private: Index: input_source_interpolation_with_magic_number.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_interpolation_with_magic_number.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** input_source_interpolation_with_magic_number.cc 11 Oct 2016 05:31:10 -0000 1.1 --- input_source_interpolation_with_magic_number.cc 12 Oct 2016 04:31:24 -0000 1.2 *************** *** 45,55 **** #include "input_source_interpolation_with_magic_number.h" ! #include <algorithm> // std::copy ! #include <cstring> // std::size_t ! #include <limits> // std::numeric_limits namespace { static const double kCannotCalculateIncrements( std::numeric_limits<double>::max()); } // namespace --- 45,57 ---- #include "input_source_interpolation_with_magic_number.h" ! #include <algorithm> // std::copy ! #include <cstring> // std::size_t ! #include <limits> // std::numeric_limits namespace { + static const double kCannotCalculateIncrements( std::numeric_limits<double>::max()); + } // namespace *************** *** 166,171 **** interpolation_period_)) { // Interpolate adjacent data without magic number. ! int size = static_cast<int>(curr_data_.size()); ! for (int i(0); i < size; ++i) { if (kCannotCalculateIncrements == increment_[i]) { curr_data_[i] = magic_number_; --- 168,172 ---- interpolation_period_)) { // Interpolate adjacent data without magic number. ! for (int i(0); i < data_length_; ++i) { if (kCannotCalculateIncrements == increment_[i]) { curr_data_[i] = magic_number_; Index: cepstrum_to_minimum_phase_impulse_response.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/cepstrum_to_minimum_phase_impulse_response.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cepstrum_to_minimum_phase_impulse_response.cc 7 Oct 2016 01:03:25 -0000 1.3 --- cepstrum_to_minimum_phase_impulse_response.cc 12 Oct 2016 04:31:24 -0000 1.4 *************** *** 45,61 **** #include "cepstrum_to_minimum_phase_impulse_response.h" ! #include <cmath> // std::exp ! #include <cstring> // std::size_t namespace sptk { bool CepstrumToMinimumPhaseImpulseResponse::Run( ! const std::vector<double>& cepstrum_coefficient, ! std::vector<double>* minimum_phase_impulse_response) const { // check inputs if (cepstrum_coefficient.size() != static_cast<std::size_t>(num_input_order_ + 1) || NULL == minimum_phase_impulse_response || ! is_valid_ == false) { return false; } --- 45,61 ---- #include "cepstrum_to_minimum_phase_impulse_response.h" ! #include <cmath> // std::exp ! #include <cstring> // std::size_t namespace sptk { bool CepstrumToMinimumPhaseImpulseResponse::Run( ! const std::vector<double>& cepstrum_coefficient, ! std::vector<double>* minimum_phase_impulse_response) const { // check inputs if (cepstrum_coefficient.size() != static_cast<std::size_t>(num_input_order_ + 1) || NULL == minimum_phase_impulse_response || ! !is_valid_) { return false; } *************** *** 63,72 **** // prepare memory if (minimum_phase_impulse_response->size() < ! static_cast<std::size_t>(num_output_order_ + 1)) { minimum_phase_impulse_response->resize(num_output_order_ + 1); } ! const double *c = &cepstrum_coefficient[0]; ! double *h = &((*minimum_phase_impulse_response)[0]); int upl; double d; --- 63,72 ---- // prepare memory if (minimum_phase_impulse_response->size() < ! static_cast<std::size_t>(num_output_order_ + 1)) { minimum_phase_impulse_response->resize(num_output_order_ + 1); } ! const double* c(&cepstrum_coefficient[0]); ! double* h(&((*minimum_phase_impulse_response)[0])); int upl; double d; *************** *** 76,81 **** d = 0; upl = (n > num_input_order_) ? num_input_order_ : n; ! for (int k(1); k <= upl; ++k) d += k * c[k] * h[n - k]; h[n] = d / n; } --- 76,82 ---- d = 0; upl = (n > num_input_order_) ? num_input_order_ : n; ! for (int k(1); k <= upl; ++k) { d += k * c[k] * h[n - k]; + } h[n] = d / n; } Index: mseq.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/mseq.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** mseq.cc 7 Oct 2016 06:50:32 -0000 1.3 --- mseq.cc 12 Oct 2016 04:31:24 -0000 1.4 *************** *** 43,46 **** --- 43,50 ---- // ----------------------------------------------------------------- // + #include <unistd.h> + #include <iostream> + #include <sstream> + #include "m_sequence_generation.h" #include "sptk_utils.h" *************** *** 62,66 **** *stream << " M-Sequence (double)" << std::endl; *stream << " notice:" << std::endl; ! *stream << " if l<0, generate infinite sequence" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; --- 66,70 ---- *stream << " M-Sequence (double)" << std::endl; *stream << " notice:" << std::endl; ! *stream << " if l < 0, generate infinite sequence" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; Index: excitation_generation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/excitation_generation.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** excitation_generation.cc 11 Oct 2016 05:31:10 -0000 1.1 --- excitation_generation.cc 12 Oct 2016 04:31:24 -0000 1.2 *************** *** 45,49 **** #include "excitation_generation.h" ! #include <cmath> // std::sqrt #include <vector> // std::vector --- 45,49 ---- #include "excitation_generation.h" ! #include <cmath> // std::sqrt #include <vector> // std::vector *************** *** 52,59 **** ExcitationGeneration::ExcitationGeneration( InputSourceInterpolationWithMagicNumber *input_source, ! RandomGenerationInterface *random_generation) : ! input_source_(input_source), random_generation_(random_generation), ! is_valid_(true), phase_(1.0) { ! if (NULL == input_source || NULL == random_generation || !input_source->IsValid()) { is_valid_ = false; --- 52,60 ---- ExcitationGeneration::ExcitationGeneration( InputSourceInterpolationWithMagicNumber *input_source, ! RandomGenerationInterface *random_generation) ! : input_source_(input_source), random_generation_(random_generation), ! is_valid_(true), phase_(1.0) { ! if (NULL == input_source || ! NULL == random_generation || !input_source->IsValid()) { is_valid_ = false; Index: m_sequence_generation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/m_sequence_generation.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** m_sequence_generation.cc 7 Oct 2016 06:50:32 -0000 1.3 --- m_sequence_generation.cc 12 Oct 2016 04:31:24 -0000 1.4 *************** *** 56,61 **** namespace sptk { ! MSequenceGeneration::MSequenceGeneration() : x_(kInitialValue) { ! } void MSequenceGeneration::Reset() { --- 56,60 ---- namespace sptk { ! MSequenceGeneration::MSequenceGeneration() : x_(kInitialValue) {} void MSequenceGeneration::Reset() { *************** *** 74,91 **** x_ >>= 1; ! if (x_ & kB0) x0 = 1; ! else x0 = -1; ! if (x_ & kB28) x28 = 1; ! else x28 = -1; ! if (x0 + x28) x_ &= kB31F; ! else x_ |= kB31; *output = static_cast<double>(x0); --- 73,93 ---- x_ >>= 1; ! if (x_ & kB0) { x0 = 1; ! } else { x0 = -1; + } ! if (x_ & kB28) { x28 = 1; ! } else { x28 = -1; + } ! if (x0 + x28) { x_ &= kB31F; ! } else { x_ |= kB31; + } *output = static_cast<double>(x0); Index: nrand.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/nrand.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** nrand.cc 7 Oct 2016 06:50:32 -0000 1.2 --- nrand.cc 12 Oct 2016 04:31:24 -0000 1.3 *************** *** 43,51 **** // ----------------------------------------------------------------- // #include "normal_distributed_random_value_generation.h" #include "sptk_utils.h" - #include <cmath> // std::sqrt - namespace { --- 43,54 ---- // ----------------------------------------------------------------- // + #include <unistd.h> + #include <cmath> // std::sqrt + #include <iostream> + #include <sstream> + #include "normal_distributed_random_value_generation.h" #include "sptk_utils.h" namespace { *************** *** 71,75 **** *stream << " random values (double)" << std::endl; *stream << " notice:" << std::endl; ! *stream << " if l<0, generate infinite sequence" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; --- 74,78 ---- *stream << " random values (double)" << std::endl; *stream << " notice:" << std::endl; ! *stream << " if l < 0, generate infinite sequence" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; Index: c2mpir.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/c2mpir.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** c2mpir.cc 7 Oct 2016 01:03:25 -0000 1.2 --- c2mpir.cc 12 Oct 2016 04:31:24 -0000 1.3 *************** *** 119,123 **** return 1; } ! num_output_order++; break; } --- 119,123 ---- return 1; } ! --num_output_order; break; } *************** *** 150,154 **** sptk::CepstrumToMinimumPhaseImpulseResponse cepstrum_to_minimum_phase_impulse_response(num_input_order, ! num_output_order); if (!cepstrum_to_minimum_phase_impulse_response.IsValid()) { std::ostringstream error_message; --- 150,154 ---- sptk::CepstrumToMinimumPhaseImpulseResponse cepstrum_to_minimum_phase_impulse_response(num_input_order, ! num_output_order); if (!cepstrum_to_minimum_phase_impulse_response.IsValid()) { std::ostringstream error_message; *************** *** 164,171 **** while (sptk::ReadStream(false, input_length, &cepstrum, &input_stream)) { ! if (!cepstrum_to_minimum_phase_impulse_response.Run(cepstrum, ! &minimum_phase_impulse_response)) { std::ostringstream error_message; ! error_message << "Failed to convert cepstrum to minimum phase impulse response"; // NOLINT sptk::PrintErrorMessage("c2mpir", error_message); return 1; --- 164,172 ---- while (sptk::ReadStream(false, input_length, &cepstrum, &input_stream)) { ! if (!cepstrum_to_minimum_phase_impulse_response.Run( ! cepstrum, &minimum_phase_impulse_response)) { std::ostringstream error_message; ! error_message ! << "Failed to convert cepstrum to minimum phase impulse response"; sptk::PrintErrorMessage("c2mpir", error_message); return 1; *************** *** 173,177 **** if (!sptk::WriteStream(output_length, minimum_phase_impulse_response, ! &std::cout)) { std::ostringstream error_message; error_message << "Failed to write an output sequence"; --- 174,178 ---- if (!sptk::WriteStream(output_length, minimum_phase_impulse_response, ! &std::cout)) { std::ostringstream error_message; error_message << "Failed to write an output sequence"; Index: excite.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/excite.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** excite.cc 11 Oct 2016 05:31:10 -0000 1.1 --- excite.cc 12 Oct 2016 04:31:24 -0000 1.2 *************** *** 43,47 **** --- 43,50 ---- // ----------------------------------------------------------------- // + #include <unistd.h> #include <fstream> + #include <iostream> + #include <sstream> #include "excitation_generation.h" *************** *** 78,82 **** *stream << " excitation (double)" << std::endl; *stream << " notice:" << std::endl; ! *stream << " if i < 0, dont interpolate pitch" << std::endl; *stream << " magic number for unvoiced frame is " << kMagicNumberForUnvoicedFrame << std::endl; // NOLINT *stream << std::endl; --- 81,85 ---- *stream << " excitation (double)" << std::endl; *stream << " notice:" << std::endl; ! *stream << " if i < 0, don't interpolate pitch" << std::endl; *stream << " magic number for unvoiced frame is " << kMagicNumberForUnvoicedFrame << std::endl; // NOLINT *stream << std::endl; Index: input_source_interpolation_with_magic_number.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_interpolation_with_magic_number.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** input_source_interpolation_with_magic_number.h 11 Oct 2016 05:31:10 -0000 1.1 --- input_source_interpolation_with_magic_number.h 12 Oct 2016 04:31:24 -0000 1.2 *************** *** 56,60 **** public: // ! InputSourceInterpolationWithMagicNumber(int frame_period, int interpolation_period, bool use_final_frame_for_exceeded_frame, --- 56,61 ---- public: // ! InputSourceInterpolationWithMagicNumber( ! int frame_period, int interpolation_period, bool use_final_frame_for_exceeded_frame, Index: normal_distributed_random_value_generation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/normal_distributed_random_value_generation.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** normal_distributed_random_value_generation.h 7 Oct 2016 06:50:32 -0000 1.2 --- normal_distributed_random_value_generation.h 12 Oct 2016 04:31:24 -0000 1.3 *************** *** 46,58 **** #define SPTK_SRC_NORMAL_DISTRIBUTED_RANDOM_VALUE_GENERATION_H_ #include "random_generation_interface.h" #include "sptk_utils.h" - #include <cstdint> // std::uint64_t - namespace sptk { ! class NormalDistributedRandomValueGeneration : ! public RandomGenerationInterface { public: // --- 46,58 ---- #define SPTK_SRC_NORMAL_DISTRIBUTED_RANDOM_VALUE_GENERATION_H_ + #include <cstdint> // std::uint64_t + #include "random_generation_interface.h" #include "sptk_utils.h" namespace sptk { ! class NormalDistributedRandomValueGeneration ! : public RandomGenerationInterface { public: // Index: normal_distributed_random_value_generation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/normal_distributed_random_value_generation.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** normal_distributed_random_value_generation.cc 7 Oct 2016 06:50:32 -0000 1.2 --- normal_distributed_random_value_generation.cc 12 Oct 2016 04:31:24 -0000 1.3 *************** *** 51,58 **** // pseudorandom generation double PseudoRandomGeneration(std::uint64_t *next) { ! double r; *next = (*next) * 1103515245L + 12345; ! r = ((*next) / 65536L) % 32768L; return r / 32767.0; --- 51,60 ---- // pseudorandom generation double PseudoRandomGeneration(std::uint64_t *next) { ! if (NULL == next) { ! return 0.0; ! } *next = (*next) * 1103515245L + 12345; ! const double r(((*next) / 65536L) % 32768L); return r / 32767.0; *************** *** 64,69 **** NormalDistributedRandomValueGeneration::NormalDistributedRandomValueGeneration( ! int seed) : ! seed_(seed), switch_(true) { next_ = static_cast<std::uint64_t>(seed_); } --- 66,70 ---- NormalDistributedRandomValueGeneration::NormalDistributedRandomValueGeneration( ! int seed) : seed_(seed), switch_(true) { next_ = static_cast<std::uint64_t>(seed_); } |