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_ |