You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(125) |
Nov
(7) |
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
(9) |
Jun
(150) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
(15) |
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
(183) |
2010 |
Jan
|
Feb
(1) |
Mar
(26) |
Apr
(23) |
May
(4) |
Jun
(8) |
Jul
(9) |
Aug
(19) |
Sep
(6) |
Oct
(27) |
Nov
(5) |
Dec
(135) |
2011 |
Jan
(1) |
Feb
|
Mar
|
Apr
(22) |
May
(8) |
Jun
(8) |
Jul
(2) |
Aug
(12) |
Sep
(3) |
Oct
(13) |
Nov
(31) |
Dec
(40) |
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(11) |
Jun
(27) |
Jul
(6) |
Aug
(19) |
Sep
(14) |
Oct
(8) |
Nov
(10) |
Dec
(82) |
2013 |
Jan
(12) |
Feb
(14) |
Mar
(11) |
Apr
(4) |
May
(2) |
Jun
(2) |
Jul
|
Aug
(11) |
Sep
(16) |
Oct
(2) |
Nov
(23) |
Dec
(86) |
2014 |
Jan
(1) |
Feb
(18) |
Mar
(5) |
Apr
(13) |
May
(2) |
Jun
(8) |
Jul
(1) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
(65) |
2015 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
(2) |
Sep
(1) |
Oct
(2) |
Nov
(6) |
Dec
(41) |
2016 |
Jan
(2) |
Feb
(2) |
Mar
(3) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
(5) |
Aug
(8) |
Sep
(3) |
Oct
(26) |
Nov
(11) |
Dec
(45) |
2017 |
Jan
(12) |
Feb
(9) |
Mar
(4) |
Apr
(8) |
May
(20) |
Jun
(13) |
Jul
(18) |
Aug
(6) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv4909 Modified Files: .clang-format all_pole_digital_filter.h all_zero_digital_filter.h autocorrelation.h cepstrum_to_minimum_phase_impulse_response.h excitation_generation.h fast_fourier_transform.h frequency_transform.h generalized_cepstrum_gain_normalization.cc generalized_cepstrum_gain_normalization.h generalized_cepstrum_inverse_gain_normalization.cc generalized_cepstrum_inverse_gain_normalization.h generalized_cepstrum_transform.cc generalized_cepstrum_transform.h input_source_from_stream.h input_source_interface.h input_source_interpolation.h input_source_interpolation_with_magic_number.h input_source_preprocessing_for_filter_gain.h levinson_durbin_recursion.h m_sequence_generation.cc m_sequence_generation.h normal_distributed_random_value_generation.h random_generation_interface.h Log Message: modify formatting Index: input_source_from_stream.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_from_stream.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** input_source_from_stream.h 14 Oct 2016 06:17:44 -0000 1.4 --- input_source_from_stream.h 24 Oct 2016 08:20:30 -0000 1.5 *************** *** 69,79 **** // ! virtual ~InputSourceFromStream() {} // ! virtual int GetSize() const { return read_size_; } // ! virtual bool IsValid() const { return is_valid_; } // --- 69,84 ---- // ! virtual ~InputSourceFromStream() { ! } // ! virtual int GetSize() const { ! return read_size_; ! } // ! virtual bool IsValid() const { ! return is_valid_; ! } // Index: generalized_cepstrum_inverse_gain_normalization.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/generalized_cepstrum_inverse_gain_normalization.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** generalized_cepstrum_inverse_gain_normalization.h 12 Oct 2016 13:39:47 -0000 1.1 --- generalized_cepstrum_inverse_gain_normalization.h 24 Oct 2016 08:20:30 -0000 1.2 *************** *** 58,71 **** // ! virtual ~GeneralizedCepstrumInverseGainNormalization() {} // ! int GetNumOrder() const { return num_order_; } // ! double GetGamma() const { return gamma_; } // ! bool IsValid() const { return is_valid_; } // --- 58,78 ---- // ! virtual ~GeneralizedCepstrumInverseGainNormalization() { ! } // ! int GetNumOrder() const { ! return num_order_; ! } // ! double GetGamma() const { ! return gamma_; ! } // ! bool IsValid() const { ! return is_valid_; ! } // Index: all_pole_digital_filter.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/all_pole_digital_filter.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** all_pole_digital_filter.h 12 Oct 2016 12:14:38 -0000 1.5 --- all_pole_digital_filter.h 24 Oct 2016 08:20:30 -0000 1.6 *************** *** 58,68 **** public: // ! StoredSignals() {} // ! ~StoredSignals() {} // ! void Clear() { std::fill(signals_.begin(), signals_.end(), 0.0); } private: --- 58,72 ---- public: // ! StoredSignals() { ! } // ! ~StoredSignals() { ! } // ! void Clear() { ! std::fill(signals_.begin(), signals_.end(), 0.0); ! } private: *************** *** 88,101 **** // ! virtual ~AllPoleDigitalFilter() {} // ! int GetNumFilterOrder() const { return num_filter_order_; } // ! bool GetTranspositionFlag() const { return transposition_; } // ! bool IsValid() const { return is_valid_; } // --- 92,112 ---- // ! virtual ~AllPoleDigitalFilter() { ! } // ! int GetNumFilterOrder() const { ! return num_filter_order_; ! } // ! bool GetTranspositionFlag() const { ! return transposition_; ! } // ! bool IsValid() const { ! return is_valid_; ! } // Index: levinson_durbin_recursion.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/levinson_durbin_recursion.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** levinson_durbin_recursion.h 12 Oct 2016 12:14:38 -0000 1.4 --- levinson_durbin_recursion.h 24 Oct 2016 08:20:30 -0000 1.5 *************** *** 56,61 **** class Buffer { public: ! Buffer() {} ! virtual ~Buffer() {} private: --- 56,63 ---- class Buffer { public: ! Buffer() { ! } ! virtual ~Buffer() { ! } private: *************** *** 66,73 **** // ! LevinsonDurbinRecursion() : epsilon_(1.0e-6) {} // ! virtual ~LevinsonDurbinRecursion() {} // --- 68,77 ---- // ! LevinsonDurbinRecursion() : epsilon_(1.0e-6) { ! } // ! virtual ~LevinsonDurbinRecursion() { ! } // *************** *** 79,83 **** // ! double GetEpsilon() const { return epsilon_; } // --- 83,89 ---- // ! double GetEpsilon() const { ! return epsilon_; ! } // Index: autocorrelation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/autocorrelation.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** autocorrelation.h 12 Oct 2016 12:14:38 -0000 1.3 --- autocorrelation.h 24 Oct 2016 08:20:30 -0000 1.4 *************** *** 55,62 **** public: // ! Autocorrelation() : num_order_(0) {} // ! virtual ~Autocorrelation() {} // --- 55,64 ---- public: // ! Autocorrelation() : num_order_(0) { ! } // ! virtual ~Autocorrelation() { ! } // *************** *** 68,72 **** // ! int GetNumOrder() const { return num_order_; } // --- 70,76 ---- // ! int GetNumOrder() const { ! return num_order_; ! } // Index: normal_distributed_random_value_generation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/normal_distributed_random_value_generation.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** normal_distributed_random_value_generation.h 12 Oct 2016 04:31:24 -0000 1.3 --- normal_distributed_random_value_generation.h 24 Oct 2016 08:20:30 -0000 1.4 *************** *** 60,64 **** // ! virtual ~NormalDistributedRandomValueGeneration() {} // --- 60,65 ---- // ! virtual ~NormalDistributedRandomValueGeneration() { ! } // Index: generalized_cepstrum_transform.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/generalized_cepstrum_transform.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** generalized_cepstrum_transform.h 14 Oct 2016 06:17:44 -0000 1.1 --- generalized_cepstrum_transform.h 24 Oct 2016 08:20:30 -0000 1.2 *************** *** 57,62 **** class Buffer { public: ! Buffer() {} ! virtual ~Buffer() {} private: --- 57,64 ---- class Buffer { public: ! Buffer() { ! } ! virtual ~Buffer() { ! } private: *************** *** 81,118 **** // ! virtual ~GeneralizedCepstrumTransform() {} // ! int GetNumInputOrder() const { return num_input_order_; } // ! double GetInputAlpha() const { return input_alpha_; } // ! double GetInputGamma() const { return input_gamma_; } // ! bool IsNormalizedInput() const { return is_normalized_input_; } // ! bool IsMultipliedInput() const { return is_multiplied_input_; } // ! int GetNumOutputOrder() const { return num_output_order_; } // ! double GetOutputAlpha() const { return output_alpha_; } // ! double GetOutputGamma() const { return output_gamma_; } // ! bool IsNormalizedOutut() const { return is_normalized_output_; } // ! bool IsMultipliedOutput() const { return is_multiplied_output_; } // ! bool IsValid() const { return is_valid_; } // --- 83,143 ---- // ! virtual ~GeneralizedCepstrumTransform() { ! } // ! int GetNumInputOrder() const { ! return num_input_order_; ! } // ! double GetInputAlpha() const { ! return input_alpha_; ! } // ! double GetInputGamma() const { ! return input_gamma_; ! } // ! bool IsNormalizedInput() const { ! return is_normalized_input_; ! } // ! bool IsMultipliedInput() const { ! return is_multiplied_input_; ! } // ! int GetNumOutputOrder() const { ! return num_output_order_; ! } // ! double GetOutputAlpha() const { ! return output_alpha_; ! } // ! double GetOutputGamma() const { ! return output_gamma_; ! } // ! bool IsNormalizedOutut() const { ! return is_normalized_output_; ! } // ! bool IsMultipliedOutput() const { ! return is_multiplied_output_; ! } // ! bool IsValid() const { ! return is_valid_; ! } // Index: excitation_generation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/excitation_generation.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** excitation_generation.h 12 Oct 2016 12:14:38 -0000 1.4 --- excitation_generation.h 24 Oct 2016 08:20:30 -0000 1.5 *************** *** 59,66 **** // ! virtual ~ExcitationGeneration() {} // ! bool IsValid() const { return is_valid_; } // --- 59,69 ---- // ! virtual ~ExcitationGeneration() { ! } // ! bool IsValid() const { ! return is_valid_; ! } // Index: m_sequence_generation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/m_sequence_generation.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** m_sequence_generation.cc 12 Oct 2016 12:14:38 -0000 1.5 --- m_sequence_generation.cc 24 Oct 2016 08:20:30 -0000 1.6 *************** *** 56,62 **** namespace sptk { ! MSequenceGeneration::MSequenceGeneration() : x_(kInitialValue) {} ! void MSequenceGeneration::Reset() { x_ = kInitialValue; } bool MSequenceGeneration::Get(double *output) { --- 56,65 ---- namespace sptk { ! MSequenceGeneration::MSequenceGeneration() : x_(kInitialValue) { ! } ! void MSequenceGeneration::Reset() { ! x_ = kInitialValue; ! } bool MSequenceGeneration::Get(double *output) { Index: generalized_cepstrum_gain_normalization.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/generalized_cepstrum_gain_normalization.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** generalized_cepstrum_gain_normalization.cc 12 Oct 2016 15:02:23 -0000 1.2 --- generalized_cepstrum_gain_normalization.cc 24 Oct 2016 08:20:30 -0000 1.3 *************** *** 45,50 **** #include "generalized_cepstrum_gain_normalization.h" ! #include <cmath> // std::pow, std::exp ! #include <vector> // std::vector #include "sptk_utils.h" --- 45,51 ---- #include "generalized_cepstrum_gain_normalization.h" ! #include <algorithm> // std::copy ! #include <cmath> // std::pow, std::exp ! #include <vector> // std::vector #include "sptk_utils.h" Index: generalized_cepstrum_gain_normalization.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/generalized_cepstrum_gain_normalization.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** generalized_cepstrum_gain_normalization.h 12 Oct 2016 13:08:14 -0000 1.1 --- generalized_cepstrum_gain_normalization.h 24 Oct 2016 08:20:30 -0000 1.2 *************** *** 58,71 **** // ! virtual ~GeneralizedCepstrumGainNormalization() {} // ! int GetNumOrder() const { return num_order_; } // ! double GetGamma() const { return gamma_; } // ! bool IsValid() const { return is_valid_; } // --- 58,78 ---- // ! virtual ~GeneralizedCepstrumGainNormalization() { ! } // ! int GetNumOrder() const { ! return num_order_; ! } // ! double GetGamma() const { ! return gamma_; ! } // ! bool IsValid() const { ! return is_valid_; ! } // Index: input_source_interface.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_interface.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** input_source_interface.h 14 Oct 2016 06:17:44 -0000 1.3 --- input_source_interface.h 24 Oct 2016 08:20:30 -0000 1.4 *************** *** 53,57 **** public: // ! virtual ~InputSourceInterface() {} // --- 53,58 ---- public: // ! virtual ~InputSourceInterface() { ! } // Index: input_source_preprocessing_for_filter_gain.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_preprocessing_for_filter_gain.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** input_source_preprocessing_for_filter_gain.h 14 Oct 2016 06:17:44 -0000 1.5 --- input_source_preprocessing_for_filter_gain.h 24 Oct 2016 08:20:30 -0000 1.6 *************** *** 74,87 **** // ! virtual ~InputSourcePreprocessingForFilterGain() {} // ! FilterGainType GetFilterGainType() const { return gain_type_; } // ! virtual int GetSize() const { return source_ ? source_->GetSize() : 0; } // ! virtual bool IsValid() const { return is_valid_; } // --- 74,94 ---- // ! virtual ~InputSourcePreprocessingForFilterGain() { ! } // ! FilterGainType GetFilterGainType() const { ! return gain_type_; ! } // ! virtual int GetSize() const { ! return source_ ? source_->GetSize() : 0; ! } // ! virtual bool IsValid() const { ! return is_valid_; ! } // 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.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** input_source_interpolation_with_magic_number.h 12 Oct 2016 12:14:38 -0000 1.4 --- input_source_interpolation_with_magic_number.h 24 Oct 2016 08:20:30 -0000 1.5 *************** *** 62,72 **** // ! virtual ~InputSourceInterpolationWithMagicNumber() {} // ! int GetFramePeriod() const { return frame_period_; } // ! int GetInterpolationPeriod() const { return interpolation_period_; } // --- 62,77 ---- // ! virtual ~InputSourceInterpolationWithMagicNumber() { ! } // ! int GetFramePeriod() const { ! return frame_period_; ! } // ! int GetInterpolationPeriod() const { ! return interpolation_period_; ! } // *************** *** 76,83 **** // ! double GetMagicNumber() const { return magic_number_; } // ! bool IsValid() const { return is_valid_; } // --- 81,92 ---- // ! double GetMagicNumber() const { ! return magic_number_; ! } // ! bool IsValid() const { ! return is_valid_; ! } // Index: fast_fourier_transform.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fast_fourier_transform.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** fast_fourier_transform.h 12 Oct 2016 12:14:38 -0000 1.6 --- fast_fourier_transform.h 24 Oct 2016 08:20:30 -0000 1.7 *************** *** 55,62 **** public: // ! FastFourierTransform() : num_dimension_(0), inverse_(false) {} // ! virtual ~FastFourierTransform() {} // Set the number of dimensions and prepare the sine table. --- 55,64 ---- public: // ! FastFourierTransform() : num_dimension_(0), inverse_(false) { ! } // ! virtual ~FastFourierTransform() { ! } // Set the number of dimensions and prepare the sine table. *************** *** 64,74 **** // ! void SetInverseFlag(bool inverse) { inverse_ = inverse; } // ! int GetNumDimension() const { return num_dimension_; } // ! bool GetInverseFlag() const { return inverse_; } // --- 66,82 ---- // ! void SetInverseFlag(bool inverse) { ! inverse_ = inverse; ! } // ! int GetNumDimension() const { ! return num_dimension_; ! } // ! bool GetInverseFlag() const { ! return inverse_; ! } // Index: m_sequence_generation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/m_sequence_generation.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** m_sequence_generation.h 12 Oct 2016 04:31:24 -0000 1.4 --- m_sequence_generation.h 24 Oct 2016 08:20:30 -0000 1.5 *************** *** 57,61 **** // ! virtual ~MSequenceGeneration() {} // --- 57,62 ---- // ! virtual ~MSequenceGeneration() { ! } // Index: generalized_cepstrum_transform.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/generalized_cepstrum_transform.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** generalized_cepstrum_transform.cc 14 Oct 2016 09:15:14 -0000 1.2 --- generalized_cepstrum_transform.cc 24 Oct 2016 08:20:30 -0000 1.3 *************** *** 45,50 **** #include "generalized_cepstrum_transform.h" ! #include <algorithm> // std::transform ! #include <vector> // std::vector #include "frequency_transform.h" --- 45,51 ---- #include "generalized_cepstrum_transform.h" ! #include <algorithm> // std::copy, std::transform ! #include <functional> // std::multiplies ! #include <vector> // std::vector #include "frequency_transform.h" Index: frequency_transform.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/frequency_transform.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** frequency_transform.h 14 Oct 2016 06:17:44 -0000 1.9 --- frequency_transform.h 24 Oct 2016 08:20:30 -0000 1.10 *************** *** 56,61 **** class Buffer { public: ! Buffer() {} ! virtual ~Buffer() {} private: --- 56,63 ---- class Buffer { public: ! Buffer() { ! } ! virtual ~Buffer() { ! } private: *************** *** 70,86 **** // ! virtual ~FrequencyTransform() {} // ! int GetNumInputOrder() const { return num_input_order_; } // ! int GetNumOutputOrder() const { return num_output_order_; } // ! double GetAlpha() const { return alpha_; } // ! bool IsValid() const { return is_valid_; } // --- 72,97 ---- // ! virtual ~FrequencyTransform() { ! } // ! int GetNumInputOrder() const { ! return num_input_order_; ! } // ! int GetNumOutputOrder() const { ! return num_output_order_; ! } // ! double GetAlpha() const { ! return alpha_; ! } // ! bool IsValid() const { ! return is_valid_; ! } // Index: generalized_cepstrum_inverse_gain_normalization.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/generalized_cepstrum_inverse_gain_normalization.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** generalized_cepstrum_inverse_gain_normalization.cc 12 Oct 2016 15:02:23 -0000 1.2 --- generalized_cepstrum_inverse_gain_normalization.cc 24 Oct 2016 08:20:30 -0000 1.3 *************** *** 45,50 **** #include "generalized_cepstrum_inverse_gain_normalization.h" ! #include <cmath> // std::pow, std::log ! #include <vector> // std::vector #include "sptk_utils.h" --- 45,51 ---- #include "generalized_cepstrum_inverse_gain_normalization.h" ! #include <algorithm> // std::copy ! #include <cmath> // std::pow, std::log ! #include <vector> // std::vector #include "sptk_utils.h" Index: .clang-format =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/.clang-format,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .clang-format 12 Oct 2016 12:14:38 -0000 1.1 --- .clang-format 24 Oct 2016 08:20:30 -0000 1.2 *************** *** 1,3 **** BasedOnStyle: Google AllowShortBlocksOnASingleLine: false ! AllowShortBlocksOnASingleLine: false --- 1,3 ---- BasedOnStyle: Google AllowShortBlocksOnASingleLine: false ! AllowShortFunctionsOnASingleLine: false Index: random_generation_interface.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/random_generation_interface.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** random_generation_interface.h 7 Oct 2016 06:50:32 -0000 1.1 --- random_generation_interface.h 24 Oct 2016 08:20:30 -0000 1.2 *************** *** 53,57 **** public: // ! virtual ~RandomGenerationInterface() {} // --- 53,58 ---- public: // ! virtual ~RandomGenerationInterface() { ! } // Index: all_zero_digital_filter.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/all_zero_digital_filter.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** all_zero_digital_filter.h 12 Oct 2016 12:14:38 -0000 1.4 --- all_zero_digital_filter.h 24 Oct 2016 08:20:30 -0000 1.5 *************** *** 58,68 **** public: // ! StoredSignals() {} // ! ~StoredSignals() {} // ! void Clear() { std::fill(signals_.begin(), signals_.end(), 0.0); } private: --- 58,72 ---- public: // ! StoredSignals() { ! } // ! ~StoredSignals() { ! } // ! void Clear() { ! std::fill(signals_.begin(), signals_.end(), 0.0); ! } private: *************** *** 88,101 **** // ! virtual ~AllZeroDigitalFilter() {} // ! int GetNumFilterOrder() const { return num_filter_order_; } // ! bool GetTranspositionFlag() const { return transposition_; } // ! bool IsValid() const { return is_valid_; } // --- 92,112 ---- // ! virtual ~AllZeroDigitalFilter() { ! } // ! int GetNumFilterOrder() const { ! return num_filter_order_; ! } // ! bool GetTranspositionFlag() const { ! return transposition_; ! } // ! bool IsValid() const { ! return is_valid_; ! } // 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.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** cepstrum_to_minimum_phase_impulse_response.h 12 Oct 2016 12:14:38 -0000 1.5 --- cepstrum_to_minimum_phase_impulse_response.h 24 Oct 2016 08:20:30 -0000 1.6 *************** *** 66,79 **** // ! virtual ~CepstrumToMinimumPhaseImpulseResponse() {} // ! int GetNumInputOrder() const { return num_input_order_; } // ! int GetNumOutputOrder() const { return num_output_order_; } // ! bool IsValid() const { return is_valid_; } // --- 66,86 ---- // ! virtual ~CepstrumToMinimumPhaseImpulseResponse() { ! } // ! int GetNumInputOrder() const { ! return num_input_order_; ! } // ! int GetNumOutputOrder() const { ! return num_output_order_; ! } // ! bool IsValid() const { ! return is_valid_; ! } // Index: input_source_interpolation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_interpolation.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** input_source_interpolation.h 12 Oct 2016 12:14:38 -0000 1.4 --- input_source_interpolation.h 24 Oct 2016 08:20:30 -0000 1.5 *************** *** 61,71 **** // ! virtual ~InputSourceInterpolation() {} // ! int GetFramePeriod() const { return frame_period_; } // ! int GetInterpolationPeriod() const { return interpolation_period_; } // --- 61,76 ---- // ! virtual ~InputSourceInterpolation() { ! } // ! int GetFramePeriod() const { ! return frame_period_; ! } // ! int GetInterpolationPeriod() const { ! return interpolation_period_; ! } // *************** *** 75,79 **** // ! bool IsValid() const { return is_valid_; } // --- 80,86 ---- // ! bool IsValid() const { ! return is_valid_; ! } // |
From: Keiichiro O. <ur...@us...> - 2016-10-14 09:15:16
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv4602 Modified Files: generalized_cepstrum_transform.cc Log Message: add generalized cepstrum transform Index: generalized_cepstrum_transform.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/generalized_cepstrum_transform.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** generalized_cepstrum_transform.cc 14 Oct 2016 06:17:44 -0000 1.1 --- generalized_cepstrum_transform.cc 14 Oct 2016 09:15:14 -0000 1.2 *************** *** 73,78 **** if (num_input_order_ < 0 || num_output_order_ < 0 || (input_alpha_ != output_alpha_ && 1.0 == input_alpha_ * output_alpha_) || ! (is_multiplied_input && 0.0 == input_gamma_) || ! (is_multiplied_output && 0.0 == output_gamma_)) { is_valid_ = false; return; --- 73,77 ---- if (num_input_order_ < 0 || num_output_order_ < 0 || (input_alpha_ != output_alpha_ && 1.0 == input_alpha_ * output_alpha_) || ! (is_multiplied_input && 0.0 == input_gamma_)) { is_valid_ = false; return; *************** *** 273,280 **** // output: output if (is_multiplied_output_) { ! std::transform( ! inverse_gain_normalized_output->begin(), ! inverse_gain_normalized_output->end(), output->begin(), ! std::bind1st(std::multiplies<double>(), 1.0 / output_gamma_)); } else { std::copy(inverse_gain_normalized_output->begin(), --- 272,278 ---- // output: output if (is_multiplied_output_) { ! std::transform(inverse_gain_normalized_output->begin(), ! inverse_gain_normalized_output->end(), output->begin(), ! std::bind1st(std::multiplies<double>(), output_gamma_)); } else { std::copy(inverse_gain_normalized_output->begin(), |
From: Keiichiro O. <ur...@us...> - 2016-10-14 06:17:47
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv29518 Modified Files: Makefile freqt.cc frequency_transform.cc frequency_transform.h input_source_from_stream.h input_source_interface.h input_source_preprocessing_for_filter_gain.cc input_source_preprocessing_for_filter_gain.h Added Files: generalized_cepstrum_transform.cc generalized_cepstrum_transform.h Log Message: add generalized cepstrum transform Index: frequency_transform.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/frequency_transform.cc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** frequency_transform.cc 12 Oct 2016 12:14:38 -0000 1.9 --- frequency_transform.cc 14 Oct 2016 06:17:44 -0000 1.10 *************** *** 50,59 **** namespace sptk { bool FrequencyTransform::Run(const std::vector<double>& minimum_phase_sequence, std::vector<double>* warped_sequence, FrequencyTransform::Buffer* buffer) const { // check inputs ! if (minimum_phase_sequence.empty() || NULL == warped_sequence || ! NULL == buffer) { return false; } --- 50,72 ---- namespace sptk { + FrequencyTransform::FrequencyTransform(int num_input_order, + int num_output_order, double alpha) + : num_input_order_(num_input_order), + num_output_order_(num_output_order), + alpha_(alpha), + is_valid_(true) { + if (num_input_order_ < 0 || num_output_order_ < 0) { + is_valid_ = false; + } + } + bool FrequencyTransform::Run(const std::vector<double>& minimum_phase_sequence, std::vector<double>* warped_sequence, FrequencyTransform::Buffer* buffer) const { // check inputs ! if (!is_valid_ || ! minimum_phase_sequence.size() != ! static_cast<std::size_t>(num_input_order_ + 1) || ! NULL == warped_sequence || NULL == buffer) { return false; } *************** *** 65,70 **** } ! const int num_input_order(minimum_phase_sequence.size() - 1); ! if (0.0 == alpha_ && num_input_order == num_output_order_) { std::copy(minimum_phase_sequence.begin(), minimum_phase_sequence.end(), warped_sequence->begin()); --- 78,82 ---- } ! if (0.0 == alpha_ && num_input_order_ == num_output_order_) { std::copy(minimum_phase_sequence.begin(), minimum_phase_sequence.end(), warped_sequence->begin()); *************** *** 93,99 **** // transform ! for (int i(0); i <= num_input_order; ++i) { d[0] = g[0]; ! g[0] = input[num_input_order - i] + alpha_ * d[0]; if (1 <= num_output_order_) { d[1] = g[1]; --- 105,111 ---- // transform ! for (int i(0); i <= num_input_order_; ++i) { d[0] = g[0]; ! g[0] = input[num_input_order_ - i] + alpha_ * d[0]; if (1 <= num_output_order_) { d[1] = g[1]; Index: freqt.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/freqt.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** freqt.cc 12 Oct 2016 12:14:38 -0000 1.6 --- freqt.cc 14 Oct 2016 06:17:44 -0000 1.7 *************** *** 171,183 **** // prepare for frequency transform ! sptk::FrequencyTransform frequency_transform; sptk::FrequencyTransform::Buffer buffer; ! if (!frequency_transform.SetNumOutputOrder(num_output_order)) { std::ostringstream error_message; ! error_message << "Failed to set the number of output orders"; sptk::PrintErrorMessage("freqt", error_message); return 1; } - frequency_transform.SetAlpha(alpha); const int input_length(num_input_order + 1); --- 171,183 ---- // prepare for frequency transform ! sptk::FrequencyTransform frequency_transform(num_input_order, ! num_output_order, alpha); sptk::FrequencyTransform::Buffer buffer; ! if (!frequency_transform.IsValid()) { std::ostringstream error_message; ! error_message << "Failed to set the condition of frequency transform"; sptk::PrintErrorMessage("freqt", error_message); return 1; } const int input_length(num_input_order + 1); --- NEW FILE: generalized_cepstrum_transform.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_TRANSFORM_H_ #define SPTK_SRC_GENERALIZED_CEPSTRUM_TRANSFORM_H_ #include <vector> // std::vector #include "frequency_transform.h" #include "sptk_utils.h" namespace sptk { class GeneralizedCepstrumTransform { public: class Buffer { public: Buffer() {} virtual ~Buffer() {} private: std::vector<double> inverse_gain_normalized_input_; std::vector<double> gamma_divided_input_; std::vector<double> frequency_transformed_input_; FrequencyTransform::Buffer frequency_transform_buffer_; std::vector<double> gain_normalized_input_; std::vector<double> generalized_cepstrum_transformed_output_; std::vector<double> inverse_gain_normalized_output_; friend class GeneralizedCepstrumTransform; DISALLOW_COPY_AND_ASSIGN(Buffer); }; // GeneralizedCepstrumTransform(int num_input_order_, double input_alpha_, double input_gamma_, bool is_normalized_input_, bool is_multiplied_input_, int num_output_order_, double output_alpha_, double output_gamma_, bool is_normalized_output_, bool is_multiplied_output_); // virtual ~GeneralizedCepstrumTransform() {} // int GetNumInputOrder() const { return num_input_order_; } // double GetInputAlpha() const { return input_alpha_; } // double GetInputGamma() const { return input_gamma_; } // bool IsNormalizedInput() const { return is_normalized_input_; } // bool IsMultipliedInput() const { return is_multiplied_input_; } // int GetNumOutputOrder() const { return num_output_order_; } // double GetOutputAlpha() const { return output_alpha_; } // double GetOutputGamma() const { return output_gamma_; } // bool IsNormalizedOutut() const { return is_normalized_output_; } // bool IsMultipliedOutput() const { return is_multiplied_output_; } // bool IsValid() const { return is_valid_; } // bool Run(const std::vector<double>& input, std::vector<double>* output, GeneralizedCepstrumTransform::Buffer* buffer) const; private: // const int num_input_order_; // const double input_alpha_; // const double input_gamma_; // const bool is_normalized_input_; // const bool is_multiplied_input_; // const int num_output_order_; // const double output_alpha_; // const double output_gamma_; // const bool is_normalized_output_; // const bool is_multiplied_output_; // double alpha_transform_; // bool is_valid_; // DISALLOW_COPY_AND_ASSIGN(GeneralizedCepstrumTransform); }; } // namespace sptk #endif // SPTK_SRC_GENERALIZED_CEPSTRUM_TRANSFORM_H_ Index: input_source_from_stream.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_from_stream.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** input_source_from_stream.h 12 Oct 2016 12:14:38 -0000 1.3 --- input_source_from_stream.h 14 Oct 2016 06:17:44 -0000 1.4 *************** *** 72,75 **** --- 72,78 ---- // + virtual int GetSize() const { return read_size_; } + + // virtual bool IsValid() const { return is_valid_; } --- NEW FILE: generalized_cepstrum_transform.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_transform.h" #include <algorithm> // std::transform #include <vector> // std::vector #include "frequency_transform.h" #include "generalized_cepstrum_gain_normalization.h" #include "generalized_cepstrum_inverse_gain_normalization.h" namespace sptk { GeneralizedCepstrumTransform::GeneralizedCepstrumTransform( int num_input_order, double input_alpha, double input_gamma, bool is_normalized_input, bool is_multiplied_input, int num_output_order, double output_alpha, double output_gamma, bool is_normalized_output, bool is_multiplied_output) : num_input_order_(num_input_order), input_alpha_(input_alpha), input_gamma_(input_gamma), is_normalized_input_(is_normalized_input), is_multiplied_input_(is_multiplied_input), num_output_order_(num_output_order), output_alpha_(output_alpha), output_gamma_(output_gamma), is_normalized_output_(is_normalized_output), is_multiplied_output_(is_multiplied_output), alpha_transform_(0.0), is_valid_(true) { if (num_input_order_ < 0 || num_output_order_ < 0 || (input_alpha_ != output_alpha_ && 1.0 == input_alpha_ * output_alpha_) || (is_multiplied_input && 0.0 == input_gamma_) || (is_multiplied_output && 0.0 == output_gamma_)) { is_valid_ = false; return; } if (input_alpha_ != output_alpha_) { alpha_transform_ = (output_alpha_ - input_alpha_) / (1.0 - input_alpha_ * output_alpha_); } } 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() || NULL == output || NULL == buffer) { return false; } if (output->size() < static_cast<std::size_t>(num_output_order_ + 1)) { output->resize(num_output_order_ + 1); } // mgc2mgc input // norm=false multi=false freqt=false // -> -> -> gnorm -> gc2gc // norm=false multi=true freqt=false // -> c[1-m]/g -> -> gnorm -> gc2gc // norm=true multi=false freqt=false // -> gc2gc // norm=true multi=true freqt=false // ignorm -> c[1-m]/g -> -> gnorm -> gc2gc // norm=false multi=false freqt=true // -> -> freqt -> gnorm -> gc2gc // norm=false multi=true freqt=true // -> c[1-m]/g -> freqt -> gnorm -> gc2gc // norm=true multi=false freqt=true // ignorm -> -> freqt -> gnorm -> gc2gc // norm=true multi=true freqt=true // ignorm -> c[1-m]/g -> freqt -> gnorm -> gc2gc // do nothing if (num_input_order_ == num_output_order_ && input_alpha_ == output_alpha_ && input_gamma_ == output_gamma_ && is_normalized_input_ == is_normalized_output_ && is_multiplied_input_ == is_multiplied_output_) { std::copy(input.begin(), input.end(), output->begin()); return true; } // inverse gain normalization // input: input // output: inverse_gain_normalized_input const std::vector<double>* inverse_gain_normalized_input; if (is_normalized_input_ && (is_multiplied_input_ || 0.0 != alpha_transform_)) { GeneralizedCepstrumInverseGainNormalization generalized_cepstrum_inverse_gain_normalization(num_input_order_, input_gamma_); if (!generalized_cepstrum_inverse_gain_normalization.IsValid()) { return false; } if (!generalized_cepstrum_inverse_gain_normalization.Run( input, &buffer->inverse_gain_normalized_input_)) { return false; } inverse_gain_normalized_input = &buffer->inverse_gain_normalized_input_; } else { inverse_gain_normalized_input = &input; } // gamma division // input: inverse_gain_normalized_input // output: gamma_divided_input const std::vector<double>* gamma_divided_input; if (is_multiplied_input_) { if (buffer->gamma_divided_input_.size() < static_cast<std::size_t>(num_input_order_ + 1)) { buffer->gamma_divided_input_.resize(num_input_order_ + 1); } std::transform(inverse_gain_normalized_input->begin(), inverse_gain_normalized_input->end(), buffer->gamma_divided_input_.begin(), std::bind1st(std::multiplies<double>(), 1.0 / input_gamma_)); gamma_divided_input = &buffer->gamma_divided_input_; } else { gamma_divided_input = inverse_gain_normalized_input; } // frequency transform // input: gamma_divided_input // output: frequency_transformed_input const std::vector<double>* frequency_transformed_input; if (0.0 != alpha_transform_) { FrequencyTransform frequency_transform(num_input_order_, num_input_order_, alpha_transform_); if (!frequency_transform.IsValid()) { return false; } if (!frequency_transform.Run(*gamma_divided_input, &buffer->frequency_transformed_input_, &buffer->frequency_transform_buffer_)) { return false; } frequency_transformed_input = &buffer->frequency_transformed_input_; } else { frequency_transformed_input = gamma_divided_input; } // gain normalization // input: frequency_transformed_input // output: gain_normalized_input const std::vector<double>* gain_normalized_input; if (!is_normalized_input_ || is_multiplied_input_ || 0.0 != alpha_transform_) { GeneralizedCepstrumGainNormalization generalized_cepstrum_gain_normalization(num_input_order_, input_gamma_); if (!generalized_cepstrum_gain_normalization.IsValid()) { return false; } if (!generalized_cepstrum_gain_normalization.Run( *frequency_transformed_input, &buffer->gain_normalized_input_)) { return false; } gain_normalized_input = &buffer->gain_normalized_input_; } else { gain_normalized_input = frequency_transformed_input; } // generalized cepstrum transform // input: gain_normalized_input // output: generalized_cepstrum_transformed_output const std::vector<double>* generalized_cepstrum_transformed_output; if (input_gamma_ != output_gamma_ || num_input_order_ != num_output_order_) { if (buffer->generalized_cepstrum_transformed_output_.size() < static_cast<std::size_t>(num_output_order_ + 1)) { buffer->generalized_cepstrum_transformed_output_.resize( num_output_order_ + 1); } const double* c1(&(*gain_normalized_input)[0]); double* c2(&(buffer->generalized_cepstrum_transformed_output_[0])); c2[0] = c1[0]; for (int i(1); i <= num_output_order_; ++i) { double ss1(0.0), ss2(0.0); const int min(num_output_order_ < i ? num_output_order_ : i - 1); for (int k(1); k <= min; ++k) { int mk(i - k); double cc(c1[k] * c2[mk]); ss2 += k * cc; ss1 += mk * cc; } if (i <= num_input_order_) c2[i] = c1[i] + (output_gamma_ * ss2 - input_gamma_ * ss1) / i; else c2[i] = (output_gamma_ * ss2 - input_gamma_ * ss1) / i; } generalized_cepstrum_transformed_output = &buffer->generalized_cepstrum_transformed_output_; } else { generalized_cepstrum_transformed_output = gain_normalized_input; } // mgc2mgc output // norm=false multi=false // ignorm -> -> // norm=false multi=true // ignorm -> -> c[1-m]*g // norm=true multi=false // -> -> // norm=true multi=true // -> -> c[1-m]*g // inverse gain normalization // input: generalized_cepstrum_transformed_output // output: inverse_gain_normalized_output const std::vector<double>* inverse_gain_normalized_output; if (!is_normalized_output_) { GeneralizedCepstrumInverseGainNormalization generalized_cepstrum_inverse_gain_normalization(num_output_order_, output_gamma_); if (!generalized_cepstrum_inverse_gain_normalization.IsValid()) { return false; } if (!generalized_cepstrum_inverse_gain_normalization.Run( *generalized_cepstrum_transformed_output, &buffer->inverse_gain_normalized_output_)) { return false; } inverse_gain_normalized_output = &buffer->inverse_gain_normalized_output_; } else { inverse_gain_normalized_output = generalized_cepstrum_transformed_output; } // gamma multiplication // input: inverse_gain_normalized_output // output: output if (is_multiplied_output_) { std::transform( inverse_gain_normalized_output->begin(), inverse_gain_normalized_output->end(), output->begin(), std::bind1st(std::multiplies<double>(), 1.0 / output_gamma_)); } else { std::copy(inverse_gain_normalized_output->begin(), inverse_gain_normalized_output->end(), output->begin()); } return true; } } // namespace sptk Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Makefile 12 Oct 2016 13:39:46 -0000 1.16 --- Makefile 14 Oct 2016 06:17:44 -0000 1.17 *************** *** 54,57 **** --- 54,58 ---- generalized_cepstrum_gain_normalization.cc \ generalized_cepstrum_inverse_gain_normalization.cc \ + generalized_cepstrum_transform.cc \ input_source_from_stream.cc \ input_source_interpolation.cc \ Index: input_source_preprocessing_for_filter_gain.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_preprocessing_for_filter_gain.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** input_source_preprocessing_for_filter_gain.cc 12 Oct 2016 12:14:38 -0000 1.3 --- input_source_preprocessing_for_filter_gain.cc 14 Oct 2016 06:17:44 -0000 1.4 *************** *** 61,64 **** --- 61,71 ---- switch (gain_type_) { + case InputSourcePreprocessingForFilterGain::FilterGainType::kLinear: { + break; + } + case InputSourcePreprocessingForFilterGain::FilterGainType::kLog: { + buffer->at(0) = std::exp(buffer->at(0)); + break; + } case InputSourcePreprocessingForFilterGain::FilterGainType::kUnity: { buffer->at(0) = 1.0; *************** *** 73,83 **** break; } - case InputSourcePreprocessingForFilterGain::FilterGainType::kLinear: { - break; - } - case InputSourcePreprocessingForFilterGain::FilterGainType::kLog: { - buffer->at(0) = std::exp(buffer->at(0)); - break; - } default: { return false; } } --- 80,83 ---- Index: frequency_transform.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/frequency_transform.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** frequency_transform.h 12 Oct 2016 12:14:38 -0000 1.8 --- frequency_transform.h 14 Oct 2016 06:17:44 -0000 1.9 *************** *** 67,84 **** // ! FrequencyTransform() : num_output_order_(0), alpha_(0.0) {} // virtual ~FrequencyTransform() {} - // num_output_order must be non-negative. - bool SetNumOutputOrder(int num_output_order) { - if (num_output_order < 0) return false; - num_output_order_ = num_output_order; - return true; - } - // ! void SetAlpha(double alpha) { alpha_ = alpha; } // --- 67,77 ---- // ! FrequencyTransform(int num_input_order, int num_output_order, double alpha); // virtual ~FrequencyTransform() {} // ! int GetNumInputOrder() const { return num_input_order_; } // *************** *** 89,92 **** --- 82,88 ---- // + bool IsValid() const { return is_valid_; } + + // bool Run(const std::vector<double>& minimum_phase_sequence, std::vector<double>* warped_sequence, *************** *** 95,102 **** private: // ! int num_output_order_; // ! double alpha_; // --- 91,104 ---- private: // ! const int num_input_order_; // ! const int num_output_order_; ! ! // ! const double alpha_; ! ! // ! bool is_valid_; // Index: input_source_interface.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_interface.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** input_source_interface.h 12 Oct 2016 11:13:51 -0000 1.2 --- input_source_interface.h 14 Oct 2016 06:17:44 -0000 1.3 *************** *** 56,59 **** --- 56,62 ---- // + virtual int GetSize() const = 0; + + // virtual bool IsValid() const = 0; Index: input_source_preprocessing_for_filter_gain.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_preprocessing_for_filter_gain.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** input_source_preprocessing_for_filter_gain.h 12 Oct 2016 12:14:38 -0000 1.4 --- input_source_preprocessing_for_filter_gain.h 14 Oct 2016 06:17:44 -0000 1.5 *************** *** 80,83 **** --- 80,86 ---- // + virtual int GetSize() const { return source_ ? source_->GetSize() : 0; } + + // virtual bool IsValid() const { return is_valid_; } |
From: Keiichiro O. <ur...@us...> - 2016-10-12 15:02:26
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv18709 Modified Files: generalized_cepstrum_gain_normalization.cc generalized_cepstrum_inverse_gain_normalization.cc Log Message: add input checker to gnorm/ignorm. Index: generalized_cepstrum_gain_normalization.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/generalized_cepstrum_gain_normalization.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** generalized_cepstrum_gain_normalization.cc 12 Oct 2016 13:08:14 -0000 1.1 --- generalized_cepstrum_gain_normalization.cc 12 Oct 2016 15:02:23 -0000 1.2 *************** *** 63,71 **** const std::vector<double>& generalized_cepstrum, std::vector<double>* normalized_generalized_cepstrum) const { ! if (!is_valid_ || generalized_cepstrum.empty() || NULL == normalized_generalized_cepstrum) { return false; } if (0.0 != gamma_) { const double* c1(&generalized_cepstrum[0]); --- 63,77 ---- const std::vector<double>& generalized_cepstrum, std::vector<double>* normalized_generalized_cepstrum) const { ! if (!is_valid_ || ! static_cast<std::size_t>(num_order_ + 1) != generalized_cepstrum.size() || NULL == normalized_generalized_cepstrum) { return false; } + if (normalized_generalized_cepstrum->size() < + static_cast<std::size_t>(num_order_ + 1)) { + normalized_generalized_cepstrum->resize(num_order_ + 1); + } + if (0.0 != gamma_) { const double* c1(&generalized_cepstrum[0]); Index: generalized_cepstrum_inverse_gain_normalization.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/generalized_cepstrum_inverse_gain_normalization.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** generalized_cepstrum_inverse_gain_normalization.cc 12 Oct 2016 13:39:46 -0000 1.1 --- generalized_cepstrum_inverse_gain_normalization.cc 12 Oct 2016 15:02:23 -0000 1.2 *************** *** 63,71 **** const std::vector<double>& normalized_generalized_cepstrum, std::vector<double>* generalized_cepstrum) const { ! if (!is_valid_ || normalized_generalized_cepstrum.empty() || NULL == generalized_cepstrum) { return false; } if (0.0 != gamma_) { const double* c1(&normalized_generalized_cepstrum[0]); --- 63,77 ---- const std::vector<double>& normalized_generalized_cepstrum, std::vector<double>* generalized_cepstrum) const { ! if (!is_valid_ || ! static_cast<std::size_t>(num_order_ + 1) != ! normalized_generalized_cepstrum.size() || NULL == generalized_cepstrum) { return false; } + if (generalized_cepstrum->size() < static_cast<std::size_t>(num_order_ + 1)) { + generalized_cepstrum->resize(num_order_ + 1); + } + if (0.0 != gamma_) { const double* c1(&normalized_generalized_cepstrum[0]); |
From: Keiichiro O. <ur...@us...> - 2016-10-12 13:39:49
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv14903 Modified Files: Makefile Added Files: generalized_cepstrum_inverse_gain_normalization.cc generalized_cepstrum_inverse_gain_normalization.h ignorm.cc Log Message: add ignorm command Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Makefile 12 Oct 2016 13:08:14 -0000 1.15 --- Makefile 12 Oct 2016 13:39:46 -0000 1.16 *************** *** 53,56 **** --- 53,57 ---- frequency_transform.cc \ generalized_cepstrum_gain_normalization.cc \ + generalized_cepstrum_inverse_gain_normalization.cc \ input_source_from_stream.cc \ input_source_interpolation.cc \ --- NEW FILE: generalized_cepstrum_inverse_gain_normalization.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_inverse_gain_normalization.h" #include <cmath> // std::pow, std::log #include <vector> // std::vector #include "sptk_utils.h" namespace sptk { GeneralizedCepstrumInverseGainNormalization:: GeneralizedCepstrumInverseGainNormalization(int num_order, double gamma) : num_order_(num_order), gamma_(gamma), is_valid_(true) { if (num_order_ < 0) { is_valid_ = false; } } bool GeneralizedCepstrumInverseGainNormalization::Run( const std::vector<double>& normalized_generalized_cepstrum, std::vector<double>* generalized_cepstrum) const { if (!is_valid_ || normalized_generalized_cepstrum.empty() || NULL == generalized_cepstrum) { return false; } if (0.0 != gamma_) { const double* c1(&normalized_generalized_cepstrum[0]); double* c2(&(*generalized_cepstrum)[0]); const double k(std::pow(c1[0], gamma_)); for (int m(num_order_); 1 <= m; --m) { c2[m] = k * c1[m]; } c2[0] = (k - 1.0) / gamma_; } else { std::copy(normalized_generalized_cepstrum.begin() + 1, normalized_generalized_cepstrum.end(), generalized_cepstrum->begin() + 1); (*generalized_cepstrum)[0] = std::log(normalized_generalized_cepstrum[0]); } return true; } } // namespace sptk --- NEW FILE: generalized_cepstrum_inverse_gain_normalization.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_INVERSE_GAIN_NORMALIZATION_H_ #define SPTK_SRC_GENERALIZED_CEPSTRUM_INVERSE_GAIN_NORMALIZATION_H_ #include <vector> // std::vector #include "sptk_utils.h" namespace sptk { class GeneralizedCepstrumInverseGainNormalization { public: // GeneralizedCepstrumInverseGainNormalization(int num_order, double gamma); // virtual ~GeneralizedCepstrumInverseGainNormalization() {} // int GetNumOrder() const { return num_order_; } // double GetGamma() const { return gamma_; } // bool IsValid() const { return is_valid_; } // bool Run(const std::vector<double>& normalized_generalized_cepstrum, std::vector<double>* generalized_cepstrum) const; private: // int num_order_; // double gamma_; // bool is_valid_; // DISALLOW_COPY_AND_ASSIGN(GeneralizedCepstrumInverseGainNormalization); }; } // namespace sptk #endif // SPTK_SRC_GENERALIZED_CEPSTRUM_INVERSE_GAIN_NORMALIZATION_H_ --- NEW FILE: ignorm.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 <fstream> #include <iostream> #include <sstream> #include <vector> #include "generalized_cepstrum_inverse_gain_normalization.h" #include "sptk_utils.h" namespace { const int kDefaultNumOrder(25); const double kDefaultGamma(0.0); void PrintUsage(std::ostream* stream) { // clang-format off *stream << std::endl; *stream << " ignorm - inverse gain normalization of generalized cepstrum" << std::endl; // NOLINT *stream << std::endl; *stream << " usage:" << std::endl; *stream << " ignorm [ options ] [ infile ] > stdout" << std::endl; *stream << " options:" << std::endl; *stream << " -m m : order of generalized cepstrum [" << kDefaultNumOrder << "]" << std::endl; // NOLINT *stream << " -a g : gamma [" << kDefaultGamma << "]" << std::endl; // NOLINT *stream << " -c c : gamma = -1 / (int) c" << std::endl; *stream << " -h : print this message" << std::endl; *stream << " infile:" << std::endl; *stream << " normalized generalized cepstrum (double) [stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; *stream << " generalized cepstrum (double)" << std::endl; *stream << " notice:" << std::endl; *stream << " value of c must be c >= 1 (double)" << 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 num_order(kDefaultNumOrder); double gamma(kDefaultGamma); for (;;) { const char option_char(getopt(argc, argv, "m:g:c: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("ignorm", 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("ignorm", 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("ignorm", error_message); return 1; } gamma = -1.0 / 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("ignorm", error_message); return 1; } std::istream& input_stream(ifs.fail() ? std::cin : ifs); // prepare for inverse gain normalization sptk::GeneralizedCepstrumInverseGainNormalization generalized_cepstrum_inverse_gain_normalization(num_order, gamma); if (!generalized_cepstrum_inverse_gain_normalization.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the condition."; sptk::PrintErrorMessage("ignorm", error_message); return 1; } const int length(num_order + 1); std::vector<double> normalized_generalized_cepstrum(length); std::vector<double> generalized_cepstrum(length); while (sptk::ReadStream(false, length, &normalized_generalized_cepstrum, &input_stream)) { if (!generalized_cepstrum_inverse_gain_normalization.Run( normalized_generalized_cepstrum, &generalized_cepstrum)) { std::ostringstream error_message; error_message << "Failed to run the normalization"; sptk::PrintErrorMessage("ignorm", error_message); return 1; } if (!sptk::WriteStream(length, generalized_cepstrum, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write an output sequence"; sptk::PrintErrorMessage("ignorm", error_message); return 1; } } return 0; } |
From: Keiichiro O. <ur...@us...> - 2016-10-12 13:08:16
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv13658 Modified Files: Makefile Added Files: generalized_cepstrum_gain_normalization.cc generalized_cepstrum_gain_normalization.h gnorm.cc Log Message: add gnorm command Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Makefile 12 Oct 2016 11:47:54 -0000 1.14 --- Makefile 12 Oct 2016 13:08:14 -0000 1.15 *************** *** 52,55 **** --- 52,56 ---- fast_fourier_transform.cc \ frequency_transform.cc \ + generalized_cepstrum_gain_normalization.cc \ input_source_from_stream.cc \ input_source_interpolation.cc \ --- NEW FILE: gnorm.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 <fstream> #include <iostream> #include <sstream> #include <vector> #include "generalized_cepstrum_gain_normalization.h" #include "sptk_utils.h" namespace { const int kDefaultNumOrder(25); const double kDefaultGamma(0.0); void PrintUsage(std::ostream* stream) { // clang-format off *stream << std::endl; *stream << " gnorm - gain normalization of generalized cepstrum" << std::endl; *stream << std::endl; *stream << " usage:" << std::endl; *stream << " gnorm [ options ] [ infile ] > stdout" << std::endl; *stream << " options:" << std::endl; *stream << " -m m : order of generalized cepstrum [" << kDefaultNumOrder << "]" << std::endl; // NOLINT *stream << " -a g : gamma [" << kDefaultGamma << "]" << std::endl; // NOLINT *stream << " -c c : gamma = -1 / (int) c" << std::endl; *stream << " -h : print this message" << std::endl; *stream << " infile:" << std::endl; *stream << " generalized cepstrum (double) [stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; *stream << " normalized generalized cepstrum (double)" << std::endl; *stream << " notice:" << std::endl; *stream << " value of c must be c >= 1 (double)" << 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 num_order(kDefaultNumOrder); double gamma(kDefaultGamma); for (;;) { const char option_char(getopt(argc, argv, "m:g:c: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("gnorm", 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("gnorm", 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("gnorm", error_message); return 1; } gamma = -1.0 / 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("gnorm", error_message); return 1; } std::istream& input_stream(ifs.fail() ? std::cin : ifs); // prepare for gain normalization sptk::GeneralizedCepstrumGainNormalization generalized_cepstrum_gain_normalization(num_order, gamma); if (!generalized_cepstrum_gain_normalization.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the condition."; sptk::PrintErrorMessage("gnorm", error_message); return 1; } const int length(num_order + 1); std::vector<double> generalized_cepstrum(length); std::vector<double> normalized_generalized_cepstrum(length); while ( sptk::ReadStream(false, length, &generalized_cepstrum, &input_stream)) { if (!generalized_cepstrum_gain_normalization.Run( generalized_cepstrum, &normalized_generalized_cepstrum)) { std::ostringstream error_message; error_message << "Failed to run the normalization"; sptk::PrintErrorMessage("gnorm", error_message); return 1; } if (!sptk::WriteStream(length, normalized_generalized_cepstrum, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write an output sequence"; sptk::PrintErrorMessage("gnorm", error_message); return 1; } } return 0; } --- NEW FILE: generalized_cepstrum_gain_normalization.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_gain_normalization.h" #include <cmath> // std::pow, std::exp #include <vector> // std::vector #include "sptk_utils.h" namespace sptk { GeneralizedCepstrumGainNormalization::GeneralizedCepstrumGainNormalization( int num_order, double gamma) : num_order_(num_order), gamma_(gamma), is_valid_(true) { if (num_order_ < 0) { is_valid_ = false; } } bool GeneralizedCepstrumGainNormalization::Run( const std::vector<double>& generalized_cepstrum, std::vector<double>* normalized_generalized_cepstrum) const { if (!is_valid_ || generalized_cepstrum.empty() || NULL == normalized_generalized_cepstrum) { return false; } if (0.0 != gamma_) { const double* c1(&generalized_cepstrum[0]); double* c2(&(*normalized_generalized_cepstrum)[0]); const double k(1.0 + gamma_ * c1[0]); for (int m(num_order_); 1 <= m; --m) { c2[m] = c1[m] / k; } c2[0] = std::pow(k, 1.0 / gamma_); } else { std::copy(generalized_cepstrum.begin() + 1, generalized_cepstrum.end(), normalized_generalized_cepstrum->begin() + 1); (*normalized_generalized_cepstrum)[0] = std::exp(generalized_cepstrum[0]); } return true; } } // namespace sptk --- NEW FILE: generalized_cepstrum_gain_normalization.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_GAIN_NORMALIZATION_H_ #define SPTK_SRC_GENERALIZED_CEPSTRUM_GAIN_NORMALIZATION_H_ #include <vector> // std::vector #include "sptk_utils.h" namespace sptk { class GeneralizedCepstrumGainNormalization { public: // GeneralizedCepstrumGainNormalization(int num_order, double gamma); // virtual ~GeneralizedCepstrumGainNormalization() {} // int GetNumOrder() const { return num_order_; } // double GetGamma() const { return gamma_; } // bool IsValid() const { return is_valid_; } // bool Run(const std::vector<double>& generalized_cepstrum, std::vector<double>* normalized_generalized_cepstrum) const; private: // int num_order_; // double gamma_; // bool is_valid_; // DISALLOW_COPY_AND_ASSIGN(GeneralizedCepstrumGainNormalization); }; } // namespace sptk #endif // SPTK_SRC_GENERALIZED_CEPSTRUM_GAIN_NORMALIZATION_H_ |
From: Keiichiro O. <ur...@us...> - 2016-10-12 12:27:55
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11775 Modified Files: excite.cc Log Message: remove InputSourcePreprocessingForFilterGain Index: excite.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/excite.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** excite.cc 12 Oct 2016 12:14:38 -0000 1.4 --- excite.cc 12 Oct 2016 12:27:53 -0000 1.5 *************** *** 50,54 **** #include "excitation_generation.h" #include "input_source_from_stream.h" - #include "input_source_preprocessing_for_filter_gain.h" #include "m_sequence_generation.h" #include "normal_distributed_random_value_generation.h" --- 50,53 ---- *************** *** 174,186 **** // Prepare input source interpolation. sptk::InputSourceFromStream input_source_from_stream(false, 1, &input_stream); - sptk::InputSourcePreprocessingForFilterGain - input_source_preprocessing_for_filter_gain( - sptk::InputSourcePreprocessingForFilterGain::FilterGainType::kLinear, - &input_source_from_stream); sptk::InputSourceInterpolationWithMagicNumber input_source_interpolation_with_magic_number( frame_period, interpolation_period, false, ! kMagicNumberForUnvoicedFrame, ! &input_source_preprocessing_for_filter_gain); if (!input_source_interpolation_with_magic_number.IsValid()) { std::ostringstream error_message; --- 173,180 ---- // Prepare input source interpolation. sptk::InputSourceFromStream input_source_from_stream(false, 1, &input_stream); sptk::InputSourceInterpolationWithMagicNumber input_source_interpolation_with_magic_number( frame_period, interpolation_period, false, ! kMagicNumberForUnvoicedFrame, &input_source_from_stream); if (!input_source_interpolation_with_magic_number.IsValid()) { std::ostringstream error_message; |
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11215 Modified Files: acorr.cc all_pole_digital_filter.cc all_pole_digital_filter.h all_zero_digital_filter.cc all_zero_digital_filter.h autocorrelation.cc autocorrelation.h c2mpir.cc cepstrum_to_minimum_phase_impulse_response.cc cepstrum_to_minimum_phase_impulse_response.h excitation_generation.cc excitation_generation.h excite.cc fast_fourier_transform.cc fast_fourier_transform.h fft.cc freqt.cc frequency_transform.cc frequency_transform.h ifft.cc input_source_from_stream.cc input_source_from_stream.h input_source_interpolation.cc input_source_interpolation.h input_source_interpolation_with_magic_number.cc input_source_interpolation_with_magic_number.h input_source_preprocessing_for_filter_gain.cc input_source_preprocessing_for_filter_gain.h levdur.cc levinson_durbin_recursion.cc levinson_durbin_recursion.h lpc.cc m_sequence_generation.cc mseq.cc normal_distributed_random_value_generation.cc nrand.cc poledf.cc sptk_utils.cc sptk_utils.h zerodf.cc Added Files: .clang-format Log Message: fix code format by clang-format command Index: frequency_transform.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/frequency_transform.cc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** frequency_transform.cc 23 Sep 2016 05:42:45 -0000 1.8 --- frequency_transform.cc 12 Oct 2016 12:14:38 -0000 1.9 *************** *** 50,60 **** namespace sptk { ! bool FrequencyTransform::Run( ! const std::vector<double>& minimum_phase_sequence, ! std::vector<double>* warped_sequence, ! FrequencyTransform::Buffer* buffer) const { // check inputs ! if (minimum_phase_sequence.empty() || ! NULL == warped_sequence || NULL == buffer) { return false; --- 50,58 ---- namespace sptk { ! bool FrequencyTransform::Run(const std::vector<double>& minimum_phase_sequence, ! std::vector<double>* warped_sequence, ! FrequencyTransform::Buffer* buffer) const { // check inputs ! if (minimum_phase_sequence.empty() || NULL == warped_sequence || NULL == buffer) { return false; *************** *** 68,75 **** const int num_input_order(minimum_phase_sequence.size() - 1); ! if (0.0 == alpha_ && ! num_input_order == num_output_order_) { ! std::copy(minimum_phase_sequence.begin(), ! minimum_phase_sequence.end(), warped_sequence->begin()); return true; --- 66,71 ---- const int num_input_order(minimum_phase_sequence.size() - 1); ! if (0.0 == alpha_ && num_input_order == num_output_order_) { ! std::copy(minimum_phase_sequence.begin(), minimum_phase_sequence.end(), warped_sequence->begin()); return true; Index: sptk_utils.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/sptk_utils.cc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** sptk_utils.cc 29 Jul 2016 07:26:20 -0000 1.9 --- sptk_utils.cc 12 Oct 2016 12:14:38 -0000 1.10 *************** *** 53,58 **** bool ReadStream(double* read_data, std::istream* input_stream) { ! if (NULL == read_data || ! NULL == input_stream) { return false; } --- 53,57 ---- bool ReadStream(double* read_data, std::istream* input_stream) { ! if (NULL == read_data || NULL == input_stream) { return false; } *************** *** 71,77 **** std::vector<double>* sequence_to_read, std::istream* input_stream) { ! if (read_size <= 0 || ! NULL == sequence_to_read || ! NULL == input_stream) { return false; } --- 70,74 ---- std::vector<double>* sequence_to_read, std::istream* input_stream) { ! if (read_size <= 0 || NULL == sequence_to_read || NULL == input_stream) { return false; } *************** *** 96,107 **** // Use std::ceil to zero incomplete data // as gcount may not be a multiple of sizeof(double). ! const int num_zeros(std::ceil( ! static_cast<double>(num_bytes - gcount) / type_byte)); if (num_zeros < 0) { return false; // Something wrong! } ! std::fill(sequence_to_read->end() - num_zeros, ! sequence_to_read->end(), 0.0); --- 93,103 ---- // Use std::ceil to zero incomplete data // as gcount may not be a multiple of sizeof(double). ! const int num_zeros( ! std::ceil(static_cast<double>(num_bytes - gcount) / type_byte)); if (num_zeros < 0) { return false; // Something wrong! } ! std::fill(sequence_to_read->end() - num_zeros, sequence_to_read->end(), 0.0); *************** *** 123,131 **** } ! bool WriteStream(int write_size, ! const std::vector<double>& sequence_to_write, std::ostream* output_stream) { ! if (write_size <= 0 || ! NULL == output_stream) { return false; } --- 119,125 ---- } ! bool WriteStream(int write_size, const std::vector<double>& sequence_to_write, std::ostream* output_stream) { ! if (write_size <= 0 || NULL == output_stream) { return false; } Index: input_source_from_stream.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_from_stream.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** input_source_from_stream.h 12 Oct 2016 11:13:51 -0000 1.2 --- input_source_from_stream.h 12 Oct 2016 12:14:38 -0000 1.3 *************** *** 59,66 **** InputSourceFromStream(bool zero_padding, int read_size, std::istream* input_stream) ! : zero_padding_(zero_padding), read_size_(read_size), ! input_stream_(input_stream), is_valid_(true) { ! if (read_size <= 0 || ! NULL == input_stream) { is_valid_ = false; } --- 59,67 ---- InputSourceFromStream(bool zero_padding, int read_size, std::istream* input_stream) ! : zero_padding_(zero_padding), ! read_size_(read_size), ! input_stream_(input_stream), ! is_valid_(true) { ! if (read_size <= 0 || NULL == input_stream) { is_valid_ = false; } *************** *** 71,77 **** // ! virtual bool IsValid() const { ! return is_valid_; ! } // --- 72,76 ---- // ! virtual bool IsValid() const { return is_valid_; } // 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.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** cepstrum_to_minimum_phase_impulse_response.cc 12 Oct 2016 04:31:24 -0000 1.4 --- cepstrum_to_minimum_phase_impulse_response.cc 12 Oct 2016 12:14:38 -0000 1.5 *************** *** 55,61 **** // check inputs if (cepstrum_coefficient.size() != ! static_cast<std::size_t>(num_input_order_ + 1) || ! NULL == minimum_phase_impulse_response || ! !is_valid_) { return false; } --- 55,60 ---- // check inputs if (cepstrum_coefficient.size() != ! static_cast<std::size_t>(num_input_order_ + 1) || ! NULL == minimum_phase_impulse_response || !is_valid_) { return false; } Index: all_pole_digital_filter.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/all_pole_digital_filter.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** all_pole_digital_filter.h 11 Oct 2016 06:38:27 -0000 1.4 --- all_pole_digital_filter.h 12 Oct 2016 12:14:38 -0000 1.5 *************** *** 64,70 **** // ! void Clear() { ! std::fill(signals_.begin(), signals_.end(), 0.0); ! } private: --- 64,68 ---- // ! void Clear() { std::fill(signals_.begin(), signals_.end(), 0.0); } private: *************** *** 81,85 **** // AllPoleDigitalFilter(int num_filter_order, bool transposition) ! : num_filter_order_(num_filter_order), transposition_(transposition), is_valid_(true) { if (num_filter_order_ < 0) { --- 79,84 ---- // AllPoleDigitalFilter(int num_filter_order, bool transposition) ! : num_filter_order_(num_filter_order), ! transposition_(transposition), is_valid_(true) { if (num_filter_order_ < 0) { *************** *** 92,112 **** // ! int GetNumFilterOrder() const { ! return num_filter_order_; ! } // ! bool GetTranspositionFlag() const { ! return transposition_; ! } // ! bool IsValid() const { ! return is_valid_; ! } // ! bool Run(const std::vector<double>& filter_coefficients, ! double filter_input, double* filter_output, AllPoleDigitalFilter::StoredSignals* signals) const; --- 91,105 ---- // ! int GetNumFilterOrder() const { return num_filter_order_; } // ! bool GetTranspositionFlag() const { return transposition_; } // ! bool IsValid() const { return is_valid_; } // ! bool Run(const std::vector<double>& filter_coefficients, double filter_input, ! double* filter_output, AllPoleDigitalFilter::StoredSignals* signals) const; Index: nrand.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/nrand.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** nrand.cc 12 Oct 2016 04:31:24 -0000 1.3 --- nrand.cc 12 Oct 2016 12:14:38 -0000 1.4 *************** *** 59,62 **** --- 59,63 ---- void PrintUsage(std::ostream* stream) { + // clang-format off *stream << std::endl; *stream << " nrand - generate normal distributed random value" << std::endl; *************** *** 78,81 **** --- 79,83 ---- *stream << " SPTK: version " << sptk::kVersion << std::endl; *stream << std::endl; + // clang-format on } *************** *** 96,101 **** if (!sptk::ConvertStringToInteger(optarg, &output_length)) { std::ostringstream error_message; ! error_message << ! "The argument for the -l option must be integer"; sptk::PrintErrorMessage("nrand", error_message); return 1; --- 98,102 ---- if (!sptk::ConvertStringToInteger(optarg, &output_length)) { std::ostringstream error_message; ! error_message << "The argument for the -l option must be integer"; sptk::PrintErrorMessage("nrand", error_message); return 1; *************** *** 106,111 **** if (!sptk::ConvertStringToInteger(optarg, &seed)) { std::ostringstream error_message; ! error_message << ! "The argument for the -s option must be integer"; sptk::PrintErrorMessage("nrand", error_message); return 1; --- 107,111 ---- if (!sptk::ConvertStringToInteger(optarg, &seed)) { std::ostringstream error_message; ! error_message << "The argument for the -s option must be integer"; sptk::PrintErrorMessage("nrand", error_message); return 1; *************** *** 116,121 **** if (!sptk::ConvertStringToDouble(optarg, &mean)) { std::ostringstream error_message; ! error_message << ! "The argument for the -m option must be double"; sptk::PrintErrorMessage("nrand", error_message); return 1; --- 116,120 ---- if (!sptk::ConvertStringToDouble(optarg, &mean)) { std::ostringstream error_message; ! error_message << "The argument for the -m option must be double"; sptk::PrintErrorMessage("nrand", error_message); return 1; *************** *** 125,133 **** case 'v': { double variance; ! if (!sptk::ConvertStringToDouble(optarg, &variance) || ! variance < 0.0) { std::ostringstream error_message; ! error_message << ! "The argument for the -v option must be double"; sptk::PrintErrorMessage("nrand", error_message); return 1; --- 124,130 ---- case 'v': { double variance; ! if (!sptk::ConvertStringToDouble(optarg, &variance) || variance < 0.0) { std::ostringstream error_message; ! error_message << "The argument for the -v option must be double"; sptk::PrintErrorMessage("nrand", error_message); return 1; *************** *** 140,145 **** standard_deviation < 0.0) { std::ostringstream error_message; ! error_message << ! "The argument for the -v option must be double"; sptk::PrintErrorMessage("nrand", error_message); return 1; --- 137,141 ---- standard_deviation < 0.0) { std::ostringstream error_message; ! error_message << "The argument for the -v option must be double"; sptk::PrintErrorMessage("nrand", error_message); return 1; Index: levinson_durbin_recursion.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/levinson_durbin_recursion.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** levinson_durbin_recursion.h 8 Oct 2016 15:14:59 -0000 1.3 --- levinson_durbin_recursion.h 12 Oct 2016 12:14:38 -0000 1.4 *************** *** 58,61 **** --- 58,62 ---- Buffer() {} virtual ~Buffer() {} + private: std::vector<double> c_; *************** *** 78,90 **** // ! double GetEpsilon() const { ! return epsilon_; ! } // bool Run(const std::vector<double>& autocorrelation_sequence, std::vector<double>* linear_predictive_coefficients, ! LevinsonDurbinRecursion::Buffer* buffer, ! bool* is_stable) const; private: --- 79,88 ---- // ! double GetEpsilon() const { return epsilon_; } // bool Run(const std::vector<double>& autocorrelation_sequence, std::vector<double>* linear_predictive_coefficients, ! LevinsonDurbinRecursion::Buffer* buffer, bool* is_stable) const; private: Index: acorr.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/acorr.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** acorr.cc 1 Apr 2016 09:05:46 -0000 1.3 --- acorr.cc 12 Oct 2016 12:14:38 -0000 1.4 *************** *** 58,61 **** --- 58,62 ---- void PrintUsage(std::ostream* stream) { + // clang-format off *stream << std::endl; *stream << " acorr - obtain autocorrelation sequence" << std::endl; *************** *** 74,77 **** --- 75,79 ---- *stream << " SPTK: version " << sptk::kVersion << std::endl; *stream << std::endl; + // clang-format on } *************** *** 91,96 **** frame_length <= 0) { std::ostringstream error_message; ! error_message << ! "The argument for the -l option must be a positive integer"; sptk::PrintErrorMessage("acorr", error_message); return 1; --- 93,98 ---- frame_length <= 0) { std::ostringstream error_message; ! error_message ! << "The argument for the -l option must be a positive integer"; sptk::PrintErrorMessage("acorr", error_message); return 1; *************** *** 102,107 **** num_order < 0) { std::ostringstream error_message; ! error_message << ! "The argument for the -m option must be a non-negative integer"; sptk::PrintErrorMessage("acorr", error_message); return 1; --- 104,109 ---- num_order < 0) { std::ostringstream error_message; ! error_message << "The argument for the -m option must be a " ! << "non-negative integer"; sptk::PrintErrorMessage("acorr", error_message); return 1; *************** *** 146,151 **** std::vector<double> output_sequence(output_length); ! while (sptk::ReadStream(false, frame_length, &input_sequence, ! &input_stream)) { if (!autocorrelation.Run(input_sequence, &output_sequence)) { std::ostringstream error_message; --- 148,153 ---- std::vector<double> output_sequence(output_length); ! while ( ! sptk::ReadStream(false, frame_length, &input_sequence, &input_stream)) { if (!autocorrelation.Run(input_sequence, &output_sequence)) { std::ostringstream error_message; Index: levdur.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/levdur.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** levdur.cc 8 Oct 2016 15:14:59 -0000 1.3 --- levdur.cc 12 Oct 2016 12:14:38 -0000 1.4 *************** *** 65,68 **** --- 65,69 ---- void PrintUsage(std::ostream* stream) { + // clang-format off *stream << std::endl; *stream << " levdur - solve an autocorrelation normal equation" << std::endl; *************** *** 91,94 **** --- 92,96 ---- *stream << " SPTK: version " << sptk::kVersion << std::endl; *stream << std::endl; + // clang-format on } *************** *** 109,114 **** num_order < 0) { std::ostringstream error_message; ! error_message << ! "The argument for the -m option must be a non-negative integer"; sptk::PrintErrorMessage("levdur", error_message); return 1; --- 111,116 ---- num_order < 0) { std::ostringstream error_message; ! error_message << "The argument for the -m option must be a " ! << "non-negative integer"; sptk::PrintErrorMessage("levdur", error_message); return 1; *************** *** 117,125 **** } case 'f': { ! if (!sptk::ConvertStringToDouble(optarg, &epsilon) || ! epsilon < 0.0) { std::ostringstream error_message; ! error_message << ! "The argument for the -f option must be a non-negative number"; sptk::PrintErrorMessage("levdur", error_message); return 1; --- 119,126 ---- } case 'f': { ! if (!sptk::ConvertStringToDouble(optarg, &epsilon) || epsilon < 0.0) { std::ostringstream error_message; ! error_message ! << "The argument for the -f option must be a non-negative number"; sptk::PrintErrorMessage("levdur", error_message); return 1; *************** *** 187,193 **** std::vector<double> linear_predictive_coefficients(length); ! for (int frame_index(0); ! sptk::ReadStream(false, length, &autocorrelation_sequence, ! &input_stream); ++frame_index) { bool is_stable(false); --- 188,193 ---- std::vector<double> linear_predictive_coefficients(length); ! for (int frame_index(0); sptk::ReadStream( ! false, length, &autocorrelation_sequence, &input_stream); ++frame_index) { bool is_stable(false); Index: autocorrelation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/autocorrelation.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** autocorrelation.h 25 Mar 2016 06:04:51 -0000 1.2 --- autocorrelation.h 12 Oct 2016 12:14:38 -0000 1.3 *************** *** 68,74 **** // ! int GetNumOrder() const { ! return num_order_; ! } // --- 68,72 ---- // ! int GetNumOrder() const { return num_order_; } // Index: excitation_generation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/excitation_generation.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** excitation_generation.h 12 Oct 2016 07:44:48 -0000 1.3 --- excitation_generation.h 12 Oct 2016 12:14:38 -0000 1.4 *************** *** 55,61 **** public: // ! ExcitationGeneration( ! InputSourceInterpolationWithMagicNumber *input_source, ! RandomGenerationInterface *random_generation); // --- 55,60 ---- public: // ! ExcitationGeneration(InputSourceInterpolationWithMagicNumber *input_source, ! RandomGenerationInterface *random_generation); // *************** *** 63,73 **** // ! bool IsValid() const { ! return is_valid_; ! } // ! bool Get(double *excitation, double *pulse, double *noise, ! double *pitch); private: --- 62,69 ---- // ! bool IsValid() const { return is_valid_; } // ! bool Get(double *excitation, double *pulse, double *noise, double *pitch); private: Index: m_sequence_generation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/m_sequence_generation.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** m_sequence_generation.cc 12 Oct 2016 04:31:24 -0000 1.4 --- m_sequence_generation.cc 12 Oct 2016 12:14:38 -0000 1.5 *************** *** 46,55 **** namespace { ! const int kInitialValue(0x55555555); ! const int kB0(0x00000001); ! const int kB28(0x10000000); ! const int kB31(0x80000000); ! const int kB31F(0x7fffffff); ! const int kZ(0x00000000); }; --- 46,55 ---- namespace { ! const int kInitialValue(0x55555555); ! const int kB0(0x00000001); ! const int kB28(0x10000000); ! const int kB31(0x80000000); ! const int kB31F(0x7fffffff); ! const int kZ(0x00000000); }; *************** *** 58,64 **** MSequenceGeneration::MSequenceGeneration() : x_(kInitialValue) {} ! void MSequenceGeneration::Reset() { ! x_ = kInitialValue; ! } bool MSequenceGeneration::Get(double *output) { --- 58,62 ---- MSequenceGeneration::MSequenceGeneration() : x_(kInitialValue) {} ! void MSequenceGeneration::Reset() { x_ = kInitialValue; } bool MSequenceGeneration::Get(double *output) { Index: lpc.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/lpc.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lpc.cc 8 Oct 2016 15:14:59 -0000 1.2 --- lpc.cc 12 Oct 2016 12:14:38 -0000 1.3 *************** *** 67,70 **** --- 67,71 ---- void PrintUsage(std::ostream* stream) { + // clang-format off *stream << std::endl; *stream << " lpc - LPC analysis using Levinson-Durbin recursion" << std::endl; *************** *** 93,96 **** --- 94,98 ---- *stream << " SPTK: version " << sptk::kVersion << std::endl; *stream << std::endl; + // clang-format on } *************** *** 112,117 **** frame_length <= 0) { std::ostringstream error_message; ! error_message << ! "The argument for the -l option must be a positive integer"; sptk::PrintErrorMessage("lpc", error_message); return 1; --- 114,119 ---- frame_length <= 0) { std::ostringstream error_message; ! error_message ! << "The argument for the -l option must be a positive integer"; sptk::PrintErrorMessage("lpc", error_message); return 1; *************** *** 123,128 **** num_order < 0) { std::ostringstream error_message; ! error_message << ! "The argument for the -m option must be a non-negative integer"; sptk::PrintErrorMessage("lpc", error_message); return 1; --- 125,130 ---- num_order < 0) { std::ostringstream error_message; ! error_message << "The argument for the -m option must be a " ! << "non-negative integer"; sptk::PrintErrorMessage("lpc", error_message); return 1; *************** *** 131,139 **** } case 'f': { ! if (!sptk::ConvertStringToDouble(optarg, &epsilon) || ! epsilon < 0.0) { std::ostringstream error_message; ! error_message << ! "The argument for the -f option must be a non-negative number"; sptk::PrintErrorMessage("lpc", error_message); return 1; --- 133,140 ---- } case 'f': { ! if (!sptk::ConvertStringToDouble(optarg, &epsilon) || epsilon < 0.0) { std::ostringstream error_message; ! error_message ! << "The argument for the -f option must be a non-negative number"; sptk::PrintErrorMessage("lpc", error_message); return 1; --- NEW FILE: .clang-format --- BasedOnStyle: Google AllowShortBlocksOnASingleLine: false AllowShortBlocksOnASingleLine: false Index: input_source_preprocessing_for_filter_gain.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_preprocessing_for_filter_gain.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** input_source_preprocessing_for_filter_gain.h 12 Oct 2016 11:13:51 -0000 1.3 --- input_source_preprocessing_for_filter_gain.h 12 Oct 2016 12:14:38 -0000 1.4 *************** *** 46,50 **** #define SPTK_SRC_INPUT_SOURCE_PREPROCESSING_FOR_FILTER_GAIN_H_ ! #include <vector> // std::vector #include "input_source_interface.h" --- 46,50 ---- #define SPTK_SRC_INPUT_SOURCE_PREPROCESSING_FOR_FILTER_GAIN_H_ ! #include <vector> // std::vector #include "input_source_interface.h" *************** *** 67,72 **** InputSourceInterface* source) : gain_type_(gain_type), source_(source), is_valid_(true) { ! if (NULL == source || ! !source->IsValid()) { is_valid_ = false; return; --- 67,71 ---- InputSourceInterface* source) : gain_type_(gain_type), source_(source), is_valid_(true) { ! if (NULL == source || !source->IsValid()) { is_valid_ = false; return; *************** *** 78,89 **** // ! FilterGainType GetFilterGainType() const { ! return gain_type_; ! } // ! virtual bool IsValid() const { ! return is_valid_; ! } // --- 77,84 ---- // ! FilterGainType GetFilterGainType() const { return gain_type_; } // ! virtual bool IsValid() const { return is_valid_; } // Index: c2mpir.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/c2mpir.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** c2mpir.cc 12 Oct 2016 04:31:24 -0000 1.3 --- c2mpir.cc 12 Oct 2016 12:14:38 -0000 1.4 *************** *** 58,61 **** --- 58,62 ---- void PrintUsage(std::ostream* stream) { + // clang-format off *stream << std::endl; *stream << " c2mpir - cepstrum to minimum phase impulse response" << std::endl; // NOLINT *************** *** 75,78 **** --- 76,80 ---- *stream << " SPTK: version " << sptk::kVersion << std::endl; *stream << std::endl; + // clang-format on } *************** *** 92,97 **** num_input_order < 0) { std::ostringstream error_message; ! error_message << ! "The argument for the -m option must be a non-negative integer"; sptk::PrintErrorMessage("c2mpir", error_message); return 1; --- 94,99 ---- num_input_order < 0) { std::ostringstream error_message; ! error_message << "The argument for the -m option must be a " ! << "non-negative integer"; sptk::PrintErrorMessage("c2mpir", error_message); return 1; *************** *** 103,108 **** num_output_order < 0) { std::ostringstream error_message; ! error_message << ! "The argument for the -M option must be a non-negative integer"; sptk::PrintErrorMessage("c2mpir", error_message); return 1; --- 105,110 ---- num_output_order < 0) { std::ostringstream error_message; ! error_message << "The argument for the -M option must be a " ! << "non-negative integer"; sptk::PrintErrorMessage("c2mpir", error_message); return 1; *************** *** 114,119 **** num_output_order < 1) { std::ostringstream error_message; ! error_message << ! "The argument for the -M option must be bigger than 0"; sptk::PrintErrorMessage("c2mpir", error_message); return 1; --- 116,121 ---- num_output_order < 1) { std::ostringstream error_message; ! error_message ! << "The argument for the -M option must be bigger than 0"; sptk::PrintErrorMessage("c2mpir", error_message); return 1; *************** *** 149,154 **** // prepare converter 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; --- 151,156 ---- // prepare converter 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; Index: excite.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/excite.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** excite.cc 12 Oct 2016 07:44:48 -0000 1.3 --- excite.cc 12 Oct 2016 12:14:38 -0000 1.4 *************** *** 64,67 **** --- 64,68 ---- void PrintUsage(std::ostream* stream) { + // clang-format off *stream << std::endl; *stream << " excite - generate excitation" << std::endl; *************** *** 86,89 **** --- 87,91 ---- *stream << " SPTK: version " << sptk::kVersion << std::endl; *stream << std::endl; + // clang-format on } *************** *** 106,111 **** frame_period <= 0) { std::ostringstream error_message; ! error_message << ! "The argument for the -p option must be a positive integer"; sptk::PrintErrorMessage("excite", error_message); return 1; --- 108,113 ---- frame_period <= 0) { std::ostringstream error_message; ! error_message ! << "The argument for the -p option must be a positive integer"; sptk::PrintErrorMessage("excite", error_message); return 1; *************** *** 117,122 **** interpolation_period < 0) { std::ostringstream error_message; ! error_message << ! "The argument for the -i option must be a non-negative integer"; sptk::PrintErrorMessage("excite", error_message); return 1; --- 119,124 ---- interpolation_period < 0) { std::ostringstream error_message; ! error_message << "The argument for the -i option must be a " ! << "non-negative integer"; sptk::PrintErrorMessage("excite", error_message); return 1; *************** *** 150,155 **** if (frame_period / 2 < interpolation_period) { std::ostringstream error_message; ! error_message << ! "Interpolation period should not be greater than half frame period"; sptk::PrintErrorMessage("excite", error_message); return 1; --- 152,157 ---- if (frame_period / 2 < interpolation_period) { std::ostringstream error_message; ! error_message ! << "Interpolation period should not be greater than half frame period"; sptk::PrintErrorMessage("excite", error_message); return 1; *************** *** 174,186 **** sptk::InputSourcePreprocessingForFilterGain input_source_preprocessing_for_filter_gain( ! sptk::InputSourcePreprocessingForFilterGain::FilterGainType::kLinear, ! &input_source_from_stream); sptk::InputSourceInterpolationWithMagicNumber input_source_interpolation_with_magic_number( ! frame_period, ! interpolation_period, ! false, ! kMagicNumberForUnvoicedFrame, ! &input_source_preprocessing_for_filter_gain); if (!input_source_interpolation_with_magic_number.IsValid()) { std::ostringstream error_message; --- 176,186 ---- sptk::InputSourcePreprocessingForFilterGain input_source_preprocessing_for_filter_gain( ! sptk::InputSourcePreprocessingForFilterGain::FilterGainType::kLinear, ! &input_source_from_stream); sptk::InputSourceInterpolationWithMagicNumber input_source_interpolation_with_magic_number( ! frame_period, interpolation_period, false, ! kMagicNumberForUnvoicedFrame, ! &input_source_preprocessing_for_filter_gain); if (!input_source_interpolation_with_magic_number.IsValid()) { std::ostringstream error_message; *************** *** 191,195 **** // Run excitation generation. ! sptk::RandomGenerationInterface *random_generation(NULL); try { if (use_normal_distributed_random_value) { --- 191,195 ---- // Run excitation generation. ! sptk::RandomGenerationInterface* random_generation(NULL); try { if (use_normal_distributed_random_value) { *************** *** 220,224 **** } } ! } catch (std::exception *e) { std::ostringstream error_message; error_message << "Unknown exception"; --- 220,224 ---- } } ! } catch (std::exception* e) { std::ostringstream error_message; error_message << "Unknown exception"; Index: levinson_durbin_recursion.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/levinson_durbin_recursion.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** levinson_durbin_recursion.cc 8 Oct 2016 15:14:59 -0000 1.4 --- levinson_durbin_recursion.cc 12 Oct 2016 12:14:38 -0000 1.5 *************** *** 53,62 **** 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() || ! NULL == linear_predictive_coefficients || ! NULL == buffer) { return false; } --- 53,60 ---- 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() || ! NULL == linear_predictive_coefficients || NULL == buffer) { return false; } 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.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** input_source_interpolation_with_magic_number.h 12 Oct 2016 11:13:51 -0000 1.3 --- input_source_interpolation_with_magic_number.h 12 Oct 2016 12:14:38 -0000 1.4 *************** *** 57,64 **** // InputSourceInterpolationWithMagicNumber( ! int frame_period, ! int interpolation_period, ! bool use_final_frame_for_exceeded_frame, ! double magic_number, InputSourceInterface* source); --- 57,62 ---- // InputSourceInterpolationWithMagicNumber( ! int frame_period, int interpolation_period, ! bool use_final_frame_for_exceeded_frame, double magic_number, InputSourceInterface* source); *************** *** 67,78 **** // ! int GetFramePeriod() const { ! return frame_period_; ! } // ! int GetInterpolationPeriod() const { ! return interpolation_period_; ! } // --- 65,72 ---- // ! int GetFramePeriod() const { return frame_period_; } // ! int GetInterpolationPeriod() const { return interpolation_period_; } // *************** *** 82,93 **** // ! double GetMagicNumber() const { ! return magic_number_; ! } // ! bool IsValid() const { ! return is_valid_; ! } // --- 76,83 ---- // ! double GetMagicNumber() const { return magic_number_; } // ! bool IsValid() const { return is_valid_; } // Index: sptk_utils.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/sptk_utils.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** sptk_utils.h 29 Jul 2016 07:26:20 -0000 1.6 --- sptk_utils.h 12 Oct 2016 12:14:38 -0000 1.7 *************** *** 52,57 **** #ifndef DISALLOW_COPY_AND_ASSIGN ! #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ ! TypeName(const TypeName&); \ void operator=(const TypeName&) #endif --- 52,57 ---- #ifndef DISALLOW_COPY_AND_ASSIGN ! #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ ! TypeName(const TypeName&); \ void operator=(const TypeName&) #endif *************** *** 66,71 **** std::istream* input_stream); bool WriteStream(double data_to_write, std::ostream* output_stream); ! bool WriteStream(int write_size, ! const std::vector<double>& sequence_to_write, std::ostream* output_stream); const char* ConvertBooleanToString(bool input); --- 66,70 ---- std::istream* input_stream); bool WriteStream(double data_to_write, std::ostream* output_stream); ! bool WriteStream(int write_size, const std::vector<double>& sequence_to_write, std::ostream* output_stream); const char* ConvertBooleanToString(bool input); Index: normal_distributed_random_value_generation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/normal_distributed_random_value_generation.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** normal_distributed_random_value_generation.cc 12 Oct 2016 04:31:24 -0000 1.3 --- normal_distributed_random_value_generation.cc 12 Oct 2016 12:14:38 -0000 1.4 *************** *** 66,70 **** NormalDistributedRandomValueGeneration::NormalDistributedRandomValueGeneration( ! int seed) : seed_(seed), switch_(true) { next_ = static_cast<std::uint64_t>(seed_); } --- 66,71 ---- NormalDistributedRandomValueGeneration::NormalDistributedRandomValueGeneration( ! int seed) ! : seed_(seed), switch_(true) { next_ = static_cast<std::uint64_t>(seed_); } Index: fast_fourier_transform.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fast_fourier_transform.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** fast_fourier_transform.h 8 Feb 2016 11:42:45 -0000 1.5 --- fast_fourier_transform.h 12 Oct 2016 12:14:38 -0000 1.6 *************** *** 64,80 **** // ! void SetInverseFlag(bool inverse) { ! inverse_ = inverse; ! } // ! int GetNumDimension() const { ! return num_dimension_; ! } // ! bool GetInverseFlag() const { ! return inverse_; ! } // --- 64,74 ---- // ! void SetInverseFlag(bool inverse) { inverse_ = inverse; } // ! int GetNumDimension() const { return num_dimension_; } // ! bool GetInverseFlag() const { return inverse_; } // Index: fast_fourier_transform.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fast_fourier_transform.cc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** fast_fourier_transform.cc 29 Jul 2016 07:26:20 -0000 1.8 --- fast_fourier_transform.cc 12 Oct 2016 12:14:38 -0000 1.9 *************** *** 78,83 **** 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; --- 78,82 ---- 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; *************** *** 85,90 **** // prepare memories ! if (real_part_output->size() != ! static_cast<std::size_t>(num_dimension_)) { real_part_output->resize(num_dimension_); } --- 84,88 ---- // prepare memories ! if (real_part_output->size() != static_cast<std::size_t>(num_dimension_)) { real_part_output->resize(num_dimension_); } *************** *** 99,114 **** // get values and fill zero ! std::copy(real_part_input.begin(), ! real_part_input.end(), real_part_output->begin()); std::fill(real_part_output->begin() + real_part_input.size(), ! real_part_output->end(), ! 0.0); ! std::copy(imaginary_part_input.begin(), ! imaginary_part_input.end(), imaginary_part_output->begin()); std::fill(imaginary_part_output->begin() + imaginary_part_input.size(), ! imaginary_part_output->end(), ! 0.0); double* x; --- 97,108 ---- // get values and fill zero ! std::copy(real_part_input.begin(), real_part_input.end(), real_part_output->begin()); std::fill(real_part_output->begin() + real_part_input.size(), ! real_part_output->end(), 0.0); ! std::copy(imaginary_part_input.begin(), imaginary_part_input.end(), imaginary_part_output->begin()); std::fill(imaginary_part_output->begin() + imaginary_part_input.size(), ! imaginary_part_output->end(), 0.0); double* x; Index: freqt.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/freqt.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** freqt.cc 1 Apr 2016 09:05:46 -0000 1.5 --- freqt.cc 12 Oct 2016 12:14:38 -0000 1.6 *************** *** 60,63 **** --- 60,64 ---- void PrintUsage(std::ostream* stream) { + // clang-format off *stream << std::endl; *stream << " freqt - frequency transform" << std::endl; *************** *** 78,81 **** --- 79,83 ---- *stream << " SPTK: version " << sptk::kVersion << std::endl; *stream << std::endl; + // clang-format on } *************** *** 97,102 **** num_input_order < 0) { std::ostringstream error_message; ! error_message << ! "The argument for the -m option must be a non-negative integer"; sptk::PrintErrorMessage("freqt", error_message); return 1; --- 99,104 ---- num_input_order < 0) { std::ostringstream error_message; ! error_message << "The argument for the -m option must be a " ! << "non-negative integer"; sptk::PrintErrorMessage("freqt", error_message); return 1; *************** *** 108,113 **** num_output_order < 0) { std::ostringstream error_message; ! error_message << ! "The argument for the -M option must be a non-negative integer"; sptk::PrintErrorMessage("freqt", error_message); return 1; --- 110,115 ---- num_output_order < 0) { std::ostringstream error_message; ! error_message << "The argument for the -M option must be a " ! << "non-negative integer"; sptk::PrintErrorMessage("freqt", error_message); return 1; Index: input_source_interpolation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_interpolation.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** input_source_interpolation.cc 12 Oct 2016 11:13:51 -0000 1.3 --- input_source_interpolation.cc 12 Oct 2016 12:14:38 -0000 1.4 *************** *** 52,59 **** InputSourceInterpolation::InputSourceInterpolation( ! int frame_period, ! int interpolation_period, ! bool use_final_frame_for_exceeded_frame, ! InputSourceInterface* source) : frame_period_(frame_period), interpolation_period_(interpolation_period), --- 52,57 ---- InputSourceInterpolation::InputSourceInterpolation( ! int frame_period, int interpolation_period, ! bool use_final_frame_for_exceeded_frame, InputSourceInterface* source) : frame_period_(frame_period), interpolation_period_(interpolation_period), *************** *** 65,72 **** source_(source), is_valid_(true) { ! if (frame_period <= 0 || ! interpolation_period < 0 || ! frame_period / 2 < interpolation_period || ! NULL == source || !source->IsValid()) { is_valid_ = false; --- 63,68 ---- source_(source), is_valid_(true) { ! if (frame_period <= 0 || interpolation_period < 0 || ! frame_period / 2 < interpolation_period || NULL == source || !source->IsValid()) { is_valid_ = false; *************** *** 84,89 **** if (!source_->Get(&next_data_)) { next_data_.resize(data_length_); ! std::copy(curr_data_.begin(), curr_data_.end(), ! next_data_.begin()); remained_num_samples_ = 1; } --- 80,84 ---- if (!source_->Get(&next_data_)) { next_data_.resize(data_length_); ! std::copy(curr_data_.begin(), curr_data_.end(), next_data_.begin()); remained_num_samples_ = 1; } *************** *** 103,108 **** bool InputSourceInterpolation::Get(std::vector<double>* buffer) { ! if (NULL == buffer || ! !is_valid_) { return false; } --- 98,102 ---- bool InputSourceInterpolation::Get(std::vector<double>* buffer) { ! if (NULL == buffer || !is_valid_) { return false; } *************** *** 116,121 **** } ! std::copy(curr_data_.begin(), curr_data_.end(), ! buffer->begin()); --remained_num_samples_; --- 110,114 ---- } ! std::copy(curr_data_.begin(), curr_data_.end(), buffer->begin()); --remained_num_samples_; *************** *** 133,142 **** if (0 == point_index_in_frame_ % frame_period_) { // Update current and next data. ! std::copy(next_data_.begin(), next_data_.end(), ! curr_data_.begin()); if (!source_->Get(&next_data_)) { // Use the final data until the end of input sequence. ! std::copy(curr_data_.begin(), curr_data_.end(), ! next_data_.begin()); remained_num_samples_ = 1; } else { --- 126,133 ---- if (0 == point_index_in_frame_ % frame_period_) { // Update current and next data. ! std::copy(next_data_.begin(), next_data_.end(), curr_data_.begin()); if (!source_->Get(&next_data_)) { // Use the final data until the end of input sequence. ! std::copy(curr_data_.begin(), curr_data_.end(), next_data_.begin()); remained_num_samples_ = 1; } else { *************** *** 154,164 **** interpolation_period_)) { // Interpolate adjacent data. ! std::transform(curr_data_.begin(), curr_data_.end(), ! increment_.begin(), curr_data_.begin(), ! std::plus<double>()); } else if (0 == interpolation_period_ && frame_period_ / 2 == point_index_in_frame_) { ! std::copy(next_data_.begin(), next_data_.end(), ! curr_data_.begin()); } --- 145,153 ---- interpolation_period_)) { // Interpolate adjacent data. ! std::transform(curr_data_.begin(), curr_data_.end(), increment_.begin(), ! curr_data_.begin(), std::plus<double>()); } else if (0 == interpolation_period_ && frame_period_ / 2 == point_index_in_frame_) { ! std::copy(next_data_.begin(), next_data_.end(), curr_data_.begin()); } Index: input_source_preprocessing_for_filter_gain.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_preprocessing_for_filter_gain.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** input_source_preprocessing_for_filter_gain.cc 11 Oct 2016 06:01:29 -0000 1.2 --- input_source_preprocessing_for_filter_gain.cc 12 Oct 2016 12:14:38 -0000 1.3 *************** *** 51,58 **** namespace sptk { ! bool InputSourcePreprocessingForFilterGain::Get( ! std::vector<double>* buffer) { ! if (NULL == buffer || ! !is_valid_) { return false; } --- 51,56 ---- namespace sptk { ! bool InputSourcePreprocessingForFilterGain::Get(std::vector<double>* buffer) { ! if (NULL == buffer || !is_valid_) { return false; } *************** *** 67,71 **** break; } ! case InputSourcePreprocessingForFilterGain::FilterGainType::kUnityForAllZeroFilter: { // NOLINT if (0.0 == buffer->at(0)) return false; const double inverse_of_b0(1.0 / buffer->at(0)); --- 65,70 ---- break; } ! case InputSourcePreprocessingForFilterGain::FilterGainType:: ! kUnityForAllZeroFilter: { if (0.0 == buffer->at(0)) return false; const double inverse_of_b0(1.0 / buffer->at(0)); *************** *** 81,87 **** break; } ! default: { ! return false; ! } } --- 80,84 ---- break; } ! default: { return false; } } Index: frequency_transform.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/frequency_transform.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** frequency_transform.h 25 Mar 2016 06:04:51 -0000 1.7 --- frequency_transform.h 12 Oct 2016 12:14:38 -0000 1.8 *************** *** 58,61 **** --- 58,62 ---- Buffer() {} virtual ~Buffer() {} + private: std::vector<double> d_; *************** *** 79,95 **** // ! void SetAlpha(double alpha) { ! alpha_ = alpha; ! } // ! int GetNumOutputOrder() const { ! return num_output_order_; ! } // ! double GetAlpha() const { ! return alpha_; ! } // --- 80,90 ---- // ! void SetAlpha(double alpha) { alpha_ = alpha; } // ! int GetNumOutputOrder() const { return num_output_order_; } // ! double GetAlpha() const { return alpha_; } // Index: excitation_generation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/excitation_generation.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** excitation_generation.cc 12 Oct 2016 07:44:48 -0000 1.3 --- excitation_generation.cc 12 Oct 2016 12:14:38 -0000 1.4 *************** *** 53,60 **** 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; --- 53,61 ---- 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; *************** *** 62,67 **** } ! 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: 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.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** input_source_interpolation_with_magic_number.cc 12 Oct 2016 11:13:51 -0000 1.3 --- input_source_interpolation_with_magic_number.cc 12 Oct 2016 12:14:38 -0000 1.4 *************** *** 60,68 **** InputSourceInterpolationWithMagicNumber:: InputSourceInterpolationWithMagicNumber( ! int frame_period, ! int interpolation_period, ! bool use_final_frame_for_exceeded_frame, ! double magic_number, ! InputSourceInterface* source) : frame_period_(frame_period), interpolation_period_(interpolation_period), --- 60,66 ---- InputSourceInterpolationWithMagicNumber:: InputSourceInterpolationWithMagicNumber( ! int frame_period, int interpolation_period, ! bool use_final_frame_for_exceeded_frame, double magic_number, ! InputSourceInterface* source) : frame_period_(frame_period), interpolation_period_(interpolation_period), *************** *** 75,82 **** source_(source), is_valid_(true) { ! if (frame_period <= 0 || ! interpolation_period < 0 || ! frame_period / 2 < interpolation_period || ! NULL == source || !source->IsValid()) { is_valid_ = false; --- 73,78 ---- source_(source), is_valid_(true) { ! if (frame_period <= 0 || interpolation_period < 0 || ! frame_period / 2 < interpolation_period || NULL == source || !source->IsValid()) { is_valid_ = false; *************** *** 94,99 **** if (!source_->Get(&next_data_)) { next_data_.resize(data_length_); ! std::copy(curr_data_.begin(), curr_data_.end(), ! next_data_.begin()); remained_num_samples_ = 1; } --- 90,94 ---- if (!source_->Get(&next_data_)) { next_data_.resize(data_length_); ! std::copy(curr_data_.begin(), curr_data_.end(), next_data_.begin()); remained_num_samples_ = 1; } *************** *** 117,122 **** bool InputSourceInterpolationWithMagicNumber::Get(std::vector<double>* buffer) { ! if (NULL == buffer || ! !is_valid_) { return false; } --- 112,116 ---- bool InputSourceInterpolationWithMagicNumber::Get(std::vector<double>* buffer) { ! if (NULL == buffer || !is_valid_) { return false; } *************** *** 130,135 **** } ! std::copy(curr_data_.begin(), curr_data_.end(), ! buffer->begin()); --remained_num_samples_; --- 124,128 ---- } ! std::copy(curr_data_.begin(), curr_data_.end(), buffer->begin()); --remained_num_samples_; *************** *** 147,156 **** if (0 == point_index_in_frame_ % frame_period_) { // Update current and next data. ! std::copy(next_data_.begin(), next_data_.end(), ! curr_data_.begin()); if (!source_->Get(&next_data_)) { // Use the final data until the end of input sequence. ! std::copy(curr_data_.begin(), curr_data_.end(), ! next_data_.begin()); remained_num_samples_ = 1; } else { --- 140,147 ---- if (0 == point_index_in_frame_ % frame_period_) { // Update current and next data. ! std::copy(next_data_.begin(), next_data_.end(), curr_data_.begin()); if (!source_->Get(&next_data_)) { // Use the final data until the end of input sequence. ! std::copy(curr_data_.begin(), curr_data_.end(), next_data_.begin()); remained_num_samples_ = 1; } else { *************** *** 177,182 **** } else if (0 == interpolation_period_ && frame_period_ / 2 == point_index_in_frame_) { ! std::copy(next_data_.begin(), next_data_.end(), ! curr_data_.begin()); } --- 168,172 ---- } else if (0 == interpolation_period_ && frame_period_ / 2 == point_index_in_frame_) { ! std::copy(next_data_.begin(), next_data_.end(), curr_data_.begin()); } Index: zerodf.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/zerodf.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** zerodf.cc 11 Oct 2016 06:38:27 -0000 1.2 --- zerodf.cc 12 Oct 2016 12:14:38 -0000 1.3 *************** *** 64,67 **** --- 64,68 ---- void PrintUsage(std::ostream* stream) { + // clang-format off *stream << std::endl; *stream << " zerodf - all-zero digital filter for speech synthesis" << std::endl; // NOLINT *************** *** 85,88 **** --- 86,90 ---- *stream << " SPTK: version " << sptk::kVersion << std::endl; *stream << std::endl; + // clang-format on } *************** *** 105,110 **** num_filter_order < 0) { std::ostringstream error_message; ! error_message << ! "The argument for the -m option must be a non-negative integer"; sptk::PrintErrorMessage("zerodf", error_message); return 1; --- 107,112 ---- num_filter_order < 0) { std::ostringstream error_message; ! error_message << "The argument for the -m option must be a " ! << "non-negative integer"; sptk::PrintErrorMessage("zerodf", error_message); return 1; *************** *** 116,121 **** frame_period <= 0) { std::ostringstream error_message; ! error_message << ! "The argument for the -p option must be a positive integer"; sptk::PrintErrorMessage("zerodf", error_message); return 1; --- 118,123 ---- frame_period <= 0) { std::ostringstream error_message; ! error_message ! << "The argument for the -p option must be a positive integer"; sptk::PrintErrorMessage("zerodf", error_message); return 1; *************** *** 127,132 **** interpolation_period < 0) { std::ostringstream error_message; ! error_message << ! "The argument for the -i option must be a non-negative integer"; sptk::PrintErrorMessage("zerodf", error_message); return 1; --- 129,134 ---- interpolation_period < 0) { std::ostringstream error_message; ! error_message << "The argument for the -i option must be a " ! << "non-negative integer"; sptk::PrintErrorMessage("zerodf", error_message); return 1; *************** *** 155,160 **** if (frame_period / 2 < interpolation_period) { std::ostringstream error_message; ! error_message << ! "Interpolation period should not be greater than half frame period"; sptk::PrintErrorMessage("zerodf", error_message); return 1; --- 157,162 ---- if (frame_period / 2 < interpolation_period) { std::ostringstream error_message; ! error_message ! << "Interpolation period should not be greater than half frame period"; sptk::PrintErrorMessage("zerodf", error_message); return 1; *************** *** 206,218 **** &stream_for_filter_coefficients); const sptk::InputSourcePreprocessingForFilterGain::FilterGainType gain_type( ! gain_flag ? ! sptk::InputSourcePreprocessingForFilterGain::FilterGainType::kLinear : ! sptk::InputSourcePreprocessingForFilterGain::FilterGainType::kUnityForAllZeroFilter); // NOLINT s... [truncated message content] |
From: Takenori Y. <tak...@us...> - 2016-10-12 11:47:56
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10147 Modified Files: Makefile Log Message: convert tab to space Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Makefile 11 Oct 2016 06:01:28 -0000 1.13 --- Makefile 12 Oct 2016 11:47:54 -0000 1.14 *************** *** 46,63 **** SOURCES = all_pole_digital_filter.cc \ ! all_zero_digital_filter.cc \ ! autocorrelation.cc \ ! cepstrum_to_minimum_phase_impulse_response.cc \ excitation_generation.cc \ ! fast_fourier_transform.cc \ frequency_transform.cc \ ! input_source_from_stream.cc \ ! input_source_interpolation.cc \ input_source_interpolation_with_magic_number.cc \ ! input_source_preprocessing_for_filter_gain.cc \ ! levinson_durbin_recursion.cc \ ! m_sequence_generation.cc \ ! normal_distributed_random_value_generation.cc \ ! sptk_utils.cc OBJECTS = $(SOURCES:.cc=.o) --- 46,63 ---- SOURCES = all_pole_digital_filter.cc \ ! all_zero_digital_filter.cc \ ! autocorrelation.cc \ ! cepstrum_to_minimum_phase_impulse_response.cc \ excitation_generation.cc \ ! fast_fourier_transform.cc \ frequency_transform.cc \ ! input_source_from_stream.cc \ ! input_source_interpolation.cc \ input_source_interpolation_with_magic_number.cc \ ! input_source_preprocessing_for_filter_gain.cc \ ! levinson_durbin_recursion.cc \ ! m_sequence_generation.cc \ ! normal_distributed_random_value_generation.cc \ ! sptk_utils.cc OBJECTS = $(SOURCES:.cc=.o) |
From: Takenori Y. <tak...@us...> - 2016-10-12 11:13:53
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv8591 Modified Files: input_source_from_stream.h input_source_interface.h input_source_interpolation.cc input_source_interpolation.h input_source_interpolation_with_magic_number.cc input_source_interpolation_with_magic_number.h input_source_preprocessing_for_filter_gain.h Removed Files: input_source_preprocessing_interface.h Log Message: remove InputSourcePreprocessingInterface Index: input_source_from_stream.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_from_stream.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** input_source_from_stream.h 8 Oct 2016 15:14:59 -0000 1.1 --- input_source_from_stream.h 12 Oct 2016 11:13:51 -0000 1.2 *************** *** 60,69 **** std::istream* input_stream) : zero_padding_(zero_padding), read_size_(read_size), ! input_stream_(input_stream), is_valid_(false) { if (read_size <= 0 || NULL == input_stream) { ! return; } - is_valid_ = true; } --- 60,68 ---- std::istream* input_stream) : zero_padding_(zero_padding), read_size_(read_size), ! input_stream_(input_stream), is_valid_(true) { if (read_size <= 0 || NULL == input_stream) { ! is_valid_ = false; } } *************** *** 72,85 **** // - virtual bool GetZeroPaddingFlag() const { - return zero_padding_; - } - - // - virtual int GetReadSize() const { - return read_size_; - } - - // virtual bool IsValid() const { return is_valid_; --- 71,74 ---- Index: input_source_interpolation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_interpolation.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** input_source_interpolation.h 10 Oct 2016 14:34:04 -0000 1.2 --- input_source_interpolation.h 12 Oct 2016 11:13:51 -0000 1.3 *************** *** 48,52 **** #include <vector> // std::vector ! #include "input_source_preprocessing_interface.h" #include "sptk_utils.h" --- 48,52 ---- #include <vector> // std::vector ! #include "input_source_interface.h" #include "sptk_utils.h" *************** *** 59,63 **** int interpolation_period, bool use_final_frame_for_exceeded_frame, ! InputSourcePreprocessingInterface* source); // --- 59,63 ---- int interpolation_period, bool use_final_frame_for_exceeded_frame, ! InputSourceInterface* source); // *************** *** 113,117 **** // ! InputSourcePreprocessingInterface* source_; // --- 113,117 ---- // ! InputSourceInterface* source_; // Index: input_source_interpolation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_interpolation.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** input_source_interpolation.cc 10 Oct 2016 14:34:04 -0000 1.2 --- input_source_interpolation.cc 12 Oct 2016 11:13:51 -0000 1.3 *************** *** 55,59 **** int interpolation_period, bool use_final_frame_for_exceeded_frame, ! InputSourcePreprocessingInterface* source) : frame_period_(frame_period), interpolation_period_(interpolation_period), --- 55,59 ---- int interpolation_period, bool use_final_frame_for_exceeded_frame, ! InputSourceInterface* source) : frame_period_(frame_period), interpolation_period_(interpolation_period), Index: input_source_interface.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_interface.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** input_source_interface.h 8 Oct 2016 15:14:59 -0000 1.1 --- input_source_interface.h 12 Oct 2016 11:13:51 -0000 1.2 *************** *** 56,65 **** // - virtual bool GetZeroPaddingFlag() const = 0; - - // - virtual int GetReadSize() const = 0; - - // virtual bool IsValid() const = 0; --- 56,59 ---- Index: input_source_preprocessing_for_filter_gain.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_preprocessing_for_filter_gain.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** input_source_preprocessing_for_filter_gain.h 11 Oct 2016 06:01:29 -0000 1.2 --- input_source_preprocessing_for_filter_gain.h 12 Oct 2016 11:13:51 -0000 1.3 *************** *** 46,59 **** #define SPTK_SRC_INPUT_SOURCE_PREPROCESSING_FOR_FILTER_GAIN_H_ ! #include <vector> // std::vector #include "input_source_interface.h" - #include "input_source_preprocessing_interface.h" #include "sptk_utils.h" namespace sptk { ! class InputSourcePreprocessingForFilterGain ! : public InputSourcePreprocessingInterface { public: // --- 46,57 ---- #define SPTK_SRC_INPUT_SOURCE_PREPROCESSING_FOR_FILTER_GAIN_H_ ! #include <vector> // std::vector #include "input_source_interface.h" #include "sptk_utils.h" namespace sptk { ! class InputSourcePreprocessingForFilterGain : public InputSourceInterface { public: // *************** *** 66,79 **** // ! InputSourcePreprocessingForFilterGain( ! FilterGainType gain_type, ! InputSourceInterface* source) ! : gain_type_(gain_type), ! source_(source), ! is_valid_(false) { ! if (NULL == source) { return; } - is_valid_ = source_->IsValid(); } --- 64,75 ---- // ! InputSourcePreprocessingForFilterGain(FilterGainType gain_type, ! InputSourceInterface* source) ! : gain_type_(gain_type), source_(source), is_valid_(true) { ! if (NULL == source || ! !source->IsValid()) { ! is_valid_ = false; return; } } 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.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** input_source_interpolation_with_magic_number.cc 12 Oct 2016 04:31:24 -0000 1.2 --- input_source_interpolation_with_magic_number.cc 12 Oct 2016 11:13:51 -0000 1.3 *************** *** 64,68 **** bool use_final_frame_for_exceeded_frame, double magic_number, ! InputSourcePreprocessingInterface* source) : frame_period_(frame_period), interpolation_period_(interpolation_period), --- 64,68 ---- bool use_final_frame_for_exceeded_frame, double magic_number, ! InputSourceInterface* source) : frame_period_(frame_period), interpolation_period_(interpolation_period), --- input_source_preprocessing_interface.h DELETED --- 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.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** input_source_interpolation_with_magic_number.h 12 Oct 2016 04:31:24 -0000 1.2 --- input_source_interpolation_with_magic_number.h 12 Oct 2016 11:13:51 -0000 1.3 *************** *** 48,52 **** #include <vector> // std::vector ! #include "input_source_preprocessing_interface.h" #include "sptk_utils.h" --- 48,52 ---- #include <vector> // std::vector ! #include "input_source_interface.h" #include "sptk_utils.h" *************** *** 61,65 **** bool use_final_frame_for_exceeded_frame, double magic_number, ! InputSourcePreprocessingInterface* source); // --- 61,65 ---- bool use_final_frame_for_exceeded_frame, double magic_number, ! InputSourceInterface* source); // *************** *** 123,127 **** // ! InputSourcePreprocessingInterface* source_; // --- 123,127 ---- // ! InputSourceInterface* source_; // |
From: Keiichiro O. <ur...@us...> - 2016-10-12 07:44:50
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv32118 Modified Files: excitation_generation.h excitation_generation.cc excite.cc Log Message: add output func of sample level info in excitation generation Index: excitation_generation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/excitation_generation.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** excitation_generation.h 12 Oct 2016 04:31:24 -0000 1.2 --- excitation_generation.h 12 Oct 2016 07:44:48 -0000 1.3 *************** *** 68,72 **** // ! bool Get(double *excitation); private: --- 68,73 ---- // ! bool Get(double *excitation, double *pulse, double *noise, ! double *pitch); private: Index: excite.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/excite.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** excite.cc 12 Oct 2016 04:31:24 -0000 1.2 --- excite.cc 12 Oct 2016 07:44:48 -0000 1.3 *************** *** 191,235 **** // Run excitation generation. ! if (use_normal_distributed_random_value) { ! sptk::NormalDistributedRandomValueGeneration random_generation(seed); ! sptk::ExcitationGeneration excitation_generation( ! &input_source_interpolation_with_magic_number, &random_generation); ! if (!excitation_generation.IsValid()) { ! std::ostringstream error_message; ! error_message << "Failed to set the condition for excitation generation"; ! sptk::PrintErrorMessage("excite", error_message); ! return 1; ! } ! ! double excitation; ! while (excitation_generation.Get(&excitation)) { ! if (!sptk::WriteStream(excitation, &std::cout)) { ! std::ostringstream error_message; ! error_message << "Failed to write an excitation"; ! sptk::PrintErrorMessage("excite", error_message); ! return 1; ! } } - } else { - sptk::MSequenceGeneration random_generation; sptk::ExcitationGeneration excitation_generation( ! &input_source_interpolation_with_magic_number, &random_generation); if (!excitation_generation.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the condition for excitation generation"; sptk::PrintErrorMessage("excite", error_message); return 1; } double excitation; ! while (excitation_generation.Get(&excitation)) { if (!sptk::WriteStream(excitation, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write an excitation"; sptk::PrintErrorMessage("excite", error_message); return 1; } } } return 0; --- 191,231 ---- // Run excitation generation. ! sptk::RandomGenerationInterface *random_generation(NULL); ! try { ! if (use_normal_distributed_random_value) { ! random_generation = ! new sptk::NormalDistributedRandomValueGeneration(seed); ! } else { ! random_generation = new sptk::MSequenceGeneration(); } sptk::ExcitationGeneration excitation_generation( ! &input_source_interpolation_with_magic_number, random_generation); ! if (!excitation_generation.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the condition for excitation generation"; sptk::PrintErrorMessage("excite", error_message); + delete random_generation; return 1; } double excitation; ! while (excitation_generation.Get(&excitation, NULL, NULL, NULL)) { if (!sptk::WriteStream(excitation, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write an excitation"; sptk::PrintErrorMessage("excite", error_message); + delete random_generation; return 1; } } + } catch (std::exception *e) { + std::ostringstream error_message; + error_message << "Unknown exception"; + sptk::PrintErrorMessage("excite", error_message); + delete random_generation; + return 1; } + delete random_generation; return 0; Index: excitation_generation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/excitation_generation.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** excitation_generation.cc 12 Oct 2016 04:31:24 -0000 1.2 --- excitation_generation.cc 12 Oct 2016 07:44:48 -0000 1.3 *************** *** 62,66 **** } ! bool ExcitationGeneration::Get(double *excitation) { if (!is_valid_) { return false; --- 62,67 ---- } ! bool ExcitationGeneration::Get(double *excitation, ! double *pulse, double *noise, double *pitch) { if (!is_valid_) { return false; *************** *** 77,85 **** } // If unvoiced point, return white noise. if (input_source_->GetMagicNumber() == pitch_in_current_point) { phase_ = 1.0; ! if (!random_generation_->Get(excitation)) { ! return false; } return true; --- 78,102 ---- } + // Get noise. + double noise_in_current_point; + if (!random_generation_->Get(&noise_in_current_point)) { + return false; + } + + if (pitch) { + *pitch = pitch_in_current_point; + } + if (noise) { + *noise = noise_in_current_point; + } + // If unvoiced point, return white noise. if (input_source_->GetMagicNumber() == pitch_in_current_point) { phase_ = 1.0; ! if (excitation) { ! *excitation = noise_in_current_point; ! } ! if (pulse) { ! *pulse = 0.0; } return true; *************** *** 87,95 **** // If voiced point, return pulse or zero. if (1.0 <= phase_) { - *excitation = std::sqrt(pitch_in_current_point); phase_ -= 1.0; } else { ! *excitation = 0.0; } --- 104,120 ---- // If voiced point, return pulse or zero. + double pulse_in_current_point; if (1.0 <= phase_) { phase_ -= 1.0; + pulse_in_current_point = std::sqrt(pitch_in_current_point); } else { ! pulse_in_current_point = 0.0; ! } ! ! if (excitation) { ! *excitation = pulse_in_current_point; ! } ! if (pulse) { ! *pulse = pulse_in_current_point; } |
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_); } |
From: Takenori Y. <tak...@us...> - 2016-10-11 06:38:29
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv29927 Modified Files: all_pole_digital_filter.cc all_pole_digital_filter.h all_zero_digital_filter.cc all_zero_digital_filter.h poledf.cc zerodf.cc Log Message: modify filter classes for checking arguments Index: all_zero_digital_filter.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/all_zero_digital_filter.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** all_zero_digital_filter.cc 11 Oct 2016 06:01:28 -0000 1.2 --- all_zero_digital_filter.cc 11 Oct 2016 06:38:27 -0000 1.3 *************** *** 58,62 **** static_cast<std::size_t>(num_filter_order_ + 1) || NULL == filter_output || ! NULL == stored_signals) { return false; } --- 58,63 ---- static_cast<std::size_t>(num_filter_order_ + 1) || NULL == filter_output || ! NULL == stored_signals || ! !is_valid_) { return false; } Index: all_zero_digital_filter.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/all_zero_digital_filter.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** all_zero_digital_filter.h 11 Oct 2016 06:01:28 -0000 1.2 --- all_zero_digital_filter.h 11 Oct 2016 06:38:27 -0000 1.3 *************** *** 80,85 **** // ! AllZeroDigitalFilter(int num_filter_order, bool transposition) : ! num_filter_order_(num_filter_order), transposition_(transposition) {} // --- 80,90 ---- // ! AllZeroDigitalFilter(int num_filter_order, bool transposition) ! : num_filter_order_(num_filter_order), transposition_(transposition), ! is_valid_(true) { ! if (num_filter_order_ < 0) { ! is_valid_ = false; ! } ! } // *************** *** 97,100 **** --- 102,110 ---- // + bool IsValid() const { + return is_valid_; + } + + // bool Run(const std::vector<double>& filter_coefficients, double filter_input, double* filter_output, *************** *** 109,112 **** --- 119,125 ---- // + bool is_valid_; + + // DISALLOW_COPY_AND_ASSIGN(AllZeroDigitalFilter); }; Index: all_pole_digital_filter.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/all_pole_digital_filter.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** all_pole_digital_filter.cc 8 Oct 2016 15:14:58 -0000 1.3 --- all_pole_digital_filter.cc 11 Oct 2016 06:38:27 -0000 1.4 *************** *** 58,62 **** static_cast<std::size_t>(num_filter_order_ + 1) || NULL == filter_output || ! NULL == stored_signals) { return false; } --- 58,63 ---- static_cast<std::size_t>(num_filter_order_ + 1) || NULL == filter_output || ! NULL == stored_signals || ! !is_valid_) { return false; } Index: all_pole_digital_filter.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/all_pole_digital_filter.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** all_pole_digital_filter.h 8 Oct 2016 15:14:59 -0000 1.3 --- all_pole_digital_filter.h 11 Oct 2016 06:38:27 -0000 1.4 *************** *** 81,86 **** // AllPoleDigitalFilter(int num_filter_order, bool transposition) ! : num_filter_order_(num_filter_order), ! transposition_(transposition) {} // --- 81,90 ---- // AllPoleDigitalFilter(int num_filter_order, bool transposition) ! : num_filter_order_(num_filter_order), transposition_(transposition), ! is_valid_(true) { ! if (num_filter_order_ < 0) { ! is_valid_ = false; ! } ! } // *************** *** 98,101 **** --- 102,110 ---- // + bool IsValid() const { + return is_valid_; + } + + // bool Run(const std::vector<double>& filter_coefficients, double filter_input, double* filter_output, *************** *** 110,113 **** --- 119,125 ---- // + bool is_valid_; + + // DISALLOW_COPY_AND_ASSIGN(AllPoleDigitalFilter); }; Index: zerodf.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/zerodf.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** zerodf.cc 11 Oct 2016 06:01:29 -0000 1.1 --- zerodf.cc 11 Oct 2016 06:38:27 -0000 1.2 *************** *** 219,223 **** sptk::AllZeroDigitalFilter::StoredSignals stored_signals; ! if (!interpolation.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the conditions for filtering"; --- 219,223 ---- sptk::AllZeroDigitalFilter::StoredSignals stored_signals; ! if (!interpolation.IsValid() || !filter.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the conditions for filtering"; Index: poledf.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/poledf.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** poledf.cc 10 Oct 2016 14:34:04 -0000 1.3 --- poledf.cc 11 Oct 2016 06:38:27 -0000 1.4 *************** *** 219,223 **** sptk::AllPoleDigitalFilter::StoredSignals stored_signals; ! if (!interpolation.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the conditions for filtering"; --- 219,223 ---- sptk::AllPoleDigitalFilter::StoredSignals stored_signals; ! if (!interpolation.IsValid() || !filter.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the conditions for filtering"; |
From: Takenori Y. <tak...@us...> - 2016-10-11 06:01:31
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv28100 Modified Files: Makefile all_zero_digital_filter.cc all_zero_digital_filter.h input_source_preprocessing_for_filter_gain.cc input_source_preprocessing_for_filter_gain.h Added Files: zerodf.cc Log Message: add zerodf command Index: all_zero_digital_filter.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/all_zero_digital_filter.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** all_zero_digital_filter.cc 23 Aug 2016 08:15:59 -0000 1.1 --- all_zero_digital_filter.cc 11 Oct 2016 06:01:28 -0000 1.2 *************** *** 55,59 **** AllZeroDigitalFilter::StoredSignals* stored_signals) const { // check inputs ! if (filter_coefficients.empty() || NULL == filter_output || NULL == stored_signals) { --- 55,60 ---- AllZeroDigitalFilter::StoredSignals* stored_signals) const { // check inputs ! if (filter_coefficients.size() != ! static_cast<std::size_t>(num_filter_order_ + 1) || NULL == filter_output || NULL == stored_signals) { *************** *** 62,69 **** // prepare memory - const int num_filter_order(filter_coefficients.size() - 1); if (stored_signals->signals_.size() != ! static_cast<std::size_t>(num_filter_order)) { ! stored_signals->signals_.resize(num_filter_order); std::fill(stored_signals->signals_.begin(), stored_signals->signals_.end(), 0.0); --- 63,69 ---- // prepare memory if (stored_signals->signals_.size() != ! static_cast<std::size_t>(num_filter_order_)) { ! stored_signals->signals_.resize(num_filter_order_); std::fill(stored_signals->signals_.begin(), stored_signals->signals_.end(), 0.0); *************** *** 72,76 **** // set value const double gained_input(filter_input * filter_coefficients[0]); ! if (0 == num_filter_order) { *filter_output = gained_input; return true; --- 72,76 ---- // set value const double gained_input(filter_input * filter_coefficients[0]); ! if (0 == num_filter_order_) { *filter_output = gained_input; return true; *************** *** 83,95 **** // apply filter double sum(gained_input); ! if (is_transposed_) { sum += signals[0]; ! for (int i(1); i < num_filter_order; ++i) { signals[i - 1] = signals[i] + coefficients[i] * filter_input; } ! signals[num_filter_order - 1] = coefficients[num_filter_order] * filter_input; } else { ! for (int i(num_filter_order - 1); 0 < i; --i) { sum += coefficients[i + 1] * signals[i]; signals[i] = signals[i - 1]; --- 83,95 ---- // apply filter double sum(gained_input); ! if (transposition_) { sum += signals[0]; ! for (int i(1); i < num_filter_order_; ++i) { signals[i - 1] = signals[i] + coefficients[i] * filter_input; } ! signals[num_filter_order_ - 1] = coefficients[num_filter_order_] * filter_input; } else { ! for (int i(num_filter_order_ - 1); 0 < i; --i) { sum += coefficients[i + 1] * signals[i]; signals[i] = signals[i - 1]; Index: all_zero_digital_filter.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/all_zero_digital_filter.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** all_zero_digital_filter.h 23 Aug 2016 08:15:58 -0000 1.1 --- all_zero_digital_filter.h 11 Oct 2016 06:01:28 -0000 1.2 *************** *** 80,85 **** // ! explicit AllZeroDigitalFilter(bool is_transposed) : ! is_transposed_(is_transposed) {} // --- 80,85 ---- // ! AllZeroDigitalFilter(int num_filter_order, bool transposition) : ! num_filter_order_(num_filter_order), transposition_(transposition) {} // *************** *** 87,92 **** // bool GetTranspositionFlag() const { ! return is_transposed_; } --- 87,97 ---- // + int GetNumFilterOrder() const { + return num_filter_order_; + } + + // bool GetTranspositionFlag() const { ! return transposition_; } *************** *** 98,102 **** private: // ! const bool is_transposed_; // --- 103,110 ---- private: // ! const int num_filter_order_; ! ! // ! const bool transposition_; // Index: input_source_preprocessing_for_filter_gain.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_preprocessing_for_filter_gain.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** input_source_preprocessing_for_filter_gain.cc 8 Oct 2016 15:14:59 -0000 1.1 --- input_source_preprocessing_for_filter_gain.cc 11 Oct 2016 06:01:29 -0000 1.2 *************** *** 45,49 **** #include "input_source_preprocessing_for_filter_gain.h" ! #include <cmath> // std::exp namespace sptk { --- 45,51 ---- #include "input_source_preprocessing_for_filter_gain.h" ! #include <algorithm> // std::transform ! #include <cmath> // std::exp ! #include <functional> // std::bind1st, std::multiplies namespace sptk { *************** *** 61,74 **** switch (gain_type_) { ! case InputSourcePreprocessingForFilterGain::FilterGainType::kUnity: buffer->at(0) = 1.0; break; ! case InputSourcePreprocessingForFilterGain::FilterGainType::kLinear: break; ! case InputSourcePreprocessingForFilterGain::FilterGainType::kLog: buffer->at(0) = std::exp(buffer->at(0)); break; ! default: return false; } --- 63,87 ---- switch (gain_type_) { ! case InputSourcePreprocessingForFilterGain::FilterGainType::kUnity: { buffer->at(0) = 1.0; break; ! } ! case InputSourcePreprocessingForFilterGain::FilterGainType::kUnityForAllZeroFilter: { // NOLINT ! if (0.0 == buffer->at(0)) return false; ! const double inverse_of_b0(1.0 / buffer->at(0)); ! std::transform(buffer->begin(), buffer->end(), buffer->begin(), ! std::bind1st(std::multiplies<double>(), inverse_of_b0)); break; ! } ! case InputSourcePreprocessingForFilterGain::FilterGainType::kLinear: { ! break; ! } ! case InputSourcePreprocessingForFilterGain::FilterGainType::kLog: { buffer->at(0) = std::exp(buffer->at(0)); break; ! } ! default: { return false; + } } Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Makefile 11 Oct 2016 05:31:10 -0000 1.12 --- Makefile 11 Oct 2016 06:01:28 -0000 1.13 *************** *** 46,49 **** --- 46,50 ---- SOURCES = all_pole_digital_filter.cc \ + all_zero_digital_filter.cc \ autocorrelation.cc \ cepstrum_to_minimum_phase_impulse_response.cc \ Index: input_source_preprocessing_for_filter_gain.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_preprocessing_for_filter_gain.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** input_source_preprocessing_for_filter_gain.h 8 Oct 2016 15:14:59 -0000 1.1 --- input_source_preprocessing_for_filter_gain.h 11 Oct 2016 06:01:29 -0000 1.2 *************** *** 59,65 **** // enum class FilterGainType { ! kUnity = 0, ! kLinear, kLog, }; --- 59,66 ---- // enum class FilterGainType { ! kLinear = 0, kLog, + kUnity, + kUnityForAllZeroFilter, }; --- NEW FILE: zerodf.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 <fstream> #include <iostream> #include <sstream> #include <vector> #include "all_zero_digital_filter.h" #include "input_source_from_stream.h" #include "input_source_interpolation.h" #include "input_source_preprocessing_for_filter_gain.h" #include "sptk_utils.h" namespace { const int kDefaultNumFilterOrder(25); const int kDefaultFramePeriod(100); const int kDefaultInterpolationPeriod(1); const bool kDefaultTranspositionFlag(false); const bool kDefaultGainFlag(true); void PrintUsage(std::ostream* stream) { *stream << std::endl; *stream << " zerodf - all-zero digital filter for speech synthesis" << std::endl; // NOLINT *stream << std::endl; *stream << " usage:" << std::endl; *stream << " zerodf [ options ] bfile [ infile ] > stdout" << std::endl; *stream << " options:" << std::endl; *stream << " -m m : order of filter coefficients [" << kDefaultNumFilterOrder << "]" << std::endl; // NOLINT *stream << " -p p : frame period [" << kDefaultFramePeriod << "]" << std::endl; // NOLINT *stream << " -i i : interpolation period [" << kDefaultInterpolationPeriod << "]" << std::endl; // NOLINT *stream << " -t : transpose filter [" << sptk::ConvertBooleanToString(kDefaultTranspositionFlag) << "]" << std::endl; // NOLINT *stream << " -k : filtering without gain [" << sptk::ConvertBooleanToString(!kDefaultGainFlag) << "]" << std::endl; // NOLINT *stream << " -h : print this message" << std::endl; *stream << " infile:" << std::endl; *stream << " filter input (double) [stdin]" << std::endl; *stream << " stdout:" << std::endl; *stream << " filter output (double)" << std::endl; *stream << " bfile:" << std::endl; *stream << " filter (MA) coefficients (double)" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; *stream << std::endl; } } // namespace int main(int argc, char* argv[]) { int num_filter_order(kDefaultNumFilterOrder); int frame_period(kDefaultFramePeriod); int interpolation_period(kDefaultInterpolationPeriod); bool transposition_flag(kDefaultTranspositionFlag); bool gain_flag(kDefaultGainFlag); for (;;) { const char option_char(getopt(argc, argv, "m:p:i:tkh")); if (-1 == option_char) break; switch (option_char) { case 'm': { if (!sptk::ConvertStringToInteger(optarg, &num_filter_order) || num_filter_order < 0) { std::ostringstream error_message; error_message << "The argument for the -m option must be a non-negative integer"; sptk::PrintErrorMessage("zerodf", error_message); return 1; } break; } case 'p': { if (!sptk::ConvertStringToInteger(optarg, &frame_period) || frame_period <= 0) { std::ostringstream error_message; error_message << "The argument for the -p option must be a positive integer"; sptk::PrintErrorMessage("zerodf", error_message); return 1; } break; } case 'i': { if (!sptk::ConvertStringToInteger(optarg, &interpolation_period) || interpolation_period < 0) { std::ostringstream error_message; error_message << "The argument for the -i option must be a non-negative integer"; sptk::PrintErrorMessage("zerodf", error_message); return 1; } break; } case 't': { transposition_flag = true; break; } case 'k': { gain_flag = false; break; } case 'h': { PrintUsage(&std::cout); return 0; } default: { PrintUsage(&std::cerr); return 1; } } } if (frame_period / 2 < interpolation_period) { std::ostringstream error_message; error_message << "Interpolation period should not be greater than half frame period"; sptk::PrintErrorMessage("zerodf", error_message); return 1; } // Get input file names. const char* filter_coefficients_file; const char* filter_input_file; const int num_rest_args(argc - optind); if (2 == num_rest_args) { filter_coefficients_file = argv[argc - 2]; filter_input_file = argv[argc - 1]; } else if (1 == num_rest_args) { filter_coefficients_file = argv[argc - 1]; filter_input_file = NULL; } else { std::ostringstream error_message; error_message << "Just two input files, bfile and infile, are required"; sptk::PrintErrorMessage("zerodf", error_message); return 1; } // Open stream for reading filter coeffcients. std::ifstream ifs1; ifs1.open(filter_coefficients_file, std::ios::in | std::ios::binary); if (ifs1.fail()) { std::ostringstream error_message; error_message << "Cannot open file " << filter_coefficients_file; sptk::PrintErrorMessage("zerodf", error_message); return 1; } std::istream& stream_for_filter_coefficients(ifs1); // Open stream for reading input signals. std::ifstream ifs2; ifs2.open(filter_input_file, std::ios::in | std::ios::binary); if (ifs2.fail() && NULL != filter_input_file) { std::ostringstream error_message; error_message << "Cannot open file " << filter_input_file; sptk::PrintErrorMessage("zerodf", error_message); return 1; } std::istream& stream_for_filter_input(ifs2.fail() ? std::cin : ifs2); // Prepare variables for filtering. const int filter_length(num_filter_order + 1); std::vector<double> filter_coefficients(filter_length); sptk::InputSourceFromStream input_source(false, filter_length, &stream_for_filter_coefficients); const sptk::InputSourcePreprocessingForFilterGain::FilterGainType gain_type( gain_flag ? sptk::InputSourcePreprocessingForFilterGain::FilterGainType::kLinear : sptk::InputSourcePreprocessingForFilterGain::FilterGainType::kUnityForAllZeroFilter); // NOLINT sptk::InputSourcePreprocessingForFilterGain preprocessing(gain_type, &input_source); sptk::InputSourceInterpolation interpolation(frame_period, interpolation_period, true, &preprocessing); double filter_input, filter_output; sptk::AllZeroDigitalFilter filter(num_filter_order, transposition_flag); sptk::AllZeroDigitalFilter::StoredSignals stored_signals; if (!interpolation.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the conditions for filtering"; sptk::PrintErrorMessage("zerodf", error_message); return 1; } while (sptk::ReadStream(&filter_input, &stream_for_filter_input)) { if (!interpolation.Get(&filter_coefficients)) { std::ostringstream error_message; error_message << "Cannot get filter coefficients"; sptk::PrintErrorMessage("zerodf", error_message); return 1; } if (!filter.Run(filter_coefficients, filter_input, &filter_output, &stored_signals)) { std::ostringstream error_message; error_message << "Failed to apply all-zero digital filter"; sptk::PrintErrorMessage("zerodf", error_message); return 1; } if (!sptk::WriteStream(filter_output, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write a filter output"; sptk::PrintErrorMessage("zerodf", error_message); return 1; } } return 0; } |
From: Keiichiro O. <ur...@us...> - 2016-10-11 05:31:13
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv26683 Modified Files: Makefile Added Files: excitation_generation.cc excitation_generation.h excite.cc input_source_interpolation_with_magic_number.cc input_source_interpolation_with_magic_number.h Log Message: add excite command --- NEW FILE: excitation_generation.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_EXCITATION_GENERATION_H_ #define SPTK_SRC_EXCITATION_GENERATION_H_ #include "input_source_interpolation_with_magic_number.h" #include "random_generation_interface.h" #include "sptk_utils.h" namespace sptk { class ExcitationGeneration { public: // ExcitationGeneration(InputSourceInterpolationWithMagicNumber *input_source, RandomGenerationInterface *random_generation); // virtual ~ExcitationGeneration() {} // bool IsValid() const { return is_valid_; } // bool Get(double *excitation); private: // InputSourceInterpolationWithMagicNumber *input_source_; // RandomGenerationInterface *random_generation_; // bool is_valid_; // from 0.0 to 1.0 double phase_; // DISALLOW_COPY_AND_ASSIGN(ExcitationGeneration); }; } // namespace sptk #endif // SPTK_SRC_EXCITATION_GENERATION_H_ Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Makefile 8 Oct 2016 15:14:58 -0000 1.11 --- Makefile 11 Oct 2016 05:31:10 -0000 1.12 *************** *** 48,55 **** --- 48,57 ---- autocorrelation.cc \ cepstrum_to_minimum_phase_impulse_response.cc \ + excitation_generation.cc \ fast_fourier_transform.cc \ frequency_transform.cc \ input_source_from_stream.cc \ input_source_interpolation.cc \ + input_source_interpolation_with_magic_number.cc \ input_source_preprocessing_for_filter_gain.cc \ levinson_durbin_recursion.cc \ --- NEW FILE: excitation_generation.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 "excitation_generation.h" #include <cmath> // std::sqrt #include <vector> // std::vector namespace sptk { 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; } } bool ExcitationGeneration::Get(double *excitation) { if (!is_valid_) { return false; } // Get pitch. double pitch_in_current_point; { std::vector<double> tmp; if (!input_source_->Get(&tmp) || tmp[0] < 0.0) { return false; } pitch_in_current_point = tmp[0]; } // If unvoiced point, return white noise. if (input_source_->GetMagicNumber() == pitch_in_current_point) { phase_ = 1.0; if (!random_generation_->Get(excitation)) { return false; } return true; } // If voiced point, return pulse or zero. if (1.0 <= phase_) { *excitation = std::sqrt(pitch_in_current_point); phase_ -= 1.0; } else { *excitation = 0.0; } // Proceed phase. phase_ += 1.0 / pitch_in_current_point; return true; } } // namespace sptk --- NEW FILE: input_source_interpolation_with_magic_number.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 "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 namespace sptk { InputSourceInterpolationWithMagicNumber:: InputSourceInterpolationWithMagicNumber( int frame_period, int interpolation_period, bool use_final_frame_for_exceeded_frame, double magic_number, InputSourcePreprocessingInterface* source) : frame_period_(frame_period), interpolation_period_(interpolation_period), first_interpolation_period_(interpolation_period / 2), use_final_frame_for_exceeded_frame_(use_final_frame_for_exceeded_frame), magic_number_(magic_number), remained_num_samples_(0), data_length_(0), point_index_in_frame_(0), source_(source), is_valid_(true) { if (frame_period <= 0 || interpolation_period < 0 || frame_period / 2 < interpolation_period || NULL == source || !source->IsValid()) { is_valid_ = false; return; } if (!source_->Get(&curr_data_)) { remained_num_samples_ = 0; return; } remained_num_samples_ = frame_period_ + 1; data_length_ = curr_data_.size(); if (!source_->Get(&next_data_)) { next_data_.resize(data_length_); std::copy(curr_data_.begin(), curr_data_.end(), next_data_.begin()); remained_num_samples_ = 1; } if (0 < interpolation_period_) { increment_.resize(data_length_); CalculateIncrement(); } } void InputSourceInterpolationWithMagicNumber::CalculateIncrement() { const double rate(static_cast<double>(interpolation_period_) / frame_period_); for (int i(0); i < data_length_; ++i) { if (magic_number_ == next_data_[i] || magic_number_ == curr_data_[i]) { increment_[i] = kCannotCalculateIncrements; } else { increment_[i] = rate * (next_data_[i] - curr_data_[i]); } } } bool InputSourceInterpolationWithMagicNumber::Get(std::vector<double>* buffer) { if (NULL == buffer || !is_valid_) { return false; } if (remained_num_samples_ <= 0) { return false; } if (buffer->size() < static_cast<std::size_t>(data_length_)) { buffer->resize(data_length_); } std::copy(curr_data_.begin(), curr_data_.end(), buffer->begin()); --remained_num_samples_; if (remained_num_samples_ <= 0) { if (use_final_frame_for_exceeded_frame_) { remained_num_samples_ = 1; } return true; } // Update internal states for the next call. ++point_index_in_frame_; if (0 == point_index_in_frame_ % frame_period_) { // Update current and next data. std::copy(next_data_.begin(), next_data_.end(), curr_data_.begin()); if (!source_->Get(&next_data_)) { // Use the final data until the end of input sequence. std::copy(curr_data_.begin(), curr_data_.end(), next_data_.begin()); remained_num_samples_ = 1; } else { remained_num_samples_ = frame_period_ + 1; } if (0 < interpolation_period_) { CalculateIncrement(); } // Rewind point index. point_index_in_frame_ = 0; } else if (0 < interpolation_period_ && 0 == ((point_index_in_frame_ + first_interpolation_period_) % 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_; } else { curr_data_[i] += increment_[i]; } } } else if (0 == interpolation_period_ && frame_period_ / 2 == point_index_in_frame_) { std::copy(next_data_.begin(), next_data_.end(), curr_data_.begin()); } return true; } } // namespace sptk --- NEW FILE: excite.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 <fstream> #include "excitation_generation.h" #include "input_source_from_stream.h" #include "input_source_preprocessing_for_filter_gain.h" #include "m_sequence_generation.h" #include "normal_distributed_random_value_generation.h" #include "sptk_utils.h" namespace { const int kDefaultFramePeriod(100); const int kDefaultInterpolationPeriod(1); const bool kDefaultFlagToUseNormalDistributedRandomValue(false); const int kDefaultSeed(1); const double kMagicNumberForUnvoicedFrame(0.0); void PrintUsage(std::ostream* stream) { *stream << std::endl; *stream << " excite - generate excitation" << std::endl; *stream << std::endl; *stream << " usage:" << std::endl; *stream << " excite [ options ] [ infile ] > stdout" << std::endl; *stream << " options:" << std::endl; *stream << " -p p : frame period [" << kDefaultFramePeriod << "]" << std::endl; // NOLINT *stream << " -i i : interpolation period [" << kDefaultInterpolationPeriod << "]" << std::endl; // NOLINT *stream << " -n : use gauss noise for unvoiced frame [" << sptk::ConvertBooleanToString(kDefaultFlagToUseNormalDistributedRandomValue) << "]" << std::endl; // NOLINT *stream << " default is M-sequence" << std::endl; *stream << " -s : seed for random generation [" << kDefaultSeed << "]" << std::endl; // NOLINT *stream << " -h : print this message" << std::endl; *stream << " infile:" << std::endl; *stream << " pitch period (double) [stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; *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; *stream << " SPTK: version " << sptk::kVersion << std::endl; *stream << std::endl; } } // namespace int main(int argc, char* argv[]) { int frame_period(kDefaultFramePeriod); int interpolation_period(kDefaultInterpolationPeriod); bool use_normal_distributed_random_value( kDefaultFlagToUseNormalDistributedRandomValue); int seed(kDefaultSeed); for (;;) { const char option_char(getopt(argc, argv, "p:i:nsh")); if (-1 == option_char) break; switch (option_char) { case 'p': { if (!sptk::ConvertStringToInteger(optarg, &frame_period) || frame_period <= 0) { std::ostringstream error_message; error_message << "The argument for the -p option must be a positive integer"; sptk::PrintErrorMessage("excite", error_message); return 1; } break; } case 'i': { if (!sptk::ConvertStringToInteger(optarg, &interpolation_period) || interpolation_period < 0) { std::ostringstream error_message; error_message << "The argument for the -i option must be a non-negative integer"; sptk::PrintErrorMessage("excite", error_message); return 1; } break; } case 'n': { use_normal_distributed_random_value = true; break; } case 's': { if (!sptk::ConvertStringToInteger(optarg, &seed)) { std::ostringstream error_message; error_message << "The argument for the -s option must be an integer"; sptk::PrintErrorMessage("excite", error_message); return 1; } break; } case 'h': { PrintUsage(&std::cout); return 0; } default: { PrintUsage(&std::cerr); return 1; } } } if (frame_period / 2 < interpolation_period) { std::ostringstream error_message; error_message << "Interpolation period should not be greater than half frame period"; sptk::PrintErrorMessage("excite", error_message); return 1; } // Get input file name. const char* input_file((optind < argc) ? argv[argc - 1] : NULL); // Open input 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("excite", error_message); return 1; } std::istream& input_stream(ifs.fail() ? std::cin : ifs); // Prepare input source interpolation. sptk::InputSourceFromStream input_source_from_stream(false, 1, &input_stream); sptk::InputSourcePreprocessingForFilterGain input_source_preprocessing_for_filter_gain( sptk::InputSourcePreprocessingForFilterGain::FilterGainType::kLinear, &input_source_from_stream); sptk::InputSourceInterpolationWithMagicNumber input_source_interpolation_with_magic_number( frame_period, interpolation_period, false, kMagicNumberForUnvoicedFrame, &input_source_preprocessing_for_filter_gain); if (!input_source_interpolation_with_magic_number.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the condition for input"; sptk::PrintErrorMessage("excite", error_message); return 1; } // Run excitation generation. if (use_normal_distributed_random_value) { sptk::NormalDistributedRandomValueGeneration random_generation(seed); sptk::ExcitationGeneration excitation_generation( &input_source_interpolation_with_magic_number, &random_generation); if (!excitation_generation.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the condition for excitation generation"; sptk::PrintErrorMessage("excite", error_message); return 1; } double excitation; while (excitation_generation.Get(&excitation)) { if (!sptk::WriteStream(excitation, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write an excitation"; sptk::PrintErrorMessage("excite", error_message); return 1; } } } else { sptk::MSequenceGeneration random_generation; sptk::ExcitationGeneration excitation_generation( &input_source_interpolation_with_magic_number, &random_generation); if (!excitation_generation.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the condition for excitation generation"; sptk::PrintErrorMessage("excite", error_message); return 1; } double excitation; while (excitation_generation.Get(&excitation)) { if (!sptk::WriteStream(excitation, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write an excitation"; sptk::PrintErrorMessage("excite", error_message); return 1; } } } return 0; } --- NEW FILE: input_source_interpolation_with_magic_number.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_INPUT_SOURCE_INTERPOLATION_WITH_MAGIC_NUMBER_H_ #define SPTK_SRC_INPUT_SOURCE_INTERPOLATION_WITH_MAGIC_NUMBER_H_ #include <vector> // std::vector #include "input_source_preprocessing_interface.h" #include "sptk_utils.h" namespace sptk { class InputSourceInterpolationWithMagicNumber { public: // InputSourceInterpolationWithMagicNumber(int frame_period, int interpolation_period, bool use_final_frame_for_exceeded_frame, double magic_number, InputSourcePreprocessingInterface* source); // virtual ~InputSourceInterpolationWithMagicNumber() {} // int GetFramePeriod() const { return frame_period_; } // int GetInterpolationPeriod() const { return interpolation_period_; } // bool UseFinalFrameForExceededFrame() const { return use_final_frame_for_exceeded_frame_; } // double GetMagicNumber() const { return magic_number_; } // bool IsValid() const { return is_valid_; } // virtual bool Get(std::vector<double>* buffer); private: // void CalculateIncrement(); // const int frame_period_; // const int interpolation_period_; // const int first_interpolation_period_; // const bool use_final_frame_for_exceeded_frame_; // const double magic_number_; // int remained_num_samples_; // int data_length_; // int point_index_in_frame_; // InputSourcePreprocessingInterface* source_; // bool is_valid_; // std::vector<double> curr_data_; // std::vector<double> next_data_; // std::vector<double> increment_; // DISALLOW_COPY_AND_ASSIGN(InputSourceInterpolationWithMagicNumber); }; } // namespace sptk #endif // SPTK_SRC_INPUT_SOURCE_INTERPOLATION_WITH_MAGIC_NUMBER_H_ |
From: Keiichiro O. <ur...@us...> - 2016-10-10 14:34:06
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv16382 Modified Files: input_source_interpolation.cc input_source_interpolation.h poledf.cc Log Message: add use_final_frame_for_exceeded_frame args to InputSourceInterpolation constructor Index: input_source_interpolation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_interpolation.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** input_source_interpolation.h 8 Oct 2016 15:14:59 -0000 1.1 --- input_source_interpolation.h 10 Oct 2016 14:34:04 -0000 1.2 *************** *** 58,61 **** --- 58,62 ---- InputSourceInterpolation(int frame_period, int interpolation_period, + bool use_final_frame_for_exceeded_frame, InputSourcePreprocessingInterface* source); *************** *** 64,78 **** // ! virtual int GetFramePeriod() const { return frame_period_; } // ! virtual int GetInterpolationPeriod() const { return interpolation_period_; } // ! virtual bool IsValid() const { return is_valid_; } --- 65,84 ---- // ! int GetFramePeriod() const { return frame_period_; } // ! int GetInterpolationPeriod() const { return interpolation_period_; } // ! bool UseFinalFrameForExceededFrame() const { ! return use_final_frame_for_exceeded_frame_; ! } ! ! // ! bool IsValid() const { return is_valid_; } *************** *** 95,98 **** --- 101,110 ---- // + const bool use_final_frame_for_exceeded_frame_; + + // + int remained_num_samples_; + + // int data_length_; Index: input_source_interpolation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_interpolation.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** input_source_interpolation.cc 8 Oct 2016 15:14:59 -0000 1.1 --- input_source_interpolation.cc 10 Oct 2016 14:34:04 -0000 1.2 *************** *** 54,76 **** int frame_period, int interpolation_period, InputSourcePreprocessingInterface* source) : frame_period_(frame_period), interpolation_period_(interpolation_period), first_interpolation_period_(interpolation_period / 2), point_index_in_frame_(0), source_(source), ! is_valid_(false) { if (frame_period <= 0 || interpolation_period < 0 || frame_period / 2 < interpolation_period || ! NULL == source) { return; } if (!source_->Get(&curr_data_)) { return; } ! is_valid_ = true; data_length_ = curr_data_.size(); --- 54,83 ---- int frame_period, int interpolation_period, + bool use_final_frame_for_exceeded_frame, InputSourcePreprocessingInterface* source) : frame_period_(frame_period), interpolation_period_(interpolation_period), first_interpolation_period_(interpolation_period / 2), + use_final_frame_for_exceeded_frame_(use_final_frame_for_exceeded_frame), + remained_num_samples_(0), + data_length_(0), point_index_in_frame_(0), source_(source), ! is_valid_(true) { if (frame_period <= 0 || interpolation_period < 0 || frame_period / 2 < interpolation_period || ! NULL == source || ! !source->IsValid()) { ! is_valid_ = false; return; } if (!source_->Get(&curr_data_)) { + remained_num_samples_ = 0; return; } ! remained_num_samples_ = frame_period_ + 1; data_length_ = curr_data_.size(); *************** *** 79,82 **** --- 86,90 ---- std::copy(curr_data_.begin(), curr_data_.end(), next_data_.begin()); + remained_num_samples_ = 1; } *************** *** 100,103 **** --- 108,115 ---- } + if (remained_num_samples_ <= 0) { + return false; + } + if (buffer->size() < static_cast<std::size_t>(data_length_)) { buffer->resize(data_length_); *************** *** 107,110 **** --- 119,131 ---- buffer->begin()); + --remained_num_samples_; + + if (remained_num_samples_ <= 0) { + if (use_final_frame_for_exceeded_frame_) { + remained_num_samples_ = 1; + } + return true; + } + // Update internal states for the next call. ++point_index_in_frame_; *************** *** 118,121 **** --- 139,145 ---- std::copy(curr_data_.begin(), curr_data_.end(), next_data_.begin()); + remained_num_samples_ = 1; + } else { + remained_num_samples_ = frame_period_ + 1; } Index: poledf.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/poledf.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** poledf.cc 8 Oct 2016 15:14:59 -0000 1.2 --- poledf.cc 10 Oct 2016 14:34:04 -0000 1.3 *************** *** 213,216 **** --- 213,217 ---- sptk::InputSourceInterpolation interpolation(frame_period, interpolation_period, + true, &preprocessing); double filter_input, filter_output; |
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv15963 Modified Files: Makefile all_pole_digital_filter.cc all_pole_digital_filter.h levdur.cc levinson_durbin_recursion.cc levinson_durbin_recursion.h lpc.cc poledf.cc Added Files: input_source_from_stream.cc input_source_from_stream.h input_source_interface.h input_source_interpolation.cc input_source_interpolation.h input_source_preprocessing_for_filter_gain.cc input_source_preprocessing_for_filter_gain.h input_source_preprocessing_interface.h Log Message: reimplement filter interpolation --- NEW FILE: input_source_preprocessing_for_filter_gain.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 "input_source_preprocessing_for_filter_gain.h" #include <cmath> // std::exp namespace sptk { bool InputSourcePreprocessingForFilterGain::Get( std::vector<double>* buffer) { if (NULL == buffer || !is_valid_) { return false; } if (!source_->Get(buffer)) { return false; } switch (gain_type_) { case InputSourcePreprocessingForFilterGain::FilterGainType::kUnity: buffer->at(0) = 1.0; break; case InputSourcePreprocessingForFilterGain::FilterGainType::kLinear: break; case InputSourcePreprocessingForFilterGain::FilterGainType::kLog: buffer->at(0) = std::exp(buffer->at(0)); break; default: return false; } return true; } } // namespace sptk --- NEW FILE: input_source_from_stream.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_INPUT_SOURCE_FROM_STREAM_H_ #define SPTK_SRC_INPUT_SOURCE_FROM_STREAM_H_ #include <istream> // std::istream #include <vector> // std::vector #include "input_source_interface.h" #include "sptk_utils.h" namespace sptk { class InputSourceFromStream : public InputSourceInterface { public: // InputSourceFromStream(bool zero_padding, int read_size, std::istream* input_stream) : zero_padding_(zero_padding), read_size_(read_size), input_stream_(input_stream), is_valid_(false) { if (read_size <= 0 || NULL == input_stream) { return; } is_valid_ = true; } // virtual ~InputSourceFromStream() {} // virtual bool GetZeroPaddingFlag() const { return zero_padding_; } // virtual int GetReadSize() const { return read_size_; } // virtual bool IsValid() const { return is_valid_; } // virtual bool Get(std::vector<double>* buffer); private: // const bool zero_padding_; // const int read_size_; // std::istream* input_stream_; // bool is_valid_; // DISALLOW_COPY_AND_ASSIGN(InputSourceFromStream); }; } // namespace sptk #endif // SPTK_SRC_INPUT_SOURCE_FROM_STREAM_H_ Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Makefile 7 Oct 2016 00:47:51 -0000 1.10 --- Makefile 8 Oct 2016 15:14:58 -0000 1.11 *************** *** 46,58 **** SOURCES = all_pole_digital_filter.cc \ ! autocorrelation.cc \ ! fast_fourier_transform.cc \ ! cepstrum_to_minimum_phase_impulse_response.cc \ ! coefficients_stream_reader.cc \ frequency_transform.cc \ ! levinson_durbin_recursion.cc \ ! m_sequence_generation.cc \ ! normal_distributed_random_value_generation.cc \ ! sptk_utils.cc OBJECTS = $(SOURCES:.cc=.o) --- 46,60 ---- SOURCES = all_pole_digital_filter.cc \ ! autocorrelation.cc \ ! cepstrum_to_minimum_phase_impulse_response.cc \ ! fast_fourier_transform.cc \ frequency_transform.cc \ ! input_source_from_stream.cc \ ! input_source_interpolation.cc \ ! input_source_preprocessing_for_filter_gain.cc \ ! levinson_durbin_recursion.cc \ ! m_sequence_generation.cc \ ! normal_distributed_random_value_generation.cc \ ! sptk_utils.cc OBJECTS = $(SOURCES:.cc=.o) Index: lpc.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/lpc.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** lpc.cc 19 Apr 2016 04:27:10 -0000 1.1 --- lpc.cc 8 Oct 2016 15:14:59 -0000 1.2 *************** *** 74,87 **** *stream << " options:" << std::endl; *stream << " -l l : frame length [" << kDefaultFrameLength << "]" << std::endl; // NOLINT ! *stream << " -m m : order of LPC coefficients [" << kDefaultNumOrder << "]" << std::endl; // NOLINT *stream << " -f f : minimum value of the determinant of [" << kDefaultEpsilon << "]" << std::endl; // NOLINT *stream << " the normal matrix" << std::endl; ! *stream << " -c c : check whether the derived LPC [0]" << std::endl; // NOLINT *stream << " coefficients are stable or not" << std::endl; *stream << " 0 (the check is not performed)" << std::endl; *stream << " 1 (if the coefficients are unstable," << std::endl; // NOLINT ! *stream << " output its index to stderr)" << std::endl; *stream << " 2 (if the coefficients are unstable," << std::endl; // NOLINT ! *stream << " output its index to stderr and" << std::endl; *stream << " exit immediately)" << std::endl; *stream << " -h : print this message" << std::endl; --- 74,87 ---- *stream << " options:" << std::endl; *stream << " -l l : frame length [" << kDefaultFrameLength << "]" << std::endl; // NOLINT ! *stream << " -m m : order of LP coefficients [" << kDefaultNumOrder << "]" << std::endl; // NOLINT *stream << " -f f : minimum value of the determinant of [" << kDefaultEpsilon << "]" << std::endl; // NOLINT *stream << " the normal matrix" << std::endl; ! *stream << " -c c : check whether the derived LP [0]" << std::endl; // NOLINT *stream << " coefficients are stable or not" << std::endl; *stream << " 0 (the check is not performed)" << std::endl; *stream << " 1 (if the coefficients are unstable," << std::endl; // NOLINT ! *stream << " output the index to stderr)" << std::endl; *stream << " 2 (if the coefficients are unstable," << std::endl; // NOLINT ! *stream << " output the index to stderr and" << std::endl; *stream << " exit immediately)" << std::endl; *stream << " -h : print this message" << std::endl; *************** *** 89,93 **** *stream << " windowed sequence (double) [stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; ! *stream << " LPC coefficients (double)" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; --- 89,93 ---- *stream << " windowed sequence (double) [stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; ! *stream << " LP coefficients (double)" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; *************** *** 191,195 **** if (!autocorrelation.SetNumOrder(num_order)) { std::ostringstream error_message; ! error_message << "Failed to set the order of LPC coefficients"; sptk::PrintErrorMessage("lpc", error_message); return 1; --- 191,195 ---- if (!autocorrelation.SetNumOrder(num_order)) { std::ostringstream error_message; ! error_message << "Failed to set the order of LP coefficients"; sptk::PrintErrorMessage("lpc", error_message); return 1; *************** *** 208,212 **** std::vector<double> windowed_sequence(frame_length); std::vector<double> autocorrelation_sequence(output_length); ! std::vector<double> lpc_coefficients(output_length); for (int frame_index(0); --- 208,212 ---- std::vector<double> windowed_sequence(frame_length); std::vector<double> autocorrelation_sequence(output_length); ! std::vector<double> linear_predictive_coefficients(output_length); for (int frame_index(0); *************** *** 221,226 **** bool is_stable(false); ! if (!recursion.Run(autocorrelation_sequence, &lpc_coefficients, &buffer, ! &is_stable)) { std::ostringstream error_message; error_message << "Failed to solve an autocorrelation normal equation"; --- 221,226 ---- 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"; *************** *** 236,242 **** } ! if (!sptk::WriteStream(output_length, lpc_coefficients, &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write LPC coefficients"; sptk::PrintErrorMessage("lpc", error_message); return 1; --- 236,243 ---- } ! if (!sptk::WriteStream(output_length, linear_predictive_coefficients, ! &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write LP coefficients"; sptk::PrintErrorMessage("lpc", error_message); return 1; --- NEW FILE: input_source_interpolation.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 "input_source_interpolation.h" #include <algorithm> // std::copy, std::transform #include <cstring> // std::size_t #include <functional> // std::plus namespace sptk { InputSourceInterpolation::InputSourceInterpolation( int frame_period, int interpolation_period, InputSourcePreprocessingInterface* source) : frame_period_(frame_period), interpolation_period_(interpolation_period), first_interpolation_period_(interpolation_period / 2), point_index_in_frame_(0), source_(source), is_valid_(false) { if (frame_period <= 0 || interpolation_period < 0 || frame_period / 2 < interpolation_period || NULL == source) { return; } if (!source_->Get(&curr_data_)) { return; } is_valid_ = true; data_length_ = curr_data_.size(); if (!source_->Get(&next_data_)) { next_data_.resize(data_length_); std::copy(curr_data_.begin(), curr_data_.end(), next_data_.begin()); } if (0 < interpolation_period_) { increment_.resize(data_length_); CalculateIncrement(); } } void InputSourceInterpolation::CalculateIncrement() { const double rate(static_cast<double>(interpolation_period_) / frame_period_); for (int i(0); i < data_length_; ++i) { increment_[i] = rate * (next_data_[i] - curr_data_[i]); } } bool InputSourceInterpolation::Get(std::vector<double>* buffer) { if (NULL == buffer || !is_valid_) { return false; } if (buffer->size() < static_cast<std::size_t>(data_length_)) { buffer->resize(data_length_); } std::copy(curr_data_.begin(), curr_data_.end(), buffer->begin()); // Update internal states for the next call. ++point_index_in_frame_; if (0 == point_index_in_frame_ % frame_period_) { // Update current and next data. std::copy(next_data_.begin(), next_data_.end(), curr_data_.begin()); if (!source_->Get(&next_data_)) { // Use the final data until the end of input sequence. std::copy(curr_data_.begin(), curr_data_.end(), next_data_.begin()); } if (0 < interpolation_period_) { CalculateIncrement(); } // Rewind point index. point_index_in_frame_ = 0; } else if (0 < interpolation_period_ && 0 == ((point_index_in_frame_ + first_interpolation_period_) % interpolation_period_)) { // Interpolate adjacent data. std::transform(curr_data_.begin(), curr_data_.end(), increment_.begin(), curr_data_.begin(), std::plus<double>()); } else if (0 == interpolation_period_ && frame_period_ / 2 == point_index_in_frame_) { std::copy(next_data_.begin(), next_data_.end(), curr_data_.begin()); } return true; } } // namespace sptk --- NEW FILE: input_source_interface.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_INPUT_SOURCE_INTERFACE_H_ #define SPTK_SRC_INPUT_SOURCE_INTERFACE_H_ #include <vector> // std::vector namespace sptk { class InputSourceInterface { public: // virtual ~InputSourceInterface() {} // virtual bool GetZeroPaddingFlag() const = 0; // virtual int GetReadSize() const = 0; // virtual bool IsValid() const = 0; // virtual bool Get(std::vector<double>* buffer) = 0; }; } // namespace sptk #endif // SPTK_SRC_INPUT_SOURCE_INTERFACE_H_ Index: all_pole_digital_filter.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/all_pole_digital_filter.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** all_pole_digital_filter.h 29 Jul 2016 07:26:20 -0000 1.2 --- all_pole_digital_filter.h 8 Oct 2016 15:14:59 -0000 1.3 *************** *** 80,85 **** // ! explicit AllPoleDigitalFilter(bool is_transposed) : ! is_transposed_(is_transposed) {} // --- 80,86 ---- // ! AllPoleDigitalFilter(int num_filter_order, bool transposition) ! : num_filter_order_(num_filter_order), ! transposition_(transposition) {} // *************** *** 87,92 **** // bool GetTranspositionFlag() const { ! return is_transposed_; } --- 88,98 ---- // + int GetNumFilterOrder() const { + return num_filter_order_; + } + + // bool GetTranspositionFlag() const { ! return transposition_; } *************** *** 98,102 **** private: // ! const bool is_transposed_; // --- 104,111 ---- private: // ! const int num_filter_order_; ! ! // ! const bool transposition_; // --- NEW FILE: input_source_preprocessing_for_filter_gain.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_INPUT_SOURCE_PREPROCESSING_FOR_FILTER_GAIN_H_ #define SPTK_SRC_INPUT_SOURCE_PREPROCESSING_FOR_FILTER_GAIN_H_ #include <vector> // std::vector #include "input_source_interface.h" #include "input_source_preprocessing_interface.h" #include "sptk_utils.h" namespace sptk { class InputSourcePreprocessingForFilterGain : public InputSourcePreprocessingInterface { public: // enum class FilterGainType { kUnity = 0, kLinear, kLog, }; // InputSourcePreprocessingForFilterGain( FilterGainType gain_type, InputSourceInterface* source) : gain_type_(gain_type), source_(source), is_valid_(false) { if (NULL == source) { return; } is_valid_ = source_->IsValid(); } // virtual ~InputSourcePreprocessingForFilterGain() {} // FilterGainType GetFilterGainType() const { return gain_type_; } // virtual bool IsValid() const { return is_valid_; } // virtual bool Get(std::vector<double>* buffer); private: // const FilterGainType gain_type_; // InputSourceInterface* source_; // bool is_valid_; // DISALLOW_COPY_AND_ASSIGN(InputSourcePreprocessingForFilterGain); }; } // namespace sptk #endif // SPTK_SRC_INPUT_SOURCE_PREPROCESSING_FOR_FILTER_GAIN_H_ --- NEW FILE: input_source_interpolation.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_INPUT_SOURCE_INTERPOLATION_H_ #define SPTK_SRC_INPUT_SOURCE_INTERPOLATION_H_ #include <vector> // std::vector #include "input_source_preprocessing_interface.h" #include "sptk_utils.h" namespace sptk { class InputSourceInterpolation { public: // InputSourceInterpolation(int frame_period, int interpolation_period, InputSourcePreprocessingInterface* source); // virtual ~InputSourceInterpolation() {} // virtual int GetFramePeriod() const { return frame_period_; } // virtual int GetInterpolationPeriod() const { return interpolation_period_; } // virtual bool IsValid() const { return is_valid_; } // virtual bool Get(std::vector<double>* buffer); private: // void CalculateIncrement(); // const int frame_period_; // const int interpolation_period_; // const int first_interpolation_period_; // int data_length_; // int point_index_in_frame_; // InputSourcePreprocessingInterface* source_; // bool is_valid_; // std::vector<double> curr_data_; // std::vector<double> next_data_; // std::vector<double> increment_; // DISALLOW_COPY_AND_ASSIGN(InputSourceInterpolation); }; } // namespace sptk #endif // SPTK_SRC_INPUT_SOURCE_INTERPOLATION_H_ Index: levinson_durbin_recursion.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/levinson_durbin_recursion.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** levinson_durbin_recursion.h 1 Apr 2016 09:05:46 -0000 1.2 --- levinson_durbin_recursion.h 8 Oct 2016 15:14:59 -0000 1.3 *************** *** 84,88 **** // bool Run(const std::vector<double>& autocorrelation_sequence, ! std::vector<double>* lpc_coefficients, LevinsonDurbinRecursion::Buffer* buffer, bool* is_stable) const; --- 84,88 ---- // bool Run(const std::vector<double>& autocorrelation_sequence, ! std::vector<double>* linear_predictive_coefficients, LevinsonDurbinRecursion::Buffer* buffer, bool* is_stable) const; --- NEW FILE: input_source_preprocessing_interface.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_INPUT_SOURCE_PREPROCESSING_INTERFACE_H_ #define SPTK_SRC_INPUT_SOURCE_PREPROCESSING_INTERFACE_H_ #include <vector> // std::vector namespace sptk { class InputSourcePreprocessingInterface { public: // virtual ~InputSourcePreprocessingInterface() {} // virtual bool IsValid() const = 0; // virtual bool Get(std::vector<double>* buffer) = 0; }; } // namespace sptk #endif // SPTK_SRC_INPUT_SOURCE_PREPROCESSING_INTERFACE_H_ Index: poledf.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/poledf.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** poledf.cc 29 Jul 2016 07:26:20 -0000 1.1 --- poledf.cc 8 Oct 2016 15:14:59 -0000 1.2 *************** *** 44,48 **** #include <unistd.h> - #include <algorithm> #include <fstream> #include <iostream> --- 44,47 ---- *************** *** 51,55 **** #include "all_pole_digital_filter.h" ! #include "coefficients_stream_reader.h" #include "sptk_utils.h" --- 50,56 ---- #include "all_pole_digital_filter.h" ! #include "input_source_from_stream.h" ! #include "input_source_interpolation.h" ! #include "input_source_preprocessing_for_filter_gain.h" #include "sptk_utils.h" *************** *** 199,216 **** std::istream& stream_for_filter_input(ifs2.fail() ? std::cin : ifs2); const int filter_length(num_filter_order + 1); std::vector<double> filter_coefficients(filter_length); ! double filter_input; ! double filter_output; ! ! sptk::AllPoleDigitalFilter filter(transposition_flag); sptk::AllPoleDigitalFilter::StoredSignals stored_signals; ! sptk::CoefficientsStreamReader reader(filter_length, ! frame_period, ! interpolation_period, ! &stream_for_filter_coefficients); ! if (!reader.IsValid()) { std::ostringstream error_message; ! error_message << "Failed to set the condition for filtering"; sptk::PrintErrorMessage("poledf", error_message); return 1; --- 200,224 ---- std::istream& stream_for_filter_input(ifs2.fail() ? std::cin : ifs2); + // Prepare variables for filtering. const int filter_length(num_filter_order + 1); std::vector<double> filter_coefficients(filter_length); ! sptk::InputSourceFromStream input_source(false, filter_length, ! &stream_for_filter_coefficients); ! const sptk::InputSourcePreprocessingForFilterGain::FilterGainType gain_type( ! gain_flag ? ! sptk::InputSourcePreprocessingForFilterGain::FilterGainType::kLinear : ! sptk::InputSourcePreprocessingForFilterGain::FilterGainType::kUnity); ! sptk::InputSourcePreprocessingForFilterGain preprocessing(gain_type, ! &input_source); ! sptk::InputSourceInterpolation interpolation(frame_period, ! interpolation_period, ! &preprocessing); ! double filter_input, filter_output; ! sptk::AllPoleDigitalFilter filter(num_filter_order, transposition_flag); sptk::AllPoleDigitalFilter::StoredSignals stored_signals; ! ! if (!interpolation.IsValid()) { std::ostringstream error_message; ! error_message << "Failed to set the conditions for filtering"; sptk::PrintErrorMessage("poledf", error_message); return 1; *************** *** 218,222 **** while (sptk::ReadStream(&filter_input, &stream_for_filter_input)) { ! if (!reader.GetCoefficients(&filter_coefficients)) { std::ostringstream error_message; error_message << "Cannot get filter coefficients"; --- 226,230 ---- while (sptk::ReadStream(&filter_input, &stream_for_filter_input)) { ! if (!interpolation.Get(&filter_coefficients)) { std::ostringstream error_message; error_message << "Cannot get filter coefficients"; *************** *** 225,232 **** } ! if (!gain_flag) filter_coefficients[0] = 1.0; ! ! if (!filter.Run(filter_coefficients, filter_input, ! &filter_output, &stored_signals)) { std::ostringstream error_message; error_message << "Failed to apply all-pole digital filter"; --- 233,238 ---- } ! if (!filter.Run(filter_coefficients, ! filter_input, &filter_output, &stored_signals)) { std::ostringstream error_message; error_message << "Failed to apply all-pole digital filter"; Index: levinson_durbin_recursion.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/levinson_durbin_recursion.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** levinson_durbin_recursion.cc 29 Jul 2016 07:26:20 -0000 1.3 --- levinson_durbin_recursion.cc 8 Oct 2016 15:14:59 -0000 1.4 *************** *** 52,61 **** bool LevinsonDurbinRecursion::Run( const std::vector<double>& autocorrelation_sequence, ! std::vector<double>* lpc_coefficients, LevinsonDurbinRecursion::Buffer* buffer, bool* is_stable) const { // check inputs if (autocorrelation_sequence.empty() || ! NULL == lpc_coefficients || NULL == buffer) { return false; --- 52,61 ---- bool LevinsonDurbinRecursion::Run( 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() || ! NULL == linear_predictive_coefficients || NULL == buffer) { return false; *************** *** 64,69 **** // prepare memories const int output_length(autocorrelation_sequence.size()); ! if (lpc_coefficients->size() < static_cast<std::size_t>(output_length)) { ! lpc_coefficients->resize(output_length); } if (buffer->c_.size() < static_cast<std::size_t>(output_length)) { --- 64,70 ---- // prepare memories const int output_length(autocorrelation_sequence.size()); ! if (linear_predictive_coefficients->size() < ! static_cast<std::size_t>(output_length)) { ! linear_predictive_coefficients->resize(output_length); } if (buffer->c_.size() < static_cast<std::size_t>(output_length)) { *************** *** 73,77 **** // get values const double* input(&(autocorrelation_sequence[0])); ! double* output(&((*lpc_coefficients)[0])); double* c(&buffer->c_[0]); --- 74,78 ---- // get values const double* input(&(autocorrelation_sequence[0])); ! double* output(&((*linear_predictive_coefficients)[0])); double* c(&buffer->c_[0]); Index: levdur.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/levdur.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** levdur.cc 19 Apr 2016 04:27:10 -0000 1.2 --- levdur.cc 8 Oct 2016 15:14:59 -0000 1.3 *************** *** 75,85 **** *stream << " -f f : minimum value of the determinant of [" << kDefaultEpsilon << "]" << std::endl; // NOLINT *stream << " the normal matrix" << std::endl; ! *stream << " -c c : check whether the derived LPC [0]" << std::endl; // NOLINT *stream << " coefficients are stable or not" << std::endl; *stream << " 0 (the check is not performed)" << std::endl; *stream << " 1 (if the coefficients are unstable," << std::endl; // NOLINT ! *stream << " output its index to stderr)" << std::endl; *stream << " 2 (if the coefficients are unstable," << std::endl; // NOLINT ! *stream << " output its index to stderr and" << std::endl; *stream << " exit immediately)" << std::endl; *stream << " -h : print this message" << std::endl; --- 75,85 ---- *stream << " -f f : minimum value of the determinant of [" << kDefaultEpsilon << "]" << std::endl; // NOLINT *stream << " the normal matrix" << std::endl; ! *stream << " -c c : check whether the derived LP [0]" << std::endl; // NOLINT *stream << " coefficients are stable or not" << std::endl; *stream << " 0 (the check is not performed)" << std::endl; *stream << " 1 (if the coefficients are unstable," << std::endl; // NOLINT ! *stream << " output the index to stderr)" << std::endl; *stream << " 2 (if the coefficients are unstable," << std::endl; // NOLINT ! *stream << " output the index to stderr and" << std::endl; *stream << " exit immediately)" << std::endl; *stream << " -h : print this message" << std::endl; *************** *** 87,91 **** *stream << " autocorrelation sequence (double) [stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; ! *stream << " LPC coefficients (double)" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; --- 87,91 ---- *stream << " autocorrelation sequence (double) [stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; ! *stream << " LP coefficients (double)" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; *************** *** 185,189 **** const int length(num_order + 1); std::vector<double> autocorrelation_sequence(length); ! std::vector<double> lpc_coefficients(length); for (int frame_index(0); --- 185,189 ---- const int length(num_order + 1); std::vector<double> autocorrelation_sequence(length); ! std::vector<double> linear_predictive_coefficients(length); for (int frame_index(0); *************** *** 192,197 **** ++frame_index) { bool is_stable(false); ! if (!recursion.Run(autocorrelation_sequence, &lpc_coefficients, &buffer, ! &is_stable)) { std::ostringstream error_message; error_message << "Failed to solve an autocorrelation normal equation"; --- 192,197 ---- ++frame_index) { 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"; *************** *** 207,213 **** } ! if (!sptk::WriteStream(length, lpc_coefficients, &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write LPC coefficients"; sptk::PrintErrorMessage("levdur", error_message); return 1; --- 207,214 ---- } ! if (!sptk::WriteStream(length, linear_predictive_coefficients, ! &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write LP coefficients"; sptk::PrintErrorMessage("levdur", error_message); return 1; Index: all_pole_digital_filter.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/all_pole_digital_filter.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** all_pole_digital_filter.cc 29 Jul 2016 07:26:20 -0000 1.2 --- all_pole_digital_filter.cc 8 Oct 2016 15:14:58 -0000 1.3 *************** *** 55,59 **** AllPoleDigitalFilter::StoredSignals* stored_signals) const { // check inputs ! if (filter_coefficients.empty() || NULL == filter_output || NULL == stored_signals) { --- 55,60 ---- AllPoleDigitalFilter::StoredSignals* stored_signals) const { // check inputs ! if (filter_coefficients.size() != ! static_cast<std::size_t>(num_filter_order_ + 1) || NULL == filter_output || NULL == stored_signals) { *************** *** 62,69 **** // prepare memory - const int num_filter_order(filter_coefficients.size() - 1); if (stored_signals->signals_.size() != ! static_cast<std::size_t>(num_filter_order)) { ! stored_signals->signals_.resize(num_filter_order); std::fill(stored_signals->signals_.begin(), stored_signals->signals_.end(), 0.0); --- 63,69 ---- // prepare memory if (stored_signals->signals_.size() != ! static_cast<std::size_t>(num_filter_order_)) { ! stored_signals->signals_.resize(num_filter_order_); std::fill(stored_signals->signals_.begin(), stored_signals->signals_.end(), 0.0); *************** *** 72,76 **** // set value const double gained_input(filter_input * filter_coefficients[0]); ! if (0 == num_filter_order) { *filter_output = gained_input; return true; --- 72,76 ---- // set value const double gained_input(filter_input * filter_coefficients[0]); ! if (0 == num_filter_order_) { *filter_output = gained_input; return true; *************** *** 83,94 **** // apply filter double sum(gained_input); ! if (is_transposed_) { sum -= signals[0]; ! for (int i(1); i < num_filter_order; ++i) { signals[i - 1] = signals[i] + coefficients[i] * sum; } ! signals[num_filter_order - 1] = coefficients[num_filter_order] * sum; } else { ! for (int i(num_filter_order - 1); 0 < i; --i) { sum -= coefficients[i + 1] * signals[i]; signals[i] = signals[i - 1]; --- 83,94 ---- // apply filter double sum(gained_input); ! if (transposition_) { sum -= signals[0]; ! for (int i(1); i < num_filter_order_; ++i) { signals[i - 1] = signals[i] + coefficients[i] * sum; } ! signals[num_filter_order_ - 1] = coefficients[num_filter_order_] * sum; } else { ! for (int i(num_filter_order_ - 1); 0 < i; --i) { sum -= coefficients[i + 1] * signals[i]; signals[i] = signals[i - 1]; --- NEW FILE: input_source_from_stream.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 "input_source_from_stream.h" namespace sptk { bool InputSourceFromStream::Get(std::vector<double>* buffer) { if (NULL == buffer || !is_valid_) { return false; } return sptk::ReadStream(zero_padding_, read_size_, buffer, input_stream_); } } // namespace sptk |
From: Takenori Y. <tak...@us...> - 2016-10-08 15:07:08
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv15484 Removed Files: coefficients_reader_interface.h coefficients_stream_reader.cc coefficients_stream_reader.h Log Message: remove coefficients_stream_reader for reimplementation --- coefficients_reader_interface.h DELETED --- --- coefficients_stream_reader.cc DELETED --- --- coefficients_stream_reader.h DELETED --- |
From: Keiichiro O. <ur...@us...> - 2016-10-07 06:50:34
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv26446 Modified Files: m_sequence_generation.cc m_sequence_generation.h mseq.cc normal_distributed_random_value_generation.cc normal_distributed_random_value_generation.h nrand.cc Added Files: random_generation_interface.h Log Message: add random generation interface class Index: m_sequence_generation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/m_sequence_generation.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** m_sequence_generation.h 7 Oct 2016 01:03:25 -0000 1.2 --- m_sequence_generation.h 7 Oct 2016 06:50:32 -0000 1.3 *************** *** 46,80 **** #define SPTK_SRC_M_SEQUENCE_GENERATION_H_ #include "sptk_utils.h" namespace sptk { ! class MSequenceGeneration { ! public: ! class Buffer { ! public: ! // ! Buffer(); ! ! // ! ~Buffer() {} ! ! // ! void Clear(); ! ! private: ! // ! int x_; ! ! // ! friend class MSequenceGeneration; ! ! // ! DISALLOW_COPY_AND_ASSIGN(Buffer); ! }; ! public: // ! MSequenceGeneration() {} // --- 46,58 ---- #define SPTK_SRC_M_SEQUENCE_GENERATION_H_ + #include "random_generation_interface.h" #include "sptk_utils.h" namespace sptk { ! class MSequenceGeneration : public RandomGenerationInterface { public: // ! MSequenceGeneration(); // *************** *** 82,89 **** // ! bool Run(double *output, MSequenceGeneration::Buffer *buffer) const; private: // DISALLOW_COPY_AND_ASSIGN(MSequenceGeneration); }; --- 60,73 ---- // ! void Reset(); ! ! // ! bool Get(double *output); private: // + int x_; + + // DISALLOW_COPY_AND_ASSIGN(MSequenceGeneration); }; Index: nrand.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/nrand.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** nrand.cc 7 Oct 2016 00:47:51 -0000 1.1 --- nrand.cc 7 Oct 2016 06:50:32 -0000 1.2 *************** *** 156,164 **** sptk::NormalDistributedRandomValueGeneration generator(seed); - sptk::NormalDistributedRandomValueGeneration::Buffer buffer; for (int i(0); output_length < 0 || i < output_length; ++i) { double output; ! if (!generator.Run(&output, &buffer)) { std::ostringstream error_message; error_message << "Failed to generate M sequence"; --- 156,163 ---- sptk::NormalDistributedRandomValueGeneration generator(seed); for (int i(0); output_length < 0 || i < output_length; ++i) { double output; ! if (!generator.Get(&output)) { std::ostringstream error_message; error_message << "Failed to generate M sequence"; Index: mseq.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/mseq.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mseq.cc 7 Oct 2016 01:03:25 -0000 1.2 --- mseq.cc 7 Oct 2016 06:50:32 -0000 1.3 *************** *** 100,108 **** sptk::MSequenceGeneration generator; - sptk::MSequenceGeneration::Buffer buffer; for (int i(0); output_length < 0 || i < output_length; ++i) { double output; ! if (!generator.Run(&output, &buffer)) { std::ostringstream error_message; error_message << "Failed to generate M-Sequence"; --- 100,107 ---- sptk::MSequenceGeneration generator; for (int i(0); output_length < 0 || i < output_length; ++i) { double output; ! if (!generator.Get(&output)) { std::ostringstream error_message; error_message << "Failed to generate M-Sequence"; Index: m_sequence_generation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/m_sequence_generation.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** m_sequence_generation.cc 7 Oct 2016 01:03:25 -0000 1.2 --- m_sequence_generation.cc 7 Oct 2016 06:50:32 -0000 1.3 *************** *** 56,70 **** namespace sptk { ! MSequenceGeneration::Buffer::Buffer() : x_(kInitialValue) { } ! void MSequenceGeneration::Buffer::Clear() { x_ = kInitialValue; } ! bool MSequenceGeneration::Run(double *output, ! MSequenceGeneration::Buffer *buffer) const { ! // check input ! if (NULL == output || NULL == buffer) { return false; } --- 56,69 ---- namespace sptk { ! MSequenceGeneration::MSequenceGeneration() : x_(kInitialValue) { } ! void MSequenceGeneration::Reset() { x_ = kInitialValue; } ! bool MSequenceGeneration::Get(double *output) { ! // check output ! if (NULL == output) { return false; } *************** *** 73,84 **** int x0, x28; ! buffer->x_ >>= 1; ! if (buffer->x_ & kB0) x0 = 1; else x0 = -1; ! if (buffer->x_ & kB28) x28 = 1; else --- 72,83 ---- int x0, x28; ! x_ >>= 1; ! if (x_ & kB0) x0 = 1; else x0 = -1; ! if (x_ & kB28) x28 = 1; else *************** *** 86,92 **** if (x0 + x28) ! buffer->x_ &= kB31F; else ! buffer->x_ |= kB31; *output = static_cast<double>(x0); --- 85,91 ---- if (x0 + x28) ! x_ &= kB31F; else ! x_ |= kB31; *output = static_cast<double>(x0); --- NEW FILE: random_generation_interface.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_RANDOM_GENERATION_INTERFACE_H_ #define SPTK_SRC_RANDOM_GENERATION_INTERFACE_H_ #include "sptk_utils.h" namespace sptk { class RandomGenerationInterface { public: // virtual ~RandomGenerationInterface() {} // virtual void Reset() = 0; // virtual bool Get(double *output) = 0; }; } // namespace sptk #endif // SPTK_SRC_RANDOM_GENERATION_INTERFACE_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.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** normal_distributed_random_value_generation.h 7 Oct 2016 00:47:51 -0000 1.1 --- normal_distributed_random_value_generation.h 7 Oct 2016 06:50:32 -0000 1.2 *************** *** 46,49 **** --- 46,50 ---- #define SPTK_SRC_NORMAL_DISTRIBUTED_RANDOM_VALUE_GENERATION_H_ + #include "random_generation_interface.h" #include "sptk_utils.h" *************** *** 52,85 **** namespace sptk { ! class NormalDistributedRandomValueGeneration { ! public: ! class Buffer { ! public: ! // ! Buffer(); ! ! // ! ~Buffer() {} ! ! // ! void Clear(); ! ! private: ! // ! bool is_first_; ! std::uint64_t next_; ! bool switch_; ! double r1_, r2_, s_; ! ! // ! friend class NormalDistributedRandomValueGeneration; ! ! // ! DISALLOW_COPY_AND_ASSIGN(Buffer); ! }; ! public: // ! explicit NormalDistributedRandomValueGeneration(int seed) : seed_(seed) {} // --- 53,61 ---- namespace sptk { ! class NormalDistributedRandomValueGeneration : ! public RandomGenerationInterface { public: // ! explicit NormalDistributedRandomValueGeneration(int seed); // *************** *** 87,92 **** // ! bool Run(double *output, ! NormalDistributedRandomValueGeneration::Buffer *buffer) const; private: --- 63,70 ---- // ! void Reset(); ! ! // ! bool Get(double *output); private: *************** *** 95,98 **** --- 73,81 ---- // + std::uint64_t next_; + bool switch_; + double r1_, r2_, s_; + + // DISALLOW_COPY_AND_ASSIGN(NormalDistributedRandomValueGeneration); }; Index: normal_distributed_random_value_generation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/normal_distributed_random_value_generation.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** normal_distributed_random_value_generation.cc 7 Oct 2016 00:47:51 -0000 1.1 --- normal_distributed_random_value_generation.cc 7 Oct 2016 06:50:32 -0000 1.2 *************** *** 63,101 **** namespace sptk { ! NormalDistributedRandomValueGeneration::Buffer::Buffer() : ! is_first_(true), switch_(true) { } ! void NormalDistributedRandomValueGeneration::Buffer::Clear() { ! is_first_ = true; switch_ = true; } ! bool NormalDistributedRandomValueGeneration::Run(double *output, ! NormalDistributedRandomValueGeneration::Buffer *buffer) const { ! // check input ! if (NULL == output || NULL == buffer) { return false; } ! // set seed ! if (buffer->is_first_) { ! buffer->next_ = static_cast<std::uint64_t>(seed_); ! buffer->is_first_ = false; ! } ! ! if (buffer->switch_) { ! buffer->switch_ = false; ! buffer->s_ = 0.0; ! while (1.0 < buffer->s_ || 0.0 == buffer->s_) { ! buffer->r1_ = 2.0 * PseudoRandomGeneration(&(buffer->next_)) - 1.0; ! buffer->r2_ = 2.0 * PseudoRandomGeneration(&(buffer->next_)) - 1.0; ! buffer->s_ = buffer->r1_ * buffer->r1_ + buffer->r2_ * buffer->r2_; } ! buffer->s_ = std::sqrt(-2.0 * std::log(buffer->s_) / buffer->s_); ! *output = buffer->r1_ * buffer->s_; } else { ! buffer->switch_ = true; ! *output = buffer->r2_ * buffer->s_; } --- 63,96 ---- namespace sptk { ! NormalDistributedRandomValueGeneration::NormalDistributedRandomValueGeneration( ! int seed) : ! seed_(seed), switch_(true) { ! next_ = static_cast<std::uint64_t>(seed_); } ! void NormalDistributedRandomValueGeneration::Reset() { ! next_ = static_cast<std::uint64_t>(seed_); switch_ = true; } ! bool NormalDistributedRandomValueGeneration::Get(double *output) { ! // check output ! if (NULL == output) { return false; } ! if (switch_) { ! switch_ = false; ! s_ = 0.0; ! while (1.0 < s_ || 0.0 == s_) { ! r1_ = 2.0 * PseudoRandomGeneration(&(next_)) - 1.0; ! r2_ = 2.0 * PseudoRandomGeneration(&(next_)) - 1.0; ! s_ = r1_ * r1_ + r2_ * r2_; } ! s_ = std::sqrt(-2.0 * std::log(s_) / s_); ! *output = r1_ * s_; } else { ! switch_ = true; ! *output = r2_ * s_; } |
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11326 Modified Files: c2mpir.cc cepstrum_to_minimum_phase_impulse_response.cc cepstrum_to_minimum_phase_impulse_response.h m_sequence_generation.cc m_sequence_generation.h mseq.cc Log Message: modify code format 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.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cepstrum_to_minimum_phase_impulse_response.h 6 Oct 2016 10:33:59 -0000 1.2 --- cepstrum_to_minimum_phase_impulse_response.h 7 Oct 2016 01:03:25 -0000 1.3 *************** *** 48,52 **** #include <vector> // std::vector ! #include "./sptk_utils.h" namespace sptk { --- 48,52 ---- #include <vector> // std::vector ! #include "sptk_utils.h" namespace sptk { Index: m_sequence_generation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/m_sequence_generation.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** m_sequence_generation.h 6 Oct 2016 10:24:54 -0000 1.1 --- m_sequence_generation.h 7 Oct 2016 01:03:25 -0000 1.2 *************** *** 46,50 **** #define SPTK_SRC_M_SEQUENCE_GENERATION_H_ ! #include "./sptk_utils.h" namespace sptk { --- 46,50 ---- #define SPTK_SRC_M_SEQUENCE_GENERATION_H_ ! #include "sptk_utils.h" namespace sptk { 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.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cepstrum_to_minimum_phase_impulse_response.cc 6 Oct 2016 10:33:59 -0000 1.2 --- cepstrum_to_minimum_phase_impulse_response.cc 7 Oct 2016 01:03:25 -0000 1.3 *************** *** 43,47 **** // ----------------------------------------------------------------- // ! #include "./cepstrum_to_minimum_phase_impulse_response.h" #include <cmath> // std::exp --- 43,47 ---- // ----------------------------------------------------------------- // ! #include "cepstrum_to_minimum_phase_impulse_response.h" #include <cmath> // std::exp Index: mseq.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/mseq.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mseq.cc 6 Oct 2016 10:24:54 -0000 1.1 --- mseq.cc 7 Oct 2016 01:03:25 -0000 1.2 *************** *** 43,58 **** // ----------------------------------------------------------------- // ! #include <unistd.h> ! #include <fstream> ! #include <iostream> ! #include <sstream> ! #include <vector> ! ! #include "./m_sequence_generation.h" ! #include "./sptk_utils.h" namespace { ! const int kDefaultNumOutputLength(256); void PrintUsage(std::ostream* stream) { --- 43,52 ---- // ----------------------------------------------------------------- // ! #include "m_sequence_generation.h" ! #include "sptk_utils.h" namespace { ! const int kDefaultOutputLength(256); void PrintUsage(std::ostream* stream) { *************** *** 63,67 **** *stream << " mseq [ options ] > stdout" << std::endl; *stream << " options:" << std::endl; ! *stream << " -l l : output length [" << kDefaultNumOutputLength << "]" << std::endl; // NOLINT *stream << " -h : print this message" << std::endl; *stream << " stdout:" << std::endl; --- 57,61 ---- *stream << " mseq [ options ] > stdout" << std::endl; *stream << " options:" << std::endl; ! *stream << " -l l : output length [" << kDefaultOutputLength << "]" << std::endl; // NOLINT *stream << " -h : print this message" << std::endl; *stream << " stdout:" << std::endl; *************** *** 77,81 **** int main(int argc, char* argv[]) { ! int num_output_length(kDefaultNumOutputLength); for (;;) { --- 71,75 ---- int main(int argc, char* argv[]) { ! int output_length(kDefaultOutputLength); for (;;) { *************** *** 85,89 **** switch (option_char) { case 'l': { ! if (!sptk::ConvertStringToInteger(optarg, &num_output_length)) { std::ostringstream error_message; error_message << --- 79,83 ---- switch (option_char) { case 'l': { ! if (!sptk::ConvertStringToInteger(optarg, &output_length)) { std::ostringstream error_message; error_message << *************** *** 108,116 **** sptk::MSequenceGeneration::Buffer buffer; ! for (int i(0); num_output_length < 0 || i < num_output_length; ++i) { double output; if (!generator.Run(&output, &buffer)) { std::ostringstream error_message; ! error_message << "Failed to generate M sequence"; sptk::PrintErrorMessage("mseq", error_message); return 1; --- 102,110 ---- sptk::MSequenceGeneration::Buffer buffer; ! for (int i(0); output_length < 0 || i < output_length; ++i) { double output; if (!generator.Run(&output, &buffer)) { std::ostringstream error_message; ! error_message << "Failed to generate M-Sequence"; sptk::PrintErrorMessage("mseq", error_message); return 1; Index: m_sequence_generation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/m_sequence_generation.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** m_sequence_generation.cc 6 Oct 2016 10:24:54 -0000 1.1 --- m_sequence_generation.cc 7 Oct 2016 01:03:25 -0000 1.2 *************** *** 43,47 **** // ----------------------------------------------------------------- // ! #include "./m_sequence_generation.h" namespace { --- 43,47 ---- // ----------------------------------------------------------------- // ! #include "m_sequence_generation.h" namespace { Index: c2mpir.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/c2mpir.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** c2mpir.cc 6 Oct 2016 10:04:46 -0000 1.1 --- c2mpir.cc 7 Oct 2016 01:03:25 -0000 1.2 *************** *** 49,54 **** #include <vector> ! #include "./cepstrum_to_minimum_phase_impulse_response.h" ! #include "./sptk_utils.h" namespace { --- 49,54 ---- #include <vector> ! #include "cepstrum_to_minimum_phase_impulse_response.h" ! #include "sptk_utils.h" namespace { |
From: Keiichiro O. <ur...@us...> - 2016-10-07 00:47:54
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10558 Modified Files: Makefile Added Files: normal_distributed_random_value_generation.cc normal_distributed_random_value_generation.h nrand.cc Log Message: add nrand command --- NEW FILE: nrand.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 "normal_distributed_random_value_generation.h" #include "sptk_utils.h" #include <cmath> // std::sqrt namespace { const int kDefaultOutputLength(256); const int kDefaultSeed(1); const double kDefaultMean(0.0); const double kDefaultStandardDeviation(1.0); void PrintUsage(std::ostream* stream) { *stream << std::endl; *stream << " nrand - generate normal distributed random value" << std::endl; *stream << std::endl; *stream << " usage:" << std::endl; *stream << " nrand [ options ] > stdout" << std::endl; *stream << " options:" << std::endl; *stream << " -l l : output length [" << kDefaultOutputLength << "]" << std::endl; // NOLINT *stream << " -s s : seed [" << kDefaultSeed << "]" << std::endl; // NOLINT *stream << " -m m : mean [" << kDefaultMean << "]" << std::endl; // NOLINT *stream << " -v v : variance [" << kDefaultStandardDeviation * kDefaultStandardDeviation << "]" << std::endl; // NOLINT *stream << " -d d : standard deviation [" << kDefaultStandardDeviation << "]" << std::endl; // NOLINT *stream << " -h : print this message" << std::endl; *stream << " stdout:" << std::endl; *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; *stream << std::endl; } } // namespace int main(int argc, char* argv[]) { int output_length(kDefaultOutputLength); int seed(kDefaultSeed); double mean(kDefaultMean); double standard_deviation(kDefaultStandardDeviation); for (;;) { const char option_char(getopt(argc, argv, "l:s:m:v:d:h")); if (-1 == option_char) break; switch (option_char) { case 'l': { if (!sptk::ConvertStringToInteger(optarg, &output_length)) { std::ostringstream error_message; error_message << "The argument for the -l option must be integer"; sptk::PrintErrorMessage("nrand", error_message); return 1; } break; } case 's': { if (!sptk::ConvertStringToInteger(optarg, &seed)) { std::ostringstream error_message; error_message << "The argument for the -s option must be integer"; sptk::PrintErrorMessage("nrand", error_message); return 1; } break; } case 'm': { if (!sptk::ConvertStringToDouble(optarg, &mean)) { std::ostringstream error_message; error_message << "The argument for the -m option must be double"; sptk::PrintErrorMessage("nrand", error_message); return 1; } break; } case 'v': { double variance; if (!sptk::ConvertStringToDouble(optarg, &variance) || variance < 0.0) { std::ostringstream error_message; error_message << "The argument for the -v option must be double"; sptk::PrintErrorMessage("nrand", error_message); return 1; } standard_deviation = std::sqrt(variance); break; } case 'd': { if (!sptk::ConvertStringToDouble(optarg, &standard_deviation) || standard_deviation < 0.0) { std::ostringstream error_message; error_message << "The argument for the -v option must be double"; sptk::PrintErrorMessage("nrand", error_message); return 1; } break; } case 'h': { PrintUsage(&std::cout); return 0; } default: { PrintUsage(&std::cerr); return 1; } } } sptk::NormalDistributedRandomValueGeneration generator(seed); sptk::NormalDistributedRandomValueGeneration::Buffer buffer; for (int i(0); output_length < 0 || i < output_length; ++i) { double output; if (!generator.Run(&output, &buffer)) { std::ostringstream error_message; error_message << "Failed to generate M sequence"; sptk::PrintErrorMessage("nrand", error_message); return 1; } output = mean + output * standard_deviation; if (!sptk::WriteStream(output, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write an output sequence"; sptk::PrintErrorMessage("nrand", error_message); return 1; } } return 0; } Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Makefile 6 Oct 2016 10:24:54 -0000 1.9 --- Makefile 7 Oct 2016 00:47:51 -0000 1.10 *************** *** 53,56 **** --- 53,57 ---- levinson_durbin_recursion.cc \ m_sequence_generation.cc \ + normal_distributed_random_value_generation.cc \ sptk_utils.cc --- NEW FILE: normal_distributed_random_value_generation.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_NORMAL_DISTRIBUTED_RANDOM_VALUE_GENERATION_H_ #define SPTK_SRC_NORMAL_DISTRIBUTED_RANDOM_VALUE_GENERATION_H_ #include "sptk_utils.h" #include <cstdint> // std::uint64_t namespace sptk { class NormalDistributedRandomValueGeneration { public: class Buffer { public: // Buffer(); // ~Buffer() {} // void Clear(); private: // bool is_first_; std::uint64_t next_; bool switch_; double r1_, r2_, s_; // friend class NormalDistributedRandomValueGeneration; // DISALLOW_COPY_AND_ASSIGN(Buffer); }; public: // explicit NormalDistributedRandomValueGeneration(int seed) : seed_(seed) {} // virtual ~NormalDistributedRandomValueGeneration() {} // bool Run(double *output, NormalDistributedRandomValueGeneration::Buffer *buffer) const; private: // const int seed_; // DISALLOW_COPY_AND_ASSIGN(NormalDistributedRandomValueGeneration); }; } // namespace sptk #endif // SPTK_SRC_NORMAL_DISTRIBUTED_RANDOM_VALUE_GENERATION_H_ --- NEW FILE: normal_distributed_random_value_generation.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 "normal_distributed_random_value_generation.h" #include <cmath> // std::sqrt, std::log namespace { // pseudorandom generation double PseudoRandomGeneration(std::uint64_t *next) { double r; *next = (*next) * 1103515245L + 12345; r = ((*next) / 65536L) % 32768L; return r / 32767.0; } }; // namespace namespace sptk { NormalDistributedRandomValueGeneration::Buffer::Buffer() : is_first_(true), switch_(true) { } void NormalDistributedRandomValueGeneration::Buffer::Clear() { is_first_ = true; switch_ = true; } bool NormalDistributedRandomValueGeneration::Run(double *output, NormalDistributedRandomValueGeneration::Buffer *buffer) const { // check input if (NULL == output || NULL == buffer) { return false; } // set seed if (buffer->is_first_) { buffer->next_ = static_cast<std::uint64_t>(seed_); buffer->is_first_ = false; } if (buffer->switch_) { buffer->switch_ = false; buffer->s_ = 0.0; while (1.0 < buffer->s_ || 0.0 == buffer->s_) { buffer->r1_ = 2.0 * PseudoRandomGeneration(&(buffer->next_)) - 1.0; buffer->r2_ = 2.0 * PseudoRandomGeneration(&(buffer->next_)) - 1.0; buffer->s_ = buffer->r1_ * buffer->r1_ + buffer->r2_ * buffer->r2_; } buffer->s_ = std::sqrt(-2.0 * std::log(buffer->s_) / buffer->s_); *output = buffer->r1_ * buffer->s_; } else { buffer->switch_ = true; *output = buffer->r2_ * buffer->s_; } return true; } } // namespace sptk |
From: Keiichiro O. <ur...@us...> - 2016-10-06 10:34:02
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv25694 Modified Files: cepstrum_to_minimum_phase_impulse_response.cc cepstrum_to_minimum_phase_impulse_response.h Log Message: add c2mpir command 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.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** cepstrum_to_minimum_phase_impulse_response.h 6 Oct 2016 10:04:46 -0000 1.1 --- cepstrum_to_minimum_phase_impulse_response.h 6 Oct 2016 10:33:59 -0000 1.2 *************** *** 59,63 **** 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; } --- 59,63 ---- 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: 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.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** cepstrum_to_minimum_phase_impulse_response.cc 6 Oct 2016 10:04:46 -0000 1.1 --- cepstrum_to_minimum_phase_impulse_response.cc 6 Oct 2016 10:33:59 -0000 1.2 *************** *** 55,59 **** // check inputs if (cepstrum_coefficient.size() != ! static_cast<std::size_t>(num_input_order_+1) || NULL == minimum_phase_impulse_response || is_valid_ == false) { --- 55,59 ---- // check inputs if (cepstrum_coefficient.size() != ! static_cast<std::size_t>(num_input_order_ + 1) || NULL == minimum_phase_impulse_response || is_valid_ == false) { |
From: Keiichiro O. <ur...@us...> - 2016-10-06 10:24:56
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv25304 Modified Files: Makefile Added Files: m_sequence_generation.cc m_sequence_generation.h mseq.cc Log Message: add mseq command --- NEW FILE: m_sequence_generation.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 "./m_sequence_generation.h" namespace { const int kInitialValue(0x55555555); const int kB0(0x00000001); const int kB28(0x10000000); const int kB31(0x80000000); const int kB31F(0x7fffffff); const int kZ(0x00000000); }; namespace sptk { MSequenceGeneration::Buffer::Buffer() : x_(kInitialValue) { } void MSequenceGeneration::Buffer::Clear() { x_ = kInitialValue; } bool MSequenceGeneration::Run(double *output, MSequenceGeneration::Buffer *buffer) const { // check input if (NULL == output || NULL == buffer) { return false; } // generate M-Sequence using X**31 + X**28 + 1 int x0, x28; buffer->x_ >>= 1; if (buffer->x_ & kB0) x0 = 1; else x0 = -1; if (buffer->x_ & kB28) x28 = 1; else x28 = -1; if (x0 + x28) buffer->x_ &= kB31F; else buffer->x_ |= kB31; *output = static_cast<double>(x0); return true; } } // namespace sptk Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Makefile 6 Oct 2016 10:04:46 -0000 1.8 --- Makefile 6 Oct 2016 10:24:54 -0000 1.9 *************** *** 52,55 **** --- 52,56 ---- frequency_transform.cc \ levinson_durbin_recursion.cc \ + m_sequence_generation.cc \ sptk_utils.cc --- NEW FILE: mseq.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 <fstream> #include <iostream> #include <sstream> #include <vector> #include "./m_sequence_generation.h" #include "./sptk_utils.h" namespace { const int kDefaultNumOutputLength(256); void PrintUsage(std::ostream* stream) { *stream << std::endl; *stream << " mseq - M-Sequence generation" << std::endl; *stream << std::endl; *stream << " usage:" << std::endl; *stream << " mseq [ options ] > stdout" << std::endl; *stream << " options:" << std::endl; *stream << " -l l : output length [" << kDefaultNumOutputLength << "]" << std::endl; // NOLINT *stream << " -h : print this message" << std::endl; *stream << " stdout:" << std::endl; *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; *stream << std::endl; } } // namespace int main(int argc, char* argv[]) { int num_output_length(kDefaultNumOutputLength); for (;;) { const char option_char(getopt(argc, argv, "l:h")); if (-1 == option_char) break; switch (option_char) { case 'l': { if (!sptk::ConvertStringToInteger(optarg, &num_output_length)) { std::ostringstream error_message; error_message << "The argument for the -l option must be integer"; sptk::PrintErrorMessage("mseq", error_message); return 1; } break; } case 'h': { PrintUsage(&std::cout); return 0; } default: { PrintUsage(&std::cerr); return 1; } } } sptk::MSequenceGeneration generator; sptk::MSequenceGeneration::Buffer buffer; for (int i(0); num_output_length < 0 || i < num_output_length; ++i) { double output; if (!generator.Run(&output, &buffer)) { std::ostringstream error_message; error_message << "Failed to generate M sequence"; sptk::PrintErrorMessage("mseq", error_message); return 1; } if (!sptk::WriteStream(output, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write an output sequence"; sptk::PrintErrorMessage("mseq", error_message); return 1; } } return 0; } --- NEW FILE: m_sequence_generation.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_M_SEQUENCE_GENERATION_H_ #define SPTK_SRC_M_SEQUENCE_GENERATION_H_ #include "./sptk_utils.h" namespace sptk { class MSequenceGeneration { public: class Buffer { public: // Buffer(); // ~Buffer() {} // void Clear(); private: // int x_; // friend class MSequenceGeneration; // DISALLOW_COPY_AND_ASSIGN(Buffer); }; public: // MSequenceGeneration() {} // virtual ~MSequenceGeneration() {} // bool Run(double *output, MSequenceGeneration::Buffer *buffer) const; private: // DISALLOW_COPY_AND_ASSIGN(MSequenceGeneration); }; } // namespace sptk #endif // SPTK_SRC_M_SEQUENCE_GENERATION_H_ |
From: Keiichiro O. <ur...@us...> - 2016-10-06 10:04:48
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24212 Modified Files: Makefile Added Files: c2mpir.cc cepstrum_to_minimum_phase_impulse_response.h cepstrum_to_minimum_phase_impulse_response.cc Log Message: add c2mpir command --- NEW FILE: cepstrum_to_minimum_phase_impulse_response.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_CEPSTRUM_TO_MINIMUM_PHASE_IMPULSE_RESPONSE_H_ #define SPTK_SRC_CEPSTRUM_TO_MINIMUM_PHASE_IMPULSE_RESPONSE_H_ #include <vector> // std::vector #include "./sptk_utils.h" namespace sptk { class CepstrumToMinimumPhaseImpulseResponse { public: // 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; } // virtual ~CepstrumToMinimumPhaseImpulseResponse() {} // int GetNumInputOrder() const { return num_input_order_; } // int GetNumOutputOrder() const { return num_output_order_; } // bool IsValid() const { return is_valid_; } // bool Run(const std::vector<double>& cepstrum_coefficient, std::vector<double>* minimum_phase_sequense) const; private: // int num_input_order_; // int num_output_order_; // bool is_valid_; // DISALLOW_COPY_AND_ASSIGN(CepstrumToMinimumPhaseImpulseResponse); }; } // namespace sptk #endif // SPTK_SRC_CEPSTRUM_TO_MINIMUM_PHASE_IMPULSE_RESPONSE_H_ --- NEW FILE: c2mpir.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 <fstream> #include <iostream> #include <sstream> #include <vector> #include "./cepstrum_to_minimum_phase_impulse_response.h" #include "./sptk_utils.h" namespace { const int kDefaultNumInputOrder(25); const int kDefaultNumOutputOrder(255); void PrintUsage(std::ostream* stream) { *stream << std::endl; *stream << " c2mpir - cepstrum to minimum phase impulse response" << std::endl; // NOLINT *stream << std::endl; *stream << " usage:" << std::endl; *stream << " c2mpir [ options ] [ infile ] > stdout" << std::endl; *stream << " options:" << std::endl; *stream << " -m m : order of cepstrum [" << kDefaultNumInputOrder << "]" << std::endl; // NOLINT *stream << " -M M : order of minimum phase impulse response [" << kDefaultNumOutputOrder << "]" << std::endl; // NOLINT *stream << " -l l : length of minimum phase impulse response [" << kDefaultNumOutputOrder + 1 << "]" << std::endl; // NOLINT *stream << " -h : print this message" << std::endl; *stream << " infile:" << std::endl; *stream << " cepstrum (double) [stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; *stream << " minimum phase impulse response (double)" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; *stream << std::endl; } } // namespace int main(int argc, char* argv[]) { int num_input_order(kDefaultNumInputOrder); int num_output_order(kDefaultNumOutputOrder); for (;;) { const char option_char(getopt(argc, argv, "m:M:l:h")); if (-1 == option_char) break; switch (option_char) { case 'm': { if (!sptk::ConvertStringToInteger(optarg, &num_input_order) || num_input_order < 0) { std::ostringstream error_message; error_message << "The argument for the -m option must be a non-negative integer"; sptk::PrintErrorMessage("c2mpir", error_message); return 1; } break; } case 'M': { if (!sptk::ConvertStringToInteger(optarg, &num_output_order) || num_output_order < 0) { std::ostringstream error_message; error_message << "The argument for the -M option must be a non-negative integer"; sptk::PrintErrorMessage("c2mpir", error_message); return 1; } break; } case 'l': { if (!sptk::ConvertStringToInteger(optarg, &num_output_order) || num_output_order < 1) { std::ostringstream error_message; error_message << "The argument for the -M option must be bigger than 0"; sptk::PrintErrorMessage("c2mpir", error_message); return 1; } num_output_order++; 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("freqt", error_message); return 1; } std::istream& input_stream(ifs.fail() ? std::cin : ifs); // prepare converter 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; error_message << "Failed to set the number of input/output orders"; sptk::PrintErrorMessage("c2mpir", error_message); return 1; } const int input_length(num_input_order + 1); const int output_length(num_output_order + 1); std::vector<double> cepstrum(input_length); std::vector<double> minimum_phase_impulse_response(output_length); 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; } if (!sptk::WriteStream(output_length, minimum_phase_impulse_response, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write an output sequence"; sptk::PrintErrorMessage("c2mpir", error_message); return 1; } } return 0; } --- NEW FILE: cepstrum_to_minimum_phase_impulse_response.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 "./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; } // 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; h[0] = std::exp(c[0]); for (int n(1); n <= num_output_order_; ++n) { 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; } return true; } } // namespace sptk Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Makefile 29 Jul 2016 07:26:20 -0000 1.7 --- Makefile 6 Oct 2016 10:04:46 -0000 1.8 *************** *** 46,54 **** SOURCES = all_pole_digital_filter.cc \ ! autocorrelation.cc \ ! fast_fourier_transform.cc \ ! coefficients_stream_reader.cc \ frequency_transform.cc \ ! levinson_durbin_recursion.cc \ sptk_utils.cc --- 46,55 ---- SOURCES = all_pole_digital_filter.cc \ ! autocorrelation.cc \ ! fast_fourier_transform.cc \ ! cepstrum_to_minimum_phase_impulse_response.cc \ ! coefficients_stream_reader.cc \ frequency_transform.cc \ ! levinson_durbin_recursion.cc \ sptk_utils.cc |
From: Takenori Y. <tak...@us...> - 2016-09-27 06:37:06
|
Update of /cvsroot/sp-tk/SPTK/src/bin/zerodf In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv25310 Modified Files: zerodf.c Log Message: bug fix in zerodf Index: zerodf.c =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/bin/zerodf/zerodf.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** zerodf.c 14 Dec 2015 01:14:25 -0000 1.25 --- zerodf.c 27 Sep 2016 06:37:04 -0000 1.26 *************** *** 139,143 **** int main(int argc, char **argv) { ! int m = ORDER, fprd = FPERIOD, iprd = IPERIOD, i, j; FILE *fp = stdin, *fpc = NULL; double *c, *inc, *cc, *d, x; --- 139,143 ---- int main(int argc, char **argv) { ! int m = ORDER, fprd = FPERIOD, iprd = IPERIOD, i, j, k; FILE *fp = stdin, *fpc = NULL; double *c, *inc, *cc, *d, x; *************** *** 205,210 **** if (ngain) ! for (i = m; i >= 0; i--) ! c[i] /= c[0]; if (!tp) --- 205,210 ---- if (ngain) ! for (k = m; k >= 0; k--) ! c[k] /= c[0]; if (!tp) |