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-12-22 06:17:10
|
Update of /cvsroot/sp-tk/SPTK/src/bin/pitch_mark In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv10175 Added Files: .cvsignore Makefile.am pitch_mark.c Log Message: add pitch mark command --- NEW FILE: .cvsignore --- Makefile pitch_mark Makefile.in .deps --- NEW FILE: Makefile.am --- AM_CPPFLAGS = -I @top_srcdir@/include bin_PROGRAMS = pitch_mark pitch_mark_SOURCES = pitch_mark.c reaper/epoch_tracker_main.cc reaper/core/file_resource.cc \ reaper/core/file_resource.h reaper/core/float_matrix.cc \ reaper/core/float_matrix.h reaper/core/float_matrix-inl.h \ reaper/core/track.cc reaper/core/track.h \ reaper/epoch_tracker/epoch_tracker.cc reaper/epoch_tracker/epoch_tracker.h \ reaper/epoch_tracker/fd_filter.cc reaper/epoch_tracker/fd_filter.h \ reaper/epoch_tracker/fft.cc reaper/epoch_tracker/fft.h \ reaper/epoch_tracker/lpc_analyzer.cc reaper/epoch_tracker/lpc_analyzer.h \ reaper/wave/codec_api.h reaper/wave/codec_api-inl.h \ reaper/wave/codec_riff.cc reaper/wave/codec_riff.h \ reaper/wave/wave.cc reaper/wave/wave.h reaper/wave/wave_io.cc \ reaper/wave/wave_io.h reaper/wave/wave_io-inl.h pitch_mark_LDADD = @top_builddir@/lib/libSPTK.a --- NEW FILE: pitch_mark.c --- /* ----------------------------------------------------------------- */ /* 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-2015 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. */ /* ----------------------------------------------------------------- */ /************************************************************************ * * * Pitch Mark Extraction * * * * * * usage: * * pitch_mark [ options ] [ infile ] > stdout * * options: * * -s s : sampling frequency (Hz) [16] * * -t t : voiced/unvoiced threshold [0.9] * * value of t should be -0.5 < t < 1.6 * * -L L : minimum fundamental frequency [60] * * to search for (Hz) * * -H H : maximum fundamental frequency [240] * * to search for (Hz) * * -o o : output format [0] * * 0 pulse sequence: if a current sample is * * a pitch mark, 1 or -1 is outputted * * considering polarity, otherwise 0 is * * outputted. * * 1 second when a pitch mark appears * * 2 sample number when a pitch mark * * appears * * infile: * * data sequence * * x(0), x(1), ..., x(n-1), ... * * stdout: * * pitch mark * * * ************************************************************************/ static char *rcs_id = "$Id: pitch_mark.c,v 1.1 2016/12/22 06:17:08 fjst15124 Exp $"; /* Standard C Libraries */ #include <stdio.h> #include <stdlib.h> #include <math.h> #ifdef HAVE_STRING_H #include <string.h> #else #include <strings.h> #ifndef HAVE_STRRCHR #define strrchr rindex #endif #endif #if defined(WIN32) # include "SPTK.h" #else # include <SPTK.h> #endif /* Default Values */ #define LOW 60.0 #define HIGH 240.0 #define SAMPLE_FREQ 16.0 #define OTYPE 0 #define THRESHOLD 0.9 /* Command Name */ char *cmnd; typedef struct _float_list { float f; struct _float_list *next; } float_list; void usage(int status) { fprintf(stderr, "\n"); fprintf(stderr, " %s - pitch mark extraction\n", cmnd); fprintf(stderr, "\n"); fprintf(stderr, " usage:\n"); fprintf(stderr, " %s [ options ] [ infile ] > stdout\n", cmnd); fprintf(stderr, " options:\n"); fprintf(stderr, " -s s : sampling frequency (kHz) [%.1f]\n", SAMPLE_FREQ); fprintf(stderr, " -t t : voiced/unvoiced threshold [%.1f]\n", THRESHOLD); fprintf(stderr, " value of t should be -0.5 < t < 1.6\n"); fprintf(stderr, " -L L : minimum fundamental [%g]\n", LOW); fprintf(stderr, " frequency to search for (Hz)\n"); fprintf(stderr, " -H H : maximum fundamental [%g]\n", HIGH); fprintf(stderr, " frequency to search for (Hz)\n"); fprintf(stderr, " -o o : output format [%d]\n", OTYPE); fprintf(stderr, " 0 pulse sequence: if a current sample is a pitch mark,\n"); fprintf(stderr, " 1 or -1 is outputted considering polarity,\n"); fprintf(stderr, " otherwise 0 is outputted.\n"); fprintf(stderr, " 1 second when a pitch mark appears\n"); fprintf(stderr, " 2 sample number when a pitch mark appears\n"); fprintf(stderr, " -h : print this message\n"); fprintf(stderr, " infile:\n"); fprintf(stderr, " waveform (%s) \n", FORMAT); fprintf(stderr, " stdout:\n"); fprintf(stderr, " pitch mark (%s)\n", FORMAT); fprintf(stderr, " notice:\n"); fprintf(stderr, " Regarding -t option, when the threshold is raised,\n"); fprintf(stderr, " the number of pitch marks increases.\n"); #ifdef PACKAGE_VERSION fprintf(stderr, "\n"); fprintf(stderr, " SPTK: version %s\n", PACKAGE_VERSION); fprintf(stderr, " CVS Info: %s", rcs_id); #endif fprintf(stderr, "\n"); exit(status); } int main(int argc, char **argv) { int length, otype = OTYPE; double *x, threshold = THRESHOLD, sample_freq = SAMPLE_FREQ, L = LOW, H = HIGH; FILE *fp = stdin; float_list *top, *cur, *prev; void pitch_mark(float_list * input, int length, double sample_freq, double min, double max, double threshold, int otype); if ((cmnd = strrchr(argv[0], '/')) == NULL) cmnd = argv[0]; else cmnd++; while (--argc) if (**++argv == '-') { switch (*(*argv + 1)) { case 's': sample_freq = atof(*++argv); --argc; break; case 't': threshold = atof(*++argv); --argc; break; case 'L': L = atof(*++argv); --argc; break; case 'H': H = atof(*++argv); --argc; break; case 'o': otype = atoi(*++argv); --argc; break; case 'h': usage(0); default: fprintf(stderr, "%s : Invalid option '%c'!\n", cmnd, *(*argv + 1)); usage(1); } } else { fp = getfp(*argv, "rb"); } sample_freq *= 1000.0; x = dgetmem(1); top = prev = (float_list *) malloc(sizeof(float_list)); length = 0; prev->next = NULL; while (freadf(x, sizeof(*x), 1, fp) == 1) { cur = (float_list *) malloc(sizeof(float_list)); cur->f = (float) x[0]; length++; prev->next = cur; cur->next = NULL; prev = cur; } pitch_mark(top->next, length, sample_freq, L, H, threshold, otype); return (0); } |
From: fujishita t. <fjs...@us...> - 2016-12-22 05:54:11
|
Update of /cvsroot/sp-tk/SPTK/src/bin/pitch_mark/reaper/wave In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv8921/wave Log Message: Directory /cvsroot/sp-tk/SPTK/src/bin/pitch_mark/reaper/wave added to the repository |
From: fujishita t. <fjs...@us...> - 2016-12-22 05:54:10
|
Update of /cvsroot/sp-tk/SPTK/src/bin/pitch_mark/reaper/core In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv8921/core Log Message: Directory /cvsroot/sp-tk/SPTK/src/bin/pitch_mark/reaper/core added to the repository |
From: fujishita t. <fjs...@us...> - 2016-12-22 05:53:30
|
Update of /cvsroot/sp-tk/SPTK/src/bin/pitch_mark/reaper In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv8907/reaper Log Message: Directory /cvsroot/sp-tk/SPTK/src/bin/pitch_mark/reaper added to the repository |
From: fujishita t. <fjs...@us...> - 2016-12-22 05:37:11
|
Update of /cvsroot/sp-tk/SPTK/src/bin/pitch_mark In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7825/pitch_mark Log Message: Directory /cvsroot/sp-tk/SPTK/src/bin/pitch_mark added to the repository |
From: fujishita t. <fjs...@us...> - 2016-12-22 05:33:00
|
Update of /cvsroot/sp-tk/SPTK/doc/ref_e In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7628 Modified Files: Makefile.in excite.tex main.tex pitch.tex Added Files: pitch_mark.tex Log Message: add pitch mark reference Index: Makefile.in =================================================================== RCS file: /cvsroot/sp-tk/SPTK/doc/ref_e/Makefile.in,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** Makefile.in 18 Dec 2015 07:53:24 -0000 1.31 --- Makefile.in 22 Dec 2016 05:32:57 -0000 1.32 *************** *** 144,147 **** --- 144,148 ---- phase.tex \ pitch.tex \ + pitch_mark.tex \ poledf.tex \ psgr.tex \ Index: excite.tex =================================================================== RCS file: /cvsroot/sp-tk/SPTK/doc/ref_e/excite.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** excite.tex 18 Dec 2015 07:53:25 -0000 1.19 --- excite.tex 22 Dec 2016 05:32:57 -0000 1.20 *************** *** 85,88 **** --- 85,90 ---- \begin{qsection}{SEE ALSO} + \hyperlink{pitch}{pitch}, + \hyperlink{pitch\_mark}{pitch\_mark}, \hyperlink{poledf}{poledf} \end{qsection} Index: pitch.tex =================================================================== RCS file: /cvsroot/sp-tk/SPTK/doc/ref_e/pitch.tex,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** pitch.tex 23 Sep 2016 05:45:42 -0000 1.31 --- pitch.tex 22 Dec 2016 05:32:58 -0000 1.32 *************** *** 108,111 **** \begin{qsection}{SEE ALSO} ! \hyperlink{excite}{excite} \end{qsection} --- 108,112 ---- \begin{qsection}{SEE ALSO} ! \hyperlink{excite}{excite}, ! \hyperlink{pitch\_mark}{pitch\_mark} \end{qsection} --- NEW FILE: pitch_mark.tex --- % ----------------------------------------------------------------- % % 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-2015 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. % % ----------------------------------------------------------------- % \hypertarget{pitch_mark}{} \name{pitch\_mark}{pitch mark extraction}{signal processing,speech analysis and synthesis} \begin{synopsis} \item[pitch\_mark] [ --s $S$ ] [ --t $T$ ] [ --L $Lo$ ] [ --H $Hi$ ] [ --o $O$ ][ {\em infile} ] \end{synopsis} \begin{qsection}{DESCRIPTION} {\em pitch\_mark} extracts the pitch mark from {\em infile} (or standard input), sending the result to standard output. The REAPER \cite{ref:pitch-REAPER} algorithm is adopted for pitch mark extraction. The output format (pulse sequence, second when a pitch mark appears or sample number when a pitch mark appears) can be specified by --o option. Both input and output files are in float format. \end{qsection} \begin{options} \argm{s}{S}{sampling frequency (kHz)}{16.0} \argm{t}{T}{voiced/unvoiced threshold \\ value of $t$ should be $-0.5 < t < 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} \argm{o}{O}{output format\\ \begin{tabular}{ll} \\[-1ex] $O=0$ & ~~~pulse sequence: if a current sample is a pitch mark,\\ & ~~~1 or -1 is outputted considering polarity,\\ & ~~~otherwise 0 is outputted.\\ $O=1$ & ~~~second when a pitch mark appears\\ $O=2$ & ~~~sample number when a pitch mark appears\\ \end{tabular}\\\hspace*{\fill}}{0} \end{options} \begin{qsection}{EXAMPLE} In the example below, speech data in float format is read from {\em data.f} and the pitch mark data is extracted under the condition that sampling frequency is 16kHz and the minimum and maximum fundamental frequency are 80 and 165 Hz, respectively. Then, the output is written to {\em data.pitch\_mark}: \begin{quote} \verb!pitch_mark -s 16 -L 80 -H 165 data.f > data.pitch_mark! \end{quote} \end{qsection} \begin{qsection}{NOTICE} Regarding -t option, when the threshold is raised, the number of pitch marks increases. \end{qsection} \begin{qsection}{SEE ALSO} \hyperlink{excite}{excite}, \hyperlink{pitch}{pitch} \end{qsection} Index: main.tex =================================================================== RCS file: /cvsroot/sp-tk/SPTK/doc/ref_e/main.tex,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** main.tex 18 Dec 2015 07:53:26 -0000 1.53 --- main.tex 22 Dec 2016 05:32:57 -0000 1.54 *************** *** 266,269 **** --- 266,270 ---- \include{phase} \include{pitch} + \include{pitch_mark} \include{poledf} \include{psgr} |
From: Takenori Y. <tak...@us...> - 2016-12-20 08:23:44
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv23561 Modified Files: Makefile input_source_from_array.h input_source_from_vector.h Added Files: input_source_from_matrix.cc input_source_from_matrix.h Log Message: add InputSourceFromMatrix class --- NEW FILE: input_source_from_matrix.cc --- // ----------------------------------------------------------------- // // The Speech Signal Processing Toolkit (SPTK) // // developed by SPTK Working Group // // http://sp-tk.sourceforge.net/ // // ----------------------------------------------------------------- // // // // Copyright (c) 1984-2007 Tokyo Institute of Technology // // Interdisciplinary Graduate School of // // Science and Engineering // // // // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // // All rights reserved. // // // // Redistribution and use in source and binary forms, with or // // without modification, are permitted provided that the following // // conditions are met: // // // // - Redistributions of source code must retain the above copyright // // notice, this list of conditions and the following disclaimer. // // - Redistributions in binary form must reproduce the above // // copyright notice, this list of conditions and the following // // disclaimer in the documentation and/or other materials provided // // with the distribution. // // - Neither the name of the SPTK working group nor the names of its // // contributors may be used to endorse or promote products derived // // from this software without specific prior written permission. // // // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND // // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, // // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS // // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON // // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // // POSSIBILITY OF SUCH DAMAGE. // // ----------------------------------------------------------------- // #include "input_source_from_matrix.h" #include <algorithm> // std::copy #include <cstddef> // std::size_t namespace sptk { bool InputSourceFromMatrix::Get(std::vector<double>* buffer) { if (NULL == buffer || !is_valid_ || col_size_ <= col_position_) { return false; } if (buffer->size() < static_cast<std::size_t>(row_size_)) { buffer->resize(row_size_); } std::copy(&(input_matrix_[col_position_][0]), &(input_matrix_[col_position_][row_size_]), buffer->begin()); ++col_position_; return true; } } // namespace sptk --- NEW FILE: input_source_from_matrix.h --- // ----------------------------------------------------------------- // // The Speech Signal Processing Toolkit (SPTK) // // developed by SPTK Working Group // // http://sp-tk.sourceforge.net/ // // ----------------------------------------------------------------- // // // // Copyright (c) 1984-2007 Tokyo Institute of Technology // // Interdisciplinary Graduate School of // // Science and Engineering // // // // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // // All rights reserved. // // // // Redistribution and use in source and binary forms, with or // // without modification, are permitted provided that the following // // conditions are met: // // // // - Redistributions of source code must retain the above copyright // // notice, this list of conditions and the following disclaimer. // // - Redistributions in binary form must reproduce the above // // copyright notice, this list of conditions and the following // // disclaimer in the documentation and/or other materials provided // // with the distribution. // // - Neither the name of the SPTK working group nor the names of its // // contributors may be used to endorse or promote products derived // // from this software without specific prior written permission. // // // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND // // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, // // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS // // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON // // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // // POSSIBILITY OF SUCH DAMAGE. // // ----------------------------------------------------------------- // #ifndef SPTK_SRC_INPUT_SOURCE_FROM_MATRIX_H_ #define SPTK_SRC_INPUT_SOURCE_FROM_MATRIX_H_ #include <vector> // std::vector #include "input_source_interface.h" #include "sptk_utils.h" namespace sptk { class InputSourceFromMatrix : public InputSourceInterface { public: // InputSourceFromMatrix(int row_size, int col_size, double** input_matrix) : row_size_(row_size), col_size_(col_size), input_matrix_(input_matrix), col_position_(0), is_valid_(true) { if (row_size <= 0 || col_size <= 0 || NULL == input_matrix) { is_valid_ = false; } } // virtual ~InputSourceFromMatrix() { } // virtual int GetSize() const { return row_size_; } // int GetRowSize() const { return row_size_; } // int GetColSize() const { return col_size_; } // virtual bool IsValid() const { return is_valid_; } // virtual bool Get(std::vector<double>* buffer); private: // const int row_size_; // const int col_size_; // double** input_matrix_; // int col_position_; // bool is_valid_; // DISALLOW_COPY_AND_ASSIGN(InputSourceFromMatrix); }; } // namespace sptk #endif // SPTK_SRC_INPUT_SOURCE_FROM_MATRIX_H_ Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Makefile 30 Nov 2016 04:23:27 -0000 1.20 --- Makefile 20 Dec 2016 08:23:42 -0000 1.21 *************** *** 57,60 **** --- 57,61 ---- generalized_cepstrum_transform.cc \ input_source_from_array.cc \ + input_source_from_matrix.cc \ input_source_from_stream.cc \ input_source_from_vector.cc \ Index: input_source_from_array.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_from_array.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** input_source_from_array.h 30 Nov 2016 04:23:28 -0000 1.1 --- input_source_from_array.h 20 Dec 2016 08:23:42 -0000 1.2 *************** *** 46,50 **** #define SPTK_SRC_INPUT_SOURCE_FROM_ARRAY_H_ - #include <istream> // std::istream #include <vector> // std::vector --- 46,49 ---- Index: input_source_from_vector.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_from_vector.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** input_source_from_vector.h 30 Nov 2016 04:23:28 -0000 1.1 --- input_source_from_vector.h 20 Dec 2016 08:23:42 -0000 1.2 *************** *** 46,50 **** #define SPTK_SRC_INPUT_SOURCE_FROM_VECTOR_H_ - #include <istream> // std::istream #include <vector> // std::vector --- 46,49 ---- |
From: Keiichiro O. <ur...@us...> - 2016-12-16 09:36:57
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv22200 Modified Files: gnorm.cc ignorm.cc Log Message: fix typos Index: gnorm.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/gnorm.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gnorm.cc 12 Oct 2016 13:08:14 -0000 1.1 --- gnorm.cc 16 Dec 2016 09:36:55 -0000 1.2 *************** *** 66,70 **** *stream << " options:" << std::endl; *stream << " -m m : order of generalized cepstrum [" << kDefaultNumOrder << "]" << std::endl; // NOLINT ! *stream << " -a g : gamma [" << kDefaultGamma << "]" << std::endl; // NOLINT *stream << " -c c : gamma = -1 / (int) c" << std::endl; *stream << " -h : print this message" << std::endl; --- 66,70 ---- *stream << " options:" << std::endl; *stream << " -m m : order of generalized cepstrum [" << kDefaultNumOrder << "]" << std::endl; // NOLINT ! *stream << " -g g : gamma [" << kDefaultGamma << "]" << std::endl; // NOLINT *stream << " -c c : gamma = -1 / (int) c" << std::endl; *stream << " -h : print this message" << std::endl; Index: ignorm.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/ignorm.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ignorm.cc 12 Oct 2016 13:39:47 -0000 1.1 --- ignorm.cc 16 Dec 2016 09:36:55 -0000 1.2 *************** *** 66,70 **** *stream << " options:" << std::endl; *stream << " -m m : order of generalized cepstrum [" << kDefaultNumOrder << "]" << std::endl; // NOLINT ! *stream << " -a g : gamma [" << kDefaultGamma << "]" << std::endl; // NOLINT *stream << " -c c : gamma = -1 / (int) c" << std::endl; *stream << " -h : print this message" << std::endl; --- 66,70 ---- *stream << " options:" << std::endl; *stream << " -m m : order of generalized cepstrum [" << kDefaultNumOrder << "]" << std::endl; // NOLINT ! *stream << " -g g : gamma [" << kDefaultGamma << "]" << std::endl; // NOLINT *stream << " -c c : gamma = -1 / (int) c" << std::endl; *stream << " -h : print this message" << std::endl; |
From: Keiichiro O. <ur...@us...> - 2016-12-16 09:36:34
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv22172 Modified Files: generalized_cepstrum_transform.cc generalized_cepstrum_transform.h Added Files: mgc2mgc.cc Log Message: add/optimize mgc2mgc --- NEW FILE: mgc2mgc.cc --- // ----------------------------------------------------------------- // // The Speech Signal Processing Toolkit (SPTK) // // developed by SPTK Working Group // // http://sp-tk.sourceforge.net/ // // ----------------------------------------------------------------- // // // // Copyright (c) 1984-2007 Tokyo Institute of Technology // // Interdisciplinary Graduate School of // // Science and Engineering // // // // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // // All rights reserved. // // // // Redistribution and use in source and binary forms, with or // // without modification, are permitted provided that the following // // conditions are met: // // // // - Redistributions of source code must retain the above copyright // // notice, this list of conditions and the following disclaimer. // // - Redistributions in binary form must reproduce the above // // copyright notice, this list of conditions and the following // // disclaimer in the documentation and/or other materials provided // // with the distribution. // // - Neither the name of the SPTK working group nor the names of its // // contributors may be used to endorse or promote products derived // // from this software without specific prior written permission. // // // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND // // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, // // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS // // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON // // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // // POSSIBILITY OF SUCH DAMAGE. // // ----------------------------------------------------------------- // #include <unistd.h> #include <fstream> #include <iostream> #include <sstream> #include <vector> #include "generalized_cepstrum_transform.h" #include "sptk_utils.h" namespace { const int kDefaultInputNumOrder(25); const double kDefaultInputAlpha(0.0); const double kDefaultInputGamma(0.0); const bool kDefaultInputNormalizationFlag(false); const bool kDefaultInputMultiplicationFlag(false); const int kDefaultOutputNumOrder(25); const double kDefaultOutputAlpha(0.0); const double kDefaultOutputGamma(1.0); const bool kDefaultOutputNormalizationFlag(false); const bool kDefaultOutputMultiplicationFlag(false); void PrintUsage(std::ostream* stream) { // clang-format off *stream << std::endl; *stream << " mgc2mgc - frequency and generalized cepstral transformation" << std::endl; // NOLINT *stream << std::endl; *stream << " usage:" << std::endl; *stream << " mgc2mgc [ options ] [ infile ] > stdout" << std::endl; *stream << " options:" << std::endl; *stream << " -m m : order of mel-generalized cepstrum (input) [" << kDefaultInputNumOrder << "]" << std::endl; // NOLINT *stream << " -a a : alpha of mel-generalized cepstrum (input) [" << kDefaultInputAlpha << "]" << std::endl; // NOLINT *stream << " -g g : gamma of mel-generalized cepstrum (input) [" << kDefaultInputGamma << "]" << std::endl; // NOLINT *stream << " -c c : gamma of mel-generalized cepstrum = -1 / (int) c (input)" << std::endl; // NOLINT *stream << " -n : regard input as normalized mel-generalized cepstrum [" << sptk::ConvertBooleanToString(kDefaultInputNormalizationFlag) << "]" << std::endl; // NOLINT *stream << " -u : regard input as multiplied by gamma [" << sptk::ConvertBooleanToString(kDefaultInputMultiplicationFlag) << "]" << std::endl; // NOLINT *stream << " -M M : order of mel-generalized cepstrum (input) [" << kDefaultOutputNumOrder << "]" << std::endl; // NOLINT *stream << " -A A : alpha of mel-generalized cepstrum (input) [" << kDefaultOutputAlpha << "]" << std::endl; // NOLINT *stream << " -G G : gamma of mel-generalized cepstrum (input) [" << kDefaultOutputGamma << "]" << std::endl; // NOLINT *stream << " -C C : gamma of mel-generalized cepstrum = -1 / (int) C (input)" << std::endl; // NOLINT *stream << " -N : regard input as normalized mel-generalized cepstrum [" << sptk::ConvertBooleanToString(kDefaultOutputNormalizationFlag) << "]" << std::endl; // NOLINT *stream << " -U : regard input as multiplied by gamma [" << sptk::ConvertBooleanToString(kDefaultOutputMultiplicationFlag) << "]" << std::endl; // NOLINT *stream << " -h : print this message" << std::endl; *stream << " infile:" << std::endl; *stream << " mel-generalized cepstrum (double) [stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; *stream << " transformed mel-generalized cepstrum (double)" << std::endl; // NOLINT *stream << " notice:" << std::endl; *stream << " value of c must be c >= 1 (double)" << std::endl; *stream << " if -u is used without -n, input is regarded as 1+g/c[0],g*c[1],...,g*c[m]" << std::endl; // NOLINT *stream << " if -U is used without -N, ouputput is regarded as 1+g/c[0],g*c[1],...,g*c[m]" << std::endl; // NOLINT *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; *stream << std::endl; // clang-format on } } // namespace int main(int argc, char* argv[]) { int input_num_order(kDefaultInputNumOrder); double input_alpha(kDefaultInputAlpha); double input_gamma(kDefaultInputGamma); bool input_normalization_flag(kDefaultInputNormalizationFlag); bool input_multiplication_flag(kDefaultInputMultiplicationFlag); int output_num_order(kDefaultOutputNumOrder); double output_alpha(kDefaultOutputAlpha); double output_gamma(kDefaultOutputGamma); bool output_normalization_flag(kDefaultOutputNormalizationFlag); bool output_multiplication_flag(kDefaultOutputMultiplicationFlag); for (;;) { const char option_char(getopt(argc, argv, "m:a:g:c:nuM:A:G:C:NUh")); if (-1 == option_char) break; switch (option_char) { case 'm': { if (!sptk::ConvertStringToInteger(optarg, &input_num_order) || input_num_order < 0) { std::ostringstream error_message; error_message << "The argument for the -m option must be a " << "non-negative integer"; sptk::PrintErrorMessage("mgc2mgc", error_message); return 1; } break; } case 'a': { if (!sptk::ConvertStringToDouble(optarg, &input_alpha)) { std::ostringstream error_message; error_message << "The argument for the -a option must be numeric"; sptk::PrintErrorMessage("mgc2mgc", error_message); return 1; } break; } case 'g': { if (!sptk::ConvertStringToDouble(optarg, &input_gamma)) { std::ostringstream error_message; error_message << "The argument for the -g option must be numeric"; sptk::PrintErrorMessage("mgc2mgc", error_message); return 1; } break; } case 'c': { int tmp; if (!sptk::ConvertStringToInteger(optarg, &tmp) || tmp < 1) { std::ostringstream error_message; error_message << "The argument for the -c option must be a " << "positive integer"; sptk::PrintErrorMessage("mgc2mgc", error_message); return 1; } input_gamma = -1.0 / tmp; break; } case 'n': { input_normalization_flag = true; break; } case 'u': { input_multiplication_flag = true; break; } case 'M': { if (!sptk::ConvertStringToInteger(optarg, &output_num_order) || output_num_order < 0) { std::ostringstream error_message; error_message << "The argument for the -M option must be a " << "non-negative integer"; sptk::PrintErrorMessage("mgc2mgc", error_message); return 1; } break; } case 'A': { if (!sptk::ConvertStringToDouble(optarg, &output_alpha)) { std::ostringstream error_message; error_message << "The argument for the -A option must be numeric"; sptk::PrintErrorMessage("mgc2mgc", error_message); return 1; } break; } case 'G': { if (!sptk::ConvertStringToDouble(optarg, &output_gamma)) { std::ostringstream error_message; error_message << "The argument for the -G option must be numeric"; sptk::PrintErrorMessage("mgc2mgc", error_message); return 1; } break; } case 'C': { int tmp; if (!sptk::ConvertStringToInteger(optarg, &tmp) || tmp < 1) { std::ostringstream error_message; error_message << "The argument for the -C option must be a " << "positive integer"; sptk::PrintErrorMessage("mgc2mgc", error_message); return 1; } output_gamma = -1.0 / tmp; break; } case 'N': { output_normalization_flag = true; break; } case 'U': { output_multiplication_flag = true; 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("mgc2mgc", error_message); return 1; } std::istream& input_stream(ifs.fail() ? std::cin : ifs); // prepare for gain normalization sptk::GeneralizedCepstrumTransform generalized_cepstrum_transform( input_num_order, input_alpha, input_gamma, input_normalization_flag, input_multiplication_flag, output_num_order, output_alpha, output_gamma, output_normalization_flag, output_multiplication_flag); sptk::GeneralizedCepstrumTransform::Buffer buffer; if (!generalized_cepstrum_transform.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the condition."; sptk::PrintErrorMessage("mgc2mgc", error_message); return 1; } const int input_length(input_num_order + 1); const int output_length(output_num_order + 1); std::vector<double> generalized_cepstrum(input_length); std::vector<double> transformed_generalized_cepstrum(output_length); while (sptk::ReadStream(false, input_length, &generalized_cepstrum, &input_stream)) { // input modification: 1*g/c[0] -> c[0] if (!input_normalization_flag && input_multiplication_flag) (*generalized_cepstrum.begin()) = (*(generalized_cepstrum.begin()) - 1.0) / input_gamma; // transform if (!generalized_cepstrum_transform.Run( generalized_cepstrum, &transformed_generalized_cepstrum, &buffer)) { std::ostringstream error_message; error_message << "Failed to run the transform"; sptk::PrintErrorMessage("mgc2mgc", error_message); return 1; } // output modification: c[0] -> 1+g*c[0] if (!output_normalization_flag && output_multiplication_flag) (*transformed_generalized_cepstrum.begin()) = *(transformed_generalized_cepstrum.begin()) * output_gamma + 1.0; // write results if (!sptk::WriteStream(output_length, transformed_generalized_cepstrum, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write an output sequence"; sptk::PrintErrorMessage("mgc2mgc", error_message); return 1; } } return 0; } Index: generalized_cepstrum_transform.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/generalized_cepstrum_transform.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** generalized_cepstrum_transform.cc 24 Oct 2016 08:20:30 -0000 1.3 --- generalized_cepstrum_transform.cc 16 Dec 2016 09:36:31 -0000 1.4 *************** *** 53,56 **** --- 53,244 ---- #include "generalized_cepstrum_inverse_gain_normalization.h" + namespace { + + class GainNormalizationModule + : public sptk::GeneralizedCepstrumTransform::ModuleInterface { + public: + GainNormalizationModule(int num_order, double gamma) + : generalized_cepstrum_gain_normalization_(num_order, gamma) { + } + virtual bool IsValid() const { + return generalized_cepstrum_gain_normalization_.IsValid(); + } + virtual bool Run( + const std::vector<double> &input, std::vector<double> *output, + sptk::FrequencyTransform::Buffer *frequency_transform_buffer) const { + if (!generalized_cepstrum_gain_normalization_.Run(input, output)) { + return false; + } + output->resize(generalized_cepstrum_gain_normalization_.GetNumOrder() + 1); + return true; + } + + private: + const sptk::GeneralizedCepstrumGainNormalization + generalized_cepstrum_gain_normalization_; + DISALLOW_COPY_AND_ASSIGN(GainNormalizationModule); + }; + + class InverseGainNormalizationModule + : public sptk::GeneralizedCepstrumTransform::ModuleInterface { + public: + InverseGainNormalizationModule(int num_order, double gamma) + : generalized_cepstrum_inverse_gain_normalization_(num_order, gamma) { + } + virtual bool IsValid() const { + return generalized_cepstrum_inverse_gain_normalization_.IsValid(); + } + virtual bool Run( + const std::vector<double> &input, std::vector<double> *output, + sptk::FrequencyTransform::Buffer *frequency_transform_buffer) const { + if (!generalized_cepstrum_inverse_gain_normalization_.Run(input, output)) { + return false; + } + output->resize( + generalized_cepstrum_inverse_gain_normalization_.GetNumOrder() + 1); + return true; + } + + private: + const sptk::GeneralizedCepstrumInverseGainNormalization + generalized_cepstrum_inverse_gain_normalization_; + DISALLOW_COPY_AND_ASSIGN(InverseGainNormalizationModule); + }; + + class FrequencyTransformModule + : public sptk::GeneralizedCepstrumTransform::ModuleInterface { + public: + FrequencyTransformModule(int num_input_order, int num_output_order, + double alpha_transform) + : frequency_transform_(num_input_order, num_output_order, + alpha_transform) { + } + virtual bool IsValid() const { + return frequency_transform_.IsValid(); + } + virtual bool Run( + const std::vector<double> &input, std::vector<double> *output, + sptk::FrequencyTransform::Buffer *frequency_transform_buffer) const { + if (!frequency_transform_.Run(input, output, frequency_transform_buffer)) { + return false; + } + output->resize(frequency_transform_.GetNumOutputOrder() + 1); + return true; + } + + private: + const sptk::FrequencyTransform frequency_transform_; + DISALLOW_COPY_AND_ASSIGN(FrequencyTransformModule); + }; + + class GeneralizedCepstrumTransformModule + : public sptk::GeneralizedCepstrumTransform::ModuleInterface { + public: + GeneralizedCepstrumTransformModule(int num_input_order, int num_output_order, + double input_gamma, double output_gamma) + : num_input_order_(num_input_order), + num_output_order_(num_output_order), + input_gamma_(input_gamma), + output_gamma_(output_gamma) { + } + virtual bool IsValid() const { + return true; + } + virtual bool Run( + const std::vector<double> &input, std::vector<double> *output, + sptk::FrequencyTransform::Buffer *frequency_transform_buffer) const { + if (output->size() != static_cast<std::size_t>(num_output_order_ + 1)) { + output->resize(num_output_order_ + 1); + } + const double *c1(&(input)[0]); + double *c2(&((*output)[0])); + + c2[0] = c1[0]; + for (int i(1); i <= num_output_order_; ++i) { + double ss1(0.0), ss2(0.0); + const int min(num_input_order_ < i ? num_input_order_ : i - 1); + for (int k(1); k <= min; ++k) { + const int mk(i - k); + const double cc(c1[k] * c2[mk]); + ss2 += k * cc; + ss1 += mk * cc; + } + + if (i <= num_input_order_) + c2[i] = c1[i] + (output_gamma_ * ss2 - input_gamma_ * ss1) / i; + else + c2[i] = (output_gamma_ * ss2 - input_gamma_ * ss1) / i; + } + return true; + } + + private: + const int num_input_order_; + const int num_output_order_; + const double input_gamma_; + const double output_gamma_; + DISALLOW_COPY_AND_ASSIGN(GeneralizedCepstrumTransformModule); + }; + + class GammaDivisionModule + : public sptk::GeneralizedCepstrumTransform::ModuleInterface { + public: + GammaDivisionModule(int num_order, double gamma) + : num_order_(num_order), gamma_(gamma) { + } + virtual bool IsValid() const { + return true; + } + virtual bool Run( + const std::vector<double> &input, std::vector<double> *output, + sptk::FrequencyTransform::Buffer *frequency_transform_buffer) const { + if (output->size() != static_cast<std::size_t>(num_order_ + 1)) { + output->resize(num_order_ + 1); + } + // c[0] is not changed + *(output->begin()) = *(input.begin()); + // c[1-m] /= g + std::transform(++(input.begin()), input.end(), ++(output->begin()), + std::bind1st(std::multiplies<double>(), 1.0 / gamma_)); + return true; + } + + private: + const int num_order_; + const double gamma_; + DISALLOW_COPY_AND_ASSIGN(GammaDivisionModule); + }; + + class GammaMultiplicationModule + : public sptk::GeneralizedCepstrumTransform::ModuleInterface { + public: + GammaMultiplicationModule(int num_order, double gamma) + : num_order_(num_order), gamma_(gamma) { + } + virtual bool IsValid() const { + return true; + } + virtual bool Run( + const std::vector<double> &input, std::vector<double> *output, + sptk::FrequencyTransform::Buffer *frequency_transform_buffer) const { + if (output->size() != static_cast<std::size_t>(num_order_ + 1)) { + output->resize(num_order_ + 1); + } + // copy c[0] + *(output->begin()) = *(input.begin()); + // c[1-m] *= g + std::transform(++(input.begin()), input.end(), ++(output->begin()), + std::bind1st(std::multiplies<double>(), gamma_)); + return true; + } + + private: + const int num_order_; + const double gamma_; + DISALLOW_COPY_AND_ASSIGN(GammaMultiplicationModule); + }; + + } // namespace + namespace sptk { *************** *** 78,282 **** return; } if (input_alpha_ != output_alpha_) { alpha_transform_ = (output_alpha_ - input_alpha_) / (1.0 - input_alpha_ * output_alpha_); } - } ! bool GeneralizedCepstrumTransform::Run( ! const std::vector<double>& input, std::vector<double>* output, ! GeneralizedCepstrumTransform::Buffer* buffer) const { ! if (!is_valid_ || ! static_cast<std::size_t>(num_input_order_ + 1) != input.size() || ! NULL == output || NULL == buffer) { ! return false; ! } ! if (output->size() < static_cast<std::size_t>(num_output_order_ + 1)) { ! output->resize(num_output_order_ + 1); ! } ! // mgc2mgc input ! // norm=false multi=false freqt=false ! // -> -> -> gnorm -> gc2gc ! // norm=false multi=true freqt=false ! // -> c[1-m]/g -> -> gnorm -> gc2gc ! // norm=true multi=false freqt=false ! // -> gc2gc ! // norm=true multi=true freqt=false ! // ignorm -> c[1-m]/g -> -> gnorm -> gc2gc ! // norm=false multi=false freqt=true ! // -> -> freqt -> gnorm -> gc2gc ! // norm=false multi=true freqt=true ! // -> c[1-m]/g -> freqt -> gnorm -> gc2gc ! // norm=true multi=false freqt=true ! // ignorm -> -> freqt -> gnorm -> gc2gc ! // norm=true multi=true freqt=true ! // ignorm -> c[1-m]/g -> freqt -> gnorm -> gc2gc ! // do nothing ! if (num_input_order_ == num_output_order_ && input_alpha_ == output_alpha_ && ! input_gamma_ == output_gamma_ && ! is_normalized_input_ == is_normalized_output_ && ! is_multiplied_input_ == is_multiplied_output_) { ! std::copy(input.begin(), input.end(), output->begin()); ! return true; ! } ! // inverse gain normalization ! // input: input ! // output: inverse_gain_normalized_input ! const std::vector<double>* inverse_gain_normalized_input; ! if (is_normalized_input_ && ! (is_multiplied_input_ || 0.0 != alpha_transform_)) { ! GeneralizedCepstrumInverseGainNormalization ! generalized_cepstrum_inverse_gain_normalization(num_input_order_, ! input_gamma_); ! if (!generalized_cepstrum_inverse_gain_normalization.IsValid()) { ! return false; ! } ! if (!generalized_cepstrum_inverse_gain_normalization.Run( ! input, &buffer->inverse_gain_normalized_input_)) { ! return false; ! } ! inverse_gain_normalized_input = &buffer->inverse_gain_normalized_input_; ! } else { ! inverse_gain_normalized_input = &input; ! } ! // gamma division ! // input: inverse_gain_normalized_input ! // output: gamma_divided_input ! const std::vector<double>* gamma_divided_input; ! if (is_multiplied_input_) { ! if (buffer->gamma_divided_input_.size() < ! static_cast<std::size_t>(num_input_order_ + 1)) { ! buffer->gamma_divided_input_.resize(num_input_order_ + 1); ! } ! std::transform(inverse_gain_normalized_input->begin(), ! inverse_gain_normalized_input->end(), ! buffer->gamma_divided_input_.begin(), ! std::bind1st(std::multiplies<double>(), 1.0 / input_gamma_)); ! gamma_divided_input = &buffer->gamma_divided_input_; ! } else { ! gamma_divided_input = inverse_gain_normalized_input; ! } ! // frequency transform ! // input: gamma_divided_input ! // output: frequency_transformed_input ! const std::vector<double>* frequency_transformed_input; ! if (0.0 != alpha_transform_) { ! FrequencyTransform frequency_transform(num_input_order_, num_input_order_, ! alpha_transform_); ! if (!frequency_transform.IsValid()) { ! return false; ! } ! if (!frequency_transform.Run(*gamma_divided_input, ! &buffer->frequency_transformed_input_, ! &buffer->frequency_transform_buffer_)) { ! return false; ! } ! frequency_transformed_input = &buffer->frequency_transformed_input_; ! } else { ! frequency_transformed_input = gamma_divided_input; ! } ! // gain normalization ! // input: frequency_transformed_input ! // output: gain_normalized_input ! const std::vector<double>* gain_normalized_input; ! if (!is_normalized_input_ || is_multiplied_input_ || ! 0.0 != alpha_transform_) { ! GeneralizedCepstrumGainNormalization ! generalized_cepstrum_gain_normalization(num_input_order_, input_gamma_); ! if (!generalized_cepstrum_gain_normalization.IsValid()) { ! return false; ! } ! if (!generalized_cepstrum_gain_normalization.Run( ! *frequency_transformed_input, &buffer->gain_normalized_input_)) { ! return false; } - gain_normalized_input = &buffer->gain_normalized_input_; } else { ! gain_normalized_input = frequency_transformed_input; } ! // generalized cepstrum transform ! // input: gain_normalized_input ! // output: generalized_cepstrum_transformed_output ! const std::vector<double>* generalized_cepstrum_transformed_output; ! if (input_gamma_ != output_gamma_ || num_input_order_ != num_output_order_) { ! if (buffer->generalized_cepstrum_transformed_output_.size() < ! static_cast<std::size_t>(num_output_order_ + 1)) { ! buffer->generalized_cepstrum_transformed_output_.resize( ! num_output_order_ + 1); } ! const double* c1(&(*gain_normalized_input)[0]); ! double* c2(&(buffer->generalized_cepstrum_transformed_output_[0])); ! c2[0] = c1[0]; ! for (int i(1); i <= num_output_order_; ++i) { ! double ss1(0.0), ss2(0.0); ! const int min(num_output_order_ < i ? num_output_order_ : i - 1); ! for (int k(1); k <= min; ++k) { ! int mk(i - k); ! double cc(c1[k] * c2[mk]); ! ss2 += k * cc; ! ss1 += mk * cc; ! } ! if (i <= num_input_order_) ! c2[i] = c1[i] + (output_gamma_ * ss2 - input_gamma_ * ss1) / i; ! else ! c2[i] = (output_gamma_ * ss2 - input_gamma_ * ss1) / i; } ! generalized_cepstrum_transformed_output = ! &buffer->generalized_cepstrum_transformed_output_; ! } else { ! generalized_cepstrum_transformed_output = gain_normalized_input; } ! // mgc2mgc output ! // norm=false multi=false ! // ignorm -> -> ! // norm=false multi=true ! // ignorm -> -> c[1-m]*g ! // norm=true multi=false ! // -> -> ! // norm=true multi=true ! // -> -> c[1-m]*g ! ! // inverse gain normalization ! // input: generalized_cepstrum_transformed_output ! // output: inverse_gain_normalized_output ! const std::vector<double>* inverse_gain_normalized_output; ! if (!is_normalized_output_) { ! GeneralizedCepstrumInverseGainNormalization ! generalized_cepstrum_inverse_gain_normalization(num_output_order_, ! output_gamma_); ! if (!generalized_cepstrum_inverse_gain_normalization.IsValid()) { ! return false; } ! if (!generalized_cepstrum_inverse_gain_normalization.Run( ! *generalized_cepstrum_transformed_output, ! &buffer->inverse_gain_normalized_output_)) { return false; } - inverse_gain_normalized_output = &buffer->inverse_gain_normalized_output_; - } else { - inverse_gain_normalized_output = generalized_cepstrum_transformed_output; - } - - // gamma multiplication - // input: inverse_gain_normalized_output - // output: output - if (is_multiplied_output_) { - std::transform(inverse_gain_normalized_output->begin(), - inverse_gain_normalized_output->end(), output->begin(), - std::bind1st(std::multiplies<double>(), output_gamma_)); - } else { - std::copy(inverse_gain_normalized_output->begin(), - inverse_gain_normalized_output->end(), output->begin()); } --- 266,446 ---- return; } + if (input_alpha_ != output_alpha_) { alpha_transform_ = (output_alpha_ - input_alpha_) / (1.0 - input_alpha_ * output_alpha_); } ! // ch_a: change alpha ! // norm_i: normalized input ! // norm_o: normalized output ! // ch_g: change gamma ! // ch_m: change order ! // ch_a=F norm_i=F norm_o=F ch_g=F ch_m=F ! // -> -> -> -> ! // ch_a=F norm_i=F norm_o=F ch_g=F ch_m=T ! // -> -> gnorm -> gc2gc -> ignorm ! // ch_a=F norm_i=F norm_o=F ch_g=T ch_m=F ! // -> -> gnorm -> gc2gc -> ignorm ! // ch_a=F norm_i=F norm_o=F ch_g=T ch_m=T ! // -> -> gnorm -> gc2gc -> ignorm ! // ch_a=F norm_i=F norm_o=T ch_g=F ch_m=F ! // -> -> gnorm -> -> ! // ch_a=F norm_i=F norm_o=T ch_g=F ch_m=T ! // -> -> gnorm -> gc2gc -> ! // ch_a=F norm_i=F norm_o=T ch_g=T ch_m=F ! // -> -> gnorm -> gc2gc -> ! // ch_a=F norm_i=F norm_o=T ch_g=T ch_m=T ! // -> -> gnorm -> gc2gc -> ! // ch_a=F norm_i=T norm_o=F ch_g=F ch_m=F ! // -> -> -> -> ignorm ! // ch_a=F norm_i=T norm_o=F ch_g=F ch_m=T ! // -> -> -> gc2gc -> ignorm ! // ch_a=F norm_i=T norm_o=F ch_g=T ch_m=F ! // -> -> -> gc2gc -> ignorm ! // ch_a=F norm_i=T norm_o=F ch_g=T ch_m=T ! // -> -> -> gc2gc -> ignorm ! // ch_a=F norm_i=T norm_o=T ch_g=F ch_m=F ! // -> -> -> -> ! // ch_a=F norm_i=T norm_o=T ch_g=F ch_m=T ! // -> -> -> gc2gc -> ! // ch_a=F norm_i=T norm_o=T ch_g=T ch_m=F ! // -> -> -> gc2gc -> ! // ch_a=F norm_i=T norm_o=T ch_g=T ch_m=T ! // -> -> -> gc2gc -> ! // ch_a=T norm_i=F norm_o=F ch_g=F ch_m=F ! // -> freqt -> -> -> ! // ch_a=T norm_i=F norm_o=F ch_g=F ch_m=T ! // -> freqt -> -> -> ! // ch_a=T norm_i=F norm_o=F ch_g=T ch_m=F ! // -> freqt -> gnorm -> gc2gc -> ignorm ! // ch_a=T norm_i=F norm_o=F ch_g=T ch_m=T ! // -> freqt -> gnorm -> gc2gc -> ignorm ! // ch_a=T norm_i=F norm_o=T ch_g=F ch_m=F ! // -> freqt -> gnorm -> -> ! // ch_a=T norm_i=F norm_o=T ch_g=F ch_m=T ! // -> freqt -> gnorm -> -> ! // ch_a=T norm_i=F norm_o=T ch_g=T ch_m=F ! // -> freqt -> gnorm -> gc2gc -> ! // ch_a=T norm_i=F norm_o=T ch_g=T ch_m=T ! // -> freqt -> gnorm -> gc2gc -> ! // ch_a=T norm_i=T norm_o=F ch_g=F ch_m=F ! // ignorm -> freqt -> -> -> ! // ch_a=T norm_i=T norm_o=F ch_g=F ch_m=T ! // ignorm -> freqt -> -> -> ! // ch_a=T norm_i=T norm_o=F ch_g=T ch_m=F ! // ignorm -> freqt -> gnorm -> gc2gc -> ignorm ! // ch_a=T norm_i=T norm_o=F ch_g=T ch_m=T ! // ignorm -> freqt -> gnorm -> gc2gc -> ignorm ! ! // ch_a=T norm_i=T norm_o=T ch_g=F ch_m=F ! // ignorm -> freqt -> gnorm -> -> ! // ch_a=T norm_i=T norm_o=T ch_g=F ch_m=T ! // ignorm -> freqt -> gnorm -> -> ! // ch_a=T norm_i=T norm_o=T ch_g=T ch_m=F ! // ignorm -> freqt -> gnorm -> gc2gc -> ! // ch_a=T norm_i=T norm_o=T ch_g=T ch_m=T ! // ignorm -> freqt -> gnorm -> gc2gc -> ! ! if (0.0 == alpha_transform_) { ! if (num_input_order_ == num_output_order_ && ! input_gamma_ == output_gamma_) { ! if (!is_multiplied_input_ && is_multiplied_output_) ! modules_.push_back( ! new GammaMultiplicationModule(num_input_order_, input_gamma_)); ! if (!is_normalized_input_ && is_normalized_output_) ! modules_.push_back( ! new GainNormalizationModule(num_input_order_, input_gamma_)); ! if (is_normalized_input_ && !is_normalized_output_) ! modules_.push_back(new InverseGainNormalizationModule(num_output_order_, ! output_gamma_)); ! if (is_multiplied_input_ && !is_multiplied_output_) ! modules_.push_back( ! new GammaDivisionModule(num_output_order_, output_gamma_)); ! } else { ! if (is_multiplied_input_) ! modules_.push_back( ! new GammaDivisionModule(num_input_order_, input_gamma_)); ! if (!is_normalized_input_) ! modules_.push_back( ! new GainNormalizationModule(num_input_order_, input_gamma_)); ! modules_.push_back(new GeneralizedCepstrumTransformModule( ! num_input_order_, num_output_order_, input_gamma_, output_gamma_)); ! if (!is_normalized_output_) ! modules_.push_back(new InverseGainNormalizationModule(num_output_order_, ! output_gamma_)); ! if (is_multiplied_output_) ! modules_.push_back( ! new GammaMultiplicationModule(num_output_order_, output_gamma_)); } } else { ! if (is_multiplied_input_) ! modules_.push_back( ! new GammaDivisionModule(num_input_order_, input_gamma_)); ! if (is_normalized_input_) ! modules_.push_back( ! new InverseGainNormalizationModule(num_input_order_, input_gamma_)); ! modules_.push_back(new FrequencyTransformModule( ! num_input_order_, num_output_order_, alpha_transform_)); ! if (is_normalized_output_ || input_gamma_ != output_gamma_) ! modules_.push_back( ! new GainNormalizationModule(num_output_order_, input_gamma_)); ! if (input_gamma_ != output_gamma_) ! modules_.push_back(new GeneralizedCepstrumTransformModule( ! num_output_order_, num_output_order_, input_gamma_, output_gamma_)); ! if (!is_normalized_output_ && input_gamma_ != output_gamma_) ! modules_.push_back( ! new InverseGainNormalizationModule(num_output_order_, output_gamma_)); ! if (is_multiplied_output_) ! modules_.push_back( ! new GammaMultiplicationModule(num_output_order_, output_gamma_)); } ! for (std::vector<GeneralizedCepstrumTransform::ModuleInterface *>::iterator ! itr(modules_.begin()); ! itr != modules_.end(); ++itr) { ! if (!(*itr)->IsValid()) { ! is_valid_ = false; ! break; } ! } ! } ! bool GeneralizedCepstrumTransform::Run( ! const std::vector<double> &input, std::vector<double> *output, ! GeneralizedCepstrumTransform::Buffer *buffer) const { ! if (!is_valid_ || ! static_cast<std::size_t>(num_input_order_ + 1) != input.size() || ! NULL == output || NULL == buffer) { ! return false; ! } ! if (modules_.empty()) { ! if (output->size() < static_cast<std::size_t>(num_output_order_ + 1)) { ! output->resize(num_output_order_ + 1); } ! std::copy(input.begin(), input.end(), output->begin()); ! return true; } ! for (std::vector<GeneralizedCepstrumTransform::ModuleInterface ! *>::const_iterator itr(modules_.begin()); ! itr != modules_.end(); ++itr) { ! if (itr != modules_.begin()) { ! output->swap(buffer->temporary_generalized_cepstrum_); } ! if (!(*itr)->Run((itr == modules_.begin()) ! ? input ! : buffer->temporary_generalized_cepstrum_, ! output, &(buffer->frequency_transform_buffer_))) { return false; } } Index: generalized_cepstrum_transform.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/generalized_cepstrum_transform.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** generalized_cepstrum_transform.h 24 Oct 2016 08:20:30 -0000 1.2 --- generalized_cepstrum_transform.h 16 Dec 2016 09:36:32 -0000 1.3 *************** *** 63,77 **** private: - std::vector<double> inverse_gain_normalized_input_; - std::vector<double> gamma_divided_input_; - std::vector<double> frequency_transformed_input_; FrequencyTransform::Buffer frequency_transform_buffer_; ! std::vector<double> gain_normalized_input_; ! std::vector<double> generalized_cepstrum_transformed_output_; ! std::vector<double> inverse_gain_normalized_output_; friend class GeneralizedCepstrumTransform; DISALLOW_COPY_AND_ASSIGN(Buffer); }; // GeneralizedCepstrumTransform(int num_input_order_, double input_alpha_, --- 63,82 ---- private: FrequencyTransform::Buffer frequency_transform_buffer_; ! std::vector<double> temporary_generalized_cepstrum_; friend class GeneralizedCepstrumTransform; DISALLOW_COPY_AND_ASSIGN(Buffer); }; + class ModuleInterface { + public: + virtual ~ModuleInterface() { + } + virtual bool IsValid() const = 0; + virtual bool Run( + const std::vector<double> &input, std::vector<double> *output, + FrequencyTransform::Buffer *frequency_transform_buffer) const = 0; + }; + // GeneralizedCepstrumTransform(int num_input_order_, double input_alpha_, *************** *** 84,87 **** --- 89,97 ---- // virtual ~GeneralizedCepstrumTransform() { + for (std::vector<GeneralizedCepstrumTransform::ModuleInterface *>::iterator + itr(modules_.begin()); + itr != modules_.end(); ++itr) { + delete (*itr); + } } *************** *** 142,147 **** // ! bool Run(const std::vector<double>& input, std::vector<double>* output, ! GeneralizedCepstrumTransform::Buffer* buffer) const; private: --- 152,157 ---- // ! bool Run(const std::vector<double> &input, std::vector<double> *output, ! GeneralizedCepstrumTransform::Buffer *buffer) const; private: *************** *** 180,183 **** --- 190,196 ---- // + std::vector<GeneralizedCepstrumTransform::ModuleInterface *> modules_; + + // bool is_valid_; |
From: Keiichiro O. <ur...@us...> - 2016-12-14 06:55:39
|
Update of /cvsroot/sp-tk/SPTK/src/bin/gc2gc In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv19183 Modified Files: gc2gc.c Log Message: fix gc2gc bug. when input/output is norm=false && gamma-multiply=true, c0 must be modified. Index: gc2gc.c =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/bin/gc2gc/gc2gc.c,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** gc2gc.c 9 Dec 2016 01:29:07 -0000 1.30 --- gc2gc.c 14 Dec 2016 06:55:37 -0000 1.31 *************** *** 242,249 **** while (freadf(gc1, sizeof(*gc1), m1 + 1, fp) == m1 + 1) { ! if (!norm1) gnorm(gc1, gc1, m1, g1); ! else if (mulg1) ! gc1[0] = (gc1[0] - 1.0) / g1; if (mulg1) --- 242,250 ---- while (freadf(gc1, sizeof(*gc1), m1 + 1, fp) == m1 + 1) { ! if (!norm1) { gnorm(gc1, gc1, m1, g1); ! if (mulg1) ! gc1[0] = (gc1[0] - 1.0) / g1; ! } if (mulg1) *************** *** 253,260 **** gc2gc(gc1, m1, g1, gc2, m2, g2); ! if (!norm2) ignorm(gc2, gc2, m2, g2); ! else if (mulg2) ! gc2[0] = gc2[0] * g2 + 1.0; if (mulg2) --- 254,262 ---- gc2gc(gc1, m1, g1, gc2, m2, g2); ! if (!norm2) { ignorm(gc2, gc2, m2, g2); ! if (mulg2) ! gc2[0] = gc2[0] * g2 + 1.0; ! } if (mulg2) |
From: Takenori Y. <tak...@us...> - 2016-12-09 01:29:09
|
Update of /cvsroot/sp-tk/SPTK/src/bin/mgc2mgc In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv12834/mgc2mgc Modified Files: mgc2mgc.c Log Message: fix bugs Index: mgc2mgc.c =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/bin/mgc2mgc/mgc2mgc.c,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** mgc2mgc.c 14 Dec 2015 01:14:19 -0000 1.32 --- mgc2mgc.c 9 Dec 2016 01:29:07 -0000 1.33 *************** *** 284,288 **** gnorm(c2, c2, m2, g2); else if (mulg2) ! c1[0] = c1[0] * g2 + 1.0; if (mulg2) --- 284,288 ---- gnorm(c2, c2, m2, g2); else if (mulg2) ! c2[0] = c2[0] * g2 + 1.0; if (mulg2) |
From: Shikano M. <sh...@us...> - 2016-12-07 08:51:28
|
Update of /cvsroot/sp-tk/SPTK/doc/ref_e/fig In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24786 Added Files: FIRflt.eps transflt.eps Log Message: Add figure --- NEW FILE: transflt.eps --- %!PS-Adobe-2.0 EPSF-2.0 %%Creator: pdvips(k) p1.7b Copyright 2010 ASCII MEDIA WORKS. (pte...@ml...) %%+ based on dvips(k) 5.98dev Copyright 2010 Radical Eye Software (www.radicaleye.com) %%Title: tgif2tex-10251.dvi %%CreationDate: Mon Sep 19 17:23:31 2016 %%BoundingBox: 135 566 470 658 %%DocumentFonts: CMMI12 CMSY10 CMR10 %%EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: /usr/bin/pdvips -E -o transflt.eps tgif2tex-10251 %DVIPSParameters: dpi=600 %DVIPSSource: TeX output 2016.09.19:1723 %%BeginProcSet: tex.pro 0 0 %! /TeXDict 300 dict def TeXDict begin/N{def}def/B{bind def}N/S{exch}N/X{S N}B/A{dup}B/TR{translate}N/isls false N/vsize 11 72 mul N/hsize 8.5 72 mul N/landplus90{false}def/@rigin{isls{[0 landplus90{1 -1}{-1 1}ifelse 0 0 0]concat}if 72 Resolution div 72 VResolution div neg scale isls{ landplus90{VResolution 72 div vsize mul 0 exch}{Resolution -72 div hsize [...1454 lines suppressed...] 98 50 10.000 4.000 57 0 TGAT CP F GR GR tgifsavedpage restore end showpage %MatchingCreationDate: Mon Sep 19 17:23:30 2016 %%EndDocument @endspecial Fd 1236 1186 a(z)p Fc 1295 1143 a(\000)p Fb(1)p Fa 1041 920 a(c\(3\)) 545 b(c\(2\))h(c\(1\))p Fb 597 672 a(Input) 2974 1074 y(Output)p Fd 1937 1186 a(z)p Fc 1996 1143 a(\000)p Fb(1)p Fd 2638 1186 a(z)p Fc 2697 1143 a(\000)p Fb(1)p dyy eop end %%Trailer userdict /end-hook known{end-hook}if %%EOF --- NEW FILE: FIRflt.eps --- %!PS-Adobe-2.0 EPSF-2.0 %%Creator: pdvips(k) p1.7b Copyright 2010 ASCII MEDIA WORKS. (pte...@ml...) %%+ based on dvips(k) 5.98dev Copyright 2010 Radical Eye Software (www.radicaleye.com) %%Title: tgif2tex-10280.dvi %%CreationDate: Mon Sep 19 17:24:12 2016 %%BoundingBox: 135 566 470 658 %%DocumentFonts: CMMI12 CMSY10 CMR10 %%EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: /usr/bin/pdvips -E -o FIRflt.eps tgif2tex-10280 %DVIPSParameters: dpi=600 %DVIPSSource: TeX output 2016.09.19:1724 %%BeginProcSet: tex.pro 0 0 %! /TeXDict 300 dict def TeXDict begin/N{def}def/B{bind def}N/S{exch}N/X{S N}B/A{dup}B/TR{translate}N/isls false N/vsize 11 72 mul N/hsize 8.5 72 mul N/landplus90{false}def/@rigin{isls{[0 landplus90{1 -1}{-1 1}ifelse 0 0 0]concat}if 72 Resolution div 72 VResolution div neg scale isls{ landplus90{VResolution 72 div vsize mul 0 exch}{Resolution -72 div hsize [...1453 lines suppressed...] S 1 W GR GR tgifsavedpage restore end showpage %MatchingCreationDate: Mon Sep 19 17:24:12 2016 %%EndDocument @endspecial Fd 1008 747 a(z)p Fc 1067 704 a(\000)p Fb(1)p Fa 2885 1028 a(c\(3\)) -855 b(c\(2\))f(c\(1\))p Fb 578 780 a(Input) 3016 1158 y(Output)p Fd 1708 747 a(z)p Fc 1767 704 a(\000)p Fb(1)p Fd 2409 747 a(z)p Fc 2468 704 a(\000)p Fb(1)p dyy eop end %%Trailer userdict /end-hook known{end-hook}if %%EOF |
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv4665 Modified Files: Makefile all_pole_digital_filter.cc all_pole_lattice_digital_filter.cc all_zero_digital_filter.cc autocorrelation.cc cepstrum_to_minimum_phase_impulse_response.cc fast_fourier_transform.cc frequency_transform.cc input_source_interpolation.cc input_source_interpolation_with_magic_number.cc levinson_durbin_recursion.cc linear_predictive_coefficients_to_cepstrum.cc Added Files: input_source_from_array.cc input_source_from_array.h input_source_from_vector.cc input_source_from_vector.h Log Message: add input source from interfaces Index: all_zero_digital_filter.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/all_zero_digital_filter.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** all_zero_digital_filter.cc 12 Oct 2016 12:14:38 -0000 1.4 --- all_zero_digital_filter.cc 30 Nov 2016 04:23:27 -0000 1.5 *************** *** 45,49 **** #include "all_zero_digital_filter.h" ! #include <cstring> // std::size_t namespace sptk { --- 45,49 ---- #include "all_zero_digital_filter.h" ! #include <cstddef> // std::size_t namespace sptk { Index: frequency_transform.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/frequency_transform.cc,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** frequency_transform.cc 14 Oct 2016 06:17:44 -0000 1.10 --- frequency_transform.cc 30 Nov 2016 04:23:28 -0000 1.11 *************** *** 46,50 **** #include <algorithm> // std::copy, std::fill_n ! #include <cstring> // std::size_t namespace sptk { --- 46,50 ---- #include <algorithm> // std::copy, std::fill_n ! #include <cstddef> // std::size_t namespace sptk { Index: cepstrum_to_minimum_phase_impulse_response.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/cepstrum_to_minimum_phase_impulse_response.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** cepstrum_to_minimum_phase_impulse_response.cc 12 Oct 2016 12:14:38 -0000 1.5 --- cepstrum_to_minimum_phase_impulse_response.cc 30 Nov 2016 04:23:28 -0000 1.6 *************** *** 46,50 **** #include <cmath> // std::exp ! #include <cstring> // std::size_t namespace sptk { --- 46,50 ---- #include <cmath> // std::exp ! #include <cstddef> // std::size_t namespace sptk { Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Makefile 24 Nov 2016 04:16:55 -0000 1.19 --- Makefile 30 Nov 2016 04:23:27 -0000 1.20 *************** *** 56,60 **** --- 56,62 ---- generalized_cepstrum_inverse_gain_normalization.cc \ generalized_cepstrum_transform.cc \ + input_source_from_array.cc \ input_source_from_stream.cc \ + input_source_from_vector.cc \ input_source_interpolation.cc \ input_source_interpolation_with_magic_number.cc \ Index: all_pole_lattice_digital_filter.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/all_pole_lattice_digital_filter.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** all_pole_lattice_digital_filter.cc 26 Oct 2016 08:18:58 -0000 1.1 --- all_pole_lattice_digital_filter.cc 30 Nov 2016 04:23:27 -0000 1.2 *************** *** 45,49 **** #include "all_pole_lattice_digital_filter.h" ! #include <cstring> // std::size_t namespace sptk { --- 45,49 ---- #include "all_pole_lattice_digital_filter.h" ! #include <cstddef> // std::size_t namespace sptk { --- NEW FILE: input_source_from_vector.h --- // ----------------------------------------------------------------- // // The Speech Signal Processing Toolkit (SPTK) // // developed by SPTK Working Group // // http://sp-tk.sourceforge.net/ // // ----------------------------------------------------------------- // // // // Copyright (c) 1984-2007 Tokyo Institute of Technology // // Interdisciplinary Graduate School of // // Science and Engineering // // // // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // // All rights reserved. // // // // Redistribution and use in source and binary forms, with or // // without modification, are permitted provided that the following // // conditions are met: // // // // - Redistributions of source code must retain the above copyright // // notice, this list of conditions and the following disclaimer. // // - Redistributions in binary form must reproduce the above // // copyright notice, this list of conditions and the following // // disclaimer in the documentation and/or other materials provided // // with the distribution. // // - Neither the name of the SPTK working group nor the names of its // // contributors may be used to endorse or promote products derived // // from this software without specific prior written permission. // // // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND // // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, // // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS // // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON // // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // // POSSIBILITY OF SUCH DAMAGE. // // ----------------------------------------------------------------- // #ifndef SPTK_SRC_INPUT_SOURCE_FROM_VECTOR_H_ #define SPTK_SRC_INPUT_SOURCE_FROM_VECTOR_H_ #include <istream> // std::istream #include <vector> // std::vector #include "input_source_interface.h" #include "sptk_utils.h" namespace sptk { class InputSourceFromVector : public InputSourceInterface { public: // InputSourceFromVector(bool zero_padding, int read_size, std::vector<double>* input_vector) : zero_padding_(zero_padding), read_size_(read_size), vector_size_(0), input_vector_(input_vector), position_(0), is_valid_(true) { if (read_size <= 0 || NULL == input_vector) { is_valid_ = false; return; } vector_size_ = input_vector->size(); } // virtual ~InputSourceFromVector() { } // virtual int GetSize() const { return read_size_; } // int VectorSize() const { return vector_size_; } // virtual bool IsValid() const { return is_valid_; } // virtual bool Get(std::vector<double>* buffer); private: // const bool zero_padding_; // const int read_size_; // int vector_size_; // std::vector<double>* input_vector_; // int position_; // bool is_valid_; // DISALLOW_COPY_AND_ASSIGN(InputSourceFromVector); }; } // namespace sptk #endif // SPTK_SRC_INPUT_SOURCE_FROM_VECTOR_H_ Index: levinson_durbin_recursion.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/levinson_durbin_recursion.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** levinson_durbin_recursion.cc 28 Nov 2016 13:51:02 -0000 1.6 --- levinson_durbin_recursion.cc 30 Nov 2016 04:23:28 -0000 1.7 *************** *** 46,50 **** #include <cmath> // std::fabs, std::sqrt ! #include <cstring> // std::size_t namespace sptk { --- 46,50 ---- #include <cmath> // std::fabs, std::sqrt ! #include <cstddef> // std::size_t namespace sptk { --- NEW FILE: input_source_from_array.cc --- // ----------------------------------------------------------------- // // The Speech Signal Processing Toolkit (SPTK) // // developed by SPTK Working Group // // http://sp-tk.sourceforge.net/ // // ----------------------------------------------------------------- // // // // Copyright (c) 1984-2007 Tokyo Institute of Technology // // Interdisciplinary Graduate School of // // Science and Engineering // // // // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // // All rights reserved. // // // // Redistribution and use in source and binary forms, with or // // without modification, are permitted provided that the following // // conditions are met: // // // // - Redistributions of source code must retain the above copyright // // notice, this list of conditions and the following disclaimer. // // - Redistributions in binary form must reproduce the above // // copyright notice, this list of conditions and the following // // disclaimer in the documentation and/or other materials provided // // with the distribution. // // - Neither the name of the SPTK working group nor the names of its // // contributors may be used to endorse or promote products derived // // from this software without specific prior written permission. // // // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND // // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, // // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS // // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON // // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // // POSSIBILITY OF SUCH DAMAGE. // // ----------------------------------------------------------------- // #include "input_source_from_array.h" #include <cstddef> // std::size_t namespace sptk { bool InputSourceFromArray::Get(std::vector<double>* buffer) { if (NULL == buffer || !is_valid_ || array_size_ <= position_) { return false; } const int next_position(position_ + read_size_); if (!zero_padding_ && array_size_ < next_position) { return false; } if (buffer->size() < static_cast<std::size_t>(read_size_)) { buffer->resize(read_size_); } if (next_position <= array_size_) { for (int i(0); i < read_size_; ++i) { (*buffer)[i] = input_array_[position_ + i]; } } else { const int num_nonzeros(array_size_ - position_); for (int i(0); i < num_nonzeros; ++i) { (*buffer)[i] = input_array_[position_ + i]; } for (int i(num_nonzeros); i < read_size_; ++i) { (*buffer)[i] = 0.0; } } position_ = next_position; return true; } } // namespace sptk --- NEW FILE: input_source_from_vector.cc --- // ----------------------------------------------------------------- // // The Speech Signal Processing Toolkit (SPTK) // // developed by SPTK Working Group // // http://sp-tk.sourceforge.net/ // // ----------------------------------------------------------------- // // // // Copyright (c) 1984-2007 Tokyo Institute of Technology // // Interdisciplinary Graduate School of // // Science and Engineering // // // // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // // All rights reserved. // // // // Redistribution and use in source and binary forms, with or // // without modification, are permitted provided that the following // // conditions are met: // // // // - Redistributions of source code must retain the above copyright // // notice, this list of conditions and the following disclaimer. // // - Redistributions in binary form must reproduce the above // // copyright notice, this list of conditions and the following // // disclaimer in the documentation and/or other materials provided // // with the distribution. // // - Neither the name of the SPTK working group nor the names of its // // contributors may be used to endorse or promote products derived // // from this software without specific prior written permission. // // // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND // // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, // // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS // // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON // // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // // POSSIBILITY OF SUCH DAMAGE. // // ----------------------------------------------------------------- // #include "input_source_from_vector.h" #include <algorithm> // std::copy, std::fill_n #include <cstddef> // std::size_t namespace sptk { bool InputSourceFromVector::Get(std::vector<double>* buffer) { if (NULL == buffer || !is_valid_ || vector_size_ <= position_) { return false; } const int next_position(position_ + read_size_); if (!zero_padding_ && vector_size_ < next_position) { return false; } if (buffer->size() < static_cast<std::size_t>(read_size_)) { buffer->resize(read_size_); } if (next_position <= vector_size_) { std::copy(input_vector_->begin() + position_, input_vector_->begin() + next_position, buffer->begin()); } else { const int num_nonzeros(vector_size_ - position_); const int num_zeros(next_position - vector_size_); std::copy(input_vector_->begin() + position_, input_vector_->begin() + position_ + num_nonzeros, buffer->begin()); std::fill_n(buffer->begin() + num_nonzeros, num_zeros, 0.0); } position_ = next_position; return true; } } // namespace sptk Index: fast_fourier_transform.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/fast_fourier_transform.cc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** fast_fourier_transform.cc 12 Oct 2016 12:14:38 -0000 1.9 --- fast_fourier_transform.cc 30 Nov 2016 04:23:28 -0000 1.10 *************** *** 47,51 **** #include <algorithm> // std::copy, std::fill #include <cmath> // std::sin ! #include <cstring> // std::size_t namespace sptk { --- 47,51 ---- #include <algorithm> // std::copy, std::fill #include <cmath> // std::sin ! #include <cstddef> // std::size_t namespace sptk { Index: autocorrelation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/autocorrelation.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** autocorrelation.cc 12 Oct 2016 12:14:38 -0000 1.4 --- autocorrelation.cc 30 Nov 2016 04:23:27 -0000 1.5 *************** *** 46,50 **** #include <algorithm> // std::fill_n ! #include <cstring> // std::size_t namespace sptk { --- 46,50 ---- #include <algorithm> // std::fill_n ! #include <cstddef> // std::size_t namespace sptk { Index: input_source_interpolation.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_interpolation.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** input_source_interpolation.cc 12 Oct 2016 12:14:38 -0000 1.4 --- input_source_interpolation.cc 30 Nov 2016 04:23:28 -0000 1.5 *************** *** 46,50 **** #include <algorithm> // std::copy, std::transform ! #include <cstring> // std::size_t #include <functional> // std::plus --- 46,50 ---- #include <algorithm> // std::copy, std::transform ! #include <cstddef> // std::size_t #include <functional> // std::plus Index: input_source_interpolation_with_magic_number.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_interpolation_with_magic_number.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** input_source_interpolation_with_magic_number.cc 12 Oct 2016 12:14:38 -0000 1.4 --- input_source_interpolation_with_magic_number.cc 30 Nov 2016 04:23:28 -0000 1.5 *************** *** 46,50 **** #include <algorithm> // std::copy ! #include <cstring> // std::size_t #include <limits> // std::numeric_limits --- 46,50 ---- #include <algorithm> // std::copy ! #include <cstddef> // std::size_t #include <limits> // std::numeric_limits Index: all_pole_digital_filter.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/all_pole_digital_filter.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** all_pole_digital_filter.cc 12 Oct 2016 12:14:38 -0000 1.5 --- all_pole_digital_filter.cc 30 Nov 2016 04:23:27 -0000 1.6 *************** *** 45,49 **** #include "all_pole_digital_filter.h" ! #include <cstring> // std::size_t namespace sptk { --- 45,49 ---- #include "all_pole_digital_filter.h" ! #include <cstddef> // std::size_t namespace sptk { --- NEW FILE: input_source_from_array.h --- // ----------------------------------------------------------------- // // The Speech Signal Processing Toolkit (SPTK) // // developed by SPTK Working Group // // http://sp-tk.sourceforge.net/ // // ----------------------------------------------------------------- // // // // Copyright (c) 1984-2007 Tokyo Institute of Technology // // Interdisciplinary Graduate School of // // Science and Engineering // // // // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // // All rights reserved. // // // // Redistribution and use in source and binary forms, with or // // without modification, are permitted provided that the following // // conditions are met: // // // // - Redistributions of source code must retain the above copyright // // notice, this list of conditions and the following disclaimer. // // - Redistributions in binary form must reproduce the above // // copyright notice, this list of conditions and the following // // disclaimer in the documentation and/or other materials provided // // with the distribution. // // - Neither the name of the SPTK working group nor the names of its // // contributors may be used to endorse or promote products derived // // from this software without specific prior written permission. // // // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND // // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, // // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS // // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON // // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // // POSSIBILITY OF SUCH DAMAGE. // // ----------------------------------------------------------------- // #ifndef SPTK_SRC_INPUT_SOURCE_FROM_ARRAY_H_ #define SPTK_SRC_INPUT_SOURCE_FROM_ARRAY_H_ #include <istream> // std::istream #include <vector> // std::vector #include "input_source_interface.h" #include "sptk_utils.h" namespace sptk { class InputSourceFromArray : public InputSourceInterface { public: // InputSourceFromArray(bool zero_padding, int read_size, int array_size, double* input_array) : zero_padding_(zero_padding), read_size_(read_size), array_size_(array_size), input_array_(input_array), position_(0), is_valid_(true) { if (read_size <= 0 || array_size <= 0 || NULL == input_array) { is_valid_ = false; } } // virtual ~InputSourceFromArray() { } // virtual int GetSize() const { return read_size_; } // int GetArraySize() const { return array_size_; } // virtual bool IsValid() const { return is_valid_; } // virtual bool Get(std::vector<double>* buffer); private: // const bool zero_padding_; // const int read_size_; // const int array_size_; // double* input_array_; // int position_; // bool is_valid_; // DISALLOW_COPY_AND_ASSIGN(InputSourceFromArray); }; } // namespace sptk #endif // SPTK_SRC_INPUT_SOURCE_FROM_ARRAY_H_ Index: linear_predictive_coefficients_to_cepstrum.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/linear_predictive_coefficients_to_cepstrum.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** linear_predictive_coefficients_to_cepstrum.cc 24 Nov 2016 04:16:55 -0000 1.1 --- linear_predictive_coefficients_to_cepstrum.cc 30 Nov 2016 04:23:28 -0000 1.2 *************** *** 45,50 **** #include "linear_predictive_coefficients_to_cepstrum.h" ! #include <cmath> // std::isfinite, std::log ! #include <cstring> // std::size_t namespace sptk { --- 45,50 ---- #include "linear_predictive_coefficients_to_cepstrum.h" ! #include <cmath> // std::log ! #include <cstddef> // std::size_t namespace sptk { |
From: Takenori Y. <tak...@us...> - 2016-11-28 13:51:04
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv25102 Modified Files: input_source_preprocessing_for_filter_gain.cc levinson_durbin_recursion.cc Log Message: minor fix Index: input_source_preprocessing_for_filter_gain.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/input_source_preprocessing_for_filter_gain.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** input_source_preprocessing_for_filter_gain.cc 14 Oct 2016 06:17:44 -0000 1.4 --- input_source_preprocessing_for_filter_gain.cc 28 Nov 2016 13:51:02 -0000 1.5 *************** *** 65,79 **** } case InputSourcePreprocessingForFilterGain::FilterGainType::kLog: { ! buffer->at(0) = std::exp(buffer->at(0)); break; } case InputSourcePreprocessingForFilterGain::FilterGainType::kUnity: { ! buffer->at(0) = 1.0; break; } case InputSourcePreprocessingForFilterGain::FilterGainType:: kUnityForAllZeroFilter: { ! if (0.0 == buffer->at(0)) return false; ! const double inverse_of_b0(1.0 / buffer->at(0)); std::transform(buffer->begin(), buffer->end(), buffer->begin(), std::bind1st(std::multiplies<double>(), inverse_of_b0)); --- 65,79 ---- } case InputSourcePreprocessingForFilterGain::FilterGainType::kLog: { ! (*buffer)[0] = std::exp((*buffer)[0]); break; } case InputSourcePreprocessingForFilterGain::FilterGainType::kUnity: { ! (*buffer)[0] = 1.0; break; } case InputSourcePreprocessingForFilterGain::FilterGainType:: kUnityForAllZeroFilter: { ! if (0.0 == (*buffer)[0]) return false; ! const double inverse_of_b0(1.0 / (*buffer)[0]); std::transform(buffer->begin(), buffer->end(), buffer->begin(), std::bind1st(std::multiplies<double>(), inverse_of_b0)); Index: levinson_durbin_recursion.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/levinson_durbin_recursion.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** levinson_durbin_recursion.cc 12 Oct 2016 12:14:38 -0000 1.5 --- levinson_durbin_recursion.cc 28 Nov 2016 13:51:02 -0000 1.6 *************** *** 56,60 **** // check inputs if (autocorrelation_sequence.empty() || ! NULL == linear_predictive_coefficients || NULL == buffer) { return false; } --- 56,61 ---- // check inputs if (autocorrelation_sequence.empty() || ! NULL == linear_predictive_coefficients || NULL == buffer || ! NULL == is_stable) { return false; } *************** *** 76,82 **** // set value ! if (NULL != is_stable) { ! *is_stable = true; ! } double rmd(input[0]); --- 77,81 ---- // set value ! *is_stable = true; double rmd(input[0]); *************** *** 104,108 **** } ! if (NULL != is_stable && 1.0 <= std::fabs(mue)) { *is_stable = false; } --- 103,107 ---- } ! if (1.0 <= std::fabs(mue)) { *is_stable = false; } |
From: Shikano M. <sh...@us...> - 2016-11-26 07:31:49
|
Update of /cvsroot/sp-tk/SPTK/doc/ref_e In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv31815 Modified Files: lpc2c.tex Log Message: correct wrong letters Index: lpc2c.tex =================================================================== RCS file: /cvsroot/sp-tk/SPTK/doc/ref_e/lpc2c.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** lpc2c.tex 18 Dec 2015 07:53:25 -0000 1.20 --- lpc2c.tex 26 Nov 2016 07:31:47 -0000 1.21 *************** *** 64,69 **** \begin{displaymath} c(n) = \begin{cases} ! \;\; \ln(h),&n=0\\ ! \;\; \displaystyle -a(n)=-\sum^{n-1}_{k=1}\frac{k}{n}c(k) a(n-k),&1\leq n\leq P\\ \;\; \displaystyle -\sum_{k=n-P}^{n-1}\frac{k}{n}c(k) a(n-k),& n>P \end{cases} --- 64,69 ---- \begin{displaymath} c(n) = \begin{cases} ! \;\; \ln(\sigma),&n=0\\ ! \;\; \displaystyle -a(n)-\sum^{n-1}_{k=1}\frac{k}{n}c(k) a(n-k),&1\leq n\leq P\\ \;\; \displaystyle -\sum_{k=n-P}^{n-1}\frac{k}{n}c(k) a(n-k),& n>P \end{cases} |
From: Takenori Y. <tak...@us...> - 2016-11-25 08:10:03
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv30985 Added Files: nan.cc Log Message: add nan command --- NEW FILE: nan.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 <cmath> #include <fstream> #include <iostream> #include <sstream> #include "sptk_utils.h" namespace { void PrintUsage(std::ostream* stream) { // clang-format off *stream << std::endl; *stream << " nan - find NaN and Infinity values" << std::endl; *stream << std::endl; *stream << " usage:" << std::endl; *stream << " nan [ options ] [ infile ] > stdout" << std::endl; *stream << " options:" << std::endl; *stream << " -h : print this message" << std::endl; *stream << " infile:" << std::endl; *stream << " data sequence (double) [stdin]" << std::endl; *stream << " stdout:" << std::endl; *stream << " result messages" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; *stream << std::endl; // clang-format on } } // namespace int main(int argc, char* argv[]) { for (;;) { const char option_char(getopt(argc, argv, "h")); if (-1 == option_char) break; switch (option_char) { 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("nan", error_message); return 1; } std::istream& input_stream(ifs.fail() ? std::cin : ifs); double data; for (int frame_index(0); sptk::ReadStream(&data, &input_stream); ++frame_index) { if (std::isnan(data)) { std::cout << "[No. " << frame_index << "] is Nan" << std::endl; } else if (std::isinf(data)) { std::cout << "[No. " << frame_index << "] is Infinity" << std::endl; } } return 0; } |
From: Takenori Y. <tak...@us...> - 2016-11-24 04:16:58
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv15203 Modified Files: Makefile levdur.cc lpc.cc Added Files: linear_predictive_coefficients_to_cepstrum.cc linear_predictive_coefficients_to_cepstrum.h lpc2c.cc Log Message: add lpc2c command --- NEW FILE: lpc2c.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 "linear_predictive_coefficients_to_cepstrum.h" #include "sptk_utils.h" namespace { const int kDefaultNumInputOrder(25); const int kDefaultNumOutputOrder(25); void PrintUsage(std::ostream* stream) { // clang-format off *stream << std::endl; *stream << " lpc2c - transform linear predictive coefficients to cepstrum" << std::endl; // NOLINT *stream << std::endl; *stream << " usage:" << std::endl; *stream << " lpc2c [ options ] [ infile ] > stdout" << std::endl; *stream << " options:" << std::endl; *stream << " -m m : order of linear predictive [" << kDefaultNumInputOrder << "]" << std::endl; // NOLINT *stream << " coefficients" << std::endl; *stream << " -M M : order of cepstrum [" << kDefaultNumOutputOrder << "]" << std::endl; // NOLINT *stream << " -h : print this message" << std::endl; *stream << " infile:" << std::endl; *stream << " linear predictive coefficients (double) [stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; *stream << " cepstrum (double)" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; *stream << std::endl; // clang-format on } } // namespace int main(int argc, char* argv[]) { int num_input_order(kDefaultNumInputOrder); int num_output_order(kDefaultNumOutputOrder); for (;;) { const char option_char(getopt(argc, argv, "m:M:h")); if (-1 == option_char) break; switch (option_char) { case 'm': { if (!sptk::ConvertStringToInteger(optarg, &num_input_order) || num_input_order < 0) { std::ostringstream error_message; error_message << "The argument for the -m option must be a " << "non-negative integer"; sptk::PrintErrorMessage("lpc2c", error_message); return 1; } break; } case 'M': { if (!sptk::ConvertStringToInteger(optarg, &num_output_order) || num_output_order < 0) { std::ostringstream error_message; error_message << "The argument for the -M option must be a " << "non-negative integer"; sptk::PrintErrorMessage("lpc2c", error_message); return 1; } 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("lpc2c", error_message); return 1; } std::istream& input_stream(ifs.fail() ? std::cin : ifs); // prepare for frequency transform sptk::LinearPredictiveCoefficientsToCepstrum linear_predictive_coefficients_to_cepstrum(num_input_order, num_output_order); if (!linear_predictive_coefficients_to_cepstrum.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the condition of input/output orders"; sptk::PrintErrorMessage("lpc2c", error_message); return 1; } const int input_length(num_input_order + 1); const int output_length(num_output_order + 1); std::vector<double> linear_predictive_coefficients(input_length); std::vector<double> cepstrum(output_length); while (sptk::ReadStream(false, input_length, &linear_predictive_coefficients, &input_stream)) { if (!linear_predictive_coefficients_to_cepstrum.Run( linear_predictive_coefficients, &cepstrum)) { std::ostringstream error_message; error_message << "Failed to convert linear predictive coefficients to cepstrum"; sptk::PrintErrorMessage("lpc2c", error_message); return 1; } if (!sptk::WriteStream(output_length, cepstrum, &std::cout)) { std::ostringstream error_message; error_message << "Failed to write an output sequence"; sptk::PrintErrorMessage("lpc2c", error_message); return 1; } } return 0; } Index: lpc.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/lpc.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** lpc.cc 12 Oct 2016 12:14:38 -0000 1.3 --- lpc.cc 24 Nov 2016 04:16:56 -0000 1.4 *************** *** 69,83 **** // clang-format off *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 LP coefficients [" << kDefaultNumOrder << "]" << std::endl; // NOLINT ! *stream << " -f f : minimum value of the determinant of [" << kDefaultEpsilon << "]" << std::endl; // NOLINT *stream << " the normal matrix" << std::endl; ! *stream << " -c c : check whether the derived LP [0]" << std::endl; // NOLINT ! *stream << " coefficients are stable or not" << std::endl; *stream << " 0 (the check is not performed)" << std::endl; *stream << " 1 (if the coefficients are unstable," << std::endl; // NOLINT --- 69,83 ---- // clang-format off *stream << std::endl; ! *stream << " lpc - linear predictive coding using Levinson-Durbin recursion" << std::endl; // NOLINT *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 linear predictive 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 linear [0]" << std::endl; // NOLINT ! *stream << " predictive coefficients are stable" << std::endl; *stream << " 0 (the check is not performed)" << std::endl; *stream << " 1 (if the coefficients are unstable," << std::endl; // NOLINT *************** *** 88,94 **** *stream << " -h : print this message" << std::endl; *stream << " infile:" << std::endl; ! *stream << " windowed sequence (double) [stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; ! *stream << " LP coefficients (double)" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; --- 88,94 ---- *stream << " -h : print this message" << std::endl; *stream << " infile:" << std::endl; ! *stream << " windowed 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; *************** *** 192,196 **** if (!autocorrelation.SetNumOrder(num_order)) { std::ostringstream error_message; ! error_message << "Failed to set the order of LP coefficients"; sptk::PrintErrorMessage("lpc", error_message); return 1; --- 192,196 ---- if (!autocorrelation.SetNumOrder(num_order)) { std::ostringstream error_message; ! error_message << "Failed to set the number of orders"; sptk::PrintErrorMessage("lpc", error_message); return 1; *************** *** 240,244 **** &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write LP coefficients"; sptk::PrintErrorMessage("lpc", error_message); return 1; --- 240,244 ---- &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write linear predictive coefficients"; sptk::PrintErrorMessage("lpc", error_message); return 1; Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Makefile 26 Oct 2016 08:18:58 -0000 1.18 --- Makefile 24 Nov 2016 04:16:55 -0000 1.19 *************** *** 61,64 **** --- 61,65 ---- input_source_preprocessing_for_filter_gain.cc \ levinson_durbin_recursion.cc \ + linear_predictive_coefficients_to_cepstrum.cc \ m_sequence_generation.cc \ normal_distributed_random_value_generation.cc \ Index: levdur.cc =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/levdur.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** levdur.cc 12 Oct 2016 12:14:38 -0000 1.4 --- levdur.cc 24 Nov 2016 04:16:55 -0000 1.5 *************** *** 76,81 **** *stream << " -f f : minimum value of the determinant of [" << kDefaultEpsilon << "]" << std::endl; // NOLINT *stream << " the normal matrix" << std::endl; ! *stream << " -c c : check whether the derived LP [0]" << std::endl; // NOLINT ! *stream << " coefficients are stable or not" << std::endl; *stream << " 0 (the check is not performed)" << std::endl; *stream << " 1 (if the coefficients are unstable," << std::endl; // NOLINT --- 76,81 ---- *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 linear [0]" << std::endl; // NOLINT ! *stream << " predictive coefficients are stable" << std::endl; *stream << " 0 (the check is not performed)" << std::endl; *stream << " 1 (if the coefficients are unstable," << std::endl; // NOLINT *************** *** 88,92 **** *stream << " autocorrelation sequence (double) [stdin]" << std::endl; // NOLINT *stream << " stdout:" << std::endl; ! *stream << " LP coefficients (double)" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; --- 88,92 ---- *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; *************** *** 210,214 **** &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write LP coefficients"; sptk::PrintErrorMessage("levdur", error_message); return 1; --- 210,214 ---- &std::cout)) { std::ostringstream error_message; ! error_message << "Failed to write linear predictive coefficients"; sptk::PrintErrorMessage("levdur", error_message); return 1; --- NEW FILE: linear_predictive_coefficients_to_cepstrum.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_LINEAR_PREDICTIVE_COEFFICIENTS_TO_CEPSTRUM_H_ #define SPTK_SRC_LINEAR_PREDICTIVE_COEFFICIENTS_TO_CEPSTRUM_H_ #include <vector> // std::vector #include "sptk_utils.h" namespace sptk { class LinearPredictiveCoefficientsToCepstrum { public: // LinearPredictiveCoefficientsToCepstrum(int num_input_order, int num_output_order); // virtual ~LinearPredictiveCoefficientsToCepstrum() { } // int GetNumInputOrder() const { return num_input_order_; } // int GetNumOutputOrder() const { return num_output_order_; } // bool IsValid() const { return is_valid_; } // bool Run(const std::vector<double>& linear_predictive_coefficients, std::vector<double>* cepstrum) const; private: // const int num_input_order_; // const int num_output_order_; // bool is_valid_; // DISALLOW_COPY_AND_ASSIGN(LinearPredictiveCoefficientsToCepstrum); }; } // namespace sptk #endif // SPTK_SRC_LINEAR_PREDICTIVE_COEFFICIENTS_TO_CEPSTRUM_H_ --- NEW FILE: linear_predictive_coefficients_to_cepstrum.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 "linear_predictive_coefficients_to_cepstrum.h" #include <cmath> // std::isfinite, std::log #include <cstring> // std::size_t namespace sptk { LinearPredictiveCoefficientsToCepstrum::LinearPredictiveCoefficientsToCepstrum( int num_input_order, int num_output_order) : num_input_order_(num_input_order), num_output_order_(num_output_order), is_valid_(true) { if (num_input_order_ < 0 || num_output_order_ < 0) { is_valid_ = false; } } bool LinearPredictiveCoefficientsToCepstrum::Run( const std::vector<double>& linear_predictive_coefficients, std::vector<double>* cepstrum) const { // check inputs if (!is_valid_ || linear_predictive_coefficients.size() != static_cast<std::size_t>(num_input_order_ + 1) || NULL == cepstrum) { return false; } // prepare memory const int output_length(num_output_order_ + 1); if (cepstrum->size() < static_cast<std::size_t>(output_length)) { cepstrum->resize(output_length); } // get values const double* input(&(linear_predictive_coefficients[0])); double* output(&((*cepstrum)[0])); output[0] = std::log(input[0]); if (0 == num_output_order_) return true; output[1] = -input[1]; for (int n(2); n <= num_output_order_; ++n) { double sum(0.0); const int k_first((num_input_order_ < n) ? (n - num_input_order_) : 1); for (int k(k_first); k < n; ++k) { sum -= k * output[k] * input[n - k]; } output[n] = sum / n; if (n <= num_input_order_) { output[n] -= input[n]; } } return true; } } // namespace sptk |
From: Keiichiro O. <ur...@us...> - 2016-11-14 04:09:17
|
Update of /cvsroot/sp-tk/SPTK/src/bin/mlsacheck In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv23353 Modified Files: mlsacheck.c Log Message: small modification Index: mlsacheck.c =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/bin/mlsacheck/mlsacheck.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** mlsacheck.c 24 Jun 2016 12:06:58 -0000 1.20 --- mlsacheck.c 14 Nov 2016 04:09:15 -0000 1.21 *************** *** 186,190 **** double mlsacheck(double *in, double *out, int m, int fftlen, ! double a, double r, int c) { int i; --- 186,190 ---- double mlsacheck(double *in, double *out, int m, int fftlen, ! double a, double r, int c) { int i; *************** *** 207,211 **** /* check stability */ ! if (c == 0 || c == 2 || c == 3) { /* usual mode */ mag = dgetmem(fftlen); fillz(mag, sizeof(*mag), fftlen); --- 207,211 ---- /* check stability */ ! if (c != 1 && c != 4) { /* usual mode */ mag = dgetmem(fftlen); fillz(mag, sizeof(*mag), fftlen); *************** *** 222,226 **** /* modify MLSA filter coefficients */ ! if (max > r) { if (c == 2) { /* clipping */ for (i = 0; i < fftlen; i++) { --- 222,228 ---- /* modify MLSA filter coefficients */ ! if (c == 0 || c == 1 || max <= r) { ! memcpy(out, in, sizeof(*out) * (m + 1)); ! } else { if (c == 2) { /* clipping */ for (i = 0; i < fftlen; i++) { *************** *** 230,233 **** --- 232,238 ---- } } + ifft(x, y, fftlen); + x[0] += gain; + memcpy(out, x, sizeof(*out) * (m + 1)); } else if (c == 3) { /* scaling */ for (i = 0; i < fftlen; i++) { *************** *** 235,258 **** y[i] *= r / max; } } else if (c == 4) { /* fast mode */ for (i = 0; i <= m; i++) x[i] *= r / max; } } - /* 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)); - } - free(x); free(y); ! if (c == 0 || c == 2 || c == 3) free(mag); return max; --- 240,259 ---- y[i] *= r / max; } + ifft(x, y, fftlen); + x[0] += gain; + memcpy(out, x, sizeof(*out) * (m + 1)); } else if (c == 4) { /* fast mode */ for (i = 0; i <= m; i++) x[i] *= r / max; + x[0] += gain; + memcpy(out, x, sizeof(*out) * (m + 1)); } } free(x); free(y); ! if (c != 1 && c != 4) { free(mag); + } return max; |
From: fujishita t. <fjs...@us...> - 2016-11-10 09:22:16
|
Update of /cvsroot/sp-tk/SPTK/src/bin/pitch In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv29155 Modified Files: pitch.c Log Message: remove default values Index: pitch.c =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/bin/pitch/pitch.c,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** pitch.c 19 Aug 2016 02:57:30 -0000 1.50 --- pitch.c 10 Nov 2016 09:22:14 -0000 1.51 *************** *** 117,132 **** #define ATYPE 0 #define OTYPE 0 - #define STR_LEN 255 #define THRESH_RAPT 0.0 #define THRESH_SWIPE 0.3 #define THRESH_REAPER 0.9 - #define NOISEMASK 50.0 - #define SEED 1 - #define RND_MAX 32767 - #define FSP 10.0 - #define ALPHA 0.00275 - #define BETA_1 9600.0 - #define BETA_2 168.0 - #define BETA_3 96000.0 /* Command Name */ --- 117,123 ---- |
From: Shikano M. <sh...@us...> - 2016-11-02 07:26:53
|
Update of /cvsroot/sp-tk/SPTK/doc/ref_e In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv9017 Modified Files: gmm.tex Log Message: correct wrong letters Index: gmm.tex =================================================================== RCS file: /cvsroot/sp-tk/SPTK/doc/ref_e/gmm.tex,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** gmm.tex 18 Dec 2015 07:53:25 -0000 1.21 --- gmm.tex 2 Nov 2016 07:26:51 -0000 1.22 *************** *** 197,203 **** \desc[1ex]{(level 2)} \argm{B}{B1~B2~$\ldots$~Bn}{block size in covariance matrix,\\ ! where $(B1+B2+\ldots+Bn)=L$}{N/A} ! \argm{c1}{}{inter-block correlation}{N/A} ! \argm{c2}{}{full covariance in each block}{N/A} \end{options} --- 197,203 ---- \desc[1ex]{(level 2)} \argm{B}{B1~B2~$\ldots$~Bn}{block size in covariance matrix,\\ ! where $(B1+B2+\ldots+Bn)=L$}{FALSE} ! \argm{c1}{}{inter-block correlation}{FALSE} ! \argm{c2}{}{full covariance in each block}{FALSE} \end{options} |
From: Shikano M. <sh...@us...> - 2016-11-02 07:13:42
|
Update of /cvsroot/sp-tk/SPTK/doc/ref_e In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv8343 Modified Files: lmadf.tex Log Message: add the cascaded filter option and the figures of LMA filter Index: lmadf.tex =================================================================== RCS file: /cvsroot/sp-tk/SPTK/doc/ref_e/lmadf.tex,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** lmadf.tex 18 Dec 2015 07:53:25 -0000 1.25 --- lmadf.tex 2 Nov 2016 07:13:40 -0000 1.26 *************** *** 42,45 **** --- 42,46 ---- % POSSIBILITY OF SUCH DAMAGE. % % ----------------------------------------------------------------- % + \hypertarget{lmadf}{} \name[ref:acep-IEEESP,ref:LMA-IECE]{lmadf}% *************** *** 47,58 **** \begin{synopsis} ! \item [lmadf] [ --m $M$ ] [ --p $P$ ] [ --i $I$ ] [ --P $Pa$ ] [ --v ] [ --t ] [ --k ] ! {\em cfile} [ {\em infile} ] \end{synopsis} \begin{qsection}{DESCRIPTION} {\em lmadf} derives a Log Magnitude Approximation filter ! from the cepstral coefficients $c(0),c(1),\ldots,c(M)$ in {\em cfile} ! and uses it to filter an excitation sequence from {\em infile} (or standard input) in order to synthesize speech data, sending the result to standard output. --- 48,60 ---- \begin{synopsis} ! \item [lmadf] [ --m $M$ ] [ --p $P$ ] [ --i $I$ ] [ --P $Pa$ ] [ --k ] ! [ --v ] [ --t ] [ --B $B1,B2,...$ ] ! \item [\ ~~~~]{\em cfile} [ {\em infile} ] \end{synopsis} \begin{qsection}{DESCRIPTION} {\em lmadf} derives a Log Magnitude Approximation filter ! from the cepstral coefficients \\ ! $c(0),c(1),\ldots,c(M)$ in {\em cfile} and uses it to filter an excitation sequence from {\em infile} (or standard input) in order to synthesize speech data, sending the result to standard output. *************** *** 66,79 **** H(z) = \exp \sum_{m=0}^{M} c(m) z^{-m} \end{displaymath} ! If we remove the gain $K = \exp c(0)$ from the transfer function $H(z)$, then we obtain the following transfer function \begin{displaymath} D(z) = \exp \sum_{m=1}^{M} c(m) z^{-m}, \end{displaymath} ! which can be realized using the basic FIR filter \begin{displaymath} F(z) = \sum_{m=1}^{M} c(m) z^{-m} \end{displaymath} ! as shown in Figure \ref{fig:lmadflt_LMA}(a). ! Also, as it can be seen in Figure \ref{fig:lmadflt_LMA}(b), the basic filter $F(z)$ can be decomposed as follows \begin{displaymath} --- 68,88 ---- H(z) = \exp \sum_{m=0}^{M} c(m) z^{-m} \end{displaymath} ! If we remove the gain $K = \exp c(0)$ from the transfer function ! $H(z)$, then we obtain the following transfer function. \begin{displaymath} D(z) = \exp \sum_{m=1}^{M} c(m) z^{-m}, \end{displaymath} ! The filter $D(z)$ can be constructed as shown in Figure ! \ref{fig:lmadflt_LMA}(a), where the basic ! FIR filter (Figure \ref{fig:lmadflt_LMA}(b)) is ! the following filter. \begin{displaymath} F(z) = \sum_{m=1}^{M} c(m) z^{-m} \end{displaymath} ! If the -t option is assigned, the basic FIR filter (Figure ! \ref{fig:lmadflt_LMA}(b)) are transposed. The transposed FIR filter ! can be constructed as shown in Figure \ref{fig:lmadflt_LMA}(c). ! ! It can be seen in Figure \ref{fig:lmadflt_LMA}(d), the basic filter $F(z)$ can be decomposed as follows \begin{displaymath} *************** *** 87,95 **** By doing this decomposition, the accuracy of the approximation is improved. ! Also, the values of the coefficients $A_{4,l}$ are given ! in table \ref{tbl:lmadflt_pade} \par \setcounter{figure}{0} ! \begin{figure}[ht] \setlength{\unitlength}{0.9mm} \begin{center} --- 96,108 ---- By doing this decomposition, the accuracy of the approximation is improved. ! ! The values of the coefficients $A_{4,l}$ are given ! in table \ref{tbl:lmadflt_pade}. ! ! \newpage ! \par \setcounter{figure}{0} ! \begin{figure}[h] \setlength{\unitlength}{0.9mm} \begin{center} *************** *** 157,161 **** \end{center} ! \vspace{2mm} \setlength{\unitlength}{0.9mm} \begin{center} --- 170,194 ---- \end{center} ! \vspace{1mm} ! \setlength{\unitlength}{0.9mm} ! \begin{center} ! \leavevmode ! \includegraphics{fig/FIRflt.eps} ! \end{center} ! \begin{center} ! (b) ! \end{center} ! ! \vspace{1mm} ! \setlength{\unitlength}{0.9mm} ! \begin{center} ! \leavevmode ! \includegraphics{fig/transflt.eps} ! \end{center} ! \begin{center} ! (c) ! \end{center} ! ! \vspace{1mm} \setlength{\unitlength}{0.9mm} \begin{center} *************** *** 167,185 **** \put(47,8){\vector(1,0){10}} \put(89,8){\vector(1,0){15}} ! \put(2,10){\makebox(0,0)[lb]{$x(n)$}} ! \put(93,10){\makebox(0,0)[lb]{$y(n)$}} ! \put(0,17){\makebox(0,0)[lb]{Input}} ! \put(91,17){\makebox(0,0)[lb]{Output}} \end{picture} \end{center} \begin{center} ! (b) \end{center} \caption{\protect\parbox[t]{8cm}{ (a)~~$R_L(F(z))\simeq D(z)$~~~$L=4$ \protect\\ ! (b)~~2 level cascade realization\protect\\ \hspace*{5mm} $R_L(F_1(z))\cdot R_L(F_2(z))\simeq D(z)$ }} \label{fig:lmadflt_LMA} \end{figure} --- 200,218 ---- \put(47,8){\vector(1,0){10}} \put(89,8){\vector(1,0){15}} ! \put(0,10){\makebox(0,0)[lb]{Input}} ! \put(91,10){\makebox(0,0)[lb]{Output}} \end{picture} \end{center} \begin{center} ! (d) \end{center} + \caption{\protect\parbox[t]{8cm}{ (a)~~$R_L(F(z))\simeq D(z)$~~~$L=4$ \protect\\ ! (d)~~2 level cascade realization\protect\\ \hspace*{5mm} $R_L(F_1(z))\cdot R_L(F_2(z))\simeq D(z)$ }} \label{fig:lmadflt_LMA} + \end{figure} *************** *** 203,208 **** --- 236,243 ---- \label{tbl:lmadflt_pade} \end{table} + \end{qsection} + \begin{options} \argm{m}{M}{order of cepstrum}{25} *************** *** 213,217 **** \argm{k}{}{filtering without gain}{FALSE} \argm{v}{}{inverse filter}{FALSE} ! \argm{v}{}{transpose filter}{FALSE} \end{options} --- 248,255 ---- \argm{k}{}{filtering without gain}{FALSE} \argm{v}{}{inverse filter}{FALSE} ! \argm{t}{}{transpose filter}{FALSE} ! \desc[1ex]{(level 2)} ! \argm{B}{B1~B2~$\ldots$~Bn}{block size of cascaded filter,\\ ! where $(|B1|+\ldots+|Bn|)=m$}{FALSE} \end{options} *************** *** 223,232 **** {\em data.syn}. \begin{quote} ! \verb!excite < data.pitch | lmadf data.cep > data.syn! \end{quote} \end{qsection} \begin{qsection}{NOTICE} ! $Pa$ = 4 or 5. \end{qsection} --- 261,283 ---- {\em data.syn}. \begin{quote} ! \verb!excite < data.pitch | lmadf -m 15 data.cep > data.syn! \end{quote} + If one wants to divide the filter into several blocks, the -B option + can be used to specify the block size of each filter. + For example, when dividing 15-dimentional filter into 3 sub-parts(4, + 5, and 6), the corresponding command line is below. + \begin{quote} + \verb!excite < data.pitch | lmadf -m 15 -B 4 5 6 data.cep > data.syn! + \end{quote} + If the block size value assigned by the -B option is negative, the + block is not used. + \begin{quote} + \verb!excite < data.pitch | lmadf -m 15 -B 4 -5 6 data.cep > data.syn! + \end{quote} + \end{qsection} \begin{qsection}{NOTICE} ! $Pa$ = 4 or 5.\\ \end{qsection} |
From: Shikano M. <sh...@us...> - 2016-11-02 07:06:42
|
Update of /cvsroot/sp-tk/SPTK/src/bin/lmadf In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7985 Modified Files: lmadf.c _lmadf.c Log Message: addition of cascaded filter Index: _lmadf.c =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/bin/lmadf/_lmadf.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** _lmadf.c 14 Dec 2015 01:14:17 -0000 1.19 --- _lmadf.c 2 Nov 2016 07:06:40 -0000 1.20 *************** *** 110,115 **** ppade = &pade[pd * (pd + 1) / 2]; ! x = lmadf1(x, c, m, d, 1, 1, pd); /* D1(z) */ ! x = lmadf1(x, c, m, &d[(m + 1) * pd], 2, m, pd); /* D2(z) */ return (x); --- 110,133 ---- ppade = &pade[pd * (pd + 1) / 2]; ! x = lmadf1(x, c, m, d, pd, 1, 1); /* D1(z) */ ! x = lmadf1(x, c, m, &d[(m + 1) * pd], pd, 2, m); /* D2(z) */ ! ! return (x); ! } ! ! double cascade_lmadf(double x, double *c, const int m, const int pd, double *d, ! const int block_num, int *block_size) ! { ! int i, block_start = 1, block_end = 0; ! ppade = &pade[pd * (pd + 1) / 2]; ! ! for (i = 0; i < block_num; i++) { ! block_end += abs(block_size[i]); ! if (block_size[i] > 0) { ! x = lmadf1(x, c, m, d, pd, block_start, block_end); ! } ! d += (m + 1) * pd; ! block_start += abs(block_size[i]); ! } return (x); *************** *** 130,135 **** *****************************************************************/ ! double lmadf1(double x, double *c, const int m, double *d, const int m1, ! const int m2, const int pd) { double y, t, *pt; --- 148,153 ---- *****************************************************************/ ! double lmadf1(double x, double *c, const int m, double *d, const int pd, ! const int m1, const int m2) { double y, t, *pt; *************** *** 150,155 **** } - /* transpose */ - double lmadf1t(double x, double *b, const int pd, double *d) { --- 168,171 ---- *************** *** 174,189 **** } ! static double lmafirt(double x, double *b, const int m, double *d) { int i; double y = 0.0; ! y = d[0]; ! d[m] = b[m] * x; ! for (i = m - 1; i > 1; i--) d[i] += b[i] * x; - d[1] += 0; - for (i = 0; i < m; i++) d[i] = d[i + 1]; --- 190,204 ---- } ! static double lmafirt(double x, double *b, const int m, double *d, const int m1, ! const int m2) { int i; double y = 0.0; ! y = d[1]; ! d[m2] = b[m2] * x; ! for (i = m2 - 1; i >= m1; i--) d[i] += b[i] * x; for (i = 0; i < m; i++) d[i] = d[i + 1]; *************** *** 192,204 **** } ! static double lmadf2t(double x, double *b, const int m, const int pd, double *d) { double v, out = 0.0, *pt; int i; ! pt = &d[pd * (m + 2)]; for (i = pd; i >= 1; i--) { ! pt[i] = lmafirt(pt[i - 1], b, m, &d[(i - 1) * (m + 2)]); v = pt[i] * ppade[i]; --- 207,220 ---- } ! double lmadf2t(double x, double *b, const int m, const int pd, double *d, ! const int m1, const int m2) { double v, out = 0.0, *pt; int i; ! pt = &d[pd * (m + 1)]; for (i = pd; i >= 1; i--) { ! pt[i] = lmafirt(pt[i - 1], b, m, &d[(i - 1) * (m + 1)], m1, m2); v = pt[i] * ppade[i]; *************** *** 213,222 **** } ! double lmadft(double x, double *c, const int m, const int pd, double *d) { ppade = &pade[pd * (pd + 1) / 2]; x = lmadf1t(x, c, pd, d); ! x = lmadf2t(x, c, m, pd, &d[2 * (pd + 1)]); return (x); --- 229,248 ---- } ! double lmadft(double x, double *c, const int m, const int pd, double *d, ! int block_num, int *block_size) { + int i, block_start = 2, block_end = 1; ppade = &pade[pd * (pd + 1) / 2]; x = lmadf1t(x, c, pd, d); ! ! for (i = 1; i < block_num; i++) { ! block_end += abs(block_size[i]); ! if (block_size[i] > 0) { ! x = lmadf2t(x, c, m, pd, &d[2 * (pd + 1)], block_start, block_end); ! } ! d += pd * (m + 1) + (pd + 1); ! block_start += abs(block_size[i]); ! } return (x); Index: lmadf.c =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/bin/lmadf/lmadf.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** lmadf.c 14 Dec 2015 01:14:17 -0000 1.33 --- lmadf.c 2 Nov 2016 07:06:40 -0000 1.34 *************** *** 43,77 **** /* ----------------------------------------------------------------- */ ! /************************************************************************ ! * * ! * LMA Digital Filter for Speech Synthesis * ! * * ! * 1986.6 K.Tokuda * ! * 1996.1 K.Koishida * ! * * ! * usage: * ! * lmadf [ options ] cfile [ infile ] > stdout * ! * options: * ! * -m m : order of cepstrum [25] * ! * -p p : frame period [100] * ! * -i i : interpolation period [1] * ! * -P P : order of Pade approximation [4] * ! * -k : filtering without gain [FALSE] * ! * -v : inverse filter [FALSE] * ! * -t : transpose filter [FALSE] * ! * infile: * ! * cepstral coefficients * ! * , c~(0), c~(1), ..., c~(M), * ! * excitation sequence * ! * , x(0), x(1), ..., * ! * stdout: * ! * filtered sequence * ! * , y(0), y(1), ..., * ! * notice: * ! * P = 4 or 5 * ! * require: * ! * lmadf() * ! * * ! ************************************************************************/ static char *rcs_id = "$Id$"; --- 43,80 ---- /* ----------------------------------------------------------------- */ ! /***************************************************************************** ! * * ! * LMA Digital Filter for Speech Synthesis * ! * * ! * 1986.6 K.Tokuda * ! * 1996.1 K.Koishida * ! * * ! * usage: * ! * lmadf [ options ] cfile [ infile ] > stdout * ! * options: * ! * -m m : order of cepstrum [25] * ! * -p p : frame period [100] * ! * -i i : interpolation period [1] * ! * -P P : order of Pade approximation [4] * ! * -k : filtering without gain [FALSE] * ! * -v : inverse filter [FALSE] * ! * -t : transpose filter [FALSE] * ! * (level 2) * ! * -B B1 B2 ... Bn : block size of cascaded filter [FALSE] * ! * where (|B1|+...+|Bn|) = m * ! * infile: * ! * cepstral coefficients * ! * , c~(0), c~(1), ..., c~(M), * ! * excitation sequence * ! * , x(0), x(1), ..., * ! * stdout: * ! * filtered sequence * ! * , y(0), y(1), ..., * ! * notice: * ! * P = 4 or 5 * ! * require: * ! * lmadf() * ! * * ! *****************************************************************************/ static char *rcs_id = "$Id$"; *************** *** 107,110 **** --- 110,114 ---- #define INVERSE FA #define TRANSPOSE FA + #define BLOCK FA char *BOOL[] = { "FALSE", "TRUE" }; *************** *** 122,141 **** fprintf(stderr, " %s [ options ] cfile [ infile ] > stdout\n", cmnd); fprintf(stderr, " options:\n"); ! fprintf(stderr, " -m m : order of cepstrum [%d]\n", ORDER); ! fprintf(stderr, " -p p : frame period [%d]\n", FPERIOD); ! fprintf(stderr, " -i i : interpolation period [%d]\n", IPERIOD); ! fprintf(stderr, " -P P : order of Pade approximation [%d]\n", PADEORD); ! fprintf(stderr, " -v : inverse filter [%s]\n", BOOL[INVERSE]); ! fprintf(stderr, " -t : transpose filter [%s]\n", BOOL[TRANSPOSE]); ! fprintf(stderr, " -k : filtering without gain [%s]\n", BOOL[NGAIN]); fprintf(stderr, " -h : print this message\n"); fprintf(stderr, " infile:\n"); ! fprintf(stderr, " filter input (%s) [stdin]\n", FORMAT); fprintf(stderr, " stdout:\n"); fprintf(stderr, " filter output (%s)\n", FORMAT); --- 126,159 ---- fprintf(stderr, " %s [ options ] cfile [ infile ] > stdout\n", cmnd); fprintf(stderr, " options:\n"); ! fprintf(stderr, ! " -m m : order of cepstrum [%d]\n", ! ORDER); ! fprintf(stderr, ! " -p p : frame period [%d]\n", FPERIOD); ! fprintf(stderr, ! " -i i : interpolation period [%d]\n", IPERIOD); ! fprintf(stderr, ! " -P P : order of Pade approximation [%d]\n", PADEORD); ! fprintf(stderr, ! " -v : inverse filter [%s]\n", BOOL[INVERSE]); ! fprintf(stderr, ! " -t : transpose filter [%s]\n", BOOL[TRANSPOSE]); ! fprintf(stderr, ! " -k : filtering without gain [%s]\n", BOOL[NGAIN]); + fprintf(stderr, " (level 2)\n"); + fprintf(stderr, + " -B B1 B2 ... Bn : block size of cascaded filter [%s]\n", + BOOL[BLOCK]); + fprintf(stderr, " where (|B1|+ ... +|Bn|) = m \n"); fprintf(stderr, " -h : print this message\n"); fprintf(stderr, " infile:\n"); ! fprintf(stderr, " filter input (%s) [stdin]\n", ! FORMAT); fprintf(stderr, " stdout:\n"); fprintf(stderr, " filter output (%s)\n", FORMAT); *************** *** 159,163 **** FILE *fp = stdin, *fpc = NULL; double *c, *inc, *cc, *d, x; ! Boolean ngain = NGAIN, inverse = INVERSE, transpose = TRANSPOSE; if ((cmnd = strrchr(argv[0], '/')) == NULL) --- 177,184 ---- FILE *fp = stdin, *fpc = NULL; double *c, *inc, *cc, *d, x; ! Boolean ngain = NGAIN, inverse = INVERSE, transpose = TRANSPOSE, block = ! BLOCK; ! int block_num = 0, block_sum = 0, *block_size; ! char **pt_block; if ((cmnd = strrchr(argv[0], '/')) == NULL) *************** *** 165,169 **** else cmnd++; ! while (--argc) if (**++argv == '-') { switch (*(*argv + 1)) { --- 186,190 ---- else cmnd++; ! while (--argc) { if (**++argv == '-') { switch (*(*argv + 1)) { *************** *** 193,196 **** --- 214,240 ---- inverse = 1 - inverse; break; + case 'B': + block = TR; + i = 0; + pt_block = argv; + while (*(*argv++) != '\0') { + if (!isdigit(**argv) + && !((**argv == '-') && isdigit(*(*argv + 1)))) { + break; + } + i++; + if (--argc <= 1) { + break; + } + } + argv = pt_block; + block_num = i; + block_sum = 0; + block_size = (int *) malloc(sizeof(int) * block_num); + for (i = 0; i < block_num; i++) { + block_size[i] = atoi(*++argv); + block_sum += abs(block_size[i]); + } + break; case 'h': usage(0); *************** *** 199,207 **** usage(1); } ! } else if (fpc == NULL) fpc = getfp(*argv, "rb"); ! else fp = getfp(*argv, "rb"); ! if ((pd < 4) || (pd > 5)) { fprintf(stderr, "%s : Order of Pade approximation should be 4 or 5!\n", --- 243,252 ---- usage(1); } ! } else if (fpc == NULL) { fpc = getfp(*argv, "rb"); ! } else { fp = getfp(*argv, "rb"); ! } ! } if ((pd < 4) || (pd > 5)) { fprintf(stderr, "%s : Order of Pade approximation should be 4 or 5!\n", *************** *** 214,219 **** return (1); } ! c = dgetmem(m + m + m + 3 + (m + 1) * pd * 2); cc = c + m + 1; inc = cc + m + 1; --- 259,281 ---- return (1); } + if (block == TR && block_sum != m) { + fprintf(stderr, "%s : block size must coincide with the value of m !\n", + cmnd); + return (1); + } ! if (!transpose) { ! if (block_num == 0) { ! c = dgetmem(m + m + m + 3 + (m + 1) * pd * 2); ! } else { ! c = dgetmem(m + m + m + 3 + ((m + 1) * pd) * block_num); ! } ! } else { ! if (block_num == 0) { ! c = dgetmem(m + m + m + 3 + ((m + 1) * pd + (pd + 1)) * 2); ! } else { ! c = dgetmem(m + m + m + 3 + ((m + 1) * pd + (pd + 1)) * block_num); ! } ! } cc = c + m + 1; inc = cc + m + 1; *************** *** 255,262 **** if (!ngain) x *= exp(c[0]); ! if (transpose) ! x = lmadft(x, c, m, pd, d); ! else ! x = lmadf(x, c, m, pd, d); fwritef(&x, sizeof(x), 1, stdout); --- 317,335 ---- if (!ngain) x *= exp(c[0]); ! if (transpose) { ! if (block_num == 0) { ! block_num = 2; ! block_size = (int *) malloc(sizeof(int) * block_num); ! block_size[0] = 1; ! block_size[1] = m - 1; ! } ! x = lmadft(x, c, m, pd, d, block_num, block_size); ! } else { ! if (block_num == 0) { ! x = lmadf(x, c, m, pd, d); ! } else { ! x = cascade_lmadf(x, c, m, pd, d, block_num, block_size); ! } ! } fwritef(&x, sizeof(x), 1, stdout); |
From: Shikano M. <sh...@us...> - 2016-11-02 07:05:08
|
Update of /cvsroot/sp-tk/SPTK/src/include In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7920 Modified Files: SPTK.h Log Message: addition of cascaded filter Index: SPTK.h =================================================================== RCS file: /cvsroot/sp-tk/SPTK/src/include/SPTK.h,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** SPTK.h 14 Dec 2015 01:14:25 -0000 1.62 --- SPTK.h 2 Nov 2016 07:05:04 -0000 1.63 *************** *** 278,285 **** int levdur(double *r, double *a, const int m, double eps); double lmadf(double x, double *c, const int m, const int pd, double *d); ! double lmadft(double x, double *c, const int m, const int pd, double *d); ! double lmadf1(double x, double *c, const int m, double *d, const int m1, ! const int m2, const int pd); ! double lmadf1t(double x, double *b, const int pd, double *d); int lpc(double *x, const int flng, double *a, const int m, const double f); void lpc2c(double *a, int m1, double *c, const int m2); --- 278,286 ---- int levdur(double *r, double *a, const int m, double eps); double lmadf(double x, double *c, const int m, const int pd, double *d); ! double cascade_lmadf(double x, double *c, const int m, const int pd, double *d, const int block_num, int *block_size); ! double lmadft(double x, double *c, const int m, const int pd, double *d, const int block_num, int *block_size); ! double lmadf1(double x, double *c, const int m, double *d, const int pd, ! const int m1, const int m2); ! double lmadf2t(double x, double *b, const int m, const int pd, double *d, const int m1, const int m2); int lpc(double *x, const int flng, double *a, const int m, const double f); void lpc2c(double *a, int m1, double *c, const int m2); |
From: Shikano M. <sh...@us...> - 2016-10-28 04:12:54
|
Update of /cvsroot/sp-tk/SPTK/doc/ref_e In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11788 Modified Files: lpc2par.tex Log Message: correct wrong letters Index: lpc2par.tex =================================================================== RCS file: /cvsroot/sp-tk/SPTK/doc/ref_e/lpc2par.tex,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** lpc2par.tex 18 Dec 2015 07:53:26 -0000 1.24 --- lpc2par.tex 28 Oct 2016 04:12:52 -0000 1.25 *************** *** 73,77 **** \begin{align} k(m) &= a^{(m)}(m) \notag \\ ! a^{(m-1)}(i) &= \frac{a^{(m)}(i)+a^{(m)}(m)a^{(m)}(m-i)}{1-k^2(m)}, \notag \end{align} where $1 \leq i \leq m-1$, $m=p, p-1, \dots, 1$. --- 73,77 ---- \begin{align} k(m) &= a^{(m)}(m) \notag \\ ! a^{(m-1)}(i) &= \frac{a^{(m)}(i)-a^{(m)}(m)a^{(m)}(m-i)}{1-k^2(m)}, \notag \end{align} where $1 \leq i \leq m-1$, $m=p, p-1, \dots, 1$. *************** *** 104,108 **** \argm{m}{M}{order of LPC}{25} \argm{g}{G}{gamma of generalized cepstrum\\ ! $\gamma=G$}{0} \argm{c}{C}{gamma of generalized cepstrum\\ $\gamma =-1 / $(int)$ C$\\ --- 104,108 ---- \argm{m}{M}{order of LPC}{25} \argm{g}{G}{gamma of generalized cepstrum\\ ! $\gamma=G$}{1} \argm{c}{C}{gamma of generalized cepstrum\\ $\gamma =-1 / $(int)$ C$\\ |
From: fujishita t. <fjs...@us...> - 2016-10-26 08:19:01
|
Update of /cvsroot/sp-tk/SPTK4/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv13988 Modified Files: Makefile Added Files: all_pole_lattice_digital_filter.cc all_pole_lattice_digital_filter.h ltcdf.cc Log Message: add ltcdf command Index: Makefile =================================================================== RCS file: /cvsroot/sp-tk/SPTK4/src/Makefile,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Makefile 14 Oct 2016 06:17:44 -0000 1.17 --- Makefile 26 Oct 2016 08:18:58 -0000 1.18 *************** *** 46,49 **** --- 46,50 ---- SOURCES = all_pole_digital_filter.cc \ + all_pole_lattice_digital_filter.cc \ all_zero_digital_filter.cc \ autocorrelation.cc \ --- NEW FILE: all_pole_lattice_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_lattice_digital_filter.h" #include <cstring> // std::size_t namespace sptk { bool AllPoleLatticeDigitalFilter::Run( const std::vector<double>& filter_coefficients, double filter_input, double* filter_output, AllPoleLatticeDigitalFilter::StoredSignals* stored_signals) const { // check inputs if (filter_coefficients.size() != static_cast<std::size_t>(num_filter_order_ + 1) || NULL == filter_output || NULL == stored_signals || !is_valid_) { return false; } // prepare memory if (stored_signals->signals_.size() != static_cast<std::size_t>(num_filter_order_)) { stored_signals->signals_.resize(num_filter_order_); std::fill(stored_signals->signals_.begin(), stored_signals->signals_.end(), 0.0); } // 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); sum -= coefficients[num_filter_order_] * signals[num_filter_order_ - 1]; for (int i(num_filter_order_ - 1); 0 < i; --i) { sum -= coefficients[i] * signals[i - 1]; signals[i] = signals[i - 1] + coefficients[i] * sum; } signals[0] = sum; // save result *filter_output = sum; return true; } } // namespace sptk --- NEW FILE: all_pole_lattice_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_LATTICE_DIGITAL_FILTER_H_ #define SPTK_SRC_ALL_POLE_LATTICE_DIGITAL_FILTER_H_ #include <algorithm> // std::fill #include <vector> // std::vector #include "sptk_utils.h" namespace sptk { class AllPoleLatticeDigitalFilter { public: class StoredSignals { public: // StoredSignals() { } // ~StoredSignals() { } // void Clear() { std::fill(signals_.begin(), signals_.end(), 0.0); } private: // std::vector<double> signals_; // friend class AllPoleLatticeDigitalFilter; // DISALLOW_COPY_AND_ASSIGN(StoredSignals); }; // explicit AllPoleLatticeDigitalFilter(int num_filter_order) : num_filter_order_(num_filter_order), is_valid_(true) { if (num_filter_order_ < 0) { is_valid_ = false; } } // virtual ~AllPoleLatticeDigitalFilter() { } // int GetNumFilterOrder() const { return num_filter_order_; } // bool IsValid() const { return is_valid_; } // bool Run(const std::vector<double>& filter_coefficients, double filter_input, double* filter_output, AllPoleLatticeDigitalFilter::StoredSignals* signals) const; private: // const int num_filter_order_; // bool is_valid_; // DISALLOW_COPY_AND_ASSIGN(AllPoleLatticeDigitalFilter); }; } // namespace sptk #endif // SPTK_SRC_ALL_POLE_LATTICE_DIGITAL_FILTER_H_ --- NEW FILE: ltcdf.cc --- // ----------------------------------------------------------------- // // The Speech Signal Processing Toolkit (SPTK) // // developed by SPTK Working Group // // http://sp-tk.sourceforge.net/ // // ----------------------------------------------------------------- // // // // Copyright (c) 1984-2007 Tokyo Institute of Technology // // Interdisciplinary Graduate School of // // Science and Engineering // // // // 1996-2016 Nagoya Institute of Technology // // Department of Computer Science // // // // All rights reserved. // // // // Redistribution and use in source and binary forms, with or // // without modification, are permitted provided that the following // // conditions are met: // // // // - Redistributions of source code must retain the above copyright // // notice, this list of conditions and the following disclaimer. // // - Redistributions in binary form must reproduce the above // // copyright notice, this list of conditions and the following // // disclaimer in the documentation and/or other materials provided // // with the distribution. // // - Neither the name of the SPTK working group nor the names of its // // contributors may be used to endorse or promote products derived // // from this software without specific prior written permission. // // // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND // // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, // // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS // // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON // // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, // // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // // POSSIBILITY OF SUCH DAMAGE. // // ----------------------------------------------------------------- // #include <unistd.h> #include <fstream> #include <iostream> #include <sstream> #include <vector> #include "all_pole_lattice_digital_filter.h" #include "input_source_from_stream.h" #include "input_source_interpolation.h" #include "input_source_preprocessing_for_filter_gain.h" #include "sptk_utils.h" namespace { const int kDefaultNumFilterOrder(25); const int kDefaultFramePeriod(100); const int kDefaultInterpolationPeriod(1); const bool kDefaultGainFlag(true); void PrintUsage(std::ostream* stream) { // clang-format off *stream << std::endl; *stream << " ltcdf - all-pole lattice digital filter for speech synthesis" << std::endl; // NOLINT *stream << std::endl; *stream << " usage:" << std::endl; *stream << " ltcdf [ options ] kfile [ 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 << " -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 << " kfile:" << std::endl; *stream << " filter (PARCOR) coefficients (double)" << std::endl; *stream << std::endl; *stream << " SPTK: version " << sptk::kVersion << std::endl; *stream << std::endl; // clang-format on } } // namespace int main(int argc, char* argv[]) { int num_filter_order(kDefaultNumFilterOrder); int frame_period(kDefaultFramePeriod); int interpolation_period(kDefaultInterpolationPeriod); 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("ltcdf", 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("ltcdf", 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("ltcdf", error_message); return 1; } 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("ltcdf", 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, kfile and infile, are required"; sptk::PrintErrorMessage("ltcdf", 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("ltcdf", 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("ltcdf", error_message); return 1; } std::istream& stream_for_filter_input(ifs2.fail() ? std::cin : ifs2); // Prepare variables for filtering. const int filter_length(num_filter_order + 1); std::vector<double> filter_coefficients(filter_length); sptk::InputSourceFromStream input_source(false, filter_length, &stream_for_filter_coefficients); const sptk::InputSourcePreprocessingForFilterGain::FilterGainType gain_type( gain_flag ? sptk::InputSourcePreprocessingForFilterGain::FilterGainType::kLinear : sptk::InputSourcePreprocessingForFilterGain::FilterGainType:: kUnity); sptk::InputSourcePreprocessingForFilterGain preprocessing(gain_type, &input_source); sptk::InputSourceInterpolation interpolation( frame_period, interpolation_period, true, &preprocessing); double filter_input, filter_output; sptk::AllPoleLatticeDigitalFilter filter(num_filter_order); sptk::AllPoleLatticeDigitalFilter::StoredSignals stored_signals; if (!interpolation.IsValid() || !filter.IsValid()) { std::ostringstream error_message; error_message << "Failed to set the conditions for filtering"; sptk::PrintErrorMessage("ltcdf", error_message); return 1; } while (sptk::ReadStream(&filter_input, &stream_for_filter_input)) { if (!interpolation.Get(&filter_coefficients)) { std::ostringstream error_message; error_message << "Cannot get filter coefficients"; sptk::PrintErrorMessage("ltcdf", error_message); return 1; } if (!filter.Run(filter_coefficients, filter_input, &filter_output, &stored_signals)) { std::ostringstream error_message; error_message << "Failed to apply all-pole lattice digital filter"; sptk::PrintErrorMessage("ltcdf", 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("ltcdf", error_message); return 1; } } return 0; } |