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
|
From: fujishita t. <fjs...@us...> - 2016-09-23 05:45:45
|
Update of /cvsroot/sp-tk/SPTK/doc/ref_e In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv19797 Modified Files: pitch.tex ref.tex Log Message: modify reference of pitch command Index: ref.tex =================================================================== RCS file: /cvsroot/sp-tk/SPTK/doc/ref_e/ref.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ref.tex 18 Dec 2015 07:53:26 -0000 1.18 --- ref.tex 23 Sep 2016 05:45:42 -0000 1.19 *************** *** 217,220 **** --- 217,224 ---- Ph.D. Thesis, University of Florida, 116p., 2007. + \bibitem{ref:pitch-REAPER} + ``REAPER: Robust Epoch And Pitch EstimatoR,'' + https://github.com/google/REAPER, 2015. + % GMM-based voice conversion \bibitem{ref:vc-IEEETASLP} Index: pitch.tex =================================================================== RCS file: /cvsroot/sp-tk/SPTK/doc/ref_e/pitch.tex,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** pitch.tex 19 Aug 2016 02:43:45 -0000 1.30 --- pitch.tex 23 Sep 2016 05:45:42 -0000 1.31 *************** *** 54,58 **** {\em pitch} extracts the pitch values from {\em infile} (or standard input), sending the result to standard output. ! The RAPT \cite{ref:pitch-RAPT} , SWIPE' \cite{ref:pitch-SWIPE} and REAPER algorithm are adopted for pitch extraction. They can be specified by --a option. The output format (pitch, F0 or log(F0)) can be specified by --o option. --- 54,58 ---- {\em pitch} extracts the pitch values from {\em infile} (or standard input), sending the result to standard output. ! The RAPT \cite{ref:pitch-RAPT} , SWIPE' \cite{ref:pitch-SWIPE} and REAPER \cite{ref:pitch-REAPER} algorithm are adopted for pitch extraction. They can be specified by --a option. The output format (pitch, F0 or log(F0)) can be specified by --o option. |
From: Takenori Y. <tak...@us...> - 2016-09-23 05:42:48
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv19623 Modified Files: frequency_transform.cc Log Message: modify FrequencyTransform class Index: frequency_transform.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/frequency_transform.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** frequency_transform.cc 29 Jul 2016 07:26:20 -0000 1.7 --- frequency_transform.cc 23 Sep 2016 05:42:45 -0000 1.8 *************** *** 45,49 **** #include "frequency_transform.h" ! #include <algorithm> // std::fill_n #include <cstring> // std::size_t --- 45,49 ---- #include "frequency_transform.h" ! #include <algorithm> // std::copy, std::fill_n #include <cstring> // std::size_t *************** *** 61,69 **** } ! // prepare memories const int output_length(num_output_order_ + 1); if (warped_sequence->size() < static_cast<std::size_t>(output_length)) { warped_sequence->resize(output_length); } if (buffer->d_.size() < static_cast<std::size_t>(output_length)) { buffer->d_.resize(output_length); --- 61,80 ---- } ! // prepare memory const int output_length(num_output_order_ + 1); if (warped_sequence->size() < static_cast<std::size_t>(output_length)) { warped_sequence->resize(output_length); } + + 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; + } + + // prepare buffer if (buffer->d_.size() < static_cast<std::size_t>(output_length)) { buffer->d_.resize(output_length); *************** *** 74,78 **** // get values - const int num_input_order(minimum_phase_sequence.size() - 1); const double* input(&(minimum_phase_sequence[0])); double* output(&((*warped_sequence)[0])); --- 85,88 ---- |
From: fujishita t. <fjs...@us...> - 2016-08-23 08:16:03
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv5285 Added Files: all_zero_digital_filter.h all_zero_digital_filter.cc Log Message: add zerodf command --- NEW FILE: all_zero_digital_filter.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 "all_zero_digital_filter.h" #include <cstring> // std::size_t namespace sptk { bool AllZeroDigitalFilter::Run( const std::vector<double>& filter_coefficients, double filter_input, double* filter_output, AllZeroDigitalFilter::StoredSignals* stored_signals) const { // check inputs if (filter_coefficients.empty() || NULL == filter_output || NULL == stored_signals) { return false; } // 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); } // set value const double gained_input(filter_input * filter_coefficients[0]); if (0 == num_filter_order) { *filter_output = gained_input; return true; } // get values const double* coefficients(&(filter_coefficients[0])); double* signals(&stored_signals->signals_[0]); // 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]; } sum += coefficients[1] * signals[0]; signals[0] = filter_input; } // save result *filter_output = sum; return true; } } // namespace sptk --- NEW FILE: all_zero_digital_filter.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_ALL_ZERO_DIGITAL_FILTER_H_ #define SPTK_SRC_ALL_ZERO_DIGITAL_FILTER_H_ #include <algorithm> // std::fill #include <vector> // std::vector #include "sptk_utils.h" namespace sptk { class AllZeroDigitalFilter { public: class StoredSignals { public: // StoredSignals() {} // ~StoredSignals() {} // void Clear() { std::fill(signals_.begin(), signals_.end(), 0.0); } private: // std::vector<double> signals_; // friend class AllZeroDigitalFilter; // DISALLOW_COPY_AND_ASSIGN(StoredSignals); }; // explicit AllZeroDigitalFilter(bool is_transposed) : is_transposed_(is_transposed) {} // virtual ~AllZeroDigitalFilter() {} // bool GetTranspositionFlag() const { return is_transposed_; } // bool Run(const std::vector<double>& filter_coefficients, double filter_input, double* filter_output, AllZeroDigitalFilter::StoredSignals* signals) const; private: // const bool is_transposed_; // DISALLOW_COPY_AND_ASSIGN(AllZeroDigitalFilter); }; } // namespace sptk #endif // SPTK_SRC_ALL_ZERO_DIGITAL_FILTER_H_ |
From: fujishita t. <fjs...@us...> - 2016-08-19 02:57:32
|
Update of /cvsroot/sp-tk/SPTK/src/bin/pitch In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv19775 Modified Files: pitch.c Log Message: modify help message Index: pitch.c =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/bin/pitch/pitch.c,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** pitch.c 19 Aug 2016 02:40:57 -0000 1.49 --- pitch.c 19 Aug 2016 02:57:30 -0000 1.50 *************** *** 66,70 **** * -t1 t1 : voiced/unvoiced threshold [0.3] * * (used only for SWIPE' algorithm) * ! * value of t1 should be 0.2 < t1 < 0.5 * * -t2 t2 : voiced/unvoiced threshold [0.9] * * (used only for REAPER algorithm) * --- 66,70 ---- * -t1 t1 : voiced/unvoiced threshold [0.3] * * (used only for SWIPE' algorithm) * ! * value of t1 should be 0.5 > t1 > 0.2 * * -t2 t2 : voiced/unvoiced threshold [0.9] * * (used only for REAPER algorithm) * |
From: fujishita t. <fjs...@us...> - 2016-08-19 02:43:47
|
Update of /cvsroot/sp-tk/SPTK/doc/ref_e In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv19216 Modified Files: pitch.tex Log Message: modify help message Index: pitch.tex =================================================================== RCS file: /cvsroot/sp-tk/SPTK/doc/ref_e/pitch.tex,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** pitch.tex 5 Aug 2016 09:30:44 -0000 1.29 --- pitch.tex 19 Aug 2016 02:43:45 -0000 1.30 *************** *** 74,78 **** value of $t0$ should be $-0.6 < t0 < 0.7$}{0.0} \argm{t1}{t1}{voiced/unvoiced threshold (used only for SWIPE' algorithm)\\ ! value of $t1$ should be $0.2 < t1 < 0.5$}{0.3} \argm{t2}{t2}{voiced/unvoiced threshold (used only for REAPER algorithm)\\ value of $t2$ should be $-0.5 < t2 < 1.6$}{0.9} --- 74,78 ---- value of $t0$ should be $-0.6 < t0 < 0.7$}{0.0} \argm{t1}{t1}{voiced/unvoiced threshold (used only for SWIPE' algorithm)\\ ! value of $t1$ should be $0.5 > t1 > 0.2$}{0.3} \argm{t2}{t2}{voiced/unvoiced threshold (used only for REAPER algorithm)\\ value of $t2$ should be $-0.5 < t2 < 1.6$}{0.9} |
From: fujishita t. <fjs...@us...> - 2016-08-19 02:41:00
|
Update of /cvsroot/sp-tk/SPTK/src/bin/pitch In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv19101 Modified Files: pitch.c Log Message: modify help message Index: pitch.c =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/bin/pitch/pitch.c,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** pitch.c 5 Aug 2016 09:30:44 -0000 1.48 --- pitch.c 19 Aug 2016 02:40:57 -0000 1.49 *************** *** 163,167 **** THRESH_SWIPE); fprintf(stderr, " (used only for SWIPE' algorithm)\n"); ! fprintf(stderr, " value of t1 should be 0.2 < t1 < 0.5\n"); fprintf(stderr, " -t2 t2 : voiced/unvoiced threshold [%.1f]\n", THRESH_REAPER); --- 163,167 ---- THRESH_SWIPE); fprintf(stderr, " (used only for SWIPE' algorithm)\n"); ! fprintf(stderr, " value of t1 should be 0.5 > t1 > 0.2\n"); fprintf(stderr, " -t2 t2 : voiced/unvoiced threshold [%.1f]\n", THRESH_REAPER); |
From: fujishita t. <fjs...@us...> - 2016-08-05 09:30:46
|
Update of /cvsroot/sp-tk/SPTK/doc/ref_e In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv20090/doc/ref_e Modified Files: pitch.tex Log Message: add REAPER algorithm Index: pitch.tex =================================================================== RCS file: /cvsroot/sp-tk/SPTK/doc/ref_e/pitch.tex,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** pitch.tex 18 Dec 2015 07:53:26 -0000 1.28 --- pitch.tex 5 Aug 2016 09:30:44 -0000 1.29 *************** *** 46,51 **** \begin{synopsis} ! \item[pitch] [ --a $A$ ] [ --s $S$ ] [ --p $P$ ] [ --T $T$ ] [ --t $t$ ] ! [ --L $Lo$ ] [ --H $Hi$ ] [ --o $O$ ][ {\em infile} ] \end{synopsis} --- 46,52 ---- \begin{synopsis} ! \item[pitch] [ --a $A$ ] [ --s $S$ ] [ --p $P$ ] [ --t0 $t0$ ] [ --t1 $t1$ ] [ --t2 $t2$ ] ! [ --L $Lo$ ] [ --H $Hi$ ] ! \item[\ ~~~~~][ --o $O$ ][ {\em infile} ] \end{synopsis} *************** *** 53,58 **** {\em pitch} extracts the pitch values from {\em infile} (or standard input), sending the result to standard output. ! The RAPT \cite{ref:pitch-RAPT} and SWIPE' \cite{ref:pitch-SWIPE} ! algorithm are adopted for pitch extraction. They can be specified by --a option. The output format (pitch, F0 or log(F0)) can be specified by --o option. --- 54,58 ---- {\em pitch} extracts the pitch values from {\em infile} (or standard input), sending the result to standard output. ! The RAPT \cite{ref:pitch-RAPT} , SWIPE' \cite{ref:pitch-SWIPE} and REAPER algorithm are adopted for pitch extraction. They can be specified by --a option. The output format (pitch, F0 or log(F0)) can be specified by --o option. *************** *** 67,75 **** $A=0$ & ~~~RAPT\\ $A=1$ & ~~~SWIPE'\\ \end{tabular}\\\hspace*{\fill}}{0} \argm{s}{S}{sampling frequency (kHz)}{16.0} \argm{p}{P}{frame shift}{80} ! \argm{T}{T}{voiced/unvoiced threshold (used only for RAPT algorithm)}{0.0} ! \argm{t}{t}{voiced/unvoiced threshold (used only for SWIPE' algorithm)}{0.3} \argm{L}{Lo}{minimum fundamental frequency to search for (Hz)}{60.0} \argm{H}{Hi}{maximum fundamental frequency to search for (Hz)}{240.0} --- 67,80 ---- $A=0$ & ~~~RAPT\\ $A=1$ & ~~~SWIPE'\\ + $A=2$ & ~~~REAPER\\ \end{tabular}\\\hspace*{\fill}}{0} \argm{s}{S}{sampling frequency (kHz)}{16.0} \argm{p}{P}{frame shift}{80} ! \argm{t0}{t0}{voiced/unvoiced threshold (used only for RAPT algorithm)\\ ! value of $t0$ should be $-0.6 < t0 < 0.7$}{0.0} ! \argm{t1}{t1}{voiced/unvoiced threshold (used only for SWIPE' algorithm)\\ ! value of $t1$ should be $0.2 < t1 < 0.5$}{0.3} ! \argm{t2}{t2}{voiced/unvoiced threshold (used only for REAPER algorithm)\\ ! value of $t2$ should be $-0.5 < t2 < 1.6$}{0.9} \argm{L}{Lo}{minimum fundamental frequency to search for (Hz)}{60.0} \argm{H}{Hi}{maximum fundamental frequency to search for (Hz)}{240.0} *************** *** 95,98 **** --- 100,110 ---- \end{qsection} + \begin{qsection}{NOTICE} + \begin{itemize} + \item Regarding -t0 and -t2 option, when the threshold is raised, the number of voiced component increases. + \item Regarding -t1 option, when the threshold is raised, the number of voiced component decreases. + \end{itemize} + \end{qsection} + \begin{qsection}{SEE ALSO} \hyperlink{excite}{excite} |
From: fujishita t. <fjs...@us...> - 2016-08-05 09:30:45
|
Update of /cvsroot/sp-tk/SPTK/src/bin/pitch/reaper/core In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv20090/d/d/d/d/core Added Files: float_matrix.h track.h track.cc file_resource.cc float_matrix-inl.h file_resource.h float_matrix.cc Log Message: add REAPER algorithm --- NEW FILE: track.cc --- /* Copyright 2015 Google Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "../core/track.h" #include <math.h> #include <memory> #include <stdlib.h> #define __STDC_FORMAT_MACROS #include <inttypes.h> #if !defined(INVALID_LOG) #define INVALID_LOG -1.0E+10F #endif // INVALID_LOG namespace { int ToInt(const std::string &s) { char *p = 0; int32_t r = strtol(s.c_str(), &p, 10); return static_cast<int>(r); } std::string ToString(float n, int p) { char buf[1000]; buf[0] = 0; snprintf(buf, sizeof(buf), "%.*f", p, n); return buf; } std::string ToString(uint32_t n) { char buf[1000]; buf[0] = 0; snprintf(buf, sizeof(buf), "%" PRIu32, n); return buf; } double ToDouble(const std::string &s) { char *p = 0; return strtod(s.c_str(), &p); } float ToFloat(const std::string &s) { return static_cast<float>(ToDouble(s)); } // // Default size of character I/O buffers: // const uint32_t kMaxCharBufSize = 8192; // 8k std::string GetToken(FileResource *fr) { char buff[kMaxCharBufSize]; uint32_t i = 0; bool foundData = false; do { buff[i] = fgetc(fr->fp()); if ((iscntrl((unsigned char)buff[i]) || isspace((unsigned char)buff[i])) && !foundData) { continue; } foundData = true; if (iscntrl((unsigned char)buff[i]) || isspace((unsigned char)buff[i])) { break; } i++; } while (i < kMaxCharBufSize && !fr->eof()); buff[i] = 0; return std::string(buff); } // Find the first whitespace/newline delimited token in the character // array c. Return the stripped token in s. return the position of // the first character following the token in tok_end. If the end of // c is found during the search, return true, else return false. If no // token is found, return 0 in tok_end. bool GetTokenFromChars(const char *c, std::string *s, int32_t *tok_end) { int32_t i = 0; s->clear(); *tok_end = 0; // skip initial whitespace while (c[i] && ((c[i] == ' ') || (c[i] == '\t') || (c[i] == '\n'))) { i++; } if (!c[i]) { return true; } int32_t start = i; while (c[i] && (c[i] != ' ') && (c[i] != '\t') && (c[i] != '\n')) { i++; } *tok_end = i; if (c[i-1] == '\r') { --i; } s->assign(c + start, i - start); return c[i] == 0; } } // namespace Track::Track() { num_frames_ = 0; num_channels_ = 0; shift_ = 0.0F; voicing_enabled_ = false; } void Track::FillFrom(const Track &t) { num_frames_ = t.num_frames_; num_channels_ = t.num_channels_; shift_ = t.shift_; data_ = t.data_; val_ = t.val_; voicing_enabled_ = t.voicing_enabled_; } Track::~Track() { Clear(); } bool Track::Save(FileResource *fr) const { fprintf(fr->fp(), "EST_File Track\n"); fprintf(fr->fp(), "DataType binary2\n"); fprintf(fr->fp(), "NumFrames %d\n", num_frames()); fprintf(fr->fp(), "NumChannels %d\n", num_channels()); fprintf(fr->fp(), "FrameShift %f\n", shift()); if (voicing_enabled_) { fprintf(fr->fp(), "VoicingEnabled true\n"); } else { fprintf(fr->fp(), "VoicingEnabled false\n"); } fprintf(fr->fp(), "EST_Header_End\n"); // write time information for (int i = 0; i < num_frames(); ++i) { float f = t(i); if (fwrite(&f, sizeof(f), 1, fr->fp()) != 1) { fprintf(stderr, "Failed to write to track file"); return false; } } // write voicing information if (voicing_enabled_) { for (int i = 0; i < num_frames(); ++i) { char vu = v(i) ? 1 : 0; if (fwrite(&vu, sizeof(vu), 1, fr->fp()) != 1) { fprintf(stderr, "Failed to write to track file"); return false; } } } // write coefficient information for (int i = 0; i < num_frames(); ++i) { for (int j = 0; j < num_channels(); ++j) { float f = a(i, j); if (fwrite(&f, sizeof(f), 1, fr->fp()) != 1) { fprintf(stderr, "Failed to write to track file"); return false; } } } return true; } int Track::Index(float x) const { if (num_frames() > 1) { // if single frame, return that index (0) int bst, bmid, bend; bst = 1; bend = num_frames(); if (x < t(bst)) { bmid = bst; } if (x >= t(bend - 1)) { bmid = bend - 1; } else { while (1) { bmid = bst + (bend - bst) / 2; if (bst == bmid) { break; } else if (x < t(bmid)) { if (x >= t(bmid - 1)) { break; } bend = bmid; } else { bst = bmid; } } } if (fabs(x - t(bmid)) < fabs(x - t(bmid - 1))) { return bmid; } else { return bmid - 1; } } return num_frames() - 1; } int Track::IndexBelow(float x) const { for (int i = 1; i < num_frames(); ++i) { if (x <= t(i)) { return i - 1; } } return num_frames() - 1; } int Track::IndexAbove(float x) const { for (int i = 0; i < num_frames(); ++i) { if (x <= t(i)) { return i; } } return num_frames() - 1; } std::string Track::HeaderToString() const { std::string ret; ret = "EST_File Track\n"; ret += "DataType ascii\n"; ret += "NumFrames " + ::ToString(num_frames()) + "\n"; ret += "NumChannels " + ::ToString(num_channels()) + "\n"; ret += "FrameShift " + ::ToString(shift(), 5) + "\n"; ret += "VoicingEnabled "; if (voicing_enabled_) { ret += "true\n"; } else { ret += "false\n"; } ret += "EST_Header_End\n"; return ret; } std::string Track::ToString(uint32_t precision) const { std::string ret; ret = HeaderToString(); char buf[1024]; for (int i = 0; i < num_frames(); ++i) { snprintf(buf, 1024, "%f %d", t(i), v(i) ? 1 : 0); ret += buf; for (int j = 0; j < num_channels(); ++j) { ret += " "; ret += ::ToString(a(i, j), precision); } ret += std::string("\n"); } return ret; } std::string Track::ToString() const { const uint32_t kPrintOutPrecision = 6; return ToString(kPrintOutPrecision); } float Track::shift() const { return shift_; } void Track::FillTime(float frame_shift, int start) { shift_ = frame_shift; for (int i = 0; i < num_frames_; ++i) { data_.Set(0, i, frame_shift * (i + start)); } } void Track::FillTime(const Track &t) { for (int i = 0; i < num_frames_; ++i) { data_.Set(0, i, t.t(i)); } } void Track::SetTimes(float *times, int length) { if (length != num_frames_) { fprintf(stderr, "Track::SetTimes: input `times` has different number " "of frames (%d != %d)", length, num_frames_); } for (int i = 0; i < num_frames_; ++i) { data_.Set(0, i, times[i]); } } bool Track::SetVoicing(const std::vector<bool> &vuv) { if (vuv.size() != num_frames_) { fprintf(stderr, "Track::SetVoicing: input has different number " "of frames (%zu != %d)", vuv.size(), num_frames_); return false; } val_ = vuv; return true; } void Track::FrameOut(std::vector<float> *fv, int n) const { fv->resize(num_channels_); for (int i = 0; i < num_channels_; i++) { (*fv)[i] = a(n, i); } } void Track::FrameOut(std::vector<double> *fv, int n) const { fv->resize(num_channels_); for (int i = 0; i < num_channels_; i++) { (*fv)[i] = a(n, i); } } void Track::FrameIn(const float &f, int n) { a(n) = f; } void Track::FrameIn(const std::vector<float> &fv, int n) { for (int i = 0; i < num_channels_; i++) { a(n, i) = fv[i]; } } void Track::FrameIn(const std::vector<double> &fv, int n) { for (int i = 0; i < num_channels_; i++) { a(n, i) = fv[i]; } } Track *Track::GetSubTrack(float start, float end, int ch_offset, int ch_size) const { int start_frame = -1; int end_frame = -1; int n_sub_frames; int i, j; for (i = 0; i < this->num_frames(); ++i) { if ((start_frame == -1) && (this->t(i) > start)) { start_frame = i - 1; } if ((end_frame == -1) && (this->t(i) > end)) { end_frame = i; } } if (start_frame == -1) { start_frame = this->num_frames() - 1; } if (end_frame == -1) { end_frame = this->num_frames() - 1; } n_sub_frames = end_frame - start_frame; if (n_sub_frames < 1) { // make sure we have at least one frame n_sub_frames = 1; } if (ch_size == -1 && ch_offset == -1) { ch_offset = 0; ch_size = this->num_channels(); } else { if (ch_size > this->num_channels()) { fprintf(stderr, "Incorrect number of channels for sub track"); return NULL; } } Track *sub_track = new Track; sub_track->resize(n_sub_frames, ch_size); for (i = 0; i < n_sub_frames; ++i) { sub_track->t(i) = this->t(i + start_frame); for (j = ch_offset; j < ch_size; ++j) { sub_track->a(i, j) = this->a(i + start_frame, j); } } return sub_track; } Track *Track::GetSubTrack(int start_frame_index, int end_frame_index, int start_channel_index, int end_channel_index) const { if (start_frame_index > end_frame_index || start_frame_index < 0 || start_frame_index >= this->num_frames() || end_frame_index < 0 || end_frame_index >= this->num_frames()) { fprintf(stderr, "Incorrect frame indices for sub-track 0<%d<=%d<%d\n", start_frame_index, end_frame_index, this->num_frames()); return NULL; } if (start_channel_index > end_channel_index || start_channel_index < 0 || start_channel_index >= this->num_channels() || end_channel_index < 0 || end_channel_index >= this->num_channels()) { fprintf(stderr, "Incorrect channel indices for sub-track 0<%d<=%d<%d\n", start_channel_index, end_channel_index, this->num_channels()); return NULL; } Track *sub_track = new Track; int number_frames = end_frame_index - start_frame_index + 1; int number_channels = end_channel_index - start_channel_index + 1; sub_track->resize(number_frames, number_channels); for (int f = 0; f < number_frames; f++) { for (int p = 0; p < number_channels; p++) { sub_track->a(f, p) = this->a(start_frame_index + f, start_channel_index + p); } sub_track->t(f) = this->t(start_frame_index + f); sub_track->set_v(f, this->v(start_frame_index + f)); } sub_track->set_shift(this->shift()); return sub_track; } void Track::resize(int n, int c) { if (n != num_frames_) { val_.resize(n, 1); } data_.resize(c + 1, n); num_frames_ = n; num_channels_ = c; } void Track::Clear() { num_frames_ = 0; num_channels_ = 0; shift_ = 0.0F; data_.clear(); val_.clear(); } void Track::CopyFrom(const char *v, int32_t num_frames, int32_t num_channels) { resize(num_frames, num_channels); const float* source = reinterpret_cast<const float*>(v); for (int32_t i = 0; i < num_frames; ++i) { for (int32_t j = 0; j < num_channels; ++j) { a(i, j) = *source++; } } } // Sets current track to be combination of two tracks bool Track::SetCombinedTrack(const Track &track_a, const Track &track_b) { if (track_a.num_frames() != track_b.num_frames()) { fprintf(stderr, "Mismatching number of frames: %d vs. %d", track_a.num_frames(), track_b.num_frames()); return false; } const int n_frames = track_a.num_frames(); const int n_channels_a = track_a.num_channels(); const int n_channels_b = track_b.num_channels(); resize(n_frames, n_channels_a + n_channels_b); for (int i = 0; i < n_frames; i++) { for (int j = 0; j < n_channels_a; j++) { a(i, j) = track_a.a(i, j); } for (int j = 0; j < n_channels_b; j++) { a(i, n_channels_a + j) = track_b.a(i, j); } set_v(i, track_a.v(i) && track_b.v(i)); } return true; } bool Track::SetCombinedTrack(const Track &track_a, const Track &track_b, const Track &track_c) { Track track_ab; if (!track_ab.SetCombinedTrack(track_a, track_b)) { return false; } return SetCombinedTrack(track_ab, track_c); } // Pads a track with <num_pads> frames: bool Track::Pad(int num_pads) { if (num_pads <= 0) { return false; } const int num_original_frames = num_frames(); const int num_original_channels = num_channels(); Track new_track; new_track.resize(num_original_frames + num_pads, num_original_channels); for (int i = 0; i < num_original_frames; ++i) { for (int j = 0; j < num_original_channels; ++j) { new_track.a(i, j) = a(i, j); } new_track.set_v(i, v(i)); } for (int i = 0; i < num_pads; ++i) { for (int j = 0; j < num_original_channels; ++j) { new_track.a(num_original_frames + i, j) = a(num_original_frames - 1, j); } new_track.set_v(i, v(num_original_frames - 1)); } const int num_new_frames = new_track.num_frames(); Clear(); resize(num_new_frames, num_original_channels); for (int i = 0; i < num_new_frames; ++i) { for (int j = 0; j < num_original_channels; ++j) { a(i, j) = new_track.a(i, j); } set_v(i, new_track.v(i)); } return true; } // Forces the two tracks to have the same size, padding if necessary. void Track::MakeSameSize(Track *track) { int max_frames = num_frames(); if (track->num_frames() > max_frames) { max_frames = track->num_frames(); } Pad(max_frames - num_frames()); track->Pad(max_frames - track->num_frames()); } // Forces the three tracks to have same size, padding if necessary. void Track::MakeSameSize(Track *track_a, Track *track_b) { int max_frames = num_frames(); if (track_a->num_frames() > max_frames) { max_frames = track_a->num_frames(); } if (track_b->num_frames() > max_frames) { max_frames = track_b->num_frames(); } Pad(max_frames - num_frames()); track_a->Pad(max_frames - track_a->num_frames()); track_b->Pad(max_frames - track_b->num_frames()); } //------------------------------------------------------------------------------ // Utils. //------------------------------------------------------------------------------ void ConvertToLogarithmic(Track *t) { for (int32_t i = 0; i < t->num_frames(); ++i) { for (int32_t j = 0; j < t->num_channels(); ++j) { if (t->a(i, j) <= 0.0F) { t->a(i, j) = INVALID_LOG; } else { t->a(i, j) = log(t->a(i, j)); } } } } float *TrackToFloatPointer(const Track &track, int *num_samples) { *num_samples = track.num_channels() * track.num_frames(); float *array = new float[*num_samples]; uint32_t k = 0; for (int i = 0; i < track.num_frames(); ++i) { for (int j = 0; j < track.num_channels(); ++j) { array[k++] = track.a(i, j); } } return array; } --- NEW FILE: float_matrix.cc --- /* Copyright 2015 Google Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "../core/float_matrix.h" #include <string.h> FloatMatrix::FloatMatrix() { data_ = NULL; x_size_ = 0; y_size_ = 0; } FloatMatrix::FloatMatrix(const FloatMatrix &m) { clear(); resize(m.x_size_, m.y_size_); for (uint32_t i = 0; i < x_size_ * y_size_; i++) { data_[i] = m.data_[i]; } } FloatMatrix::~FloatMatrix() { clear(); } void FloatMatrix::operator=(const FloatMatrix &m) { clear(); resize(m.x_size_, m.y_size_); for (uint32_t i = 0; i < x_size_ * y_size_; i++) { data_[i] = m.data_[i]; } } void FloatMatrix::clear() { if (data_ != NULL) { delete [] data_; data_ = NULL; } x_size_ = 0; y_size_ = 0; } void FloatMatrix::resize(uint32_t x_size, uint32_t y_size) { if (data_ == NULL) { data_ = new float [x_size * y_size]; memset(data_, 0, sizeof(float)*x_size * y_size); } else if (x_size == x_size_ && y_size == y_size_) { return; } else { float *newdata = new float [x_size * y_size]; memset(newdata, 0, sizeof(float) * x_size * y_size); int min_x = x_size < x_size_ ? x_size : x_size_; int min_y = y_size < y_size_ ? y_size : y_size_; for (int y = 0; y < min_y; y++) { memcpy(newdata + y * x_size, data_ + y * x_size_, min_x * sizeof(float)); } delete [] data_; data_ = newdata; } x_size_ = x_size; y_size_ = y_size; } --- NEW FILE: float_matrix.h --- /* Copyright 2015 Google Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // A memory mappable float matrix with restricted use, composite audio and // track classes being its current uses. Its further use should be avoided // as its designed to meet the specific needs of these classes. #ifndef _FLOAT_MATRIX_H_ #define _FLOAT_MATRIX_H_ #include <stdint.h> #include <string> class FloatMatrix { public: FloatMatrix(); FloatMatrix(const FloatMatrix &); ~FloatMatrix(); void operator = (const FloatMatrix &); void resize(uint32_t x_size, uint32_t y_size); void clear(); float Get(uint32_t x, uint32_t y) const; float &Get(uint32_t x, uint32_t y); void Set(uint32_t x, uint32_t y, float val); uint32_t get_x_size() const; uint32_t get_y_size() const; uint32_t size() const; const float *data(void) const; void StringWrite(std::string *out) const; private: float *data_; uint32_t x_size_; uint32_t y_size_; }; #include "float_matrix-inl.h" #endif // _FLOAT_MATRIX_H_ --- NEW FILE: track.h --- /* Copyright 2015 Google Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef _TRACK_H_ #define _TRACK_H_ #include <stdint.h> #include <string> #include <vector> #include "../core/file_resource.h" #include "../core/float_matrix.h" class Track { public: Track(); ~Track(); void FillFrom(const Track &track); // Returns the number of frames contained within this track instance. int num_frames() const; // Returns the number of channels contained within this track instance. int num_channels() const; // Returns whether the voicing is enabled on this track instance. bool voicing_enabled() const; // Sets the voicing enable flag on this track instance. void set_voicing_enabled(bool b); // Gets values for frame "f" and channel "c". float &a(int f, int c = 0); // Gets values for frame "f" and channel "c". float a(int f, int c = 0) const; // Gets voiced flags for frame "f". void set_v(int f, bool value); // Gets voiced flags for frame "f". bool v(int f) const; // Gets time instant for frame "f". float &t(int f); // Gets time instant for frame "f". float t(int f) const; // Sets the interval between frames in seconds. void set_shift(float shift); // Returns the interval between frames in seconds. float shift() const; // Modifies this track instances frame times with that given, from the // given frame index. void FillTime(float frame_shift, int start = 1); // Modifies this track instances frame times with the value corresponding // to its frame index. void FillTime(const Track &t); // Modifies the times of this track instance with the given values. // NOTE: the length must be equal to the number of frames in the track. void SetTimes(float *times, int length); // Modifies the voicing flag of this track instance with the given values. bool SetVoicing(const std::vector<bool> &vuv); // Sets the track from the given time and value vectors. // All frames are set to voiced. template <typename ValueType> void Set(const std::vector<ValueType> ×, const std::vector<ValueType> &values); // Sets the track from the given time and value vectors. // All frames are set to voiced. template <typename ValueType> void Set(float time_shift, const std::vector<ValueType> &values); // Populates the given vector with the values for all channels for // the given frame index. void FrameOut(std::vector<float> *fv, int n) const; // Populates the given vector with the values for all channels for // the given frame index. void FrameOut(std::vector<double> *fv, int n) const; // Updates the values for all channels for the given frame index with // the values given. void FrameIn(const float &f, int n); // Updates the values for all channels for the given frame index with // the values given. void FrameIn(const std::vector<float> &fv, int n); // Updates the values for all channels for the given frame index with // the values given. void FrameIn(const std::vector<double> &fv, int n); // Returns the index of the frame at the given time index. int Index(float x) const; // Returns the index of the first frame below that at the given time index, x. int IndexBelow(float x) const; // Returns the index of the first frame above that at the given time index, x. int IndexAbove(float x) const; // Resizes the data and voicing flags to the given value, n, and the // number of channels to that given, c. void resize(int n, int c = 1); // Resets all the data associated with this track instance. void Clear(); // Returns a portion of this track instance as defined by the input // start and end times along with the channels required. // Note: Ownership of the returned track is required to prevent // memory leaks downstream. Track *GetSubTrack(float start, float end, int ch_offset = -1, int ch_size = -1) const; // Returns a portion of this track instance as defined by the input // start and end frame indices along with the channels required. // Note: Ownership of the returned track is required to prevent // memory leaks downstream. Track *GetSubTrack(int start_frame_index, int end_frame_index, int start_channel_index, int end_channel_index) const; // Returns a std::string representation of the header of this track: // The number of frames in this track // The number of channels in this track // The interval between frames // Whether voicing is enabled or not std::string HeaderToString() const; // Returns a std::string representation of this track instance containing: // The number of frames in this track // The number of channels in this track // The interval between frames // Whether voicing is enabled or not // values // If precision is specified, float numbers are printed out up to // the specified number of decimal places. std::string ToString(uint32_t precision) const; std::string ToString() const; // Saves this track instance to the given FileResource. bool Save(FileResource *fr) const; // Saves this track instance to the given FileResource. bool Save(const std::string &filename, bool ascii) const; const FloatMatrix &data() const; // Resizes the track to the number of frames and channels given, // copying the given data into the track. void CopyFrom(const char *v, int32_t num_frames, int32_t num_channels); // Sets this track to be a combination of two input tracks bool SetCombinedTrack(const Track &track_a, const Track &track_b); // Sets this track to be combination of three input tracks bool SetCombinedTrack(const Track &track_a, const Track &track_b, const Track &track_c); // Pads a track by repeating the last frame num_pads times. bool Pad(int num_pads); // Makes the current track and ref track equal lengths, use the longest length // and zero pad the shorter track if the are different lengths. void MakeSameSize(Track *track); // Makes the current track and ref track equal lengths, use the longest length // and zero pad the shorter tracks if any are shorter than the longest. void MakeSameSize(Track *track_a, Track *track_b); private: // Holds the number of frames of this track instance. int num_frames_; // Holds the number of channels of this track instance. int num_channels_; // Holds the frames values and times of this track instance. FloatMatrix data_; // Holds the voicing flags of this track instance. std::vector<bool> val_; // Holds whether this track instance has voicing enabled. bool voicing_enabled_; // The frame interval in seconds. float shift_; }; // Applies logarithm to all data values. Invalid values are set to INVALID_LOG. void ConvertToLogarithmic(Track *t); // Returns a new vector with the track data as a single sequence of // values. The caller takes ownership fo the pointer. float *TrackToFloatPointer(const Track &track, int *num_samples); inline int Track::num_frames() const { return num_frames_; } inline int Track::num_channels() const { return num_channels_; } inline float &Track::a(int f, int c) { return data_.Get(c + 1, f); } inline float Track::a(int f, int c) const { return data_.Get(c + 1, f); } inline void Track::set_v(int f, bool value) { // If a writable reference is used, force the track into // voicing enabled mode. voicing_enabled_ = true; val_[f] = value; } inline bool Track::v(int f) const { return val_[f]; } inline float &Track::t(int f) { return data_.Get(0, f); } inline float Track::t(int f) const { return data_.Get(0, f); } inline void Track::set_shift(float shift) { shift_ = shift; } inline const FloatMatrix &Track::data() const { return data_; } inline bool Track::voicing_enabled() const { return voicing_enabled_; } inline void Track::set_voicing_enabled(bool b) { voicing_enabled_ = b; } inline bool Track::Save(const std::string &filename, bool ascii) const { FileResource fr(filename, "wb"); if (!fr.Get()) { fprintf(stderr, "Failed to write '%s'", filename.c_str()); return false; } if (!ascii) { return Save(&fr); } const std::string data = ToString(); if (fprintf(fr.fp(), "%s", data.c_str()) != data.size()) { return false; } return true; } template <typename ValueType> void Track::Set(const std::vector<ValueType> ×, const std::vector<ValueType> &values) { if (times.size() != values.size()) { fprintf(stderr, "Length of time and value vectors should equal (%d != %d)", times.size(), values.size()); return; } resize(times.size()); for (int n = 0; n < times.size(); ++n) { t(n) = times[n]; a(n) = values[n]; set_v(n, true); } } template <typename ValueType> void Track::Set(float time_shift, const std::vector<ValueType> &values) { resize(values.size()); FillTime(time_shift, 0); for (int n = 0; n < values.size(); ++n) { a(n) = values[n]; set_v(n, true); } } #endif // _TRACK_H_ --- NEW FILE: float_matrix-inl.h --- /* Copyright 2015 Google Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef _FLOAT_MATRIX_INL_H_ #define _FLOAT_MATRIX_INL_H_ // IWYU pragma: private, include "float_matrix.h" inline uint32_t FloatMatrix::get_x_size(void) const { return x_size_; } inline uint32_t FloatMatrix::get_y_size(void) const { return y_size_; } // y1x1 y1x2 y1x3 y1x4 y2x1 y2x2 y2x3 y2x4 inline float FloatMatrix::Get(uint32_t x, uint32_t y) const { return data_[y * x_size_ + x]; } inline float &FloatMatrix::Get(uint32_t x, uint32_t y) { #ifdef _DEBUG if (y >= y_size_ || x >= x_size_) { fprintf(stderr, "Matrix boundary overrun error"); } #endif return data_[y * x_size_ + x]; } inline void FloatMatrix::Set(uint32_t x, uint32_t y, float val) { #ifdef _DEBUG if (y >= y_size_ || x >= x_size_) { fprintf(stderr, "Matrix boundary overrun error"); } #endif data_[y *x_size_ + x] = val; } inline uint32_t FloatMatrix::size() const { return x_size_ * y_size_; } inline const float *FloatMatrix::data(void) const { return data_; } inline void FloatMatrix::StringWrite(std::string *out) const { if (size()) { char *source = reinterpret_cast<char*>(data_); out->append(source, size() * sizeof(*data_)); } } #endif // SPEECH_PATTS_ENGINE_COMMON_CORE_FLOAT_MATRIX_INL_H_ --- NEW FILE: file_resource.cc --- /* Copyright 2015 Google Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "../core/file_resource.h" FileResource::FileResource(const std::string &filename, const std::string &mode) : filename_(filename), mode_(mode) { } FileResource::~FileResource() { fclose(fp_); } bool FileResource::Get() { fp_ = fopen(filename_.c_str(), mode_.c_str()); return fp_ != NULL; } --- NEW FILE: file_resource.h --- /* Copyright 2015 Google Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef _FILE_RESOURCE_H_ #define _FILE_RESOURCE_H_ #include <stdio.h> #include <string> class FileResource { public: // Mode follows the standard (eg. "wb", "r"). FileResource(const std::string &filename, const std::string &mode); ~FileResource(); // Opens a file with the specified mode. Returns false if it fails. bool Get(); FILE *fp() { return fp_; } bool eof() const { return feof(fp_) != 0; } private: std::string filename_; std::string mode_; FILE *fp_; }; #endif // _FILE_RESOURCE_H_ |
From: fujishita t. <fjs...@us...> - 2016-08-05 08:23:38
|
Update of /cvsroot/sp-tk/SPTK/src/bin/pitch/reaper/core In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv17160/core Log Message: Directory /cvsroot/sp-tk/SPTK/src/bin/pitch/reaper/core added to the repository |
From: fujishita t. <fjs...@us...> - 2016-08-05 08:21:28
|
Update of /cvsroot/sp-tk/SPTK/src/bin/pitch/reaper In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv17081/reaper Log Message: Directory /cvsroot/sp-tk/SPTK/src/bin/pitch/reaper added to the repository |
From: Takenori Y. <tak...@us...> - 2016-07-29 07:26:23
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv21106 Modified Files: Makefile all_pole_digital_filter.cc all_pole_digital_filter.h autocorrelation.cc fast_fourier_transform.cc fft.cc frequency_transform.cc levinson_durbin_recursion.cc sptk_utils.cc sptk_utils.h Added Files: coefficients_reader_interface.h coefficients_stream_reader.cc coefficients_stream_reader.h poledf.cc Log Message: add poledf command Index: frequency_transform.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/frequency_transform.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** frequency_transform.cc 25 Mar 2016 06:04:51 -0000 1.6 --- frequency_transform.cc 29 Jul 2016 07:26:20 -0000 1.7 *************** *** 57,71 **** if (minimum_phase_sequence.empty() || NULL == warped_sequence || ! NULL == buffer) return false; // prepare memories const int output_length(num_output_order_ + 1); ! if (warped_sequence->size() < static_cast<std::size_t>(output_length)) warped_sequence->resize(output_length); ! if (buffer->d_.size() < static_cast<std::size_t>(output_length)) buffer->d_.resize(output_length); ! if (buffer->g_.size() < static_cast<std::size_t>(output_length)) buffer->g_.resize(output_length); // get values --- 57,75 ---- if (minimum_phase_sequence.empty() || NULL == warped_sequence || ! NULL == buffer) { return false; + } // prepare memories const int output_length(num_output_order_ + 1); ! if (warped_sequence->size() < static_cast<std::size_t>(output_length)) { warped_sequence->resize(output_length); ! } ! if (buffer->d_.size() < static_cast<std::size_t>(output_length)) { buffer->d_.resize(output_length); ! } ! if (buffer->g_.size() < static_cast<std::size_t>(output_length)) { buffer->g_.resize(output_length); + } // get values Index: sptk_utils.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/sptk_utils.cc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** sptk_utils.cc 19 Apr 2016 04:27:10 -0000 1.8 --- sptk_utils.cc 29 Jul 2016 07:26:20 -0000 1.9 *************** *** 52,68 **** namespace sptk { ! bool ReadStream(const bool& zero_padding, const int& read_size, std::vector<double>* sequence_to_read, std::istream* input_stream) { if (read_size <= 0 || NULL == sequence_to_read || ! NULL == input_stream) return false; ! if (input_stream->eof()) return false; ! if (sequence_to_read->size() < static_cast<std::size_t>(read_size)) sequence_to_read->resize(read_size); const int type_byte(sizeof((*sequence_to_read)[0])); --- 52,87 ---- namespace sptk { ! bool ReadStream(double* read_data, std::istream* input_stream) { ! if (NULL == read_data || ! NULL == input_stream) { ! return false; ! } ! ! if (input_stream->eof()) { ! return false; ! } ! ! const int type_byte(sizeof(*read_data)); ! input_stream->read(reinterpret_cast<char*>(read_data), type_byte); ! ! return (type_byte == input_stream->gcount()) ? !input_stream->fail() : false; ! } ! ! bool ReadStream(bool zero_padding, int read_size, std::vector<double>* sequence_to_read, std::istream* input_stream) { if (read_size <= 0 || NULL == sequence_to_read || ! NULL == input_stream) { return false; + } ! if (input_stream->eof()) { return false; + } ! if (sequence_to_read->size() < static_cast<std::size_t>(read_size)) { sequence_to_read->resize(read_size); + } const int type_byte(sizeof((*sequence_to_read)[0])); *************** *** 79,84 **** 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, --- 98,104 ---- 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, *************** *** 92,104 **** } ! bool WriteStream(const int& write_size, const std::vector<double>& sequence_to_write, std::ostream* output_stream) { if (write_size <= 0 || ! NULL == output_stream) return false; ! if (sequence_to_write.size() < static_cast<std::size_t>(write_size)) return false; output_stream->write(reinterpret_cast<const char*>(&(sequence_to_write[0])), --- 112,137 ---- } ! bool WriteStream(double data_to_write, std::ostream* output_stream) { ! if (NULL == output_stream) { ! return false; ! } ! ! output_stream->write(reinterpret_cast<const char*>(&data_to_write), ! sizeof(data_to_write)); ! ! return !output_stream->fail(); ! } ! ! 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; + } ! if (sequence_to_write.size() < static_cast<std::size_t>(write_size)) { return false; + } output_stream->write(reinterpret_cast<const char*>(&(sequence_to_write[0])), *************** *** 108,120 **** } bool ConvertStringToInteger(const std::string& input, int* output) { ! if (NULL == output) return false; char* end; int converted_value(static_cast<int>(std::strtol(input.c_str(), &end, 10))); ! if (0 == input.compare(end) || '\0' != *end || ERANGE == errno) return false; *output = converted_value; --- 141,159 ---- } + const char* ConvertBooleanToString(bool input) { + return input ? "TRUE" : "FALSE"; + } + bool ConvertStringToInteger(const std::string& input, int* output) { ! if (NULL == output) { return false; + } char* end; int converted_value(static_cast<int>(std::strtol(input.c_str(), &end, 10))); ! if (0 == input.compare(end) || '\0' != *end || ERANGE == errno) { return false; + } *output = converted_value; *************** *** 123,134 **** bool ConvertStringToDouble(const std::string& input, double* output) { ! if (NULL == output) return false; char* end; double converted_value(std::strtod(input.c_str(), &end)); ! if (0 == input.compare(end) || '\0' != *end || ERANGE == errno) return false; *output = converted_value; --- 162,175 ---- bool ConvertStringToDouble(const std::string& input, double* output) { ! if (NULL == output) { return false; + } char* end; double converted_value(std::strtod(input.c_str(), &end)); ! if (0 == input.compare(end) || '\0' != *end || ERANGE == errno) { return false; + } *output = converted_value; *************** *** 136,140 **** } ! bool IsInRange(const int& value, const int& min, const int& max) { return (value < min || max < value) ? false : true; } --- 177,181 ---- } ! bool IsInRange(int value, int min, int max) { return (value < min || max < value) ? false : true; } Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile 25 Mar 2016 06:04:51 -0000 1.6 --- Makefile 29 Jul 2016 07:26:20 -0000 1.7 *************** *** 45,50 **** TARGET = libsptk.a ! SOURCES = autocorrelation.cc \ fast_fourier_transform.cc \ frequency_transform.cc \ levinson_durbin_recursion.cc \ --- 45,52 ---- TARGET = libsptk.a ! SOURCES = all_pole_digital_filter.cc \ ! autocorrelation.cc \ fast_fourier_transform.cc \ + coefficients_stream_reader.cc \ frequency_transform.cc \ levinson_durbin_recursion.cc \ *************** *** 53,59 **** OBJECTS = $(SOURCES:.cc=.o) ! CXX = gcc AR = ar ! CXXFLAGS = -Wall -O2 -g INCLUDE = -I . --- 55,61 ---- OBJECTS = $(SOURCES:.cc=.o) ! CXX = g++ AR = ar ! CXXFLAGS = -Wall -O2 -g -std=c++0x INCLUDE = -I . Index: all_pole_digital_filter.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/all_pole_digital_filter.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** all_pole_digital_filter.h 29 Jun 2016 01:23:30 -0000 1.1 --- all_pole_digital_filter.h 29 Jul 2016 07:26:20 -0000 1.2 *************** *** 93,97 **** // bool Run(const std::vector<double>& filter_coefficients, ! double excitation_input, double* filtered_output, AllPoleDigitalFilter::StoredSignals* signals) const; --- 93,97 ---- // bool Run(const std::vector<double>& filter_coefficients, ! double filter_input, double* filter_output, AllPoleDigitalFilter::StoredSignals* signals) const; --- NEW FILE: coefficients_reader_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_COEFFICIENTS_READER_INTERFACE_H_ #define SPTK_SRC_COEFFICIENTS_READER_INTERFACE_H_ #include <vector> // std::vector namespace sptk { class CoefficientsReaderInterface { public: // virtual ~CoefficientsReaderInterface() {} // virtual int GetCoefficientsLength() const = 0; // virtual int GetFramePeriod() const = 0; // virtual int GetInterpolationPeriod() const = 0; // virtual bool IsValid() const = 0; // virtual bool GetCoefficients( std::vector<double>* interpolated_coefficients) = 0; }; } // namespace sptk #endif // SPTK_SRC_COEFFICIENTS_READER_INTERFACE_H_ --- NEW FILE: coefficients_stream_reader.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 "coefficients_stream_reader.h" #include <algorithm> // std::copy, std::transform #include <cstring> // std::size_t #include <functional> // std::plus namespace sptk { CoefficientsStreamReader::CoefficientsStreamReader( int coefficients_length, int frame_period, int interpolation_period, std::istream* input_stream) : coefficients_length_(coefficients_length), frame_period_(frame_period), interpolation_period_(interpolation_period), first_interpolation_period_(interpolation_period / 2), input_stream_(input_stream), point_index_in_frame_(0), is_valid_(true) { if (coefficients_length <= 0 || frame_period <= 0 || interpolation_period < 0 || frame_period / 2 < interpolation_period || NULL == input_stream) { is_valid_ = false; return; } if (!sptk::ReadStream(false, coefficients_length, &curr_coefficients_, input_stream)) { is_valid_ = false; return; } if (!sptk::ReadStream(false, coefficients_length, &next_coefficients_, input_stream)) { next_coefficients_.resize(coefficients_length); std::copy(curr_coefficients_.begin(), curr_coefficients_.end(), next_coefficients_.begin()); } if (0 < interpolation_period_) { increment_.resize(coefficients_length_); CalculateIncrement(); } } void CoefficientsStreamReader::CalculateIncrement() { if (!is_valid_) return; const double rate(static_cast<double>(interpolation_period_) / frame_period_); for (int i(0); i < coefficients_length_; ++i) { increment_[i] = rate * (next_coefficients_[i] - curr_coefficients_[i]); } } bool CoefficientsStreamReader::GetCoefficients( std::vector<double>* interpolated_coefficients) { if (!is_valid_ || NULL == interpolated_coefficients) { return false; } if (interpolated_coefficients->size() < static_cast<std::size_t>(coefficients_length_)) { interpolated_coefficients->resize(coefficients_length_); } std::copy(curr_coefficients_.begin(), curr_coefficients_.end(), interpolated_coefficients->begin()); // Update internal states for the next call. ++point_index_in_frame_; if (0 == point_index_in_frame_ % frame_period_) { // Update current and next coefficients. std::copy(next_coefficients_.begin(), next_coefficients_.end(), curr_coefficients_.begin()); if (!sptk::ReadStream(false, coefficients_length_, &next_coefficients_, input_stream_)) { // Use the final coefficients until the end of input sequence. std::copy(curr_coefficients_.begin(), curr_coefficients_.end(), next_coefficients_.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_)) { // Interpoalte adjacent coefficients. std::transform(curr_coefficients_.begin(), curr_coefficients_.end(), increment_.begin(), curr_coefficients_.begin(), std::plus<double>()); } else if (0 == interpolation_period_ && frame_period_ / 2 == point_index_in_frame_) { std::copy(next_coefficients_.begin(), next_coefficients_.end(), curr_coefficients_.begin()); } return true; } } // namespace sptk Index: levinson_durbin_recursion.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/levinson_durbin_recursion.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** levinson_durbin_recursion.cc 1 Apr 2016 09:05:46 -0000 1.2 --- levinson_durbin_recursion.cc 29 Jul 2016 07:26:20 -0000 1.3 *************** *** 58,70 **** if (autocorrelation_sequence.empty() || NULL == lpc_coefficients || ! NULL == buffer) return false; // 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)) buffer->c_.resize(output_length); // get values --- 58,73 ---- if (autocorrelation_sequence.empty() || NULL == lpc_coefficients || ! NULL == buffer) { return false; + } // 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)) { buffer->c_.resize(output_length); + } // get values *************** *** 74,83 **** // set value ! if (NULL != is_stable) *is_stable = true; double rmd(input[0]); ! if (std::fabs(rmd) <= epsilon_ || std::isnan(rmd)) return false; output[0] = 0.0; --- 77,88 ---- // set value ! if (NULL != is_stable) { *is_stable = true; + } double rmd(input[0]); ! if (std::fabs(rmd) <= epsilon_ || std::isnan(rmd)) { return false; + } output[0] = 0.0; *************** *** 96,104 **** rmd *= 1.0 - mue * mue; ! if (std::fabs(rmd) <= epsilon_ || std::isnan(rmd)) return false; ! if (NULL != is_stable && 1.0 <= std::fabs(mue)) *is_stable = false; for (int j(0); j <= i; ++j) { --- 101,111 ---- rmd *= 1.0 - mue * mue; ! if (std::fabs(rmd) <= epsilon_ || std::isnan(rmd)) { return false; + } ! if (NULL != is_stable && 1.0 <= std::fabs(mue)) { *is_stable = false; + } for (int j(0); j <= i; ++j) { Index: sptk_utils.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/sptk_utils.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** sptk_utils.h 8 Feb 2016 11:42:45 -0000 1.5 --- sptk_utils.h 29 Jul 2016 07:26:20 -0000 1.6 *************** *** 61,73 **** static const char* const kVersion("4.0"); ! bool ReadStream(const bool& zero_padding, const int& read_size, std::vector<double>* sequence_to_read, std::istream* input_stream); ! bool WriteStream(const int& write_size, const std::vector<double>& sequence_to_write, std::ostream* output_stream); bool ConvertStringToInteger(const std::string& input, int* output); bool ConvertStringToDouble(const std::string& input, double* output); ! bool IsInRange(const int& value, const int& min, const int& max); void PrintErrorMessage(const std::string& program_name, const std::ostringstream& message); --- 61,76 ---- static const char* const kVersion("4.0"); ! bool ReadStream(double* data_to_read, std::istream* input_stream); ! bool ReadStream(bool zero_padding, int read_size, std::vector<double>* sequence_to_read, 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); bool ConvertStringToInteger(const std::string& input, int* output); bool ConvertStringToDouble(const std::string& input, double* output); ! bool IsInRange(int value, int min, int max); void PrintErrorMessage(const std::string& program_name, const std::ostringstream& message); Index: fast_fourier_transform.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fast_fourier_transform.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** fast_fourier_transform.cc 25 Mar 2016 06:04:51 -0000 1.7 --- fast_fourier_transform.cc 29 Jul 2016 07:26:20 -0000 1.8 *************** *** 52,57 **** bool FastFourierTransform::SetNumDimension(const int num_dimension) { ! if (num_dimension < 4 || num_dimension & (num_dimension - 1)) return false; const int table_size(num_dimension - num_dimension / 4 + 1); --- 52,58 ---- bool FastFourierTransform::SetNumDimension(const int num_dimension) { ! if (num_dimension < 4 || num_dimension & (num_dimension - 1)) { return false; + } const int table_size(num_dimension - num_dimension / 4 + 1); *************** *** 79,94 **** if (sine_table_.empty() || NULL == real_part_output || ! NULL == imaginary_part_output) return false; // prepare memories ! if (real_part_output->size() != static_cast<std::size_t>(num_dimension_)) real_part_output->resize(num_dimension_); ! if (imaginary_part_output->size() != static_cast<std::size_t>(num_dimension_)) imaginary_part_output->resize(num_dimension_); ! if (real_part_output->size() < real_part_input.size() || ! imaginary_part_output->size() < imaginary_part_input.size()) return false; // get values and fill zero --- 80,100 ---- if (sine_table_.empty() || NULL == real_part_output || ! NULL == imaginary_part_output) { return false; + } // prepare memories ! if (real_part_output->size() != ! static_cast<std::size_t>(num_dimension_)) { real_part_output->resize(num_dimension_); ! } ! if (imaginary_part_output->size() != ! static_cast<std::size_t>(num_dimension_)) { imaginary_part_output->resize(num_dimension_); ! } if (real_part_output->size() < real_part_input.size() || ! imaginary_part_output->size() < imaginary_part_input.size()) { return false; + } // get values and fill zero --- NEW FILE: poledf.cc --- // ----------------------------------------------------------------- // // The Speech Signal Processing Toolkit (SPTK) // // developed by SPTK Working Group // // http://sp-tk.sourceforge.net/ // // ----------------------------------------------------------------- // // // // Copyright (c) 1984-2007 Tokyo Institute of Technology // // Interdisciplinary Graduate School of // // Science and Engineering // // // // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // // All rights reserved. // // // // Redistribution and use in source and binary forms, with or // // without modification, are permitted provided that the following // // conditions are met: // // // // - Redistributions of source code must retain the above copyright // // notice, this list of conditions and the following disclaimer. // // - Redistributions in binary form must reproduce the above // // copyright notice, this list of conditions and the following // // disclaimer in the documentation and/or other materials provided // // with the distribution. // // - Neither the name of the SPTK working group nor the names of its // // contributors may be used to endorse or promote products derived // // from this software without specific prior written permission. // // // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND // // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, // // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS // // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON // // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // // POSSIBILITY OF SUCH DAMAGE. // // ----------------------------------------------------------------- // #include <unistd.h> #include <algorithm> #include <fstream> #include <iostream> #include <sstream> #include <vector> #include "all_pole_digital_filter.h" #include "coefficients_stream_reader.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 << " poledf - all-pole digital filter for speech synthesis" << std::endl; // NOLINT *stream << std::endl; *stream << " usage:" << std::endl; *stream << " poledf [ options ] afile [ 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 << " afile:" << std::endl; *stream << " filter (AR) 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("poledf", 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("poledf", 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("poledf", 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("poledf", 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, afile and infile, are required"; sptk::PrintErrorMessage("poledf", 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("poledf", 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("poledf", error_message); return 1; } 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; } while (sptk::ReadStream(&filter_input, &stream_for_filter_input)) { if (!reader.GetCoefficients(&filter_coefficients)) { std::ostringstream error_message; error_message << "Cannot get filter coefficients"; sptk::PrintErrorMessage("poledf", error_message); return 1; } 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"; sptk::PrintErrorMessage("poledf", 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("poledf", error_message); return 1; } } return 0; } Index: fft.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fft.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** fft.cc 1 Apr 2016 09:05:46 -0000 1.7 --- fft.cc 29 Jul 2016 07:26:20 -0000 1.8 *************** *** 211,221 **** if (kOutputAmplitude == output_format) { ! for (int i(0); i < fft_size; ++i) output_x[i] = std::sqrt(output_x[i] * output_x[i] + output_y[i] * output_y[i]); } else if (kOutputPower == output_format) { ! for (int i(0); i < fft_size; ++i) output_x[i] = output_x[i] * output_x[i] + output_y[i] * output_y[i]; } --- 211,223 ---- if (kOutputAmplitude == output_format) { ! for (int i(0); i < fft_size; ++i) { output_x[i] = std::sqrt(output_x[i] * output_x[i] + output_y[i] * output_y[i]); + } } else if (kOutputPower == output_format) { ! for (int i(0); i < fft_size; ++i) { output_x[i] = output_x[i] * output_x[i] + output_y[i] * output_y[i]; + } } --- NEW FILE: coefficients_stream_reader.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_COEFFICIENTS_STREAM_READER_H_ #define SPTK_SRC_COEFFICIENTS_STREAM_READER_H_ #include <istream> // std::istream #include <vector> // std::vector #include "coefficients_reader_interface.h" #include "sptk_utils.h" namespace sptk { class CoefficientsStreamReader : public CoefficientsReaderInterface { public: // CoefficientsStreamReader(int coefficients_length, int frame_period, int interpolation_period, std::istream* input_stream); // virtual ~CoefficientsStreamReader() {} // virtual int GetCoefficientsLength() const { return coefficients_length_; } // virtual int GetFramePeriod() const { return frame_period_; } // virtual int GetInterpolationPeriod() const { return interpolation_period_; } // virtual bool IsValid() const { return is_valid_; } // virtual bool GetCoefficients(std::vector<double>* interpolated_coefficients); private: // void CalculateIncrement(); // const int coefficients_length_; // const int frame_period_; // const int interpolation_period_; // const int first_interpolation_period_; // std::istream* input_stream_; // int point_index_in_frame_; // bool is_valid_; // std::vector<double> curr_coefficients_; // std::vector<double> next_coefficients_; // std::vector<double> increment_; // DISALLOW_COPY_AND_ASSIGN(CoefficientsStreamReader); }; } // namespace sptk #endif // SPTK_SRC_COEFFICIENTS_STREAM_READER_H_ Index: all_pole_digital_filter.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/all_pole_digital_filter.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** all_pole_digital_filter.cc 29 Jun 2016 01:23:30 -0000 1.1 --- all_pole_digital_filter.cc 29 Jul 2016 07:26:20 -0000 1.2 *************** *** 51,62 **** bool AllPoleDigitalFilter::Run( const std::vector<double>& filter_coefficients, ! double excitation_input, ! double* filtered_output, AllPoleDigitalFilter::StoredSignals* stored_signals) const { // check inputs if (filter_coefficients.empty() || ! NULL == filtered_output || ! NULL == stored_signals) return false; // prepare memory --- 51,63 ---- bool AllPoleDigitalFilter::Run( const std::vector<double>& filter_coefficients, ! double filter_input, ! double* filter_output, AllPoleDigitalFilter::StoredSignals* stored_signals) const { // check inputs if (filter_coefficients.empty() || ! NULL == filter_output || ! NULL == stored_signals) { return false; + } // prepare memory *************** *** 70,76 **** // set value ! const double gained_input(excitation_input * filter_coefficients[0]); if (0 == num_filter_order) { ! *filtered_output = gained_input; return true; } --- 71,77 ---- // set value ! const double gained_input(filter_input * filter_coefficients[0]); if (0 == num_filter_order) { ! *filter_output = gained_input; return true; } *************** *** 98,102 **** // save result ! *filtered_output = sum; return true; --- 99,103 ---- // save result ! *filter_output = sum; return true; Index: autocorrelation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/autocorrelation.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** autocorrelation.cc 25 Mar 2016 06:04:51 -0000 1.2 --- autocorrelation.cc 29 Jul 2016 07:26:20 -0000 1.3 *************** *** 54,64 **** // check inputs if (input_sequence.empty() || ! NULL == output_sequence) return false; // prepare memories const int output_length(num_order_ + 1); ! if (output_sequence->size() < static_cast<std::size_t>(output_length)) output_sequence->resize(output_length); // get values --- 54,66 ---- // check inputs if (input_sequence.empty() || ! NULL == output_sequence) { return false; + } // prepare memories const int output_length(num_order_ + 1); ! if (output_sequence->size() < static_cast<std::size_t>(output_length)) { output_sequence->resize(output_length); + } // get values *************** *** 71,77 **** // calculate ! for (int i(0); i < output_length; ++i) ! for (int j(0); j <= input_length - i; ++j) output[i] += input[j] * input[i + j]; return true; --- 73,81 ---- // calculate ! for (int i(0); i < output_length; ++i) { ! for (int j(0); j <= input_length - i; ++j) { output[i] += input[j] * input[i + j]; + } + } return true; |
From: Shikano M. <sh...@us...> - 2016-07-15 07:16:09
|
Update of /cvsroot/sp-tk/SPTK/src/bin/agcep In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv5949/agcep Modified Files: _agcep.c Log Message: Fix out of memory error Index: _agcep.c =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/bin/agcep/_agcep.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** _agcep.c 14 Dec 2015 01:14:10 -0000 1.18 --- _agcep.c 15 Jul 2016 07:16:07 -0000 1.19 *************** *** 87,98 **** ep = eg + m + 1; d = ep + m + 1; ! size = m; } ! if (m > size) { free(eg); eg = dgetmem(2 * (m + 1) + m * stage); ep = eg + m + 1; d = ep + m + 1; ! size = m; } --- 87,98 ---- ep = eg + m + 1; d = ep + m + 1; ! size = m * stage; } ! if (m * stage > size) { free(eg); eg = dgetmem(2 * (m + 1) + m * stage); ep = eg + m + 1; d = ep + m + 1; ! size = m * stage; } |
From: Shikano M. <sh...@us...> - 2016-07-15 07:02:12
|
Update of /cvsroot/sp-tk/SPTK/src/bin/amcep In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv5274/amcep Modified Files: amcep.c Log Message: Delete variables Index: amcep.c =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/bin/amcep/amcep.c,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** amcep.c 15 Jul 2016 06:23:20 -0000 1.30 --- amcep.c 15 Jul 2016 07:02:10 -0000 1.31 *************** *** 165,169 **** Boolean aveflag = AVEFLAG; double alpha = ALPHA, lambda = LAMBDA, tau = TAU, step = STEP, eps = EPS, ! *mc, *b, *ep, *e, *bb, *d, *avemc, x, xx, ll, tt, gg, mu, ttx; if ((cmnd = strrchr(argv[0], '/')) == NULL) --- 165,169 ---- Boolean aveflag = AVEFLAG; double alpha = ALPHA, lambda = LAMBDA, tau = TAU, step = STEP, eps = EPS, ! *mc, *b, *avemc, x, mu; if ((cmnd = strrchr(argv[0], '/')) == NULL) |
From: Shikano M. <sh...@us...> - 2016-07-15 06:23:23
|
Update of /cvsroot/sp-tk/SPTK/src/bin/amcep In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv2968/amcep Modified Files: amcep.c Log Message: use of function Index: amcep.c =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/bin/amcep/amcep.c,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** amcep.c 14 Dec 2015 01:14:10 -0000 1.29 --- amcep.c 15 Jul 2016 06:23:20 -0000 1.30 *************** *** 224,261 **** } ! mc = dgetmem(6 * (m + 1) + 3 * (pd + 1) + pd * (m + 2)); b = mc + m + 1; ! bb = b + m + 1; ! e = bb + m + 1; ! ep = e + m + 1; ! avemc = ep + m + 1; ! d = avemc + m + 1; j = period; - ll = 1.0 - lambda; - gg = 1.0; - tt = 2 * (1.0 - tau); - step /= (double) m; - xx = 0.0; while (freadf(&x, sizeof(x), 1, fp) == 1) { - for (i = 1; i <= m; i++) - bb[i] = -b[i]; ! x = mlsadf(x, bb, m, alpha, pd, d); ! phidf(xx, m, alpha, e); ! xx = x; ! ! gg = gg * lambda + ll * x * x; ! gg = (gg < eps) ? eps : gg; ! b[0] = 0.5 * log(gg); ! ! mu = step / gg; ! ttx = tt * x; ! ! for (i = 1; i <= m; i++) { ! ep[i] = tau * ep[i] - ttx * e[i]; ! b[i] -= mu * ep[i]; ! } b2mc(b, mc, m, alpha); --- 224,236 ---- } ! mc = dgetmem(2 * (m + 1) + 3 * (pd + 1) + pd * (m + 2)); b = mc + m + 1; ! avemc = b + m + 1; j = period; while (freadf(&x, sizeof(x), 1, fp) == 1) { ! x = amcep(x, b, m, alpha, lambda, step, tau, pd, eps); b2mc(b, mc, m, alpha); |
From: Shikano M. <sh...@us...> - 2016-07-15 06:23:22
|
Update of /cvsroot/sp-tk/SPTK/src/bin/agcep In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv2968/agcep Modified Files: agcep.c Log Message: use of function Index: agcep.c =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/bin/agcep/agcep.c,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** agcep.c 14 Dec 2015 01:14:10 -0000 1.31 --- agcep.c 15 Jul 2016 06:23:20 -0000 1.32 *************** *** 232,267 **** gamma = -1.0 / (double) stage; ! c = dgetmem(5 * (m + 1) + m * stage); cc = c + m + 1; ! eg = cc + m + 1; ! ep = eg + m + 1; ! avec = ep + m + 1; ! d = avec + m + 1; j = period; - ll = 1.0 - lambda; - gg = 1.0; - ee = 1.0; - step /= (double) m; - tt = 2 * (1.0 - tau); while (freadf(&x, sizeof(x), 1, fp) == 1) { - eg[m] = d[stage * m - 1]; - x = iglsadf1(x, c, m, stage, d); ! movem(d + (stage - 1) * m, eg, sizeof(*d), m); ! ! gg = lambda * gg + ll * eg[0] * eg[0]; ! gg = (gg < eps) ? eps : gg; ! mu = step / gg; ! ttx = tt * x; ! ! for (i = 1; i <= m; i++) { ! ep[i] = tau * ep[i] - ttx * eg[i]; ! c[i] -= mu * ep[i]; ! } ! ! ee = lambda * ee + ll * x * x; ! c[0] = sqrt(ee); if (ave) --- 232,244 ---- gamma = -1.0 / (double) stage; ! c = dgetmem(2 * (m + 1) + m * stage); cc = c + m + 1; ! avec = cc + m + 1; j = period; while (freadf(&x, sizeof(x), 1, fp) == 1) { ! x = agcep(x, c, m, stage, lambda, step, tau, eps); if (ave) |
From: Takenori Y. <tak...@us...> - 2016-06-29 01:23:33
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv14600 Added Files: all_pole_digital_filter.cc all_pole_digital_filter.h Log Message: add AllPoleDigitalFilter class --- NEW FILE: all_pole_digital_filter.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 "all_pole_digital_filter.h" #include <cstring> // std::size_t namespace sptk { bool AllPoleDigitalFilter::Run( const std::vector<double>& filter_coefficients, double excitation_input, double* filtered_output, AllPoleDigitalFilter::StoredSignals* stored_signals) const { // check inputs if (filter_coefficients.empty() || NULL == filtered_output || NULL == stored_signals) return false; // 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); } // set value const double gained_input(excitation_input * filter_coefficients[0]); if (0 == num_filter_order) { *filtered_output = gained_input; return true; } // get values const double* coefficients(&(filter_coefficients[0])); double* signals(&stored_signals->signals_[0]); // 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]; } sum -= coefficients[1] * signals[0]; signals[0] = sum; } // save result *filtered_output = sum; return true; } } // namespace sptk --- NEW FILE: all_pole_digital_filter.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_ALL_POLE_DIGITAL_FILTER_H_ #define SPTK_SRC_ALL_POLE_DIGITAL_FILTER_H_ #include <algorithm> // std::fill #include <vector> // std::vector #include "sptk_utils.h" namespace sptk { class AllPoleDigitalFilter { public: class StoredSignals { public: // StoredSignals() {} // ~StoredSignals() {} // void Clear() { std::fill(signals_.begin(), signals_.end(), 0.0); } private: // std::vector<double> signals_; // friend class AllPoleDigitalFilter; // DISALLOW_COPY_AND_ASSIGN(StoredSignals); }; // explicit AllPoleDigitalFilter(bool is_transposed) : is_transposed_(is_transposed) {} // virtual ~AllPoleDigitalFilter() {} // bool GetTranspositionFlag() const { return is_transposed_; } // bool Run(const std::vector<double>& filter_coefficients, double excitation_input, double* filtered_output, AllPoleDigitalFilter::StoredSignals* signals) const; private: // const bool is_transposed_; // DISALLOW_COPY_AND_ASSIGN(AllPoleDigitalFilter); }; } // namespace sptk #endif // SPTK_SRC_ALL_POLE_DIGITAL_FILTER_H_ |
From: Takenori Y. <tak...@us...> - 2016-06-24 12:07:00
|
Update of /cvsroot/sp-tk/SPTK/src/bin/mlsacheck In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv21293 Modified Files: mlsacheck.c Log Message: make code more readable Index: mlsacheck.c =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/bin/mlsacheck/mlsacheck.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** mlsacheck.c 14 Dec 2015 01:14:20 -0000 1.19 --- mlsacheck.c 24 Jun 2016 12:06:58 -0000 1.20 *************** *** 185,189 **** } ! void mlsacheck(double *mcep, int m, int fftlen, int frame, double a, double r, int c) { --- 185,189 ---- } ! double mlsacheck(double *in, double *out, int m, int fftlen, double a, double r, int c) { *************** *** 199,203 **** /* calculate gain factor */ for (i = 0, gain = 0.0; i <= m; i++) { ! x[i] = mcep[i]; gain += x[i] * pow(-a, i); } --- 199,203 ---- /* calculate gain factor */ for (i = 0, gain = 0.0; i <= m; i++) { ! x[i] = in[i]; gain += x[i] * pow(-a, i); } *************** *** 221,232 **** } ! /* modification MLSA filter coefficients */ if (max > r) { - /* output ascii report */ - fprintf(stderr, - "[No. %d] is unstable frame (maximum = %f, threshold = %f)\n", - frame, max, r); - - /* modification */ if (c == 2) { /* clipping */ for (i = 0; i < fftlen; i++) { --- 221,226 ---- } ! /* modify MLSA filter coefficients */ if (max > r) { if (c == 2) { /* clipping */ for (i = 0; i < fftlen; i++) { *************** *** 247,258 **** } ! /* output MLSA filter coefficients */ if (c == 0 || c == 1 || max <= r) { /* no modification */ ! fwritef(mcep, sizeof(*mcep), m + 1, stdout); } else { if (c == 2 || c == 3) ifft(x, y, fftlen); x[0] += gain; ! fwritef(x, sizeof(*x), m + 1, stdout); } --- 241,252 ---- } ! /* store MLSA filter coefficients */ if (c == 0 || c == 1 || max <= r) { /* no modification */ ! memcpy(out, in, sizeof(*out) * (m + 1)); } else { if (c == 2 || c == 3) ifft(x, y, fftlen); x[0] += gain; ! memcpy(out, x, sizeof(*out) * (m + 1)); } *************** *** 261,264 **** --- 255,260 ---- if (c == 0 || c == 2 || c == 3) free(mag); + + return max; } *************** *** 267,271 **** int m = ORDER, pd = PADEORDER, fftlen = FFTLENGTH, stable_condition = STABLE1, frame = 0, c = 0; ! double *mcep, a = ALPHA, r = PADE4_THRESH1, R = 0.0; FILE *fp = stdin; --- 263,267 ---- int m = ORDER, pd = PADEORDER, fftlen = FFTLENGTH, stable_condition = STABLE1, frame = 0, c = 0; ! double *in, *out, max, a = ALPHA, r = PADE4_THRESH1, R = 0.0; FILE *fp = stdin; *************** *** 357,365 **** r = R; ! mcep = dgetmem(m + 1); /* check stability of MLSA filter and output */ ! while (freadf(mcep, sizeof(*mcep), m + 1, fp) == m + 1) { ! mlsacheck(mcep, m, fftlen, frame, a, r, c); frame++; } --- 353,371 ---- r = R; ! in = dgetmem(m + 1); ! out = dgetmem(m + 1); /* check stability of MLSA filter and output */ ! while (freadf(in, sizeof(*in), m + 1, fp) == m + 1) { ! max = mlsacheck(in, out, m, fftlen, a, r, c); ! ! /* output ascii report */ ! if (max > r) { ! fprintf(stderr, ! "[No. %d] is unstable frame (maximum = %f, threshold = %f)\n", ! frame, max, r); ! } ! ! fwritef(out, sizeof(*out), m + 1, stdout); frame++; } |
From: Shikano M. <sh...@us...> - 2016-05-03 04:21:53
|
Update of /cvsroot/sp-tk/SPTK/src/bin/lpc2csm In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv2533/lpc2csm Log Message: Directory /cvsroot/sp-tk/SPTK/src/bin/lpc2csm added to the repository |
From: Takenori Y. <tak...@us...> - 2016-04-19 04:27:12
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv6803 Modified Files: levdur.cc sptk_utils.cc Added Files: lpc.cc Log Message: add lpc command Index: sptk_utils.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/sptk_utils.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** sptk_utils.cc 25 Mar 2016 06:04:51 -0000 1.7 --- sptk_utils.cc 19 Apr 2016 04:27:10 -0000 1.8 *************** *** 142,146 **** void PrintErrorMessage(const std::string& program_name, const std::ostringstream& message) { ! std::cerr << program_name << " : " << message.str() << "!" << std::endl; } --- 142,148 ---- void PrintErrorMessage(const std::string& program_name, const std::ostringstream& message) { ! std::ostringstream stream; ! stream << program_name << " : " << message.str() << "!" << std::endl; ! std::cerr << stream.str(); } --- NEW FILE: lpc.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 "autocorrelation.h" #include "levinson_durbin_recursion.h" #include "sptk_utils.h" namespace { enum BehaviorForUnstableCoefficients { kIgnore = 0, kWarn, kExit, kNumKindsOfBehavior }; const int kDefaultFrameLength(256); const int kDefaultNumOrder(25); const double kDefaultEpsilon(1.0e-6); void PrintUsage(std::ostream* stream) { *stream << std::endl; *stream << " lpc - LPC analysis using Levinson-Durbin recursion" << std::endl; *stream << std::endl; *stream << " usage:" << std::endl; *stream << " lpc [ options ] [ infile ] > stdout" << std::endl; *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; *stream << " infile:" << std::endl; *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; *stream << std::endl; } } // namespace int main(int argc, char* argv[]) { int frame_length(kDefaultFrameLength); int num_order(kDefaultNumOrder); double epsilon(kDefaultEpsilon); BehaviorForUnstableCoefficients behavior(kIgnore); for (;;) { const char option_char(getopt(argc, argv, "l:m:f:c:h")); if (-1 == option_char) break; switch (option_char) { case 'l': { if (!sptk::ConvertStringToInteger(optarg, &frame_length) || 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; } break; } 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("lpc", error_message); return 1; } break; } 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; } break; } case 'c': { int given_integer(-1); if (!sptk::ConvertStringToInteger(optarg, &given_integer)) { std::ostringstream error_message; error_message << "The argument for the -c option must be an integer"; sptk::PrintErrorMessage("lpc", error_message); return 1; } const int min(0); const int max(static_cast<int>(kNumKindsOfBehavior) - 1); if (!sptk::IsInRange(given_integer, min, max)) { std::ostringstream error_message; error_message << "The argument for the -c option must be in range" << " (" << min << " .. " << max << ")"; sptk::PrintErrorMessage("lpc", error_message); return 1; } behavior = static_cast<BehaviorForUnstableCoefficients>(given_integer); 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("lpc", error_message); return 1; } std::istream& input_stream(ifs.fail() ? std::cin : ifs); sptk::Autocorrelation autocorrelation; 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; } sptk::LevinsonDurbinRecursion recursion; sptk::LevinsonDurbinRecursion::Buffer buffer; if (!recursion.SetEpsilon(epsilon)) { std::ostringstream error_message; error_message << "Failed to set the minimum value of the determinant"; sptk::PrintErrorMessage("lpc", error_message); return 1; } const int output_length(num_order + 1); 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); sptk::ReadStream(false, frame_length, &windowed_sequence, &input_stream); ++frame_index) { if (!autocorrelation.Run(windowed_sequence, &autocorrelation_sequence)) { std::ostringstream error_message; error_message << "Failed to obtain an autocorrelation sequence"; sptk::PrintErrorMessage("lpc", error_message); return 1; } 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"; sptk::PrintErrorMessage("lpc", error_message); return 1; } if (!is_stable && kIgnore != behavior) { std::ostringstream error_message; error_message << frame_index << "th frame is unstable"; sptk::PrintErrorMessage("lpc", error_message); if (kExit == behavior) return 1; } 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; } } return 0; } Index: levdur.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/levdur.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** levdur.cc 1 Apr 2016 09:05:46 -0000 1.1 --- levdur.cc 19 Apr 2016 04:27:10 -0000 1.2 *************** *** 79,85 **** *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; --- 79,85 ---- *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; *************** *** 87,91 **** *stream << " autocorrelation sequence (double) [stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; ! *stream << " linear predictive 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 << " LPC coefficients (double)" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; |
From: Takenori Y. <tak...@us...> - 2016-04-01 09:05:48
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv31202 Modified Files: acorr.cc fft.cc freqt.cc ifft.cc levinson_durbin_recursion.cc levinson_durbin_recursion.h Added Files: levdur.cc Log Message: add levdur command Index: fft.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fft.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** fft.cc 25 Mar 2016 06:04:51 -0000 1.6 --- fft.cc 1 Apr 2016 09:05:46 -0000 1.7 *************** *** 66,92 **** const int kDefaultFftSize(256); ! void PrintUsage() { ! std::cout << std::endl; ! std::cout << " fft - FFT for complex sequence" << std::endl; ! std::cout << std::endl; ! std::cout << " usage:" << std::endl; ! std::cout << " fft [ options ] [ infile ] > stdout" << std::endl; ! std::cout << " options:" << std::endl; ! std::cout << " -l l : FFT size [" << kDefaultFftSize << "]" << std::endl; // NOLINT ! std::cout << " -m m : order of sequence [l-1]" << std::endl; // NOLINT ! std::cout << " -o : output format [0]" << std::endl; // NOLINT ! std::cout << " 0 (real and imaginary parts)" << std::endl; ! std::cout << " 1 (real part)" << std::endl; ! std::cout << " 2 (imaginary part)" << std::endl; ! std::cout << " 3 (amplitude)" << std::endl; ! std::cout << " 4 (power)" << std::endl; ! std::cout << " -h : print this message" << std::endl; ! std::cout << " infile:" << std::endl; ! std::cout << " data sequence (double) [stdin]" << std::endl; // NOLINT ! std::cout << " stdout:" << std::endl; ! std::cout << " FFT sequence (double)" << std::endl; ! std::cout << std::endl; ! std::cout << " SPTK: version " << sptk::kVersion << std::endl; ! std::cout << std::endl; } --- 66,92 ---- const int kDefaultFftSize(256); ! void PrintUsage(std::ostream* stream) { ! *stream << std::endl; ! *stream << " fft - FFT for complex sequence" << std::endl; ! *stream << std::endl; ! *stream << " usage:" << std::endl; ! *stream << " fft [ options ] [ infile ] > stdout" << std::endl; ! *stream << " options:" << std::endl; ! *stream << " -l l : FFT size [" << kDefaultFftSize << "]" << std::endl; // NOLINT ! *stream << " -m m : order of sequence [l-1]" << std::endl; ! *stream << " -o o : output format [0]" << std::endl; ! *stream << " 0 (real and imaginary parts)" << std::endl; ! *stream << " 1 (real part)" << std::endl; ! *stream << " 2 (imaginary part)" << std::endl; ! *stream << " 3 (amplitude)" << std::endl; ! *stream << " 4 (power)" << std::endl; ! *stream << " -h : print this message" << std::endl; ! *stream << " infile:" << std::endl; ! *stream << " data sequence (double) [stdin]" << std::endl; // NOLINT ! *stream << " stdout:" << std::endl; ! *stream << " FFT sequence (double)" << std::endl; ! *stream << std::endl; ! *stream << " SPTK: version " << sptk::kVersion << std::endl; ! *stream << std::endl; } *************** *** 95,103 **** int main(int argc, char* argv[]) { int fft_size(kDefaultFftSize); ! int num_order(0); bool is_num_order_specified(false); OutputFormats output_format(kOutputRealAndImaginaryParts); ! while (true) { const char option_char(getopt(argc, argv, "l:m:o:h")); if (-1 == option_char) break; --- 95,103 ---- int main(int argc, char* argv[]) { int fft_size(kDefaultFftSize); ! int num_order(kDefaultFftSize - 1); bool is_num_order_specified(false); OutputFormats output_format(kOutputRealAndImaginaryParts); ! for (;;) { const char option_char(getopt(argc, argv, "l:m:o:h")); if (-1 == option_char) break; *************** *** 126,131 **** } case 'o': { ! int output_format_integer; ! if (!sptk::ConvertStringToInteger(optarg, &output_format_integer)) { std::ostringstream error_message; error_message << "The argument for the -o option must be an integer"; --- 126,131 ---- } case 'o': { ! int given_integer(-1); ! if (!sptk::ConvertStringToInteger(optarg, &given_integer)) { std::ostringstream error_message; error_message << "The argument for the -o option must be an integer"; *************** *** 136,140 **** const int min(0); const int max(static_cast<int>(kNumOutputFormats) - 1); ! if (!sptk::IsInRange(output_format_integer, min, max)) { std::ostringstream error_message; error_message << "The argument for the -o option must be in range" --- 136,140 ---- const int min(0); const int max(static_cast<int>(kNumOutputFormats) - 1); ! if (!sptk::IsInRange(given_integer, min, max)) { std::ostringstream error_message; error_message << "The argument for the -o option must be in range" *************** *** 144,156 **** } ! output_format = static_cast<OutputFormats>(output_format_integer); break; } case 'h': { ! PrintUsage(); return 0; } default: { ! PrintUsage(); return 1; } --- 144,156 ---- } ! output_format = static_cast<OutputFormats>(given_integer); break; } case 'h': { ! PrintUsage(&std::cout); return 0; } default: { ! PrintUsage(&std::cerr); return 1; } *************** *** 201,211 **** std::vector<double> output_y(fft_size); ! while (!input_stream.eof()) { ! // get input ! if (!sptk::ReadStream(true, length, &input_x, &input_stream)) ! break; ! if (!sptk::ReadStream(true, length, &input_y, &input_stream)) ! break; ! if (!fft.Run(input_x, input_y, &output_x, &output_y)) { std::ostringstream error_message; --- 201,206 ---- std::vector<double> output_y(fft_size); ! while (sptk::ReadStream(true, length, &input_x, &input_stream) && ! sptk::ReadStream(true, length, &input_y, &input_stream)) { if (!fft.Run(input_x, input_y, &output_x, &output_y)) { std::ostringstream error_message; Index: freqt.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/freqt.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** freqt.cc 25 Mar 2016 06:04:51 -0000 1.4 --- freqt.cc 1 Apr 2016 09:05:46 -0000 1.5 *************** *** 59,81 **** const double kDefaultOutputAlpha(0.35); ! void PrintUsage() { ! std::cout << std::endl; ! std::cout << " freqt - frequency transform" << std::endl; ! std::cout << std::endl; ! std::cout << " usage:" << std::endl; ! std::cout << " freqt [ options ] [ infile ] > stdout" << std::endl; ! std::cout << " options:" << std::endl; ! std::cout << " -m m : order of minimum phase sequence [" << kDefaultNumInputOrder << "]" << std::endl; // NOLINT ! std::cout << " -M M : order of warped sequence [" << kDefaultNumOutputOrder << "]" << std::endl; // NOLINT ! std::cout << " -a a : all-pass constant of input sequence [" << kDefaultInputAlpha << "]" << std::endl; // NOLINT ! std::cout << " -A A : all-pass constant of output sequence [" << kDefaultOutputAlpha << "]" << std::endl; // NOLINT ! std::cout << " -h : print this message" << std::endl; ! std::cout << " infile:" << std::endl; ! std::cout << " minimum phase sequence (double) [stdin]" << std::endl; // NOLINT ! std::cout << " stdout:" << std::endl; ! std::cout << " warped sequence (double)" << std::endl; ! std::cout << std::endl; ! std::cout << " SPTK: version " << sptk::kVersion << std::endl; ! std::cout << std::endl; } --- 59,81 ---- const double kDefaultOutputAlpha(0.35); ! void PrintUsage(std::ostream* stream) { ! *stream << std::endl; ! *stream << " freqt - frequency transform" << std::endl; ! *stream << std::endl; ! *stream << " usage:" << std::endl; ! *stream << " freqt [ options ] [ infile ] > stdout" << std::endl; ! *stream << " options:" << std::endl; ! *stream << " -m m : order of minimum phase sequence [" << kDefaultNumInputOrder << "]" << std::endl; // NOLINT ! *stream << " -M M : order of warped sequence [" << kDefaultNumOutputOrder << "]" << std::endl; // NOLINT ! *stream << " -a a : all-pass constant of input sequence [" << kDefaultInputAlpha << "]" << std::endl; // NOLINT ! *stream << " -A A : all-pass constant of output sequence [" << kDefaultOutputAlpha << "]" << std::endl; // NOLINT ! *stream << " -h : print this message" << std::endl; ! *stream << " infile:" << std::endl; ! *stream << " minimum phase sequence (double) [stdin]" << std::endl; // NOLINT ! *stream << " stdout:" << std::endl; ! *stream << " warped sequence (double)" << std::endl; ! *stream << std::endl; ! *stream << " SPTK: version " << sptk::kVersion << std::endl; ! *stream << std::endl; } *************** *** 88,92 **** double output_alpha(kDefaultOutputAlpha); ! while (true) { const char option_char(getopt(argc, argv, "m:M:a:A:h")); if (-1 == option_char) break; --- 88,92 ---- double output_alpha(kDefaultOutputAlpha); ! for (;;) { const char option_char(getopt(argc, argv, "m:M:a:A:h")); if (-1 == option_char) break; *************** *** 134,142 **** } case 'h': { ! PrintUsage(); return 0; } default: { ! PrintUsage(); return 1; } --- 134,142 ---- } case 'h': { ! PrintUsage(&std::cout); return 0; } default: { ! PrintUsage(&std::cerr); return 1; } *************** *** 184,192 **** std::vector<double> warped_sequence(output_length); ! while (true) { ! if (!sptk::ReadStream(false, input_length, ! &minimum_phase_sequence, &input_stream)) ! break; ! if (!frequency_transform.Run(minimum_phase_sequence, &warped_sequence, &buffer)) { --- 184,189 ---- std::vector<double> warped_sequence(output_length); ! while (sptk::ReadStream(false, input_length, &minimum_phase_sequence, ! &input_stream)) { if (!frequency_transform.Run(minimum_phase_sequence, &warped_sequence, &buffer)) { Index: ifft.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/ifft.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ifft.cc 25 Mar 2016 06:04:51 -0000 1.3 --- ifft.cc 1 Apr 2016 09:05:46 -0000 1.4 *************** *** 63,86 **** const int kDefaultFftSize(256); ! void PrintUsage() { ! std::cout << std::endl; ! std::cout << " ifft - inverse FFT for complex sequence" << std::endl; ! std::cout << std::endl; ! std::cout << " usage:" << std::endl; ! std::cout << " ifft [ options ] [ infile ] > stdout" << std::endl; ! std::cout << " options:" << std::endl; ! std::cout << " -l l : FFT size [" << kDefaultFftSize << "]" << std::endl; // NOLINT ! std::cout << " -o : output format [0]" << std::endl; // NOLINT ! std::cout << " 0 (real and imaginary parts)" << std::endl; ! std::cout << " 1 (real part)" << std::endl; ! std::cout << " 2 (imaginary part)" << std::endl; ! std::cout << " -h : print this message" << std::endl; ! std::cout << " infile:" << std::endl; ! std::cout << " data sequence (double) [stdin]" << std::endl; // NOLINT ! std::cout << " stdout:" << std::endl; ! std::cout << " inverse FFT sequence (double)" << std::endl; ! std::cout << std::endl; ! std::cout << " SPTK: version " << sptk::kVersion << std::endl; ! std::cout << std::endl; } --- 63,86 ---- const int kDefaultFftSize(256); ! void PrintUsage(std::ostream* stream) { ! *stream << std::endl; ! *stream << " ifft - inverse FFT for complex sequence" << std::endl; ! *stream << std::endl; ! *stream << " usage:" << std::endl; ! *stream << " ifft [ options ] [ infile ] > stdout" << std::endl; ! *stream << " options:" << std::endl; ! *stream << " -l l : FFT size [" << kDefaultFftSize << "]" << std::endl; // NOLINT ! *stream << " -o o : output format [0]" << std::endl; ! *stream << " 0 (real and imaginary parts)" << std::endl; ! *stream << " 1 (real part)" << std::endl; ! *stream << " 2 (imaginary part)" << std::endl; ! *stream << " -h : print this message" << std::endl; ! *stream << " infile:" << std::endl; ! *stream << " data sequence (double) [stdin]" << std::endl; // NOLINT ! *stream << " stdout:" << std::endl; ! *stream << " inverse FFT sequence (double)" << std::endl; ! *stream << std::endl; ! *stream << " SPTK: version " << sptk::kVersion << std::endl; ! *stream << std::endl; } *************** *** 91,95 **** OutputFormats output_format(kOutputRealAndImaginaryParts); ! while (true) { const char option_char(getopt(argc, argv, "l:o:h")); if (-1 == option_char) break; --- 91,95 ---- OutputFormats output_format(kOutputRealAndImaginaryParts); ! for (;;) { const char option_char(getopt(argc, argv, "l:o:h")); if (-1 == option_char) break; *************** *** 106,111 **** } case 'o': { ! int output_format_integer; ! if (!sptk::ConvertStringToInteger(optarg, &output_format_integer)) { std::ostringstream error_message; error_message << "The argument for the -o option must be an integer"; --- 106,111 ---- } case 'o': { ! int given_integer(-1); ! if (!sptk::ConvertStringToInteger(optarg, &given_integer)) { std::ostringstream error_message; error_message << "The argument for the -o option must be an integer"; *************** *** 116,120 **** const int min(0); const int max(static_cast<int>(kNumOutputFormats) - 1); ! if (!sptk::IsInRange(output_format_integer, min, max)) { std::ostringstream error_message; error_message << "The argument for the -o option must be in range" --- 116,120 ---- const int min(0); const int max(static_cast<int>(kNumOutputFormats) - 1); ! if (!sptk::IsInRange(given_integer, min, max)) { std::ostringstream error_message; error_message << "The argument for the -o option must be in range" *************** *** 124,136 **** } ! output_format = static_cast<OutputFormats>(output_format_integer); break; } case 'h': { ! PrintUsage(); return 0; } default: { ! PrintUsage(); return 1; } --- 124,136 ---- } ! output_format = static_cast<OutputFormats>(given_integer); break; } case 'h': { ! PrintUsage(&std::cout); return 0; } default: { ! PrintUsage(&std::cerr); return 1; } *************** *** 167,177 **** std::vector<double> output_y(fft_size); ! while (!input_stream.eof()) { ! // get input ! if (!sptk::ReadStream(false, fft_size, &input_x, &input_stream)) ! break; ! if (!sptk::ReadStream(false, fft_size, &input_y, &input_stream)) ! break; ! if (!fft.Run(input_x, input_y, &output_x, &output_y)) { std::ostringstream error_message; --- 167,172 ---- std::vector<double> output_y(fft_size); ! while (sptk::ReadStream(false, fft_size, &input_x, &input_stream) && ! sptk::ReadStream(false, fft_size, &input_y, &input_stream)) { if (!fft.Run(input_x, input_y, &output_x, &output_y)) { std::ostringstream error_message; Index: levinson_durbin_recursion.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/levinson_durbin_recursion.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** levinson_durbin_recursion.h 25 Mar 2016 06:04:51 -0000 1.1 --- levinson_durbin_recursion.h 1 Apr 2016 09:05:46 -0000 1.2 *************** *** 84,88 **** // bool Run(const std::vector<double>& autocorrelation_sequence, ! std::vector<double>* linear_predictive_coefficients, LevinsonDurbinRecursion::Buffer* buffer, bool* is_stable) const; --- 84,88 ---- // bool Run(const std::vector<double>& autocorrelation_sequence, ! std::vector<double>* lpc_coefficients, LevinsonDurbinRecursion::Buffer* buffer, bool* is_stable) const; Index: acorr.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/acorr.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** acorr.cc 25 Mar 2016 06:04:51 -0000 1.2 --- acorr.cc 1 Apr 2016 09:05:46 -0000 1.3 *************** *** 57,77 **** const int kDefaultNumOrder(25); ! void PrintUsage() { ! std::cout << std::endl; ! std::cout << " acorr - obtain autocorrelation sequence" << std::endl; ! std::cout << std::endl; ! std::cout << " usage:" << std::endl; ! std::cout << " acorr [ options ] [ infile ] > stdout" << std::endl; ! std::cout << " options:" << std::endl; ! std::cout << " -l l : frame length [" << kDefaultFrameLength << "]" << std::endl; // NOLINT ! std::cout << " -m m : order of sequence [" << kDefaultNumOrder << "]" << std::endl; // NOLINT ! std::cout << " -h : print this message" << std::endl; ! std::cout << " infile:" << std::endl; ! std::cout << " data sequence (double) [stdin]" << std::endl; ! std::cout << " stdout:" << std::endl; ! std::cout << " autocorrelation sequence (double)" << std::endl; ! std::cout << std::endl; ! std::cout << " SPTK: version " << sptk::kVersion << std::endl; ! std::cout << std::endl; } --- 57,77 ---- const int kDefaultNumOrder(25); ! void PrintUsage(std::ostream* stream) { ! *stream << std::endl; ! *stream << " acorr - obtain autocorrelation sequence" << std::endl; ! *stream << std::endl; ! *stream << " usage:" << std::endl; ! *stream << " acorr [ options ] [ infile ] > stdout" << std::endl; ! *stream << " options:" << std::endl; ! *stream << " -l l : frame length [" << kDefaultFrameLength << "]" << std::endl; // NOLINT ! *stream << " -m m : order of sequence [" << kDefaultNumOrder << "]" << std::endl; // NOLINT ! *stream << " -h : print this message" << std::endl; ! *stream << " infile:" << std::endl; ! *stream << " data sequence (double) [stdin]" << std::endl; ! *stream << " stdout:" << std::endl; ! *stream << " autocorrelation sequence (double)" << std::endl; ! *stream << std::endl; ! *stream << " SPTK: version " << sptk::kVersion << std::endl; ! *stream << std::endl; } *************** *** 82,86 **** int num_order(kDefaultNumOrder); ! while (true) { const char option_char(getopt(argc, argv, "l:m:h")); if (-1 == option_char) break; --- 82,86 ---- int num_order(kDefaultNumOrder); ! for (;;) { const char option_char(getopt(argc, argv, "l:m:h")); if (-1 == option_char) break; *************** *** 110,118 **** } case 'h': { ! PrintUsage(); return 0; } default: { ! PrintUsage(); return 1; } --- 110,118 ---- } case 'h': { ! PrintUsage(&std::cout); return 0; } default: { ! PrintUsage(&std::cerr); return 1; } *************** *** 146,153 **** std::vector<double> output_sequence(output_length); ! while (true) { ! if (!sptk::ReadStream(false, frame_length, &input_sequence, &input_stream)) ! break; ! if (!autocorrelation.Run(input_sequence, &output_sequence)) { std::ostringstream error_message; --- 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; Index: levinson_durbin_recursion.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/levinson_durbin_recursion.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** levinson_durbin_recursion.cc 25 Mar 2016 06:04:51 -0000 1.1 --- levinson_durbin_recursion.cc 1 Apr 2016 09:05:46 -0000 1.2 *************** *** 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; --- 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; *************** *** 63,76 **** // 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)) buffer->c_.resize(output_length); // get values const double* input(&(autocorrelation_sequence[0])); ! double* output(&((*linear_predictive_coefficients)[0])); double* c(&buffer->c_[0]); --- 63,74 ---- // 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)) buffer->c_.resize(output_length); // get values const double* input(&(autocorrelation_sequence[0])); ! double* output(&((*lpc_coefficients)[0])); double* c(&buffer->c_[0]); --- NEW FILE: levdur.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 "levinson_durbin_recursion.h" #include "sptk_utils.h" namespace { enum BehaviorForUnstableCoefficients { kIgnore = 0, kWarn, kExit, kNumKindsOfBehavior }; const int kDefaultNumOrder(25); const double kDefaultEpsilon(1.0e-6); void PrintUsage(std::ostream* stream) { *stream << std::endl; *stream << " levdur - solve an autocorrelation normal equation" << std::endl; *stream << " using Levinson-Durbin recursion" << std::endl; *stream << std::endl; *stream << " usage:" << std::endl; *stream << " levdur [ options ] [ infile ] > stdout" << std::endl; *stream << " options:" << std::endl; *stream << " -m m : order of autocorrelation [" << 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 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; *stream << " infile:" << std::endl; *stream << " autocorrelation sequence (double) [stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; *stream << " linear predictive 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_order(kDefaultNumOrder); double epsilon(kDefaultEpsilon); BehaviorForUnstableCoefficients behavior(kIgnore); for (;;) { const char option_char(getopt(argc, argv, "m:f: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("levdur", error_message); return 1; } break; } 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; } break; } case 'c': { int given_integer(-1); if (!sptk::ConvertStringToInteger(optarg, &given_integer)) { std::ostringstream error_message; error_message << "The argument for the -c option must be an integer"; sptk::PrintErrorMessage("levdur", error_message); return 1; } const int min(0); const int max(static_cast<int>(kNumKindsOfBehavior) - 1); if (!sptk::IsInRange(given_integer, min, max)) { std::ostringstream error_message; error_message << "The argument for the -c option must be in range" << " (" << min << " .. " << max << ")"; sptk::PrintErrorMessage("levdur", error_message); return 1; } behavior = static_cast<BehaviorForUnstableCoefficients>(given_integer); 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("levdur", error_message); return 1; } std::istream& input_stream(ifs.fail() ? std::cin : ifs); sptk::LevinsonDurbinRecursion recursion; sptk::LevinsonDurbinRecursion::Buffer buffer; if (!recursion.SetEpsilon(epsilon)) { std::ostringstream error_message; error_message << "Failed to set the minimum value of the determinant"; sptk::PrintErrorMessage("levdur", error_message); return 1; } const int length(num_order + 1); std::vector<double> autocorrelation_sequence(length); std::vector<double> lpc_coefficients(length); for (int frame_index(0); sptk::ReadStream(false, length, &autocorrelation_sequence, &input_stream); ++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"; sptk::PrintErrorMessage("levdur", error_message); return 1; } if (!is_stable && kIgnore != behavior) { std::ostringstream error_message; error_message << frame_index << "th frame is unstable"; sptk::PrintErrorMessage("levdur", error_message); if (kExit == behavior) return 1; } 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; } } return 0; } |
From: Takenori Y. <tak...@us...> - 2016-03-25 06:04:54
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv23767 Modified Files: Makefile acorr.cc autocorrelation.cc autocorrelation.h fast_fourier_transform.cc fft.cc freqt.cc frequency_transform.cc frequency_transform.h ifft.cc sptk_utils.cc Added Files: levinson_durbin_recursion.cc levinson_durbin_recursion.h Log Message: add LevinsonDurbinRecursion class Index: frequency_transform.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/frequency_transform.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** frequency_transform.cc 8 Feb 2016 11:42:45 -0000 1.5 --- frequency_transform.cc 25 Mar 2016 06:04:51 -0000 1.6 *************** *** 62,70 **** // prepare memories const int output_length(num_output_order_ + 1); ! if (static_cast<std::size_t>(output_length) > warped_sequence->size()) warped_sequence->resize(output_length); ! if (static_cast<std::size_t>(output_length) > buffer->d_.size()) buffer->d_.resize(output_length); ! if (static_cast<std::size_t>(output_length) > buffer->g_.size()) buffer->g_.resize(output_length); --- 62,70 ---- // prepare memories const int output_length(num_output_order_ + 1); ! if (warped_sequence->size() < static_cast<std::size_t>(output_length)) warped_sequence->resize(output_length); ! if (buffer->d_.size() < static_cast<std::size_t>(output_length)) buffer->d_.resize(output_length); ! if (buffer->g_.size() < static_cast<std::size_t>(output_length)) buffer->g_.resize(output_length); Index: fft.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fft.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** fft.cc 8 Feb 2016 11:42:45 -0000 1.5 --- fft.cc 25 Mar 2016 06:04:51 -0000 1.6 *************** *** 114,120 **** } case 'm': { ! if (!sptk::ConvertStringToInteger(optarg, &num_order)) { std::ostringstream error_message; ! error_message << "The argument for the -m option must be an integer"; sptk::PrintErrorMessage("fft", error_message); return 1; --- 114,122 ---- } 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("fft", error_message); return 1; *************** *** 160,164 **** if (!fft.SetNumDimension(fft_size)) { std::ostringstream error_message; ! error_message << "The FFT size must be an power of 2 and greater than 2"; sptk::PrintErrorMessage("fft", error_message); return 1; --- 162,166 ---- if (!fft.SetNumDimension(fft_size)) { std::ostringstream error_message; ! error_message << "The FFT size must be a power of 2 and greater than 2"; sptk::PrintErrorMessage("fft", error_message); return 1; *************** *** 170,182 **** if (fft_size <= num_order) { std::ostringstream error_message; ! error_message << "The order of sequence " << num_order ! << " should less than the FFT size " << fft_size; ! sptk::PrintErrorMessage("fft", error_message); ! return 1; ! } ! if (0 > num_order) { ! std::ostringstream error_message; ! error_message << "The order of sequence " << num_order ! << " should at least 0"; sptk::PrintErrorMessage("fft", error_message); return 1; --- 172,177 ---- if (fft_size <= num_order) { std::ostringstream error_message; ! error_message << "The order of a sequence " << num_order ! << " should be less than the FFT size " << fft_size; sptk::PrintErrorMessage("fft", error_message); return 1; *************** *** 233,237 **** !sptk::WriteStream(fft_size, output_x, &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write output sequence"; sptk::PrintErrorMessage("fft", error_message); return 1; --- 228,232 ---- !sptk::WriteStream(fft_size, output_x, &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write an output sequence"; sptk::PrintErrorMessage("fft", error_message); return 1; *************** *** 242,246 **** !sptk::WriteStream(fft_size, output_y, &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write output sequence"; sptk::PrintErrorMessage("fft", error_message); return 1; --- 237,241 ---- !sptk::WriteStream(fft_size, output_y, &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write an output sequence"; sptk::PrintErrorMessage("fft", error_message); return 1; Index: sptk_utils.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/sptk_utils.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** sptk_utils.cc 8 Feb 2016 11:42:45 -0000 1.6 --- sptk_utils.cc 25 Mar 2016 06:04:51 -0000 1.7 *************** *** 55,59 **** std::vector<double>* sequence_to_read, std::istream* input_stream) { ! if (0 >= read_size || NULL == sequence_to_read || NULL == input_stream) --- 55,59 ---- std::vector<double>* sequence_to_read, std::istream* input_stream) { ! if (read_size <= 0 || NULL == sequence_to_read || NULL == input_stream) *************** *** 63,67 **** return false; ! if (static_cast<std::size_t>(read_size) > sequence_to_read->size()) sequence_to_read->resize(read_size); --- 63,67 ---- return false; ! if (sequence_to_read->size() < static_cast<std::size_t>(read_size)) sequence_to_read->resize(read_size); *************** *** 79,87 **** const int num_zeros(std::ceil( static_cast<double>(num_bytes - gcount) / type_byte)); ! if (0 > num_zeros) return false; // Something wrong! std::fill(sequence_to_read->end() - num_zeros, ! sequence_to_read->end(), 0.0); return !input_stream->bad(); } --- 79,89 ---- 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); ! return !input_stream->bad(); } *************** *** 93,101 **** const std::vector<double>& sequence_to_write, std::ostream* output_stream) { ! if (0 >= write_size || NULL == output_stream) return false; ! if (static_cast<std::size_t>(write_size) > sequence_to_write.size()) return false; --- 95,103 ---- const std::vector<double>& sequence_to_write, std::ostream* output_stream) { ! if (write_size <= 0 || NULL == output_stream) return false; ! if (sequence_to_write.size() < static_cast<std::size_t>(write_size)) return false; *************** *** 135,139 **** bool IsInRange(const int& value, const int& min, const int& max) { ! return (min > value || max < value) ? false : true; } --- 137,141 ---- bool IsInRange(const int& value, const int& min, const int& max) { ! return (value < min || max < value) ? false : true; } Index: freqt.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/freqt.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** freqt.cc 8 Feb 2016 11:42:45 -0000 1.3 --- freqt.cc 25 Mar 2016 06:04:51 -0000 1.4 *************** *** 95,102 **** case 'm': { if (!sptk::ConvertStringToInteger(optarg, &num_input_order) || ! 0 > num_input_order) { std::ostringstream error_message; ! error_message ! << "The argument for the -m option must be positive integer or 0"; sptk::PrintErrorMessage("freqt", error_message); return 1; --- 95,102 ---- 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("freqt", error_message); return 1; *************** *** 106,113 **** case 'M': { if (!sptk::ConvertStringToInteger(optarg, &num_output_order) || ! 0 > num_output_order) { std::ostringstream error_message; ! error_message ! << "The argument for the -M option must be positive integer or 0"; sptk::PrintErrorMessage("freqt", error_message); return 1; --- 106,113 ---- 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("freqt", error_message); return 1; *************** *** 173,177 **** if (!frequency_transform.SetNumOutputOrder(num_output_order)) { std::ostringstream error_message; ! error_message << "Invalid number of output orders " << num_output_order; sptk::PrintErrorMessage("freqt", error_message); return 1; --- 173,177 ---- 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; *************** *** 199,203 **** if (!sptk::WriteStream(output_length, warped_sequence, &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write output sequence"; sptk::PrintErrorMessage("freqt", error_message); return 1; --- 199,203 ---- if (!sptk::WriteStream(output_length, warped_sequence, &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write an output sequence"; sptk::PrintErrorMessage("freqt", error_message); return 1; Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile 8 Feb 2016 11:42:45 -0000 1.5 --- Makefile 25 Mar 2016 06:04:51 -0000 1.6 *************** *** 48,51 **** --- 48,52 ---- fast_fourier_transform.cc \ frequency_transform.cc \ + levinson_durbin_recursion.cc \ sptk_utils.cc Index: fast_fourier_transform.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fast_fourier_transform.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** fast_fourier_transform.cc 8 Feb 2016 11:42:45 -0000 1.6 --- fast_fourier_transform.cc 25 Mar 2016 06:04:51 -0000 1.7 *************** *** 58,62 **** const double argument(M_PI / num_dimension * 2); ! if (static_cast<std::size_t>(table_size) != sine_table_.size()) { sine_table_.resize(table_size); for (int i(0); i < table_size; ++i) { --- 58,62 ---- const double argument(M_PI / num_dimension * 2); ! if (sine_table_.size() != static_cast<std::size_t>(table_size)) { sine_table_.resize(table_size); for (int i(0); i < table_size; ++i) { *************** *** 83,93 **** // prepare memories ! if (static_cast<std::size_t>(num_dimension_) != real_part_output->size()) real_part_output->resize(num_dimension_); ! if (static_cast<std::size_t>(num_dimension_) != imaginary_part_output->size()) imaginary_part_output->resize(num_dimension_); ! if (real_part_input.size() > real_part_output->size() || ! imaginary_part_input.size() > imaginary_part_output->size()) return false; --- 83,93 ---- // prepare memories ! if (real_part_output->size() != static_cast<std::size_t>(num_dimension_)) real_part_output->resize(num_dimension_); ! if (imaginary_part_output->size() != static_cast<std::size_t>(num_dimension_)) imaginary_part_output->resize(num_dimension_); ! if (real_part_output->size() < real_part_input.size() || ! imaginary_part_output->size() < imaginary_part_input.size()) return false; *************** *** 125,129 **** int lf(1); ! while (lmx > 1) { double* sinp(const_cast<double*>(&(sine_table_[0]))); double* cosp(const_cast<double*>(&(sine_table_[0])) + num_dimension_ / 4); --- 125,129 ---- int lf(1); ! while (1 < lmx) { double* sinp(const_cast<double*>(&(sine_table_[0]))); double* cosp(const_cast<double*>(&(sine_table_[0])) + num_dimension_ / 4); Index: frequency_transform.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/frequency_transform.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** frequency_transform.h 8 Feb 2016 11:42:45 -0000 1.6 --- frequency_transform.h 25 Mar 2016 06:04:51 -0000 1.7 *************** *** 73,77 **** // num_output_order must be non-negative. bool SetNumOutputOrder(int num_output_order) { ! if (0 > num_output_order) return false; num_output_order_ = num_output_order; return true; --- 73,77 ---- // 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; Index: ifft.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/ifft.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ifft.cc 8 Feb 2016 11:42:45 -0000 1.2 --- ifft.cc 25 Mar 2016 06:04:51 -0000 1.3 *************** *** 142,146 **** if (!fft.SetNumDimension(fft_size)) { std::ostringstream error_message; ! error_message << "The FFT size must be an power of 2 and greater than 2"; sptk::PrintErrorMessage("ifft", error_message); return 1; --- 142,146 ---- if (!fft.SetNumDimension(fft_size)) { std::ostringstream error_message; ! error_message << "The FFT size must be a power of 2 and greater than 2"; sptk::PrintErrorMessage("ifft", error_message); return 1; *************** *** 184,188 **** !sptk::WriteStream(fft_size, output_x, &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write output sequence"; sptk::PrintErrorMessage("ifft", error_message); return 1; --- 184,188 ---- !sptk::WriteStream(fft_size, output_x, &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write an output sequence"; sptk::PrintErrorMessage("ifft", error_message); return 1; *************** *** 193,197 **** !sptk::WriteStream(fft_size, output_y, &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write output sequence"; sptk::PrintErrorMessage("ifft", error_message); return 1; --- 193,197 ---- !sptk::WriteStream(fft_size, output_y, &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write an output sequence"; sptk::PrintErrorMessage("ifft", error_message); return 1; --- NEW FILE: levinson_durbin_recursion.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_LEVINSON_DURBIN_RECURSION_H_ #define SPTK_SRC_LEVINSON_DURBIN_RECURSION_H_ #include <vector> // std::vector #include "sptk_utils.h" namespace sptk { class LevinsonDurbinRecursion { public: class Buffer { public: Buffer() {} virtual ~Buffer() {} private: std::vector<double> c_; friend class LevinsonDurbinRecursion; DISALLOW_COPY_AND_ASSIGN(Buffer); }; // LevinsonDurbinRecursion() : epsilon_(1.0e-6) {} // virtual ~LevinsonDurbinRecursion() {} // bool SetEpsilon(double epsilon) { if (epsilon < 0.0) return false; epsilon_ = epsilon; return true; } // 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: // double epsilon_; // DISALLOW_COPY_AND_ASSIGN(LevinsonDurbinRecursion); }; } // namespace sptk #endif // SPTK_SRC_LEVINSON_DURBIN_RECURSION_H_ Index: acorr.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/acorr.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** acorr.cc 8 Feb 2016 11:42:45 -0000 1.1 --- acorr.cc 25 Mar 2016 06:04:51 -0000 1.2 *************** *** 89,96 **** case 'l': { if (!sptk::ConvertStringToInteger(optarg, &frame_length) || ! 0 >= frame_length) { std::ostringstream error_message; ! error_message ! << "The argument for the -l option must be positive integer"; sptk::PrintErrorMessage("acorr", error_message); return 1; --- 89,96 ---- case 'l': { if (!sptk::ConvertStringToInteger(optarg, &frame_length) || ! 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; *************** *** 100,107 **** case 'm': { if (!sptk::ConvertStringToInteger(optarg, &num_order) || ! 0 > num_order) { std::ostringstream error_message; ! error_message ! << "The argument for the -m option must be positive integer or 0"; sptk::PrintErrorMessage("acorr", error_message); return 1; --- 100,107 ---- 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("acorr", error_message); return 1; *************** *** 137,141 **** if (!autocorrelation.SetNumOrder(num_order)) { std::ostringstream error_message; ! error_message << "Invalid number of orders " << num_order; sptk::PrintErrorMessage("acorr", error_message); return 1; --- 137,141 ---- if (!autocorrelation.SetNumOrder(num_order)) { std::ostringstream error_message; ! error_message << "Failed to set the order of autocorrelation sequences"; sptk::PrintErrorMessage("acorr", error_message); return 1; *************** *** 152,164 **** if (!autocorrelation.Run(input_sequence, &output_sequence)) { std::ostringstream error_message; ! error_message << "Failed to obtatin autocorrelation sequence"; sptk::PrintErrorMessage("acorr", error_message); return 1; } ! if (!sptk::WriteStream(output_length, output_sequence, ! &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write autocorrelation sequence"; sptk::PrintErrorMessage("acorr", error_message); return 1; --- 152,163 ---- if (!autocorrelation.Run(input_sequence, &output_sequence)) { std::ostringstream error_message; ! error_message << "Failed to obtain an autocorrelation sequence"; sptk::PrintErrorMessage("acorr", error_message); return 1; } ! if (!sptk::WriteStream(output_length, output_sequence, &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write an autocorrelation sequence"; sptk::PrintErrorMessage("acorr", error_message); return 1; --- NEW FILE: levinson_durbin_recursion.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 "levinson_durbin_recursion.h" #include <cmath> // std::fabs, std::sqrt #include <cstring> // std::size_t namespace sptk { 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; // 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)) buffer->c_.resize(output_length); // get values const double* input(&(autocorrelation_sequence[0])); double* output(&((*linear_predictive_coefficients)[0])); double* c(&buffer->c_[0]); // set value if (NULL != is_stable) *is_stable = true; double rmd(input[0]); if (std::fabs(rmd) <= epsilon_ || std::isnan(rmd)) return false; output[0] = 0.0; for (int i(1); i < output_length; ++i) { double mue(-input[i]); for (int j(1); j < i; ++j) { mue -= c[j] * input[i - j]; } mue /= rmd; for (int j(1); j < i; ++j) { output[j] = c[j] + mue * c[i - j]; } output[i] = mue; rmd *= 1.0 - mue * mue; if (std::fabs(rmd) <= epsilon_ || std::isnan(rmd)) return false; if (NULL != is_stable && 1.0 <= std::fabs(mue)) *is_stable = false; for (int j(0); j <= i; ++j) { c[j] = output[j]; } } output[0] = std::sqrt(rmd); return true; } } // namespace sptk Index: autocorrelation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/autocorrelation.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** autocorrelation.cc 8 Feb 2016 11:42:45 -0000 1.1 --- autocorrelation.cc 25 Mar 2016 06:04:51 -0000 1.2 *************** *** 59,64 **** // prepare memories const int output_length(num_order_ + 1); ! if (static_cast<std::size_t>(output_length) > ! output_sequence->size()) output_sequence->resize(output_length); --- 59,63 ---- // prepare memories const int output_length(num_order_ + 1); ! if (output_sequence->size() < static_cast<std::size_t>(output_length)) output_sequence->resize(output_length); Index: autocorrelation.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/autocorrelation.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** autocorrelation.h 8 Feb 2016 11:42:45 -0000 1.1 --- autocorrelation.h 25 Mar 2016 06:04:51 -0000 1.2 *************** *** 62,66 **** // bool SetNumOrder(int num_order) { ! if (0 > num_order) return false; num_order_ = num_order; return true; --- 62,66 ---- // bool SetNumOrder(int num_order) { ! if (num_order < 0) return false; num_order_ = num_order; return true; |
From: fujishita t. <fjs...@us...> - 2016-03-16 08:00:10
|
Update of /cvsroot/sp-tk/SPTK/src/script In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv5799 Modified Files: gseries.in Log Message: modify temporary file Index: gseries.in =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/script/gseries.in,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** gseries.in 15 Mar 2016 09:35:11 -0000 1.11 --- gseries.in 16 Mar 2016 08:00:08 -0000 1.12 *************** *** 239,243 **** @ term = `echo "$wctmp - $reduced + 1" | bc -l` set mterm = `echo "$mwc - 1" | bc -l` ! x2x +${type}f /tmp/sptk-gseries-$uid-$$-5 | bcp -S $start -l $mwc -s 0 -e $mterm -f 0 | x2x +f${type} >> /tmp/sptk-gseries-$uid-$$-5 else if ( $flagMAGIC ) then echo2 "${cmnd} : -MAGIC option need magic number\!" --- 239,244 ---- @ term = `echo "$wctmp - $reduced + 1" | bc -l` set mterm = `echo "$mwc - 1" | bc -l` ! x2x +${type}f /tmp/sptk-gseries-$uid-$$-5 | bcp -S $start -l $mwc -s 0 -e $mterm -f 0 | x2x +f${type} > /tmp/sptk-gseries-$uid-$$-6 ! cat /tmp/sptk-gseries-$uid-$$-6 > /tmp/sptk-gseries-$uid-$$-5 else if ( $flagMAGIC ) then echo2 "${cmnd} : -MAGIC option need magic number\!" *************** *** 440,444 **** clean: ! set i = 5 while ( $i >= 0 ) /bin/rm -f /tmp/sptk-gseries-$uid-$$-$i --- 441,445 ---- clean: ! set i = 6 while ( $i >= 0 ) /bin/rm -f /tmp/sptk-gseries-$uid-$$-$i |
From: fujishita t. <fjs...@us...> - 2016-03-15 09:35:14
|
Update of /cvsroot/sp-tk/SPTK/src/script In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11803 Modified Files: gseries.in raw2wav.in Log Message: modify temporary file Index: raw2wav.in =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/script/raw2wav.in,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** raw2wav.in 15 Jan 2016 04:27:09 -0000 1.20 --- raw2wav.in 15 Mar 2016 09:35:12 -0000 1.21 *************** *** 385,390 **** set frequency = `echo "$frequency * 1000" | bc` ! rawtowav $frequency $bit /tmp/sptk-raw2wav-$uid-$$.raw /tmp/raw2wav ! /bin/mv /tmp/raw2wav "$outfile" if ( $white[$i] ) then /bin/rm -f $f --- 385,389 ---- set frequency = `echo "$frequency * 1000" | bc` ! rawtowav $frequency $bit /tmp/sptk-raw2wav-$uid-$$.raw $outfile if ( $white[$i] ) then /bin/rm -f $f Index: gseries.in =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/script/gseries.in,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** gseries.in 15 Jan 2016 04:27:09 -0000 1.10 --- gseries.in 15 Mar 2016 09:35:11 -0000 1.11 *************** *** 226,230 **** if ( ($start != 0) || ($term > 0) ) then if ( $flagmagic && $flagMAGIC ) then ! x2x +${type}f "$file" | sopr -magic $magic -MAGIC $MAGIC | x2x +f${type} > /tmp/$$ else if ( $flagmagic ) then if ( $term < 0 ) then --- 226,230 ---- if ( ($start != 0) || ($term > 0) ) then if ( $flagmagic && $flagMAGIC ) then ! x2x +${type}f "$file" | sopr -magic $magic -MAGIC $MAGIC | x2x +f${type} > /tmp/sptk-gseries-$uid-$$-5 else if ( $flagmagic ) then if ( $term < 0 ) then *************** *** 235,244 **** endif set mwc = `x2x +${type}f "$file" | bcut -s $start -e $wctmp | sopr -magic $magic | x2x +fa | wc -l` ! x2x +${type}f "$file" | bcut -s $start -e $wctmp | sopr -magic $magic | x2x +f${type} > /tmp/$$ @ reduced = `echo "$wctmp + 1 - $start - $mwc" | bc -l` @ term = `echo "$wctmp - $reduced + 1" | bc -l` set mterm = `echo "$mwc - 1" | bc -l` ! x2x +${type}f /tmp/$$ | bcp -S $start -l $mwc -s 0 -e $mterm -f 0 | x2x +f${type} > /tmp/$$-1 ! cat /tmp/$$-1 > /tmp/$$ else if ( $flagMAGIC ) then echo2 "${cmnd} : -MAGIC option need magic number\!" --- 235,243 ---- endif set mwc = `x2x +${type}f "$file" | bcut -s $start -e $wctmp | sopr -magic $magic | x2x +fa | wc -l` ! x2x +${type}f "$file" | bcut -s $start -e $wctmp | sopr -magic $magic | x2x +f${type} > /tmp/sptk-gseries-$uid-$$-5 @ reduced = `echo "$wctmp + 1 - $start - $mwc" | bc -l` @ term = `echo "$wctmp - $reduced + 1" | bc -l` set mterm = `echo "$mwc - 1" | bc -l` ! x2x +${type}f /tmp/sptk-gseries-$uid-$$-5 | bcp -S $start -l $mwc -s 0 -e $mterm -f 0 | x2x +f${type} >> /tmp/sptk-gseries-$uid-$$-5 else if ( $flagMAGIC ) then echo2 "${cmnd} : -MAGIC option need magic number\!" *************** *** 246,256 **** goto usage else ! cat "$file" > /tmp/$$ endif else if ( $flagmagic && $flagMAGIC ) then ! x2x +${type}f "$file" | sopr -magic $magic -MAGIC $MAGIC | x2x +f${type} > /tmp/$$ else if ( $flagmagic ) then ! x2x +${type}f "$file" | sopr -magic $magic | x2x +f${type} > /tmp/$$ else if ( $flagMAGIC ) then echo2 "${cmnd} : -MAGIC option need magic number\!" --- 245,255 ---- goto usage else ! cat "$file" > /tmp/sptk-gseries-$uid-$$-5 endif else if ( $flagmagic && $flagMAGIC ) then ! x2x +${type}f "$file" | sopr -magic $magic -MAGIC $MAGIC | x2x +f${type} > /tmp/sptk-gseries-$uid-$$-5 else if ( $flagmagic ) then ! x2x +${type}f "$file" | sopr -magic $magic | x2x +f${type} > /tmp/sptk-gseries-$uid-$$-5 else if ( $flagMAGIC ) then echo2 "${cmnd} : -MAGIC option need magic number\!" *************** *** 258,262 **** goto usage else ! cat "$file" > /tmp/$$ endif endif --- 257,261 ---- goto usage else ! cat "$file" > /tmp/sptk-gseries-$uid-$$-5 endif endif *************** *** 264,268 **** rm -fr /tmp/sptk-gseries-$uid-$$ ! set file = /tmp/$$ goto main --- 263,267 ---- rm -fr /tmp/sptk-gseries-$uid-$$ ! set file = /tmp/sptk-gseries-$uid-$$-5 goto main *************** *** 412,420 **** @ tmp = $numscreen % 5 ! echo "x $xsw $xew" >! /tmp/$$-$tmp ! echo "y $ymin $ymax" >> /tmp/$$-$tmp ! echo "xscale $xscale" >> /tmp/$$-$tmp ! echo "yscale $ymin $ymax" >> /tmp/$$-$tmp ! echo "ygrid 0" >> /tmp/$$-$tmp if ( ($numscreen == 1) && ($numdata > ($allnumdata % $numscreentmp)) ) then --- 411,419 ---- @ tmp = $numscreen % 5 ! echo "x $xsw $xew" >! /tmp/sptk-gseries-$uid-$$-$tmp ! echo "y $ymin $ymax" >> /tmp/sptk-gseries-$uid-$$-$tmp ! echo "xscale $xscale" >> /tmp/sptk-gseries-$uid-$$-$tmp ! echo "yscale $ymin $ymax" >> /tmp/sptk-gseries-$uid-$$-$tmp ! echo "ygrid 0" >> /tmp/sptk-gseries-$uid-$$-$tmp if ( ($numscreen == 1) && ($numdata > ($allnumdata % $numscreentmp)) ) then *************** *** 423,432 **** foreach line (`x2x +${type}f < $file | bcut -s $start -e $end | x2x +fa`) ! echo "box $count 0 $count $line" >> /tmp/$$-$tmp ! echo "$count $line $mtype" >> /tmp/$$-$tmp @ count += 1 end ! fig -o $ox $oy -W $width -H $height -p $pen -F $F /tmp/$$-$tmp @ numscreen-- --- 422,431 ---- foreach line (`x2x +${type}f < $file | bcut -s $start -e $end | x2x +fa`) ! echo "box $count 0 $count $line" >> /tmp/sptk-gseries-$uid-$$-$tmp ! echo "$count $line $mtype" >> /tmp/sptk-gseries-$uid-$$-$tmp @ count += 1 end ! fig -o $ox $oy -W $width -H $height -p $pen -F $F /tmp/sptk-gseries-$uid-$$-$tmp @ numscreen-- *************** *** 441,449 **** clean: ! /bin/rm -f /tmp/$$ ! ! set i = 4 while ( $i >= 0 ) ! /bin/rm -f /tmp/$$-$i @ i-- end --- 440,446 ---- clean: ! set i = 5 while ( $i >= 0 ) ! /bin/rm -f /tmp/sptk-gseries-$uid-$$-$i @ i-- end |
From: Shikano M. <sh...@us...> - 2016-02-25 07:03:23
|
Update of /cvsroot/sp-tk/SPTK/src/bin/vstat In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv20071 Modified Files: vstat.c Log Message: Change of type Index: vstat.c =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/bin/vstat/vstat.c,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** vstat.c 14 Dec 2015 01:14:24 -0000 1.38 --- vstat.c 25 Feb 2016 07:03:21 -0000 1.39 *************** *** 269,274 **** { int i, j; ! int pivot; ! int tmp; i = left; --- 269,274 ---- { int i, j; ! double pivot; ! double tmp; i = left; |
From: Takenori Y. <tak...@us...> - 2016-02-08 11:42:48
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv12021 Modified Files: Makefile fast_fourier_transform.cc fast_fourier_transform.h fft.cc freqt.cc frequency_transform.cc frequency_transform.h ifft.cc sptk_utils.cc sptk_utils.h Added Files: acorr.cc autocorrelation.cc autocorrelation.h Log Message: add autocorrelation class and acorr command Index: fast_fourier_transform.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fast_fourier_transform.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** fast_fourier_transform.h 28 Dec 2015 12:51:50 -0000 1.4 --- fast_fourier_transform.h 8 Feb 2016 11:42:45 -0000 1.5 *************** *** 9,13 **** // Science and Engineering // // // ! // 1996-2015 Nagoya Institute of Technology // // Department of Computer Science // // // --- 9,13 ---- // Science and Engineering // // // ! // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // *************** *** 46,50 **** #define SPTK_SRC_FAST_FOURIER_TRANSFORM_H_ ! #include <vector> namespace sptk { --- 46,52 ---- #define SPTK_SRC_FAST_FOURIER_TRANSFORM_H_ ! #include <vector> // std::vector ! ! #include "sptk_utils.h" namespace sptk { *************** *** 58,62 **** virtual ~FastFourierTransform() {} ! // Set the number of dimension and prepare the sine table. bool SetNumDimension(int num_dimension); --- 60,64 ---- virtual ~FastFourierTransform() {} ! // Set the number of dimensions and prepare the sine table. bool SetNumDimension(int num_dimension); *************** *** 84,93 **** private: // - explicit FastFourierTransform(const FastFourierTransform&); - - // - FastFourierTransform& operator=(const FastFourierTransform&); - - // int num_dimension_; --- 86,89 ---- *************** *** 97,100 **** --- 93,99 ---- // std::vector<double> sine_table_; + + // + DISALLOW_COPY_AND_ASSIGN(FastFourierTransform); }; Index: frequency_transform.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/frequency_transform.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** frequency_transform.cc 25 Nov 2015 11:35:26 -0000 1.4 --- frequency_transform.cc 8 Feb 2016 11:42:45 -0000 1.5 *************** *** 9,13 **** // Science and Engineering // // // ! // 1996-2015 Nagoya Institute of Technology // // Department of Computer Science // // // --- 9,13 ---- // Science and Engineering // // // ! // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // *************** *** 45,49 **** #include "frequency_transform.h" ! #include <cstring> namespace sptk { --- 45,50 ---- #include "frequency_transform.h" ! #include <algorithm> // std::fill_n ! #include <cstring> // std::size_t namespace sptk { *************** *** 60,77 **** // prepare memories ! const int num_output_length(num_output_order_ + 1); ! if (static_cast<std::size_t>(num_output_length) != buffer->d_.size()) ! buffer->d_.resize(num_output_length); ! if (static_cast<std::size_t>(num_output_length) != buffer->g_.size()) ! buffer->g_.resize(num_output_length); ! if (static_cast<std::size_t>(num_output_length) != warped_sequence->size()) ! warped_sequence->resize(num_output_length); // get values ! double* d(&buffer->d_[0]); ! double* g(&buffer->g_[0]); const double* input(&(minimum_phase_sequence[0])); double* output(&((*warped_sequence)[0])); ! const int num_input_order(minimum_phase_sequence.size() - 1); // set value --- 61,78 ---- // prepare memories ! const int output_length(num_output_order_ + 1); ! if (static_cast<std::size_t>(output_length) > warped_sequence->size()) ! warped_sequence->resize(output_length); ! if (static_cast<std::size_t>(output_length) > buffer->d_.size()) ! buffer->d_.resize(output_length); ! if (static_cast<std::size_t>(output_length) > buffer->g_.size()) ! buffer->g_.resize(output_length); // get values ! const int num_input_order(minimum_phase_sequence.size() - 1); const double* input(&(minimum_phase_sequence[0])); double* output(&((*warped_sequence)[0])); ! double* d(&buffer->d_[0]); ! double* g(&buffer->g_[0]); // set value *************** *** 79,83 **** // fill zero ! std::memset(g, 0, sizeof(*g) * num_output_length); // transform --- 80,84 ---- // fill zero ! std::fill_n(g, output_length, 0.0); // transform Index: fft.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fft.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** fft.cc 28 Dec 2015 12:51:50 -0000 1.4 --- fft.cc 8 Feb 2016 11:42:45 -0000 1.5 *************** *** 9,13 **** // Science and Engineering // // // ! // 1996-2015 Nagoya Institute of Technology // // Department of Computer Science // // // --- 9,13 ---- // Science and Engineering // // // ! // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // *************** *** 95,100 **** int main(int argc, char* argv[]) { int fft_size(kDefaultFftSize); ! int order(0); ! bool order_is_specified(false); OutputFormats output_format(kOutputRealAndImaginaryParts); --- 95,100 ---- int main(int argc, char* argv[]) { int fft_size(kDefaultFftSize); ! int num_order(0); ! bool is_num_order_specified(false); OutputFormats output_format(kOutputRealAndImaginaryParts); *************** *** 114,118 **** } case 'm': { ! if (!sptk::ConvertStringToInteger(optarg, &order)) { std::ostringstream error_message; error_message << "The argument for the -m option must be an integer"; --- 114,118 ---- } case 'm': { ! if (!sptk::ConvertStringToInteger(optarg, &num_order)) { std::ostringstream error_message; error_message << "The argument for the -m option must be an integer"; *************** *** 120,124 **** return 1; } ! order_is_specified = true; break; } --- 120,124 ---- return 1; } ! is_num_order_specified = true; break; } *************** *** 167,181 **** // check order ! if (order_is_specified) { ! if (fft_size <= order) { std::ostringstream error_message; ! error_message << "The order of sequence " << order << " should less than the FFT size " << fft_size; sptk::PrintErrorMessage("fft", error_message); return 1; } ! if (0 > order) { std::ostringstream error_message; ! error_message << "The order of sequence " << order << " should at least 0"; sptk::PrintErrorMessage("fft", error_message); --- 167,181 ---- // check order ! if (is_num_order_specified) { ! if (fft_size <= num_order) { std::ostringstream error_message; ! error_message << "The order of sequence " << num_order << " should less than the FFT size " << fft_size; sptk::PrintErrorMessage("fft", error_message); return 1; } ! if (0 > num_order) { std::ostringstream error_message; ! error_message << "The order of sequence " << num_order << " should at least 0"; sptk::PrintErrorMessage("fft", error_message); *************** *** 183,187 **** } } else { ! order = fft_size - 1; } --- 183,187 ---- } } else { ! num_order = fft_size - 1; } *************** *** 200,204 **** std::istream& input_stream(ifs.fail() ? std::cin : ifs); ! const int length(order + 1); std::vector<double> input_x(length); std::vector<double> input_y(length); --- 200,204 ---- std::istream& input_stream(ifs.fail() ? std::cin : ifs); ! const int length(num_order + 1); std::vector<double> input_x(length); std::vector<double> input_y(length); Index: sptk_utils.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/sptk_utils.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** sptk_utils.cc 28 Dec 2015 12:51:50 -0000 1.5 --- sptk_utils.cc 8 Feb 2016 11:42:45 -0000 1.6 *************** *** 9,13 **** // Science and Engineering // // // ! // 1996-2015 Nagoya Institute of Technology // // Department of Computer Science // // // --- 9,13 ---- // Science and Engineering // // // ! // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // *************** *** 45,52 **** #include "sptk_utils.h" ! #include <algorithm> ! #include <cerrno> ! #include <cmath> ! #include <cstdlib> namespace sptk { --- 45,52 ---- #include "sptk_utils.h" ! #include <algorithm> // std::fill ! #include <cerrno> // errno, ERANGE ! #include <cmath> // std::ceil ! #include <cstdlib> // std::size_t, std::strtol. std::strtod namespace sptk { *************** *** 75,79 **** return !input_stream->fail(); } else if (zero_padding && 0 < gcount) { ! // Use std::ceil to zero the last incomplete data // as gcount may not be a multiple of sizeof(double). const int num_zeros(std::ceil( --- 75,79 ---- return !input_stream->fail(); } else if (zero_padding && 0 < gcount) { ! // Use std::ceil to zero incomplete data // as gcount may not be a multiple of sizeof(double). const int num_zeros(std::ceil( Index: freqt.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/freqt.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** freqt.cc 25 Nov 2015 11:35:26 -0000 1.2 --- freqt.cc 8 Feb 2016 11:42:45 -0000 1.3 *************** *** 9,13 **** // Science and Engineering // // // ! // 1996-2015 Nagoya Institute of Technology // // Department of Computer Science // // // --- 9,13 ---- // Science and Engineering // // // ! // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // *************** *** 54,59 **** namespace { ! const int kDefaultInputOrder(25); ! const int kDefaultOutputOrder(25); const double kDefaultInputAlpha(0.0); const double kDefaultOutputAlpha(0.35); --- 54,59 ---- namespace { ! const int kDefaultNumInputOrder(25); ! const int kDefaultNumOutputOrder(25); const double kDefaultInputAlpha(0.0); const double kDefaultOutputAlpha(0.35); *************** *** 66,76 **** std::cout << " freqt [ options ] [ infile ] > stdout" << std::endl; std::cout << " options:" << std::endl; ! std::cout << " -m m : order of minimum phase sequence [" << kDefaultInputOrder << "]" << std::endl; // NOLINT ! std::cout << " -M M : order of warped sequence [" << kDefaultOutputOrder << "]" << std::endl; // NOLINT std::cout << " -a a : all-pass constant of input sequence [" << kDefaultInputAlpha << "]" << std::endl; // NOLINT std::cout << " -A A : all-pass constant of output sequence [" << kDefaultOutputAlpha << "]" << std::endl; // NOLINT std::cout << " -h : print this message" << std::endl; std::cout << " infile:" << std::endl; ! std::cout << " minimum phase sequence (double) [stdin]" << std::endl; // NOLINT std::cout << " stdout:" << std::endl; std::cout << " warped sequence (double)" << std::endl; --- 66,76 ---- std::cout << " freqt [ options ] [ infile ] > stdout" << std::endl; std::cout << " options:" << std::endl; ! std::cout << " -m m : order of minimum phase sequence [" << kDefaultNumInputOrder << "]" << std::endl; // NOLINT ! std::cout << " -M M : order of warped sequence [" << kDefaultNumOutputOrder << "]" << std::endl; // NOLINT std::cout << " -a a : all-pass constant of input sequence [" << kDefaultInputAlpha << "]" << std::endl; // NOLINT std::cout << " -A A : all-pass constant of output sequence [" << kDefaultOutputAlpha << "]" << std::endl; // NOLINT std::cout << " -h : print this message" << std::endl; std::cout << " infile:" << std::endl; ! std::cout << " minimum phase sequence (double) [stdin]" << std::endl; // NOLINT std::cout << " stdout:" << std::endl; std::cout << " warped sequence (double)" << std::endl; *************** *** 83,88 **** int main(int argc, char* argv[]) { ! int input_order(kDefaultInputOrder); ! int output_order(kDefaultOutputOrder); double input_alpha(kDefaultInputAlpha); double output_alpha(kDefaultOutputAlpha); --- 83,88 ---- int main(int argc, char* argv[]) { ! int num_input_order(kDefaultNumInputOrder); ! int num_output_order(kDefaultNumOutputOrder); double input_alpha(kDefaultInputAlpha); double output_alpha(kDefaultOutputAlpha); *************** *** 94,99 **** switch (option_char) { case 'm': { ! if (!sptk::ConvertStringToInteger(optarg, &input_order) || ! 0 > input_order) { std::ostringstream error_message; error_message --- 94,99 ---- switch (option_char) { case 'm': { ! if (!sptk::ConvertStringToInteger(optarg, &num_input_order) || ! 0 > num_input_order) { std::ostringstream error_message; error_message *************** *** 105,110 **** } case 'M': { ! if (!sptk::ConvertStringToInteger(optarg, &output_order) || ! 0 > output_order) { std::ostringstream error_message; error_message --- 105,110 ---- } case 'M': { ! if (!sptk::ConvertStringToInteger(optarg, &num_output_order) || ! 0 > num_output_order) { std::ostringstream error_message; error_message *************** *** 171,178 **** sptk::FrequencyTransform frequency_transform; sptk::FrequencyTransform::Buffer buffer; ! if (!frequency_transform.SetNumOutputOrder(output_order)) { std::ostringstream error_message; ! error_message ! << "The order of warped sequence must be positive integer or 0"; sptk::PrintErrorMessage("freqt", error_message); return 1; --- 171,177 ---- sptk::FrequencyTransform frequency_transform; sptk::FrequencyTransform::Buffer buffer; ! if (!frequency_transform.SetNumOutputOrder(num_output_order)) { std::ostringstream error_message; ! error_message << "Invalid number of output orders " << num_output_order; sptk::PrintErrorMessage("freqt", error_message); return 1; *************** *** 180,185 **** frequency_transform.SetAlpha(alpha); ! const int input_length(input_order + 1); ! const int output_length(output_order + 1); std::vector<double> minimum_phase_sequence(input_length); std::vector<double> warped_sequence(output_length); --- 179,184 ---- frequency_transform.SetAlpha(alpha); ! const int input_length(num_input_order + 1); ! const int output_length(num_output_order + 1); std::vector<double> minimum_phase_sequence(input_length); std::vector<double> warped_sequence(output_length); Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile 17 Nov 2015 10:15:37 -0000 1.4 --- Makefile 8 Feb 2016 11:42:45 -0000 1.5 *************** *** 9,13 **** # Science and Engineering # # # ! # 1996-2015 Nagoya Institute of Technology # # Department of Computer Science # # # --- 9,13 ---- # Science and Engineering # # # ! # 1996-2016 Nagoya Institute of Technology # # Department of Computer Science # # # *************** *** 45,49 **** TARGET = libsptk.a ! SOURCES = fast_fourier_transform.cc \ frequency_transform.cc \ sptk_utils.cc --- 45,50 ---- TARGET = libsptk.a ! SOURCES = autocorrelation.cc \ ! fast_fourier_transform.cc \ frequency_transform.cc \ sptk_utils.cc Index: frequency_transform.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/frequency_transform.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** frequency_transform.h 28 Dec 2015 12:51:50 -0000 1.5 --- frequency_transform.h 8 Feb 2016 11:42:45 -0000 1.6 *************** *** 9,13 **** // Science and Engineering // // // ! // 1996-2015 Nagoya Institute of Technology // // Department of Computer Science // // // --- 9,13 ---- // Science and Engineering // // // ! // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // *************** *** 46,50 **** #define SPTK_SRC_FREQUENCY_TRANSFORM_H_ ! #include <vector> namespace sptk { --- 46,52 ---- #define SPTK_SRC_FREQUENCY_TRANSFORM_H_ ! #include <vector> // std::vector ! ! #include "sptk_utils.h" namespace sptk { *************** *** 57,67 **** virtual ~Buffer() {} private: - // todo: following 2 lines should be modified by using - // DISALLOW_COPY_AND_ASSIGN or etc. - Buffer(const Buffer&); - Buffer& operator=(const Buffer&); std::vector<double> d_; std::vector<double> g_; friend class FrequencyTransform; }; --- 59,66 ---- virtual ~Buffer() {} private: std::vector<double> d_; std::vector<double> g_; friend class FrequencyTransform; + DISALLOW_COPY_AND_ASSIGN(Buffer); }; *************** *** 72,76 **** virtual ~FrequencyTransform() {} ! // num_output_order must be not negative bool SetNumOutputOrder(int num_output_order) { if (0 > num_output_order) return false; --- 71,75 ---- virtual ~FrequencyTransform() {} ! // num_output_order must be non-negative. bool SetNumOutputOrder(int num_output_order) { if (0 > num_output_order) return false; *************** *** 101,114 **** private: // - explicit FrequencyTransform(const FrequencyTransform&); - - // - FrequencyTransform& operator=(const FrequencyTransform&); - - // int num_output_order_; // double alpha_; }; --- 100,110 ---- private: // int num_output_order_; // double alpha_; + + // + DISALLOW_COPY_AND_ASSIGN(FrequencyTransform); }; Index: ifft.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/ifft.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ifft.cc 28 Dec 2015 12:51:50 -0000 1.1 --- ifft.cc 8 Feb 2016 11:42:45 -0000 1.2 *************** *** 9,13 **** // Science and Engineering // // // ! // 1996-2015 Nagoya Institute of Technology // // Department of Computer Science // // // --- 9,13 ---- // Science and Engineering // // // ! // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // Index: fast_fourier_transform.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fast_fourier_transform.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** fast_fourier_transform.cc 28 Dec 2015 12:51:50 -0000 1.5 --- fast_fourier_transform.cc 8 Feb 2016 11:42:45 -0000 1.6 *************** *** 9,13 **** // Science and Engineering // // // ! // 1996-2015 Nagoya Institute of Technology // // Department of Computer Science // // // --- 9,13 ---- // Science and Engineering // // // ! // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // *************** *** 45,55 **** #include "fast_fourier_transform.h" ! #include <algorithm> ! #include <cmath> ! #include <cstddef> namespace sptk { ! bool FastFourierTransform::SetNumDimension(int num_dimension) { if (num_dimension < 4 || num_dimension & (num_dimension - 1)) return false; --- 45,55 ---- #include "fast_fourier_transform.h" ! #include <algorithm> // std::copy, std::fill ! #include <cmath> // std::sin ! #include <cstring> // std::size_t namespace sptk { ! bool FastFourierTransform::SetNumDimension(const int num_dimension) { if (num_dimension < 4 || num_dimension & (num_dimension - 1)) return false; --- NEW FILE: acorr.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 "autocorrelation.h" #include "sptk_utils.h" namespace { const int kDefaultFrameLength(256); const int kDefaultNumOrder(25); void PrintUsage() { std::cout << std::endl; std::cout << " acorr - obtain autocorrelation sequence" << std::endl; std::cout << std::endl; std::cout << " usage:" << std::endl; std::cout << " acorr [ options ] [ infile ] > stdout" << std::endl; std::cout << " options:" << std::endl; std::cout << " -l l : frame length [" << kDefaultFrameLength << "]" << std::endl; // NOLINT std::cout << " -m m : order of sequence [" << kDefaultNumOrder << "]" << std::endl; // NOLINT std::cout << " -h : print this message" << std::endl; std::cout << " infile:" << std::endl; std::cout << " data sequence (double) [stdin]" << std::endl; std::cout << " stdout:" << std::endl; std::cout << " autocorrelation sequence (double)" << std::endl; std::cout << std::endl; std::cout << " SPTK: version " << sptk::kVersion << std::endl; std::cout << std::endl; } } // namespace int main(int argc, char* argv[]) { int frame_length(kDefaultFrameLength); int num_order(kDefaultNumOrder); while (true) { const char option_char(getopt(argc, argv, "l:m:h")); if (-1 == option_char) break; switch (option_char) { case 'l': { if (!sptk::ConvertStringToInteger(optarg, &frame_length) || 0 >= frame_length) { std::ostringstream error_message; error_message << "The argument for the -l option must be positive integer"; sptk::PrintErrorMessage("acorr", error_message); return 1; } break; } case 'm': { if (!sptk::ConvertStringToInteger(optarg, &num_order) || 0 > num_order) { std::ostringstream error_message; error_message << "The argument for the -m option must be positive integer or 0"; sptk::PrintErrorMessage("acorr", error_message); return 1; } break; } case 'h': { PrintUsage(); return 0; } default: { PrintUsage(); 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("acorr", error_message); return 1; } std::istream& input_stream(ifs.fail() ? std::cin : ifs); sptk::Autocorrelation autocorrelation; if (!autocorrelation.SetNumOrder(num_order)) { std::ostringstream error_message; error_message << "Invalid number of orders " << num_order; sptk::PrintErrorMessage("acorr", error_message); return 1; } const int output_length(num_order + 1); std::vector<double> input_sequence(frame_length); std::vector<double> output_sequence(output_length); while (true) { if (!sptk::ReadStream(false, frame_length, &input_sequence, &input_stream)) break; if (!autocorrelation.Run(input_sequence, &output_sequence)) { std::ostringstream error_message; error_message << "Failed to obtatin autocorrelation sequence"; sptk::PrintErrorMessage("acorr", error_message); return 1; } if (!sptk::WriteStream(output_length, output_sequence, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write autocorrelation sequence"; sptk::PrintErrorMessage("acorr", error_message); return 1; } } return 0; } --- NEW FILE: autocorrelation.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 "autocorrelation.h" #include <algorithm> // std::fill_n #include <cstring> // std::size_t namespace sptk { bool Autocorrelation::Run(const std::vector<double>& input_sequence, std::vector<double>* output_sequence) const { // check inputs if (input_sequence.empty() || NULL == output_sequence) return false; // prepare memories const int output_length(num_order_ + 1); if (static_cast<std::size_t>(output_length) > output_sequence->size()) output_sequence->resize(output_length); // get values const int input_length(input_sequence.size()); const double* input(&(input_sequence[0])); double* output(&((*output_sequence)[0])); // fill zero std::fill_n(output, output_length, 0.0); // calculate for (int i(0); i < output_length; ++i) for (int j(0); j <= input_length - i; ++j) output[i] += input[j] * input[i + j]; return true; } } // namespace sptk --- NEW FILE: autocorrelation.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_AUTOCORRELATION_H_ #define SPTK_SRC_AUTOCORRELATION_H_ #include <vector> // std::vector #include "sptk_utils.h" namespace sptk { class Autocorrelation { public: // Autocorrelation() : num_order_(0) {} // virtual ~Autocorrelation() {} // bool SetNumOrder(int num_order) { if (0 > num_order) return false; num_order_ = num_order; return true; } // int GetNumOrder() const { return num_order_; } // bool Run(const std::vector<double>& input_sequence, std::vector<double>* output_sequence) const; private: // int num_order_; // DISALLOW_COPY_AND_ASSIGN(Autocorrelation); }; } // namespace sptk #endif // SPTK_SRC_AUTOCORRELATION_H_ Index: sptk_utils.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/sptk_utils.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sptk_utils.h 14 Dec 2015 11:56:42 -0000 1.4 --- sptk_utils.h 8 Feb 2016 11:42:45 -0000 1.5 *************** *** 9,13 **** // Science and Engineering // // // ! // 1996-2015 Nagoya Institute of Technology // // Department of Computer Science // // // --- 9,13 ---- // Science and Engineering // // // ! // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // *************** *** 46,53 **** #define SPTK_SRC_SPTK_UTILS_H_ ! #include <iostream> ! #include <sstream> ! #include <string> ! #include <vector> namespace sptk { --- 46,59 ---- #define SPTK_SRC_SPTK_UTILS_H_ ! #include <iostream> // std::istream, std::ostream ! #include <sstream> // std::ostringstream ! #include <string> // std::string ! #include <vector> // std::vector ! ! #ifndef DISALLOW_COPY_AND_ASSIGN ! #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ ! TypeName(const TypeName&); \ ! void operator=(const TypeName&) ! #endif namespace sptk { |